-
Notifications
You must be signed in to change notification settings - Fork 710
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
Clarify build.rs C compiler and linker configuration. #1697
Conversation
// Compile all the (dirty) source files into object files. | ||
let objs = additional_srcs | ||
.iter() | ||
.chain(srcs.iter()) | ||
.map(|f| compile(f, target, out_dir, out_dir)) | ||
.map(|f| compile(&c, f, target, out_dir, out_dir)) |
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.
Now all the calls to compile()
share a single build configuration that is constructed once per library, instead of once per source file.
.collect::<Vec<_>>(); | ||
|
||
// Rebuild the library if necessary. | ||
let lib_path = PathBuf::from(out_dir).join(format!("lib{}.a", lib_name)); | ||
|
||
let mut c = cc::Build::new(); | ||
|
||
for f in LD_FLAGS { |
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.
LD_FLAGS was empty so this wasn't doing anything.
match ext { | ||
"c" | "S" => (), | ||
e => panic!("Unsupported file extension: {:?}", e), | ||
}; |
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.
Moved to the top of the new cc()
.
Clarify which parts of the build script modify the compiler configuration (`configure_cc`) and which don't (`cc`). Ensure that the configuration is only done once per library, instead of once per source file, as each `cc` invocation can reuse the configuration work done by a single `configure_cc` call.
ace2a13
to
43eb390
Compare
Codecov Report
@@ Coverage Diff @@
## main #1697 +/- ##
==========================================
+ Coverage 95.97% 95.98% +0.01%
==========================================
Files 134 134
Lines 19980 19980
Branches 199 199
==========================================
+ Hits 19175 19177 +2
Misses 767 767
+ Partials 38 36 -2 see 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
cc-rs's documentation says that it already handles this automatically, which is why we'd already removed it for other targets.
First, we were passing `-Wl,--gc-sections` to the compiler regardless of whether it is MSVC, which didn't make any sense on its own. But, even more generally, it doesn't make sense for us to try to tell the linker what to do when we aren't actually linking. (We're building static libraries of the C and assembly code.)
ae3dcc2
to
34f6ec8
Compare
See each individual commit message for details.