Skip to content

Commit f2a2135

Browse files
authored
Rollup merge of #139677 - jchecahi:profiler-builtin-rtlib-path-fix, r=kobzol
Fix profiler_builtins build script to handle full path to profiler lib LLVM_PROFILER_RT_LIB may be set to an absolute path (e.g., in Fedora builds), but `-l` expects a library name, not a path. After #138273, this caused builds to fail with a "could not find native static library" error. This patch updates the build script to split the path into directory and filename, using `cargo::rustc-link-search` for the directory and `cargo::rustc-link-lib=+verbatim` for the file. This allows profiler_builtins to correctly link the static library even when an absolute path is provided.
2 parents 423e7b8 + dc0fbca commit f2a2135

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Diff for: library/profiler_builtins/build.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@ use std::path::PathBuf;
99

1010
fn main() {
1111
if let Ok(rt) = tracked_env_var("LLVM_PROFILER_RT_LIB") {
12-
println!("cargo::rustc-link-lib=static:+verbatim={rt}");
13-
return;
12+
let rt = PathBuf::from(rt);
13+
if let Some(lib) = rt.file_name() {
14+
if let Some(dir) = rt.parent() {
15+
println!("cargo::rustc-link-search=native={}", dir.display());
16+
}
17+
println!("cargo::rustc-link-lib=static:+verbatim={}", lib.to_str().unwrap());
18+
return;
19+
}
1420
}
1521

1622
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");

0 commit comments

Comments
 (0)