Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
args: "--features local_dynamic_tls"
- name: lto
args: "--features lto"
- name: build_cc-lto
args: '--features "build_cc lto"'
# Don't abort runners if a single one fails
fail-fast: false
steps:
Expand Down
2 changes: 1 addition & 1 deletion snmalloc-rs/snmalloc-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ include = [
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
cc = { version = "1.0", optional = true }
cc = { version = "1.0.74", optional = true }
cmake = { version = "0.1", optional = true }

[features]
Expand Down
10 changes: 10 additions & 0 deletions snmalloc-rs/snmalloc-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,12 @@ fn configure_platform(config: &mut BuildConfig) {
.define("CMAKE_INTERPROCEDURAL_OPTIMIZATION", "TRUE")
.define("SNMALLOC_IPO", "ON");
println!("cargo:rustc-link-arg=/LTCG");
// rustc cannot index /GL (LTCG) objects, so bundling the
// library into the rlib drops its sn_rust_* symbols. Leave it
// out of the rlib and pass it to the final link, as the CMake
// build already does (rust-lang/rust#26003).
#[cfg(feature = "build_cc")]
config.builder.link_lib_modifier("-bundle");
}

config.builder
Expand Down Expand Up @@ -686,6 +692,10 @@ fn main() {
println!("cargo:rustc-link-arg=-Wl,--whole-archive");
println!("cargo:rustc-link-lib=static={}", config.target_lib);
println!("cargo:rustc-link-arg=-Wl,--no-whole-archive");
} else if cfg!(feature = "build_cc") && config.is_msvc() {
// cc already emits the link-lib line for the library (with -bundle
// under lto). rustc rejects a second line for the same library when
// either one carries modifiers.
} else {
println!("cargo:rustc-link-lib={}", config.target_lib);
}
Expand Down
Loading