-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/cgo: build warning from freebsd/clang: DWARF2 only supports one section per compilation unit #14705
Comments
What does This kind of sounds like a bug in clang. What do you see if you compile a simple C program with the |
clang --version FreeBSD clang version 3.7.1 (tags/RELEASE_371/final 255217) 20151225 Target: x86_64-unknown-freebsd11.0 Thread model: posix hello.c // Hello world #include int main(void){ printf("Hello, world!\n"); return 0; } clang -gdwarf-2 hello.c [NOTE: nothing printed] |
@wheelcomplex, has there been a clang update on FreeBSD since the report? Did it fix this? |
Also, does this stop the build or just print a warning? |
Re-try in a new snapshot version of FreeBSD 11(r297692) and most recent tip(+ cdcb827), the warning generated as before. It only warning when CGO_ENABLED="1" and not an error stopping the build, postpone it to Go 1.8 would be OK. clang -version: FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0) Target: x86_64-unknown-freebsd11.0 Thread model: posix InstalledDir: /usr/bin uname -a: FreeBSD n550jk.localdomain 11.0-CURRENT FreeBSD 11.0-CURRENT #0 r297692: Fri Apr 8 03:07:13 UTC 2016 root@releng2.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 |
I can recreate the warning with clang 3.6:
But what I don't know is where the |
@ianlancetaylor, -gdwarf-2 is set by both cmd/cgo and cmd/link. I think the original motivation was to avoid some dwarf extensions we didn't understand. We could try changing it to -gdwarf and see what happens. There's certainly some dwarf 4 code in debug/dwarf now, with a comment:
:-) |
Since this is only a warning, let's leave it for now and address this in Go 1.8. |
|
I can recreate the warning by running
but I can't recreate it without setting |
No CGO_CFLAGS found in env command, would you please to tell me where is the source code line that invoke "CC=clang go build runtime/cgo" in $GOROOT/src/, so I can make a local change to print out the real command and all current environment at time. |
There is no such source code in Try running |
Thanks for reply @ianlancetaylor , I mean the command invoke by runOut() at https://github.com/golang/go/blob/master/src/cmd/go/build.go#L2039 Following log is the real command and all environment when build runtime/cgo: This issue has postpone to Go 1.8, just save relative information for analysis late. $ clang --version FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on LLVM 3.8.0) Target: x86_64-unknown-freebsd11.0 Thread model: posix InstalledDir: /usr/bin ./all.bash invoke command: ##### Building packages and commands for freebsd/amd64. runtime/internal/sys runtime/internal/atomic runtime errors internal/race sync/atomic .... cmd/internal/bio cmd/compile/internal/big runtime/cgo cd /home/rhinofly/sandspace/go/src/runtime/cgo CGO_LDFLAGS="-g" "-O2" "-lpthread" /home/rhinofly/sandspace/go/pkg/tool/freebsd_amd64/cgo -objdir $WORK/runtime/cgo/_obj/ -importpath runtime/cgo -import_runtime_cgo=false -import_syscall=false -- -I $WORK/runtime/cgo/_obj/ -Wall -Werror cgo.go clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/_cgo_main.o -c $WORK/runtime/cgo/_obj/_cgo_main.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/_cgo_export.o -c $WORK/runtime/cgo/_obj/_cgo_export.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/cgo.cgo2.o -c $WORK/runtime/cgo/_obj/cgo.cgo2.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_context.o -c ./gcc_context.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_freebsd_amd64.o -c ./gcc_freebsd_amd64.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_libinit.o -c ./gcc_libinit.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_setenv.o -c ./gcc_setenv.c clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_util.o -c ./gcc_util.c --- environment for src/runtime/cgo CC=clang GOHOSTARCH=amd64 LC_MONETARY=en_US.UTF-8 GLADE_PIXMAP_PATH=: XDG_MENU_PREFIX=xfce- SHELL=/usr/local/bin/bash TERM=dumb XDG_SESSION_COOKIE=12deea0229a14da431e00f8d57332f61-1463131597.699032-679227067 GOBIN=/home/rhinofly/sandspace/go/bin LC_NUMERIC=en_US.UTF-8 WINDOWID=44040196 GNOME_KEYRING_CONTROL=/home/rhinofly/home/.cache/keyring-N2ZOHY OLDPWD=/home/rhinofly/sandspace/go/src LC_ALL=en_US.UTF-8 USER=rhinofly GOROOT_BOOTSTRAP=/home/rhinofly/home/sandspace/bootstrap.official/freebsd_amd64 GLADE_MODULE_PATH=: SSH_AUTH_SOCK=/tmp/ssh-hytb0ID0idxx/agent.1203 USERNAME=rhinofly SESSION_MANAGER=local/n550jk.localdomain:/tmp/.ICE-unix/1216 GOSPACE=/home/rhinofly/home/sandspace XDG_CONFIG_DIRS=/etc/xdg:/usr/local/etc/xdg DESKTOP_SESSION=xfce PATH=/home/rhinofly/sandspace/go/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/games:/usr/local/games LC_MESSAGES=en_US.UTF-8 QT_IM_MODULE=fcitx LC_COLLATE=en_US.UTF-8 GOARM=7 PWD=/home/rhinofly/sandspace/go/src XDG_SESSION_TYPE=x11 XMODIFIERS=@im=fcitx GOARCH=amd64 LANG=en_US.UTF-8 GDMSESSION=xfce CGO_ENABLED=1 HOME=/home/rhinofly/home SHLVL=4 GOROOT=/home/rhinofly/sandspace/go GOOS=freebsd LOGNAME=rhinofly XDG_SESSION_DESKTOP=xfce LC_CTYPE=en_US.UTF-8 XDG_DATA_DIRS=/usr/local/share:/usr/share GOHOSTOS=freebsd GOPATH= WINDOWPATH=9 DISPLAY=:0.0 GTK3_IM_MODULE=fcitx GLADE_CATALOG_PATH=: GTK_IM_MODULE=fcitx XDG_CURRENT_DESKTOP=XFCE LC_TIME=en_US.UTF-8 XAUTHORITY=/var/run/gdm/auth-for-rhinofly-5ZAgcz/database COLORTERM=xfce4-terminal _=/home/rhinofly/sandspace/go/pkg/tool/freebsd_amd64/go_bootstrap GOTOOLDIR=/home/rhinofly/sandspace/go/pkg/tool/freebsd_amd64 GOGCCFLAGS=-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/home/rhinofly/home/sandspace/tmp/go-build049237945=/tmp/go-build -gno-record-gcc-switches CXX=clang++ --- clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -I $WORK/runtime/cgo/_obj/ -g -O2 -Wall -Werror -o $WORK/runtime/cgo/_obj/gcc_amd64.o -c ./gcc_amd64.S # runtime/cgo runtime/cgo/gcc_amd64.S:47:1: warning: DWARF2 only supports one section per compilation unit .section .note.GNU-stack,"",@progbits ^ clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/runtime/cgo/_obj/_cgo_.o $WORK/runtime/cgo/_obj/_cgo_main.o $WORK/runtime/cgo/_obj/_cgo_export.o $WORK/runtime/cgo/_obj/cgo.cgo2.o $WORK/runtime/cgo/_obj/gcc_context.o $WORK/runtime/cgo/_obj/gcc_freebsd_amd64.o $WORK/runtime/cgo/_obj/gcc_libinit.o $WORK/runtime/cgo/_obj/gcc_setenv.o $WORK/runtime/cgo/_obj/gcc_util.o $WORK/runtime/cgo/_obj/gcc_amd64.o -g -O2 -lpthread /home/rhinofly/sandspace/go/pkg/tool/freebsd_amd64/cgo -objdir $WORK/runtime/cgo/_obj/ -dynpackage cgo -dynimport $WORK/runtime/cgo/_obj/_cgo_.o -dynout $WORK/runtime/cgo/_obj/_cgo_import.go -dynlinker clang -I . -fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=$WORK=/tmp/go-build -gno-record-gcc-switches -o $WORK/runtime/cgo/_obj/_all.o $WORK/runtime/cgo/_obj/_cgo_export.o $WORK/runtime/cgo/_obj/cgo.cgo2.o $WORK/runtime/cgo/_obj/gcc_context.o $WORK/runtime/cgo/_obj/gcc_freebsd_amd64.o $WORK/runtime/cgo/_obj/gcc_libinit.o $WORK/runtime/cgo/_obj/gcc_setenv.o $WORK/runtime/cgo/_obj/gcc_util.o $WORK/runtime/cgo/_obj/gcc_amd64.o -g -O2 -Wl,-r -nostdlib /home/rhinofly/sandspace/go/pkg/tool/freebsd_amd64/compile -o $WORK/runtime/cgo.a -trimpath $WORK -p runtime/cgo -buildid f6d80b347c15845bdb589d38b0202f637d2e07c0 -D _/home/rhinofly/sandspace/go/src/runtime/cgo -I $WORK -pack -asmhdr $WORK/runtime/cgo/_obj/go_asm.h ./callbacks.go ./freebsd.go ./iscgo.go ./setenv.go $WORK/runtime/cgo/_obj/_cgo_gotypes.go $WORK/runtime/cgo/_obj/cgo.cgo1.go $WORK/runtime/cgo/_obj/_cgo_import.go /home/rhinofly/sandspace/go/pkg/tool/freebsd_amd64/asm -o $WORK/runtime/cgo/_obj/asm_amd64.o -trimpath $WORK -I $WORK/runtime/cgo/_obj/ -I /home/rhinofly/sandspace/go/pkg/include -D GOOS_freebsd -D GOARCH_amd64 ./asm_amd64.s go/importer net os/user cmd/asm/internal/arch cmd/compile/internal/ssa ... ... BTW: ./all.bash does not PASS at present, effected by #15405 |
Thanks for the detail. I have no explanation. I can't recreate the problem. I don't understand why clang is saying anything about DWARF-2 at all. Nothing in the command line you show is telling clang to use DWARF-2. |
May be I have fingered it out: http://comments.gmane.org/gmane.os.freebsd.devel.toolchain/1982 saying "these are harmless" and can not disabled. tested with CGO_CFLAGS=-gdwarf-4, the waring is gone. Should we use -gdwarf-4 by default? Or just change the Milestone to "Unplanned " and wait for FreeBSD 11 reach it's release day(it's in -CURRENT now)? |
Our only reasonable default is -g, and that is what we use. In the command line you showed, nothing is passing -gdwarf-2 to clang. Why does clang default to -gdwarf-2? I'll note that it's also pointless to issue a warning about a .note section, particularly a .note.GNU-stack section. The warning may be harmless but it's completely pointless. Those sections are essentially required on GNU/Linux, and have no contents so the lack of debug info is irrelevant. |
Current freebsd source code showed the dwarf version is default to version 2 when only -g was specified:
BTW: They change default value from 3 to 2 at: freebsd/freebsd-src@a65c336 |
I'm dropping this to unplanned, because the problem seems to be due to a set of bugs in tools other than Go. If somebody figures out a clean fix, great. Otherwise, it's just a warning. |
If FreeBSD does not support the |
@ianlancetaylor, we have FreeBSD 11 builders accessible via gomote now. |
@ianlancetaylor, should I just disable the compiler-warnings-promoted-to-errors-on-builders feature for our FreeBSD 11 builders for now? |
I think this is clearly a bug in clang's assembler, which should not issue a warning about an empty section regardless of the DWARF version. But I will send a CL to work around the problem. |
CL https://golang.org/cl/38072 mentions this issue. |
Reopening for Go 1.8 backport. |
CL https://golang.org/cl/42500 mentions this issue. |
… try without -g Backport of CL 38072 Fixes #14705 Change-Id: Ie66a19d406c80e011e9918d6eddafbfc4abf95e4 Reviewed-on: https://go-review.googlesource.com/42500 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
CL https://golang.org/cl/43995 mentions this issue. |
… try without -g Backport of CL 38072 Fixes #14705 Reviewed-on: https://go-review.googlesource.com/42500 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Change-Id: Ia6ce2a41434aef2f8745a6a862ea66608b1e25f7 Reviewed-on: https://go-review.googlesource.com/43995 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Please answer these questions before submitting your issue. Thanks!
go version
)?go version devel +beabd87 Tue Mar 8 06:02:15 2016 +0000 freebsd/amd64
go env
)?(Use play.golang.org to provide a runnable example, if possible.)
git clone https://github.com/golang/go.git tips-go && cd tips-go/src && ./all.bash
build done without error and warning.
The text was updated successfully, but these errors were encountered: