[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
56/84: gnu: Add zig-0.13.
From: |
guix-commits |
Subject: |
56/84: gnu: Add zig-0.13. |
Date: |
Mon, 30 Dec 2024 21:59:35 -0500 (EST) |
hako pushed a commit to branch wip-zig-bootstrap
in repository guix.
commit 8808ea98ae1429232a1b7df35e1b75f4c9bac42b
Author: Hilton Chain <hako@ultrarare.space>
AuthorDate: Mon Nov 11 21:20:00 2024 +0800
gnu: Add zig-0.13.
* gnu/packages/patches/zig-0.13-fix-runpath.patch: New file.
* gnu/local.mk (dist_patch_DATA): Regisiter it.
* gnu/packages/zig.scm (zig-0.13-glibc-abi-tool,zig-0.13): New variables.
Change-Id: I217a1d444acb600d8cc38abcaa3950156b11cbae
---
gnu/local.mk | 1 +
gnu/packages/patches/zig-0.13-fix-runpath.patch | 121 ++++++++++++++++++++++++
gnu/packages/zig.scm | 37 ++++++++
3 files changed, 159 insertions(+)
diff --git a/gnu/local.mk b/gnu/local.mk
index a8581ccabb..8f61b2d65c 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2428,6 +2428,7 @@ dist_patch_DATA =
\
%D%/packages/patches/zig-0.12-fix-runpath.patch \
%D%/packages/patches/zig-0.12-use-baseline-cpu-by-default.patch \
%D%/packages/patches/zig-0.12-use-system-paths.patch \
+ %D%/packages/patches/zig-0.13-fix-runpath.patch \
%D%/packages/patches/zsh-egrep-failing-test.patch \
%D%/packages/patches/zuo-bin-sh.patch
diff --git a/gnu/packages/patches/zig-0.13-fix-runpath.patch
b/gnu/packages/patches/zig-0.13-fix-runpath.patch
new file mode 100644
index 0000000000..b77686a0b9
--- /dev/null
+++ b/gnu/packages/patches/zig-0.13-fix-runpath.patch
@@ -0,0 +1,121 @@
+From 68a437ab4ab3aeac0f7a7932f3e5b78d9dfb25b7 Mon Sep 17 00:00:00 2001
+From: Hilton Chain <hako@ultrarare.space>
+Date: Fri, 29 Nov 2024 14:13:46 +0800
+Subject: [PATCH] Fix RUNPATH issue.
+
+Add needed libraries and libc to RUNPATH when CROSS_LIBRARY_PATH or
LIBRARY_PATH
+is set.
+---
+ lib/std/Build/Step/Compile.zig | 3 +++
+ src/link/Elf.zig | 14 +++++++++++++
+ src/main.zig | 37 +++++++++++++++++++++++++++++++++-
+ 3 files changed, 53 insertions(+), 1 deletion(-)
+
+diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig
+index d18d8de413..5bb442e4a1 100644
+--- a/lib/std/Build/Step/Compile.zig
++++ b/lib/std/Build/Step/Compile.zig
+@@ -741,6 +741,9 @@ fn runPkgConfig(compile: *Compile, lib_name: []const u8)
!PkgConfigResult {
+ try zig_cflags.appendSlice(&[_][]const u8{ "-D", macro });
+ } else if (mem.startsWith(u8, arg, "-D")) {
+ try zig_cflags.append(arg);
++ } else if (mem.startsWith(u8, arg, "-Wl,-rpath=")) {
++ const dir = arg["-Wl,-rpath=".len..];
++ try zig_libs.appendSlice(&[_][]const u8{ "-L", dir });
+ } else if (b.debug_pkg_config) {
+ return compile.step.fail("unknown pkg-config flag '{s}'", .{arg});
+ }
+diff --git a/src/link/Elf.zig b/src/link/Elf.zig
+index 770d483e98..38660d5d80 100644
+--- a/src/link/Elf.zig
++++ b/src/link/Elf.zig
+@@ -1504,6 +1504,13 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
+ try argv.append(rpath);
+ }
+
++ if (comp.config.link_libc and link_mode == .dynamic and
std.zig.system.NativePaths.isGuix(arena)) {
++ if (self.base.comp.libc_installation) |libc_installation| {
++ try argv.append("-rpath");
++ try argv.append(libc_installation.crt_dir.?);
++ }
++ }
++
+ try argv.appendSlice(&.{
+ "-z",
+ try std.fmt.allocPrint(arena, "stack-size={d}",
.{self.base.stack_size}),
+@@ -2533,6 +2540,13 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node:
std.Progress.Node) !void
+ }
+ }
+
++ if (comp.config.link_libc and link_mode == .dynamic and
std.zig.system.NativePaths.isGuix(arena)) {
++ if (self.base.comp.libc_installation) |libc_installation| {
++ try argv.append("-rpath");
++ try argv.append(libc_installation.crt_dir.?);
++ }
++ }
++
+ for (self.symbol_wrap_set.keys()) |symbol_name| {
+ try argv.appendSlice(&.{ "-wrap", symbol_name });
+ }
+diff --git a/src/main.zig b/src/main.zig
+index 90f78d51d4..9306b7be44 100644
+--- a/src/main.zig
++++ b/src/main.zig
+@@ -3719,7 +3719,7 @@ fn createModule(
+ create_module.want_native_include_dirs = true;
+ }
+
+- if (create_module.each_lib_rpath orelse resolved_target.is_native_os)
{
++ if (create_module.each_lib_rpath orelse false) {
+ try create_module.rpath_list.appendSlice(arena,
create_module.lib_dirs.items);
+ }
+
+@@ -3939,6 +3939,24 @@ fn createModule(
+ if (create_module.resolved_system_libs.len != 0)
+ create_module.opts.any_dyn_libs = true;
+
++ if (std.zig.system.NativePaths.isGuix(arena)) {
++ for (create_module.resolved_system_libs.items(.name)) |lib_name| {
++ for (create_module.lib_dirs.items) |lib_dir_path| {
++ if (try libPathExists(arena, lib_dir_path, lib_name,
target)) {
++ try create_module.rpath_list.append(arena,
lib_dir_path);
++ break;
++ }
++ }
++ }
++ for (create_module.link_objects.items) |obj| {
++ if (Compilation.classifyFileExt(obj.path) == .shared_library)
{
++ const lib_dir_path = fs.path.dirname(obj.path) orelse
continue;
++ if (obj.loption) continue;
++ try create_module.rpath_list.append(arena, lib_dir_path);
++ }
++ }
++ }
++
+ create_module.resolved_options =
Compilation.Config.resolve(create_module.opts) catch |err| switch (err) {
+ error.WasiExecModelRequiresWasi => fatal("only WASI OS targets
support execution model", .{}),
+ error.SharedMemoryIsWasmOnly => fatal("only WebAssembly CPU
targets support shared memory", .{}),
+@@ -7448,3 +7466,20 @@ fn handleModArg(
+ c_source_files_owner_index.* = create_module.c_source_files.items.len;
+ rc_source_files_owner_index.* = create_module.rc_source_files.items.len;
+ }
++
++fn libPathExists(
++ arena: Allocator,
++ lib_dir_path: []const u8,
++ lib_name: []const u8,
++ target: std.Target,
++) !bool {
++ const sep = fs.path.sep_str;
++ const lib_path = try std.fmt.allocPrint(arena, "{s}" ++ sep ++
"{s}{s}{s}", .{
++ lib_dir_path,
++ target.libPrefix(),
++ lib_name,
++ target.dynamicLibSuffix(),
++ });
++ fs.cwd().access(lib_path, .{}) catch return false;
++ return true;
++}
+--
+2.46.0
+
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index a06b6de530..cbdff2c2ff 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -1526,4 +1526,41 @@ toolchain. Among other features it provides
(modify-inputs (package-native-inputs base)
(replace "zig" `(,base "out")))))))
+(define zig-0.13-glibc-abi-tool
+ (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/ziglang/glibc-abi-tool")
+ (commit "fc5d0a7046b76795e4219f8f168e118ec29fbc53")))
+ (file-name "glibc-abi-tool")
+ (sha256
+ (base32 "1q9plbqkkk3jzrvsgcjmj5jjdncz4ym9p0snglz4kkjwwm65gqs1"))))
+
+(define-public zig-0.13
+ (package
+ (inherit zig-0.12)
+ (name "zig")
+ (version "0.13.0")
+ (source
+ (origin
+ (inherit (zig-source
+ version version
+ "0ly8042lbsa8019g0d1jg4l06rxpq2530n9mijq66n4lmx7a5976"))
+ (patches
+ (search-patches
+ "zig-0.12-use-baseline-cpu-by-default.patch"
+ "zig-0.12-use-system-paths.patch"
+ "zig-0.13-fix-runpath.patch"))))
+ (inputs
+ (modify-inputs (package-inputs zig-0.12)
+ (replace "clang" clang-18)
+ (replace "lld" lld-18)))
+ (native-inputs
+ (modify-inputs (package-native-inputs zig-0.12)
+ (replace "glibc-abi-tool" zig-0.13-glibc-abi-tool)
+ (replace "llvm" llvm-18)
+ (replace "zig" `(,zig-0.12.0-109 "zig1"))))
+ (properties `((max-silent-time . 9600)
+ ,@(clang-compiler-cpu-architectures "18")))))
+
(define-public zig zig-0.10)
- 20/84: gnu: Add zig-0.10.0-1681., (continued)
- 20/84: gnu: Add zig-0.10.0-1681., guix-commits, 2024/12/30
- 21/84: gnu: Add zig-0.10.0-1712., guix-commits, 2024/12/30
- 15/84: gnu: Add zig-0.10.0-1073., guix-commits, 2024/12/30
- 23/84: gnu: Add zig-0.10.0-1888., guix-commits, 2024/12/30
- 32/84: gnu: Add zig-0.10.0-3728., guix-commits, 2024/12/30
- 30/84: gnu: Add zig-0.10.0-3660., guix-commits, 2024/12/30
- 29/84: gnu: Add zig-0.10.0-2838., guix-commits, 2024/12/30
- 36/84: gnu: Add zig-0.10.0-3985., guix-commits, 2024/12/30
- 52/84: gnu: Add zig-0.11.0-3604., guix-commits, 2024/12/30
- 47/84: gnu: Add zig-0.11.0-3245., guix-commits, 2024/12/30
- 56/84: gnu: Add zig-0.13.,
guix-commits <=
- 41/84: gnu: Add zig-0.11.0-587., guix-commits, 2024/12/30
- 54/84: gnu: ncdu: Update to 2.6., guix-commits, 2024/12/30
- 63/84: gnu: zig: Default to zig-0.13., guix-commits, 2024/12/30
- 59/84: gnu: zig: Respect the PKG_CONFIG environment variable., guix-commits, 2024/12/30
- 65/84: teams: zig: Add manifest for Zig packages., guix-commits, 2024/12/30
- 58/84: build/zig: Adjust the build triplets for some systems., guix-commits, 2024/12/30
- 66/84: gnu: Add zig-pixman., guix-commits, 2024/12/30
- 72/84: gnu: Add zig-known-folders., guix-commits, 2024/12/30
- 75/84: gnu: Add zig-zls-0.13., guix-commits, 2024/12/30
- 77/84: gnu: Add zig-ini., guix-commits, 2024/12/30