-
Notifications
You must be signed in to change notification settings - Fork 66
Optimize build for libbz2.a
#88
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,26 @@ fn main() { | |
|
||
let dst = PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
|
||
cfg.flag_if_supported("-ffunction-sections") | ||
.flag_if_supported("-fdata-sections") | ||
.flag_if_supported("-fmerge-all-constants") | ||
.flag_if_supported("-Wl,--gc-sections") | ||
.flag_if_supported("-Wl,--icf=safe"); | ||
|
||
if cfg!(feature = "fat-lto") { | ||
cfg.flag_if_supported("-flto"); | ||
} else if cfg!(feature = "thin-lto") { | ||
if cfg.is_flag_supported("-flto=thin").unwrap_or(false) { | ||
cfg.flag("-flto=thin"); | ||
} else { | ||
cfg.flag_if_supported("-flto"); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've asked at https://rust-lang.zulipchat.com/#narrow/channel/246057-t-cargo/topic/read.20lto.20config.20from.20build.20script if there is a way to read the LTO state from cargo without having to use feature flags. In any case this won't actually LTO between bzip2 and any rust code. That is only possible when using the rust port of bzip2 rather than the C original or by using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out the cc crate itself nowadays handles |
||
|
||
if cfg!(feature = "thin") { | ||
cfg.opt_level_str("z"); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably forward the |
||
|
||
cfg.include("bzip2-1.0.8") | ||
.define("_FILE_OFFSET_BITS", Some("64")) | ||
.define("BZ_NO_STDIO", None) | ||
|
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.
Makes sense to have
-ffunction-sections
and co.-Wl,--gc-sections
and-Wl,--icf=safe
can be omitted though as those only apply to linking by the cc crate, but we only build a staticlib here. They don't have any effect on linking done by rustc.