| 1 | From 4a5397b856564d0fbc0b89186e682e6694a909b0 Mon Sep 17 00:00:00 2001
|
| 2 | From: Hilton Chain <[email protected]>
|
| 3 | Date: Wed, 27 Nov 2024 11:55:44 +0800
|
| 4 | Subject: [PATCH] Fix RUNPATH issue.
|
| 5 |
|
| 6 | Add needed libraries and libc to RUNPATH when CROSS_LIBRARY_PATH or LIBRARY_PATH
|
| 7 | is set.
|
| 8 | ---
|
| 9 | src/Compilation.zig | 2 +-
|
| 10 | src/link/Elf.zig | 6 ++++++
|
| 11 | 2 files changed, 7 insertions(+), 1 deletion(-)
|
| 12 |
|
| 13 | diff --git a/src/Compilation.zig b/src/Compilation.zig
|
| 14 | index a08c3e09f4..add374d0ba 100644
|
| 15 | |
| 16 | |
| 17 | @@ -1542,7 +1542,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
|
| 18 | .llvm_cpu_features = llvm_cpu_features,
|
| 19 | .skip_linker_dependencies = options.skip_linker_dependencies,
|
| 20 | .parent_compilation_link_libc = options.parent_compilation_link_libc,
|
| 21 | - .each_lib_rpath = options.each_lib_rpath orelse false,
|
| 22 | + .each_lib_rpath = std.zig.system.NativePaths.isGuix(arena) or options.each_lib_rpath orelse false,
|
| 23 | .build_id = build_id,
|
| 24 | .cache_mode = cache_mode,
|
| 25 | .disable_lld_caching = options.disable_lld_caching or cache_mode == .whole,
|
| 26 | diff --git a/src/link/Elf.zig b/src/link/Elf.zig
|
| 27 | index dd88d47fab..b6e3944725 100644
|
| 28 | |
| 29 | |
| 30 | @@ -1730,6 +1730,12 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
|
| 31 | }
|
| 32 | }
|
| 33 | }
|
| 34 | + if (self.base.options.link_libc and self.base.options.link_mode == .Dynamic) {
|
| 35 | + if (self.base.options.libc_installation) |libc_installation| {
|
| 36 | + try argv.append("-rpath");
|
| 37 | + try argv.append(libc_installation.crt_dir.?);
|
| 38 | + }
|
| 39 | + }
|
| 40 | }
|
| 41 |
|
| 42 | for (self.base.options.lib_dirs) |lib_dir| {
|
| 43 | --
|
| 44 | 2.46.0
|
| 45 |
|