Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gollvm: build fail on slackware 14.2 in tools/gollvm/libgo/runtime_sysinfo.go #26405

Open
bcgraham opened this issue Jul 16, 2018 · 15 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@bcgraham
Copy link

Please answer these questions before submitting your issue. Thanks!

What operating system and processor architecture are you using (go env)?

x86_64, slackware 14.2

What did you do?

In my build directory: cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86" -G "Unix Makefiles" ../llvm && make all -j4 but as far as I can tell, it just happens on my system regardless of other options when I build x86 (use gold linker, build with other targets, etc.)

What did you expect to see?

Successful build.

What did you see instead?

/[my-build-path]/tools/gollvm/libgo/runtime_sysinfo.go:5966:32: error: expected ')'
/[my-build-path]/tools/gollvm/libgo/runtime_sysinfo.go:5966:32: error: expected '='
/[my-build-path]/tools/gollvm/libgo/runtime_sysinfo.go:5966:32: error: expected ';' or newline after top level declaration
/[my-build-path]/tools/gollvm/libgo/runtime_sysinfo.go:5965:36: use of undefined type 'ext'
make[2]: *** [tools/gollvm/libgo/CMakeFiles/libgotool.dir/build.make:1737: tools/gollvm/libgo/.pic/runtime.o] Error 3
make[1]: *** [CMakeFiles/Makefile2:15851: tools/gollvm/libgo/CMakeFiles/libgotool.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

Those lines in runtime_sysinfo.go contain:

const ___glibc_clang_has_extension(ext) = 0
const ___glibc_clang_prereq(maj,min) = 0

A little investigation seemed to indicate these slipped through libgo/godumpspec/m{parser,tokenizer} because their bodies don't reference their parameters.

If I comment these lines out, and analogous lines in /[my-build-path]/tools/gollvm/libgo/sysinfo.go when building syscall, the build errors out while building libgo_shared because ld.gold can't find __morestack, -lgcc, crt1.o, etc. This part superficially has more in common with building gccgo. My binutils use gold, so even when I don't tell CMake to use gold, eventually it gets invoked. I am still investigating this latter part, but the above const/macro stuff seemed reportable.

@FiloSottile FiloSottile added this to the Gccgo milestone Jul 16, 2018
@FiloSottile
Copy link
Contributor

/cc @thanm @cherrymui

@thanm thanm self-assigned this Jul 17, 2018
@thanm
Copy link
Contributor

thanm commented Jul 17, 2018

Thanks for reporting this; I will take a look.

@gopherbot
Copy link

Change https://golang.org/cl/124375 mentions this issue: gollvm: fix bug in godumpspec macro parser

@thanm
Copy link
Contributor

thanm commented Jul 17, 2018

OK, I have sent a CL that should fix the macro parser issue.

For the second part, not sure what the issue might be without more info. If you can post more details on the failure mode that would be helpful. Also the output of a - v run, e.g. from the top of your build area

$ echo "package tiny" > tiny.go
$ ./llvm-goc -v -c tiny.go
<...>
$

@thanm
Copy link
Contributor

thanm commented Jul 17, 2018

Sorry that last bit should read:

$ ./bin/llvm-goc -v -c tiny.go

@bcgraham
Copy link
Author

go env output:

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/brian/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/brian/go"
GORACE=""
GOROOT="/usr"
GOTMPDIR=""
GOTOOLDIR="/usr/libexec/gcc/x86_64-slackware-linux/8.1.0"
GCCGO="/usr/bin/gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build260219685=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

The llvm source directory is at git commit 9ca09e7b2d2. The gollvm source directory is at git commit fef66b4.

I usually run fish shell, but it doesn't seem to play nice with the build scripts, so this is run from bash, with export SHELL=/bin/bash, in a build directory.

cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=gold -DLLVM_TARGETS_TO_BUILD="X86" -G "Unix Makefiles" ../llvm && make

This eventually errors out with:

...
[ 10%] Building Go package 'net/rpc/jsonrpc' (non-PIC)
[ 10%] Building Go package 'net/smtp' (non-PIC)
[ 10%] Building Go package 'os/signal/internal/pty' (non-PIC)
[ 10%] Building Go package 'runtime/pprof/internal/profile' (non-PIC)
[ 10%] Building Go package 'testing/iotest' (non-PIC)
[ 10%] Building Go package 'testing/quick' (non-PIC)
Scanning dependencies of target libgo_static
[ 10%] Linking C static library libgo.a
[ 10%] Built target libgo_static
Scanning dependencies of target gotools_cmd_buildid
[ 10%] Building object for go program buildid
[ 10%] Building go program buildid
ld.gold: error: cannot open crt1.o: No such file or directory
ld.gold: error: cannot open crti.o: No such file or directory
ld.gold: error: cannot open crtbegin.o: No such file or directory
ld.gold: error: cannot open crtend.o: No such file or directory
ld.gold: error: cannot open crtn.o: No such file or directory
ld.gold: error: cannot find -lgobegin
ld.gold: error: cannot find -lm
ld.gold: error: cannot find -lgcc_s
ld.gold: error: cannot find -lgcc
ld.gold: error: cannot find -lc
ld.gold: error: cannot find -lgcc_s
ld.gold: error: cannot find -lgcc
/home/brian/code/gollvm/r336809/llvm/tools/gollvm/gofrontend/libgo/go/cmd/buildid/buildid.go:5: error: undefined reference to '__morestack'
/home/brian/code/gollvm/r336809/llvm/tools/gollvm/gofrontend/libgo/go/cmd/buildid/buildid.go:17: error: undefined reference to '__morestack'
/home/brian/code/gollvm/r336809/llvm/tools/gollvm/gofrontend/libgo/go/cmd/buildid/buildid.go:25: error: undefined reference to '__morestack'
<built-in>:1: error: undefined reference to '__morestack'
/home/brian/code/gollvm/r336809/llvm/tools/gollvm/gofrontend/libgo/go/cmd/internal/buildid/buildid.go:104: error: undefined reference to '_Unwind_Resume'
make[2]: *** [tools/gollvm/gotools/CMakeFiles/gotools_cmd_buildid.dir/build.make:66: tools/gollvm/gotools/buildid] Error 4
make[1]: *** [CMakeFiles/Makefile2:34523: tools/gollvm/gotools/CMakeFiles/gotools_cmd_buildid.dir/all] Error 2
make: *** [Makefile:152: all] Error 2

Running ./bin/llvm-goc -v -c tiny.go results in:

$ ./bin/llvm-goc -v -c tiny.go
gollvm version 1 (experimental)
Candidate GCC install:
version:
foundTriple:
libPath:
parentLibPath:
installPath:
ProgramPaths:
/..//bin
FilePaths:
/../
Target: x86_64-unknown-linux-gnu
 ./bin/llvm-goc -S tiny.go -L/home/brian/code/gollvm/r336809/build.x86.gold2/./bin/../lib64 -o /tmp/compile-00e22c.s
 /usr/bin/as --64 -o tiny.o /tmp/compile-00e22c.s

@thanm
Copy link
Contributor

thanm commented Jul 20, 2018

Thanks -- that is helpful. What's happening is that Gollvm can't seem to locate the GCC installation on your machine. There is code in the gollvm driver (modeled after similar code in clang) that examines the host system to figure out which copy of GCC to use (for things like libgcc) -- evidently that code is not working properly.

If you could do one more experiment -- run "clang -c -v himom.c" and show the first part of the output for that (up until the actual tool path invocation).

@bcgraham
Copy link
Author

Sure, here's that output:

$ clang -c -v himom.c
clang version 5.0.0 (tags/RELEASE_500/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-slackware-linux/5.3.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-slackware-linux/7.2.0
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-slackware-linux/8.1.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-slackware-linux/5.3.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-slackware-linux/7.2.0
Found candidate GCC installation: /usr/lib64/gcc/x86_64-slackware-linux/8.1.0
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-slackware-linux/8.1.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
clang-5.0: error: no such file or directory: 'himom.c'

@thanm
Copy link
Contributor

thanm commented Jul 20, 2018

Thanks. I will work on a fix.

@bcgraham
Copy link
Author

Thanks very much for your time & help.

zchee pushed a commit to zchee/golang-gollvm that referenced this issue Aug 22, 2018
Be more restrictive about function-style macros -- they need to be
weeded out from the get-go (as opposed to indirectly as a result of
uses in other macros).

Updates golang/go#26405.

Change-Id: Ic8548df72d71d26ffa6b65886a08b21730026e65
Reviewed-on: https://go-review.googlesource.com/124375
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@luan-cestari
Copy link

Hi,

O think I got the same issue today, the build failed and it couldn't find the same libraries even they were already installed and available in the default path. I'm using Fedora 28 x86_64.

I ran the build with cmake:

cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_USE_LINKER=gold -G Ninja ../llvm

The error :

...
[3249/3257] Building go program buildid
FAILED: tools/gollvm/gotools/buildid 
cd /home/lcestari/workarea/build-release/tools/gollvm/gotools && /home/lcestari/workarea/build-release/./bin/llvm-goc -o /home/lcestari/workarea/build-release/tools/gollvm/gotools/buildid buildid_.o -I /home/lcestari/workarea/build-release/tools/gollvm/libgo -L /home/lcestari/workarea/build-release/tools/gollvm/libgo /home/lcestari/workarea/build-release/tools/gollvm/libgo/libgotool.a
/usr/bin/ld.gold: error: cannot open crt1.o: No such file or directory
/usr/bin/ld.gold: error: cannot open crti.o: No such file or directory
/usr/bin/ld.gold: error: cannot open crtn.o: No such file or directory
/usr/bin/ld.gold: error: cannot find -lm
/usr/bin/ld.gold: error: cannot find -lc
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function free_dynamic_blocks: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function free_dynamic_blocks: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_fail: error: undefined reference to 'writev'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_fail: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'munmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigemptyset'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigfillset'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigdelset'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'munmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'mmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'mmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'mprotect'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'writev'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space: error: undefined reference to 'malloc'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space: error: undefined reference to 'malloc'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'mmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'mprotect'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'munmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'getpagesize'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'getenv'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to 'mmap'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to 'mprotect'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigdelset'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_block_signals: error: undefined reference to 'sigprocmask'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_unblock_signals: error: undefined reference to 'sigprocmask'
/usr/lib/gcc/x86_64-redhat-linux/8/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space.cold.4: error: undefined reference to 'abort'
[3253/3257] Building object for go program cgo
ninja: build stopped: subcommand failed.

But I have them:

/usr/lib64/crtn.o
/usr/lib64/crt1.o
/usr/lib64/crti.o

I tried to find a way (like an environment variable) to inform cmake about them but I think there isn't an option.

@dmeibusch
Copy link

I've had a similar issue on Oracle Linux 7 using devtoolset-7 which puts gcc-7 in the path, but llvm-goc still detects the gcc-4 in /usr/bin/gcc
It's not a clean solution, I added:

  • renamed /usr/bin/gcc
  • symlinks from /usr/lib/gcc/x86_64-redhat-linux/7 to the /opt/rh/... devtoolset lib directory
  • added a line in Linux::Linux adding addIfPathExists(fpaths, llvm::Twine("/lib64");

The latter is a hack - not a proper detection. I know clang goes to further lengths to get this right.

@rsc rsc unassigned thanm Jun 23, 2022
@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 20, 2022
@seankhliao seankhliao modified the milestones: Gccgo, gollvm Aug 20, 2022
@alexanius
Copy link

Got the same problem as in the comment:

FAILED: tools/gollvm/gotools/go /home/alex/test/gollvm/build-debug/tools/gollvm/gotools/go 
cd /home/alex/test/gollvm/build-debug/tools/gollvm/gotools && /home/alex/test/gollvm/build-debug/./bin/llvm-goc -o /home/alex/test/gollvm/build-debug/tools/gollvm/gotools/go go_.o -I /home/alex/test/gollvm/build-debug/tools/gollvm/libgo -L /home/alex/test/gollvm/build-debug/tools/gollvm/libgo /home/alex/test/gollvm/build-debug/tools/gollvm/libgo/libgotool.a
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: cannot open crtn.o: Нет такого файла или каталога
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: warning: skipping incompatible /usr/lib/libm.so while searching for m
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: cannot find -lm
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: warning: skipping incompatible /usr/lib/libc.so while searching for c
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../x86_64-pc-linux-gnu/bin/ld.gold: error: cannot find -lc
/usr/lib64/crt1.o:function _start: error: undefined reference to '__libc_start_main'
/home/alex/test/gollvm/llvm-project/llvm/tools/gollvm/gofrontend/libgo/runtime/go-main.c:59: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_fail: error: undefined reference to 'writev'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_fail: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'syscall'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to 'free'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_release_segments: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigemptyset'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigfillset'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigdelset'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'syscall'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'sysconf'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'syscall'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'mprotect'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'sysconf'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'syscall'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'writev'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack: error: undefined reference to 'abort'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space: error: undefined reference to 'malloc'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space: error: undefined reference to 'malloc'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space: error: undefined reference to 'sigprocmask'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space: error: undefined reference to 'sigprocmask'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'mprotect'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'getpagesize'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_load_mmap: error: undefined reference to 'getenv'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to 'sysconf'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to 'mprotect'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to 'sysconf'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __splitstack_makecontext: error: undefined reference to '__errno_location'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __generic_morestack_set_initial_sp: error: undefined reference to 'sigdelset'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_block_signals: error: undefined reference to 'sigprocmask'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_unblock_signals: error: undefined reference to 'sigprocmask'
/usr/lib/gcc/x86_64-pc-linux-gnu/12.2.0/libgcc.a(generic-morestack.o):function __morestack_allocate_stack_space.cold: error: undefined reference to 'abort'
[1265/1273] Building object for go program cgo

For my system I fixed it with hard coding in file GnuTools.cpp. I replaced lines that added crt*.o with the following way:

cmdArgs.push_back(args.MakeArgString("/usr/lib64/crt1.o"));
cmdArgs.push_back(args.MakeArgString("/usr/lib64/crti.o"));
cmdArgs.push_back(args.MakeArgString("/usr/lib64/crtn.o"));

And also I added the line:

cmdArgs.push_back(args.MakeArgString("-L/usr/lib64/"));

After that build finished successfully.

@thanm
Copy link
Contributor

thanm commented Oct 26, 2022

@alexanius Thanks for that. Would you be willing to send a patch for this?

@alexanius
Copy link

@alexanius Thanks for that. Would you be willing to send a patch for this?

Well, it does not solve the problem in general but fixes build on gentoo. Also it is possible that we can remove condition for addIfPathExists(fpaths, llvm::Twine("/usr/" + osLibDir).str()); line and it will be more universal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

8 participants