-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Expose function sections option #28088
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
This is inspired from Alan Dragomirecký's https://github.com/swift-embedded/swift, which is focused on microcontrollers and is a lot more aggressive. I'm aiming for a safe, small subset of that which still results in significant wins and follow-up with additional changes to reap a lot more benefits. |
d7df7a1
to
fcd2c57
Compare
@@ -0,0 +1,10 @@ | |||
// REQUIRES: OS=linux-gnu || OS=linux-androideabi || OS=linux-android || OS=freebsd |
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.
Can we use %target-object-format
and compare it to ELF
instead?
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.
Not in the REQUIRES
directive:
ValueError: couldn't parse text: '%target-object-format=elf'
in expression: '%target-object-format=elf'
in REQUIRES: directive on test line 1
If there is another way to limit it to ELF, that'd be cool.
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.
That is rather unfortunate. Out of curiosity, what happens if you use -function-sections
on MachO or PE/COFF? I'm wondering if we should actually prevent that in the driver. Apple's usage of MachO actually uses .subsections_via_symbols
which means that everything is atomized and you effectively are doing -function-sections
, and PE/COFF's symbol resolution is pretty close to this already.
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 don't have easy access to the other platforms. Also, is the linker / the map file format the same, at this point?
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.
The linker map is linker dependent unfortunately.
@swift-ci please smoke test |
@swift-ci please test |
Build failed |
Build failed |
I honestly don't know enough to know if this is a good idea, so I'll tag a reviewer who's more likely to. |
fcd2c57
to
c26e00a
Compare
@swift-ci please smoke test |
@brentdax - this is a good idea; MachO sorta does this implicitly through |
c26e00a
to
abd0aa5
Compare
@swift-ci please smoke test |
Swift generally doesn't use |
@swift-ci please test windows platform |
abd0aa5
to
10c620d
Compare
@swift-ci please test windows platform |
@swift-ci please test Windows platform |
1 similar comment
@swift-ci please test Windows platform |
@swift-ci please clean test Windows platform |
10c620d
to
dbc50fb
Compare
@swift-ci please clean test Windows platform |
@swift-ci please test |
@swift-ci please clean test Windows platform |
@swift-ci please test Windows platform |
Build failed |
daa1a1d
to
05815d1
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test Windows platform |
Build failed |
05815d1
to
a210fb7
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
@swift-ci please test Windows platform |
a210fb7
to
f07de92
Compare
@swift-ci please test Windows platform |
@swift-ci please test |
@swift-ci please test Windows platform |
@swift-ci please clean test windows platform |
f07de92
to
1de737f
Compare
@swift-ci please test |
@swift-ci please test Windows platform |
@swift-ci please clean test Windows platform |
The test that flaked on Windows is unrelated to this. Going to go ahead and merge this. |
Add an option to generate an ELF section for each function, similar to the
-ffunction-sections
in Clang. In conjunction with the section elimination feature in the linker, this helps reducing the binary size for applications. This is especially helpful when an application only uses a small fraction of the Swift standard library and links it statically (the standard library needs be built with-Xfrontend -function-sections
in that case).