Skip to content

Commit c9ac474

Browse files
David Tolnayfacebook-github-bot
authored andcommitted
Split out link style for buildscript.build
Summary: Previously, if a bin crate had a build script, and the fixup specified a `link_style`, that link style would apply to **both** the Rust binary and the build script build. There is no reason this should be the case. There is no expectation that a binary should want to use the same link style as its build script. In general they will have very different dependency graphs, with the build script using host tools like bindgen and libclang, while the binary links against target code. This diff makes the build script link style independently configurable. We need this for libclang on macOS, such as in the fixup for the `libproc` and `coreaudio-sys` crates. ```lang=toml link_style = "shared" # applies to rust_binary only [buildscript.build] link_style = "shared" # applies to build-script-build only ``` Reviewed By: cjlongoria Differential Revision: D74046797 fbshipit-source-id: 20b59901b5670c607b1a69c939224121b965d46d
1 parent 9199ad8 commit c9ac474

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/buckify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ fn generate_target_rules<'scope>(
894894
// don't use fixed ones because it will be a cyclic dependency
895895
rustc_flags: Default::default(),
896896
env: Selectable::default(),
897-
link_style: bin_base.link_style.clone(),
897+
link_style: None,
898898
..base
899899
},
900900
platform: bin_perplat,

src/fixups.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ impl<'meta> Fixups<'meta> {
522522
.iter()
523523
.map(|(k, v)| (k.clone(), StringOrPath::String(v.clone()))),
524524
);
525+
buildscript_build.common.base.link_style =
526+
self.fixup_config.base.buildscript.build.link_style.clone();
525527

526528
for (_platform, fixup) in self.fixup_config.configs(&self.package.version) {
527529
for cargo_env in fixup.cargo_env.iter() {

src/fixups/buildscript.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ impl Default for BuildscriptFixups {
4646
pub struct BuildscriptBuild {
4747
#[serde(default)]
4848
pub env: BTreeMap<String, String>,
49+
pub link_style: Option<String>,
4950
#[serde(skip_deserializing)]
5051
pub defaulted_to_empty: bool,
5152
}
@@ -54,6 +55,7 @@ impl Default for BuildscriptBuild {
5455
fn default() -> Self {
5556
BuildscriptBuild {
5657
env: BTreeMap::new(),
58+
link_style: None,
5759
defaulted_to_empty: true,
5860
}
5961
}

0 commit comments

Comments
 (0)