Restore -static-executable on Linux.#29039
Conversation
|
Please test with following pull request: @swift-ci please test |
There was a problem hiding this comment.
Why not just use the alternate version always? The cost is nearly negligible - the cost is largely associated with the fact that the information from the ELF header parsing may be cached by the loader, which is not guaranteed.
340fd22 to
15ac30f
Compare
|
@swift-ci test |
|
Build failed |
|
Build failed |
|
Please test with following pull request: @swift-ci please test |
|
Build failed |
|
Please test with following pull request: @swift-ci please test linux |
|
Build failed |
|
Please test with following pull request: @swift-ci please test linux |
|
Build failed |
|
@swift-ci smoke test linux |
1 similar comment
|
@swift-ci smoke test linux |
|
Please test with following pull request: @swift-ci please test linux |
compnerd
left a comment
There was a problem hiding this comment.
I think I missed it or something ... why not use the parsing logic even for the shared linking?
There was a problem hiding this comment.
I really wish we had linker options ... -u pthread_self -u pthread_once -u pthead_key_create is so much better than this. sigh
There was a problem hiding this comment.
I had used ---defsym=__import_pthread_self=pthread_self options to the linker before but it looks like that doesnt create strong linkage anymore.
There was a problem hiding this comment.
--defsym creating a strong reference sounds like a bug. If you want to create a strong reference, you should use --require-defined or -u at the very least.
There was a problem hiding this comment.
I didnt know about this option! I had to use -undefined (-u) since ld.gold is being used, --require-defined seems to only work on ld
- Add back StaticBinaryELF.cpp which provides swift::lookupSymbol() for statically linked ELF binaries. - Build libswiftImageInspectionStatic.a from StaticBinaryELF.cpp - Update static-executable-args.lnk and replace libswiftImageInspectionShared with libswiftImageInspectionStatic. - Fix linkage to pthreads to avoid weak linkage issues in a static executable. - Add driver test for '-static-executable' on Linux to validate that output binary is statically linked.
15ac30f to
3b25795
Compare
|
Please test with following pull request: @swift-ci please test |
|
Build failed |
|
Build failed |
|
Please test with following pull request: @swift-ci please smoketest macos |
|
Please test with following pull request: @swift-ci please smoke test macos |
|
Please test with following pull request: @swift-ci please test macos |
|
Build failed |
This will only parse 1 ELF file and wont handle the extra shared libraries that are dynamically linked in or their relocations. There would also be no benefit to replacing a platform's |
|
Please test with following pull request: @swift-ci please test macos |
|
Build failed |
compnerd
left a comment
There was a problem hiding this comment.
This will only parse 1 ELF file and wont handle the extra shared libraries that are dynamically linked in or their relocations. There would also be no benefit to replacing a platform's
dladdr()even if a full implementation was written.
The registration is per module, and is not shared across dynamically shared libraries. I think that you are focusing too much about the fact that there is a wrapper for the dladdr in this file. That doesn't really belong in there, it was just convenient for it to get placed there I think.
There was a problem hiding this comment.
--defsym creating a strong reference sounds like a bug. If you want to create a strong reference, you should use --require-defined or -u at the very least.
pthread functions.
|
Please test with following pull request: @swift-ci please test |
|
Build failed |
|
Build failed |
|
|
|
Thats correct, its only really used for stack traces hence why it doesnt matter too much if the |
For server side work, I think we'd want to encourage building with at least
IIRC, at some point |
|
After checking the man pages and doing a test I found that So |
|
@spevans I think more than main bin vs library, IIRC |
|
An updated and more simplified version of this pr is #34180 |
Add back StaticBinaryELF.cpp which provides swift::lookupSymbol()
for statically linked ELF binaries.
Build libswiftImageInspectionStatic.a from StaticBinaryELF.cpp
Update static-executable-args.lnk and replace
libswiftImageInspectionShared with libswiftImageInspectionStatic.
Add driver tests for '-static-executable' on Linux to validate
that output binary is statically linked.
Fix linkage to pthreads to avoid weak linkage issues in a static
executable.
This is a rebase of a previous PR but that didnt work with Ubutnu18.04 only 16.04. This version has been tested with 16.04, 18.04 and 19.10.
Note, as with
-static-stdlib, onlyDispatchcan be used with-static-executable,Foundationcannot at this time.Integration tests have also been added to catch any future breakage of this change.