-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Restore -static-executable on Linux. #15183
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
Conversation
Hmm, why not leave this as is, and just modify the swiftrt.o to have a static version which doesn't invoke the register method? That way, this can fully be reincorporated into the runtime, and the driver can make the appropriate choice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment, I suppose that the notification might work better this way.
@compnerd Sorry for the delay in replying, are you suggesting something like create a |
9026cf6
to
176f2ad
Compare
@spevans, yes, effectively that. However, thinking more about this, we can be even more clever about this. On the static builds, you still need to link to the (static) runtime. The static runtime can include the object file, and we can create a reference to it, causing the linker to preserve the object from the runtime itself and avoid having to have the driver push the file into the actual linker invocation. |
@compnerd In the most recent version I created |
While functionally equivalent, this introduces yet another copy of the table of sections. It is another place where we need to update that list. If we compile the single file with a macro we can get away with a single place for all of ELF, which I think is better. |
Addresses the functional change, stylistic changes remain
@swift-ci please test |
43f9658
to
e9774ac
Compare
@swift-ci please test |
Build failed |
Build failed |
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just a duplication of the swift_addNewDSOImage
? Why not just use that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it might be possible to reduce some duplication of the code which would be better.
cea1288
to
b5d0def
Compare
@swift-ci test linux |
Build failed |
@swift-ci test linux |
Build failed |
b5d0def
to
1d2ea19
Compare
@swift-ci test linux |
@swift-ci Please smoke test OS X platform |
@compnerd I know this PR is quite old but I have updated it including a test and removed the duplicate sections I added in |
Any updates on this PR? |
I have bumped into this issue and filed a bug: https://bugs.swift.org/browse/SR-10328. |
@frol Unfortunately this PR still has some issues on Ubuntu18.04, relating to glibc and pthreads so it still needs some more work |
As I think you were alluding to, in a fully-static binary there really isn't any need for a table of sections at all, since we ought to be able to link the runtime directly against the beginnings and ends of the sections from the main program. |
Just a quick question, I was using
This PR will solve this error? |
Apple platforms do not support statically linked executables, see https://developer.apple.com/library/content/qa/qa1118/_index.html |
- Build libswiftImageInspectionStatic.a from SwiftRT-ELF.cpp and 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 and SwiftRT-ELF.o in a static executable
- If an address does not fall inside a symbol's region then return the symbol with the smallest gap between then end of the symbol's region and the address.
1d2ea19
to
c77d3a6
Compare
Please test with following PR: |
Build failed |
Build failed |
Please test with following PR: |
Build failed |
Please test with following PR: swiftlang/swift-integration-tests#59 |
@spevans It's been a while and this has gathered quite a few conflicts. Is this still something you're interested in pursuing? |
Would restoring the static executable flag for Linux allow statically-linked toolchains on Linux? Because if so, I think that would be incredibly helpful for producing cross-distro compatible Linux toolchains. |
@CodaFi I'll close this off for now, I need to get @aemino This PR was for producing statically linked binaries as the output of |
Build libswiftImageInspectionStatic.a from
ImageInspectionELF.cpp and StaticBinaryELF.cpp
Update static-executable-args.lnk and replace
libswiftImageInspectionShared with libswiftImageInspectionStatic.
This fixes
-static-executable
on Linux to build a static binary (when linked with appropiate libicu .a libs`