I'm getting a funny print when trying to create a statically linked executable
on Linux x64.
The driver does not actually support this
(https://bugs.swift.org/browse/SR-730) and so I'm compiling by hand so I can
learn to write the correct driver patch.
$ cat test.swift
print("hello world")
$ swiftc -frontend -c -primary-file test.swift -target x86_64-unknown-linux-gnu
-disable-objc-interop -color-diagnostics -module-name test -o test.o
$ clang++ -ldl -lpthread -lbsd -licui18n -licuuc
/usr/local/lib/swift/linux/x86_64/swift_begin.o test.o -L
/usr/local/lib/swift_static/linux/ -lswiftCore -lswiftSwiftOnoneSupport
--target=x86_64-unknown-linux-gnu
/usr/local/lib/swift/linux/x86_64/swift_end.o -o test
$ ./test
String(_core: Swift._StringCore(_baseAddress: Swift.COpaquePointer(_rawValue:
(Opaque Value)), _countAndFlags: Swift.UInt(_value: (Opaque Value)), _owner:
Swift.Optional<Swift.AnyObject>.None))
Literally the *only* difference between this and an ordinary swift build that
works fine is that I'm linking with libswiftCore.a libswiftSwiftOnoneSupport.a
instead of libswiftCore.so libswiftSwiftOnoneSupport.so.
It's been suggested that this problem is due to "missing protocol conformance
tables", but I'm afraid that vocabulary is greek to me. Things I've tried:
* Make sure swift_begin.o and swift_end.o surround the invocation (you can see
them above)
* Make sure swift_begin.o and swift_end.o surround the *link* invocation
(here's clang++ -v)
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/usr/bin/ld" --hash-style=both --build-id --eh-frame-hdr -m elf_x86_64
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -o test
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o
-L/usr/local/lib/swift_static/linux/ -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
-L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu
-L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu
-L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../..
-L/usr/lib/llvm-3.5/bin/../lib -L/lib -L/usr/lib -ldl -lpthread -lbsd -licui18n
-licuuc /usr/local/lib/swift/linux/x86_64/swift_begin.o test.o -lswiftCore
-lswiftSwiftOnoneSupport /usr/local/lib/swift/linux/x86_64/swift_end.o -lstdc++
-lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/crtend.o
/usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crtn.o
* Look at the executable with objdump. Here is the objdump for a
statically-linked executable
<https://bugs.swift.org/browse/SR-730?focusedCommentId=12798&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12798>
(broken) and compared to a dynamically linked executable
<https://bugs.swift.org/browse/SR-730?focusedCommentId=12799&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12799>.
I don't know exactly what I'm looking for, but people a lot smarter than me
seem satisfied the output is plausible.
* Extract libswiftCore.a and libswiftSwiftOnoneSupport.a into object files and
link the object files manually. This has no effect.
I am totally out of leads on this, and many very bright people have tried, and
failed, to help me understand WTF is going on. I would greatly appreciate any
leads, suggestions, ideas, or help.
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev