[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/81: gnu: Add zig-0.10.0-610.
From: |
guix-commits |
Subject: |
05/81: gnu: Add zig-0.10.0-610. |
Date: |
Thu, 5 Dec 2024 01:33:21 -0500 (EST) |
hako pushed a commit to branch wip-zig-bootstrap
in repository guix.
commit e34be6a4127b5b247f32b3419d49418d7b8aac0f
Author: Hilton Chain <hako@ultrarare.space>
AuthorDate: Mon Nov 11 10:46:05 2024 +0800
gnu: Add zig-0.10.0-610.
* gnu/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch: New
file.
* gnu/local.mk (dist_patch_DATA): Regisiter it.
* gnu/packages/zig.scm (zig-0.10.0-538-source,zig-0.10.0-539-patch)
(zig-0.10.0-542-patch,zig-0.10.0-610): New variables.
Change-Id: Ic1f1b13e6e7f84a13eb5761576b727e6ecc5fddf
---
gnu/local.mk | 1 +
...ig-0.10.0-610-bootstrap-resolve-conflicts.patch | 87 +++++++++++++++++
gnu/packages/zig.scm | 104 ++++++++++++++++++++-
3 files changed, 191 insertions(+), 1 deletion(-)
diff --git a/gnu/local.mk b/gnu/local.mk
index d3e16ef7b5..ed5b1d2304 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2392,6 +2392,7 @@ dist_patch_DATA =
\
%D%/packages/patches/zig-0.9-use-system-paths.patch \
%D%/packages/patches/zig-0.10-fix-runpath.patch \
%D%/packages/patches/zig-0.10-use-system-paths.patch \
+ %D%/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch
\
%D%/packages/patches/zsh-egrep-failing-test.patch \
%D%/packages/patches/zuo-bin-sh.patch
diff --git
a/gnu/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch
b/gnu/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch
new file mode 100644
index 0000000000..5ad5ffc249
--- /dev/null
+++ b/gnu/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch
@@ -0,0 +1,87 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 1c03faf1e9..89406eb1b2 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -846,16 +846,17 @@ else()
+ endif()
+
+ set(ZIG_BUILD_ARGS
+- --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
+- "-Dconfig_h=${ZIG_CONFIG_H_OUT}"
+- "-Denable-llvm"
+- ${ZIG_RELEASE_ARG}
+- ${ZIG_STATIC_ARG}
+- ${ZIG_NO_LIB_ARG}
+- ${ZIG_SINGLE_THREADED_ARG}
+- "-Dtarget=${ZIG_TARGET_TRIPLE}"
+- "-Dcpu=${ZIG_TARGET_MCPU}"
+- "-Dversion-string=${RESOLVED_ZIG_VERSION}"
++ --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
++ "-Dconfig_h=${ZIG_CONFIG_H_OUT}"
++ "-Denable-llvm"
++ "-Denable-stage1"
++ ${ZIG_RELEASE_ARG}
++ ${ZIG_STATIC_ARG}
++ ${ZIG_NO_LIB_ARG}
++ ${ZIG_SINGLE_THREADED_ARG}
++ "-Dtarget=${ZIG_TARGET_TRIPLE}"
++ "-Dcpu=${ZIG_TARGET_MCPU}"
++ "-Dversion-string=${RESOLVED_ZIG_VERSION}"
+ )
+
+ add_custom_target(stage3 ALL
+diff --git a/build.zig b/build.zig
+index cf0e092326..7f80c3e1df 100644
+--- a/build.zig
++++ b/build.zig
+@@ -142,7 +142,8 @@ pub fn build(b: *Builder) !void {
+ const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use
GeneralPurposeAllocator") orelse false;
+ const link_libc = b.option(bool, "force-link-libc", "Force self-hosted
compiler to link libc") orelse (enable_llvm or only_c);
+ const sanitize_thread = b.option(bool, "sanitize-thread", "Enable
thread-sanitization") orelse false;
+- const strip = b.option(bool, "strip", "Omit debug information");
++ const strip = b.option(bool, "strip", "Omit debug information") orelse
false;
++ const use_zig0 = b.option(bool, "zig0", "Bootstrap using zig0") orelse
false;
+ const value_tracing = b.option(bool, "value-tracing", "Enable extra state
tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace
API)") orelse false;
+
+ const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many
stack frames to print when a memory leak occurs. Tests get 2x this amount.")
orelse blk: {
+@@ -151,7 +152,22 @@ pub fn build(b: *Builder) !void {
+ break :blk 4;
+ };
+
+- const exe = addCompilerStep(b);
++ if (only_c) {
++ target.ofmt = .c;
++ }
++
++ const main_file: ?[]const u8 = mf: {
++ if (!have_stage1) break :mf "src/main.zig";
++ if (use_zig0) break :mf null;
++ break :mf "src/stage1.zig";
++ };
++
++ const exe = b.addExecutable("zig", main_file);
++
++ const compile_step = b.step("compile", "Build the self-hosted compiler");
++ compile_step.dependOn(&exe.step);
++
++ exe.stack_size = stack_size;
+ exe.strip = strip;
+ exe.sanitize_thread = sanitize_thread;
+ exe.build_id = b.option(bool, "build-id", "Include a build id note")
orelse false;
+diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig
+index 20e4259725..bc0f002c21 100644
+--- a/src/translate_c/ast.zig
++++ b/src/translate_c/ast.zig
+@@ -1448,6 +1448,12 @@ fn renderNode(c: *Context, node: Node)
Allocator.Error!NodeIndex {
+ .optional_type => return renderPrefixOp(c, node, .optional_type,
.question_mark, "?"),
+ .address_of => {
+ const payload = node.castTag(.address_of).?.data;
++ if (c.zig_is_stage1 and payload.tag() == .fn_identifier)
++ return try c.addNode(.{
++ .tag = .identifier,
++ .main_token = try
c.addIdentifier(payload.castTag(.fn_identifier).?.data),
++ .data = undefined,
++ });
+
+ const ampersand = try c.addToken(.ampersand, "&");
+ const base = if (payload.tag() == .fn_identifier)
diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm
index bb2c8486a7..6f54d52cbc 100644
--- a/gnu/packages/zig.scm
+++ b/gnu/packages/zig.scm
@@ -23,13 +23,15 @@
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix utils)
+ #:use-module (guix download)
#:use-module (guix git-download)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix build-system cmake)
#:use-module (gnu packages)
#:use-module (gnu packages compression)
#:use-module (gnu packages llvm)
- #:use-module (gnu packages llvm-meta))
+ #:use-module (gnu packages llvm-meta)
+ #:use-module (gnu packages web))
(define (zig-source version commit hash)
(origin
@@ -262,4 +264,104 @@ toolchain. Among other features it provides
(properties `((max-silent-time . 9600)
,@(clang-compiler-cpu-architectures "15")))))
+
+;;;
+;;; Bootstrap path for Zig 0.11.
+;;; See also: <https://git.jakstys.lt/motiejus/zig-repro>.
+;;;
+
+;; Restore C++ stage 1 and build the initial zig1.wasm.
+(define zig-0.10.0-538-source
+ (let ((commit "bf316e550671cc71eb498b3cf799493627bb0fdc")
+ (revision "538"))
+ (zig-source
+ (git-version "0.10.0" revision commit)
+ commit "1dchc2bp842jlw0byssqzindv8cigpqcj2hk3752667jrrww13vv")))
+
+(define zig-0.10.0-539-patch
+ (let ((commit "28514476ef8c824c3d189d98f23d0f8d23e496ea"))
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/ziglang/zig/commit/" commit ".patch"))
+ (file-name "zig-0.10.0-539.patch")
+ (sha256
+ (base32 "0qxxiafg2sd5rr4xhw0c12rygd7zh1rmf3x8hfialyxmsbi5pfxp")))))
+
+(define zig-0.10.0-542-patch
+ (let ((commit "3ba916584db5485c38ebf2390e8d22bc6d81bf8e"))
+ (origin
+ (method url-fetch)
+ (uri (string-append
+ "https://github.com/ziglang/zig/commit/" commit ".patch"))
+ (file-name "zig-0.10.0-542.patch")
+ (sha256
+ (base32 "1l09gmbr3vqzinb63kvaskgs1d0mvm1m7w3ai3ngwg5zlabyya35")))))
+
+(define zig-0.10.0-610
+ (let ((commit "e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118")
+ (revision "610")
+ (base zig-0.10))
+ (package
+ (inherit base)
+ (name "zig")
+ (version (git-version "0.10.0" revision commit))
+ (source (zig-source
+ version commit
+ "08pm3f4hh6djl3szhqgm7fa3qisdl2xh9jrp18m0z7bk2vd0bzw7"))
+ (arguments
+ (substitute-keyword-arguments (package-arguments base)
+ ;; Patch for fixing RUNPATH not applied to intermediate versions.
+ ((#:validate-runpath? _ #t) #f)
+ ;; Disable tests for intermediate versions.
+ ((#:tests? _ #t) #f)
+ ((#:phases phases '%standard-phases)
+ #~(modify-phases #$phases
+ (add-after 'unpack 'backup-source
+ (lambda _
+ (copy-recursively "." "../source-backup")))
+ (add-after 'backup-source 'prepare-source
+ (lambda* (#:key native-inputs inputs #:allow-other-keys)
+ ;; Revert "actually remove stage1".
+ (invoke "patch" "--reverse" "--strip=1"
+ "--input" #+zig-0.10.0-542-patch)
+ ;; Revert "remove `-fstage1` option".
+ (false-if-exception
+ (invoke "patch" "--reverse" "--strip=1"
+ "--input" #+zig-0.10.0-539-patch))
+ ;; Resolve conflicts in previous patching.
+ (invoke
+ "patch" "--forward" "--strip=1" "--input"
+ #+(local-file
+ (search-patch
+ "zig-0.10.0-610-bootstrap-resolve-conflicts.patch")))
+ ;; Restore build system.
+ (rename-file "stage1/config.zig.in" "src/config.zig.in")
+ (substitute* "src/config.zig.in"
+ (("(have_stage1 = )false" _ prefix)
+ (string-append prefix "true")))
+ (for-each
+ (lambda (file)
+ (copy-file (string-append #+zig-0.10.0-538-source "/"
file)
+ file))
+ '("build.zig" "CMakeLists.txt"))))
+ (add-after 'install 'restore-source
+ (lambda _
+ (for-each delete-file-recursively (find-files "."))
+ (copy-recursively "../source-backup" ".")))
+ (add-after 'restore-source 'build-zig1
+ (lambda _
+ (invoke (string-append #$output "/bin/zig")
+ "build" "update-zig1" "--verbose")))
+ (add-after 'build-zig1 'install-zig1
+ (lambda _
+ (install-file "stage1/zig1.wasm.zst"
+ (string-append #$output:zig1 "/bin"))))
+ (delete 'install-glibc-abilists)))))
+ (native-inputs
+ (modify-inputs (package-native-inputs base)
+ (prepend binaryen)
+ (delete "glibc-abi-tool")))
+ (outputs '("out" "zig1")))))
+
(define-public zig zig-0.10)
- 10/81: gnu: Add zig-0.10.0-851., (continued)
- 10/81: gnu: Add zig-0.10.0-851., guix-commits, 2024/12/05
- 02/81: gnu: zig-0.9: Update patches., guix-commits, 2024/12/05
- 08/81: gnu: Add zig-0.10.0-747., guix-commits, 2024/12/05
- 23/81: gnu: Add zig-0.10.0-1888., guix-commits, 2024/12/05
- 19/81: gnu: Add zig-0.10.0-1657., guix-commits, 2024/12/05
- 27/81: gnu: Add zig-0.10.0-2571., guix-commits, 2024/12/05
- 26/81: gnu: Add zig-0.10.0-2566., guix-commits, 2024/12/05
- 03/81: gnu: zig-0.10: Fix RUNPATH issue., guix-commits, 2024/12/05
- 04/81: gnu: zig-0.10: Fix lint warning., guix-commits, 2024/12/05
- 14/81: gnu: Add zig-0.10.0-1027., guix-commits, 2024/12/05
- 05/81: gnu: Add zig-0.10.0-610.,
guix-commits <=
- 07/81: gnu: Add zig-0.10.0-722., guix-commits, 2024/12/05
- 09/81: gnu: Add zig-0.10.0-748., guix-commits, 2024/12/05
- 12/81: gnu: Add zig-0.10.0-961., guix-commits, 2024/12/05
- 11/81: gnu: Add zig-0.10.0-853., guix-commits, 2024/12/05
- 13/81: gnu: Add zig-0.10.0-962., guix-commits, 2024/12/05
- 17/81: gnu: Add zig-0.10.0-1506., guix-commits, 2024/12/05
- 18/81: gnu: Add zig-0.10.0-1638., guix-commits, 2024/12/05
- 20/81: gnu: Add zig-0.10.0-1681., guix-commits, 2024/12/05
- 21/81: gnu: Add zig-0.10.0-1712., guix-commits, 2024/12/05
- 22/81: gnu: Add zig-0.10.0-1713., guix-commits, 2024/12/05