add patch to add library directories

This commit is contained in:
Jan200101 2025-05-27 16:16:32 +02:00
commit 5466b3ff26
No known key found for this signature in database
GPG key ID: 5B71B1D78B882E05
6 changed files with 56 additions and 7 deletions

View file

@ -1,7 +1,7 @@
From 874ce2357bb7e7398115fc6f37f3f3817a9116ba Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Tue, 11 Jun 2024 13:35:37 +0200
Subject: [PATCH 1/4] remove native lib directories from rpath
Subject: [PATCH 1/5] remove native lib directories from rpath
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---

View file

@ -1,7 +1,7 @@
From fd127fafb534eade533655688c4977ae4f7cebe0 Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Fri, 17 Jan 2025 20:53:30 +0100
Subject: [PATCH 2/4] std.Build: add build-id option
Subject: [PATCH 2/5] std.Build: add build-id option
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---

View file

@ -1,7 +1,7 @@
From e4b31d2e6cba763f4427bc689c7aa27978d47f49 Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Mon, 21 Apr 2025 23:28:27 +0200
Subject: [PATCH 3/4] increase upper bounds of main zig executable to 9G
Subject: [PATCH 3/5] increase upper bounds of main zig executable to 9G
On Fedora 42 aarch64 memory usage peaked at 8736403456 bytes

View file

@ -1,7 +1,7 @@
From 2f379308820b58049cfe0aaca1eb4f77700d0047 Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Thu, 24 Apr 2025 17:35:29 +0200
Subject: [PATCH 4/4] build: pass zig lib dir as directory instead of as string
Subject: [PATCH 4/5] build: pass zig lib dir as directory instead of as string
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---

View file

@ -0,0 +1,40 @@
From 48aa23307d1a47b444854fc09478da6d4ee8e624 Mon Sep 17 00:00:00 2001
From: Jan200101 <sentrycraft123@gmail.com>
Date: Sun, 11 May 2025 01:09:41 +0200
Subject: [PATCH 5/5] link.Elf: add root directory of libraries to linker path
all the given dynamic shared objects will be linked with an absolute path however they may link to other dynamic shared objects which won't have an absolute path, for this we need to add the library path so that lld can resolve it
Signed-off-by: Jan200101 <sentrycraft123@gmail.com>
---
src/link/Elf.zig | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 53f88101b1..fe2b7abd48 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -1938,9 +1938,19 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
// Positional arguments to the linker such as object files.
var whole_archive = false;
+ var lib_directories = std.StringArrayHashMap(void).init(gpa);
+ defer lib_directories.deinit();
+
for (self.base.comp.link_inputs) |link_input| switch (link_input) {
.res => unreachable, // Windows-only
- .dso => continue,
+ .dso => |dso| {
+ if (dso.path.root_dir.path) |root_dir| {
+ const lib_dir = try lib_directories.getOrPut(root_dir);
+ if (lib_dir.found_existing) continue;
+ try argv.append("-L");
+ try argv.append(root_dir);
+ }
+ },
.object, .archive => |obj| {
if (obj.must_link and !whole_archive) {
try argv.append("-whole-archive");
--
2.49.0

View file

@ -44,7 +44,7 @@
Name: zig
Version: 0.14.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Programming language for maintaining robust, optimal, and reusable software
License: MIT AND NCSA AND LGPL-2.1-or-later AND LGPL-2.1-or-later WITH GCC-exception-2.0 AND GPL-2.0-or-later AND GPL-2.0-or-later WITH GCC-exception-2.0 AND BSD-3-Clause AND Inner-Net-2.0 AND ISC AND LicenseRef-Fedora-Public-Domain AND GFDL-1.1-or-later AND ZPL-2.1
@ -71,11 +71,17 @@ Patch: 0003-increase-upper-bounds-of-main-zig-executable-to-9G.patch
# every snippet of code in the documentation is tested to see if it works
# while doing this zig incorrectly passes a relative path to the doctest tool
# which is ran in a temporary directory making that path invalid
# This patch was superseded by https://github.com/ziglang/zig/pull/23894 which
# implements a proper fix, but for our use case this is good enough.
# https://github.com/ziglang/zig/pull/23644
Patch: 0004-build-pass-zig-lib-dir-as-directory-instead-of-as-st.patch
# lld will try to resolve every libary of a shared object thats used for this we need
# add specify the library directories, this patch adds them back.
# This wasn't an issue with the cc binary present because zig will call it to figure
# out more system paths.
# https://github.com/ziglang/zig/pull/23850
Patch: 0005-link.Elf-add-root-directory-of-libraries-to-linker-p.patch
# Zig invokes the C compiler to figure out system info
Requires: gcc
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: cmake
@ -244,6 +250,9 @@ install -D -pv -m 0644 %{SOURCE2} %{buildroot}%{_rpmmacrodir}/macros.%{name}
%endif
%changelog
* Tue May 27 2025 Jan200101 <sentrycraft123@gmail.com> - 0.14.0-4
- add patch to add library directories
* Fri May 09 2025 Jan200101 <sentrycraft123@gmail.com> - 0.14.0-3
- add gcc to runtime dependencies