Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

__compact_unwind linker issue (possibly darwin specific) #146

Open
quarnster opened this issue Apr 18, 2014 · 3 comments
Open

__compact_unwind linker issue (possibly darwin specific) #146

quarnster opened this issue Apr 18, 2014 · 3 comments

Comments

@quarnster
Copy link
Contributor

Didn't find one for this one neither, and it still happens (also originally from #70 (comment)). Any ideas?

14:34 /tmp $ cat hello.go
package main

func main() {
    println("hello")
}
14:34 /tmp $ llgo-build -run hello.go
2014/04/18 14:34:24 building main
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
clang: warning: argument unused during compilation: '-pthread'
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o /var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/llgo102561321/hello.bc -L/usr/local/Cellar/llvm/3.4/lib /var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/llgo102561321/hello.bc.o -lz -lpthread -lcurses -lm -L/usr/local/Cellar/llvm/3.4/lib -lLLVM-3.4 -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
ld: warning: __LD,__compact_unwind entries for _runtime.ctlz8 have a gap at offset 0x1D
ld: warning: __LD,__compact_unwind entries for _runtime.ctlz8 have a gap at offset 0xCD
ld: warning: __LD,__compact_unwind entries for _runtime.ctlz8 have a gap at offset 0xE7
hello
14:34 /tmp $ cat hello.go
package main

import "fmt"

func main() {
    fmt.Println("hello")
}
14:34 /tmp $ llgo-build -run hello.go
2014/04/18 14:34:31 building main
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
clang: warning: argument unused during compilation: '-pthread'
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o /var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/llgo252369648/hello.bc -L/usr/local/Cellar/llvm/3.4/lib -L/usr/local/Cellar/llvm/3.4/lib /var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/llgo252369648/hello.bc.o -lz -lpthread -lcurses -lm -L/usr/local/Cellar/llvm/3.4/lib -lLLVM-3.4 -lz -lpthread -lcurses -lm -L/usr/local/Cellar/llvm/3.4/lib -lLLVM-3.4 -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.osx.a
ld: warning: __LD,__compact_unwind entries for _(fmt.ScanState).Read have a gap at offset 0x4D
ld: warning: __LD,__compact_unwind entries for _(fmt.ScanState).Read have a gap at offset 0x6E
ld: warning: __LD,__compact_unwind entries for _(fmt.ScanState).Read have a gap at offset 0x1DE
ld: warning: __LD,__compact_unwind entries for _(fmt.ScanState).Read have a gap at offset 0x1F7
ld: warning: __LD,__compact_unwind entries for _(fmt.ScanState).Read have a gap at offset 0x217
ld: warning: __LD,__compact_unwind entries for _(fmt.ScanState).Read have a gap at offset 0x263
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x6
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x75
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x97
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0xBA
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0xDA
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0xFA
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x11A
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x13A
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x15A
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x17A
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x19A
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x1BA
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x1DA
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x1FA
ld: warning: __LD,__compact_unwind entries for _reflect.methodFuncStub have a gap at offset 0x21A
ld: too many compact unwind infos in function _reflect.methodFuncStub file '/var/folders/n1/yjqlqd2s04x7th1152h48hsr0000gn/T/llgo252369648/hello.bc.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
2014/04/18 14:34:33 exit status 1
14:34 /tmp $
@axw
Copy link
Member

axw commented Apr 19, 2014

No idea I'm afraid. Looks like wonky DWARF/debug metadata, but I'm not really sure.

@geoff-nixon
Copy link

Ah. I know this one. And yes, its very Darwin specific.

Apple screwed up back during the upheaval/insurrection transition from gcc, libgcc, and libsupc++ to clang, compiler-rt and libc++abi. 10.4-10.6 days. It's a long, sordid, horrible story; but if you're really interested, a good enough place to start as any:

https://llvm.org/svn/llvm-project/libcxxabi/trunk/include/unwind.h
http://lists.apple.com/archives/xcode-users/2011/Feb/msg00043.html

The short of it is that the GCC support libraries on Darwin were never fixed (and aren't to this day).

Apple walked away, re-implimented them all entirely; and from what I can gather, the GNU libs are perma-wontfix in GCC upstream.

Amongst other things, this affair is responsible for things like:

  • The system libgcc_s.10.4, libgcc_s.10.5 vs. libgcc_ext.10.4 and libgcc_ext.10.5 installed by GCC.
    (Any/All of these can be drop-in replaced with libclang_rt.a OR libgcc.a. All effectively identical.)
  • Lots of weird ABI breakage related to C++ stdlibs, for no explicable reason (like, no C++ linked).
  • This issue… more.

I'm not really familiar with your project (I stumbled on this issue trying to figure out if the golang "6l" linker implements a true, non-ld64-wrapping, independent linker on Darwin. Anyone know?), but if I had to guess, this looks to be a good candidate for why you're seeing this (generally speaking):

https://github.com/go-llvm/llgo/blob/master/cmd/llgo-build/build.go#L290

Basically, you really don't wan't to be doing that on this platform. Its a pretty a toxic combination. Should be avoided if at all possible, for a host of reasons besides this one (linkage dependency, etc).

But perhaps its unavoidable here (?), i.e., by virtue of the fact that, (last I checked?) GCC Go can't be built against either libc++ or Apple's old libstdc++, but only late-model libstdc++?

Anyway… hope that helps a bit.

P.S.
Similar story, different time, different operating system:
https://wiki.freebsd.org/NewC++Stack

@quarnster
Copy link
Contributor Author

(I stumbled on this issue trying to figure out if the golang "6l" linker implements a true, non-ld64-wrapping, independent linker on Darwin. Anyone know?)

It does, compare output of go build -x -ldflags="-v" hello.go and go build -x -ldflags="-v -linkmode=external" hello.go.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants