I'm building gccgo with crosstool-ng 1.24.0. Got linker error when compiling the very simple main.go. Any idea how to solve this? Any pointer to a successful gogcc build even for a different popular target that can easily be verified?
The host is ubuntu 18.04 with gcc 7.3.0. The crosstool-ng target is x86_64-ubuntu16.04-linux-gnu which should create gcc 8.3.0 with glibc 2.23.
Here are the missing symbols:
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'
More details of the build steps:
[1] Check out crosstool-ng. It's master is now on 1.24.0.
[2] Run these commands to build a plain c and c++ toolchain:
./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] Verify that the gcc works by compiling a hello-world program and run.
[4] Edit the script to enable go. The patch looks like:
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] Run ./ct-ng build
again.
[6] Compile a very simple main.go:
// main.go
package main
import "fmt"
func main() {
fmt.Printf("Ok, ok, this is exactly perfect!
")
}
Using command:
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
Got these errors:
~/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