File: Fix-profiler_builtins-build-script-to-handle-full-path-to.patch

package info (click to toggle)
rustc 1.87.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 925,564 kB
  • sloc: xml: 158,127; python: 36,039; javascript: 19,761; sh: 19,737; cpp: 18,981; ansic: 13,133; asm: 4,376; makefile: 710; perl: 29; lisp: 28; ruby: 19; sql: 11
file content (40 lines) | stat: -rw-r--r-- 1,706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From: Jesus Checa Hidalgo <jchecahi@redhat.com>
Date: Fri, 11 Apr 2025 16:57:38 +0200
Subject: 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.

(cherry picked from commit dc0fbcab7e0673afe62b3e8e74905d9e5f5b74a4)
---
 library/profiler_builtins/build.rs | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/library/profiler_builtins/build.rs b/library/profiler_builtins/build.rs
index dd85239..fc1a9ec 100644
--- a/library/profiler_builtins/build.rs
+++ b/library/profiler_builtins/build.rs
@@ -9,8 +9,14 @@ use std::path::PathBuf;
 
 fn main() {
     if let Ok(rt) = tracked_env_var("LLVM_PROFILER_RT_LIB") {
-        println!("cargo::rustc-link-lib=static:+verbatim={rt}");
-        return;
+        let rt = PathBuf::from(rt);
+        if let Some(lib) = rt.file_name() {
+            if let Some(dir) = rt.parent() {
+                println!("cargo::rustc-link-search=native={}", dir.display());
+            }
+            println!("cargo::rustc-link-lib=static:+verbatim={}", lib.to_str().unwrap());
+            return;
+        }
     }
 
     let target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS was not set");