带有未定义的更多堆栈符号的crosstool-ng gccgo构建错误

时间:2019-05-02 15:21:30

标签: go cross-compiling crosstool-ng gccgo

我正在使用crosstool-ng 1.24.0构建gccgo。编译非常简单的main.go时出现链接器错误。任何想法如何解决这个问题?是否有指向成功gogcc构建的指针,甚至可以轻松验证的其他受欢迎目标也是如此?

主机是带有gcc 7.3.0的ubuntu 18.04。 crosstool-ng目标是x86_64-ubuntu16.04-linux-gnu,应使用glibc 2.23创建gcc 8.3.0。

以下是缺少的符号:

undefined reference to `__morestack_block_signals'
undefined reference to `__generic_morestack'
undefined reference to `__morestack_unblock_signals'
undefined reference to `__morestack_block_signals'
undefined reference to `__generic_releasestack'
undefined reference to `__generic_findstack'
undefined reference to `__generic_morestack_set_initial_sp'
undefined reference to `__morestack_load_mmap'

构建步骤的更多详细信息:

[1]检出crosstool-ng。它的主人现在是1.24.0。

[2]运行以下命令以构建纯c和c ++工具链:

./bootstrap
./configure --enable-local
make
./ct-ng show-x86_64-ubuntu16.04-linux-gnu
./ct-ng x86_64-ubuntu16.04-linux-gnu
./ct-ng build

[3]通过编译hello-world程序并运行来验证gcc是否工作。

[4]编辑脚本以启用go。该补丁看起来像:

diff --git a/scripts/build/cc/gcc.sh b/scripts/build/cc/gcc.sh
@@ -597,7 +597,7 @@ do_gcc_core_backend() {
-        --enable-languages="${lang_list}"              \
+        --enable-languages="${lang_list},go"              \
@@ -903,7 +903,7 @@ do_gcc_backend() {
-    extra_config+=("--enable-languages=${lang_list}")
+    extra_config+=("--enable-languages=${lang_list},go")

[5]再次运行./ct-ng build

[6]编译一个非常简单的main.go:

// main.go
package main

import "fmt"
func main() {
    fmt.Printf("Ok, ok, this is exactly perfect!\n")
}

使用命令:

PATH=${HOME}/x-tools/x86_64-ubuntu16.04-linux-gnu/bin/:${PATH}
export PATH

x86_64-ubuntu16.04-linux-gnu-gccgo -o main main.go

遇到这些错误:

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/x-tools/x86_64-ubuntu16.04-linux-gnu/lib/gcc/x86_64-ubuntu16.04-linux-gnu/8.3.0/libgcc.a(morestack.o): 
in function `__morestack':

~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:504:
undefined reference to `__morestack_block_signals'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:512:
undefined reference to `__generic_morestack'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:531:
undefined reference to `__morestack_unblock_signals'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:556:
undefined reference to `__morestack_block_signals'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:562:
undefined reference to `__generic_releasestack'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:588:
undefined reference to `__morestack_unblock_signals'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:609:
undefined reference to `__generic_findstack'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/x-tools/x86_64-ubuntu16.04-linux-gnu/lib/gcc/x86_64-ubuntu16.04-linux-gnu/8.3.0/libgcc.a(morestack.o):
in function `__stack_split_initialize':

~/crosstool-ng/.build/x86_64-ubuntu16.04-linux-gnu/src/gcc/libgcc/config/i386/morestack.S:758:
undefined reference to `__generic_morestack_set_initial_sp'

~/x-tools/x86_64-ubuntu16.04-linux-gnu/lib/gcc/x86_64-ubuntu16.04-linux-gnu/8.3.0/../../../../x86_64-ubuntu16.04-linux-gnu/bin/ld:
~/x-tools/x86_64-ubuntu16.04-linux-gnu/lib/gcc/x86_64-ubuntu16.04-linux-gnu/8.3.0/libgcc.a(morestack.o):
(.ctors.65535+0x8):
undefined reference to `__morestack_load_mmap'

collect2: error: ld returned 1 exit status

0 个答案:

没有答案