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
gccgo: cross compiling with GCC11.1 cause many undefined reference #45843
Comments
Did you build gccgo yourself? In your build directory, what is the contents of the generated file sparcv9-sun-solaris2.11/libgo/runtime_linknames.go? Thanks. |
Yes I'm build gcc by myself and here you are content of sparcv9-sun-solaris2.11/libgo/runtime_linknames.go root@d3fc663ba707:/tmp/tmp.x6cBnklrDH# cat sparcv9-sun-solaris2.11/libgo/runtime_linknames.go // Code generated by mklinknames.awk. DO NOT EDIT. package runtime import _ "unsafe" //go:linkname libcPipe pip //go:linkname libcPipe2 pipe //go:linkname sigaction sigactio //go:linkname sigprocmask sigprocmas //go:linkname sigfillset sigfillse //go:linkname sigemptyset sigemptyse //go:linkname c_sigaddset sigaddse //go:linkname c_sigdelset sigdelse //go:linkname sigaltstack sigaltstac //go:linkname raise rais //go:linkname getpid getpi //go:linkname kill kil //go:linkname setitimer setitime //go:linkname exit exi |
Thanks. That file is generated by libgo/mklinknames.awk, and clearly it is not working. But I don't see why. What version of awk do you have installed? What do you see if you run |
I was compile gcc in docker build base on buildpack-deps:buster root@e815928baf27:/tmp/tmp.x6cBnklrDH# grep sigaltstack sparcv9-sun-solaris2.11/libgo/gen-sysinfo.go type _sigaltstack struct { ss_sp *byte; ss_size uint64; ss_flags int32; Godump_0_pad [4]byte; } const _sizeof_sigaltstack = 24 type _stack_t _sigaltstack func _sigaltstack (*_stack_t, *_stack_t) int32 __asm__("sigaltstack") const _SYS_sigaltstack = 97 and awk version root@e815928baf27:/tmp/tmp.x6cBnklrDH# awk -W version mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan compiled limits: max NF 32767 sprintf buffer 2040 |
tl;dr: Check the binutils version used when linking go object files I encountered the very same problem without cross compiling today. Unfortunately, I do not have access to the log files right now, but here is how to replicate it:
The result is a very similar error as above. The failing step was the compilation of some go tools. When I tried to dig into it, it looked like all references had one letter cut off. I digged further and what I found was that collect2 was running /usr/bin/ld instead of the one bootstrapped from the binutils. Now I am not an expert regarding the build/bootstrap/cross compilation process and it might be that I missed some environment variables when digging, so take this with a grain of salt. But I am 100% certain that the same build script worked just fine on fedora 33 and I think it also passed on ubuntu 20.04 - so the older version of binutils seems to be related. I think gcc upgraded some internal formats (DWARF?) and the older binutils cannot cope with that. |
My last comment is not the root cause. The cause is in the mklinknames.awk script. It contains the following line:
That 0 should be a 1 according to
I will try to come up with a patch. Where do I submit it, if it works? |
Here is the patch I used to fix the build problem. @bearx3f you might want to give it a try. I tried to upstream it, but somehow I cannot send to gcc-patches@gcc.gnu.org . (The changelog part might not apply to the 11.1.0 release tarball, just delete it, it doesn't matter). |
@ianlancetaylor I confirm that @choeger's solution works
|
@choeger I think here https://github.com/golang/gofrontend is proper way to submit patch |
The awk script used a zero-based index which worked on surprisingly many plattforms. According to the man page, however, the function expects one-based indexing. For reference see this bug in the go git repository: golang/go#45843 Signed-off-by: Christoph Höger <choeger@umpa-net.de>
@ianlancetaylor maybe my problem is all about awk version problem version root@e815928baf27:/tmp/tmp.x6cBnklrDH# awk -W version mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan compiled limits: max NF 32767 sprintf buffer 2040 success version apt-get install gawk root@d772f8344b47:/go# awk -W version GNU Awk 4.2.1, API: 2.0 (GNU MPFR 4.0.2, GNU MP 6.1.2) Copyright (C) 1989, 1991-2018 Free Software Foundation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/. my issue is closed. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
compile go with gccgo
I'm guessing link func name is missing last character
sparcv9-sun-solaris2.11-ld -v
Outputgccgo -v
OutputWhat did you expect to see?
successfully compile
What did you see instead?
The text was updated successfully, but these errors were encountered: