From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id uMF0NFNOLmcODgEAe85BDQ:P1 (envelope-from ) for ; Fri, 08 Nov 2024 17:45:56 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id uMF0NFNOLmcODgEAe85BDQ (envelope-from ) for ; Fri, 08 Nov 2024 18:45:55 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=eC9SBOOw; dkim=fail ("headers rsa verify failed") header.d=ultrarare.space header.s=dkim header.b=g3ZiN6Yj; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1731087955; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=BR5zMJrzWGzum5ceUW2ib55K6AConScSaX29qBdVwx8=; b=mLDVtuw60QA9jhGBTs2x41qYcnOzPKa5Jj96hgJjQxoWlwdGM2ampPaEs6N79KFtZih/hv tUHw1ufFArrNfkaVln92GP1vRIdNw1LJLLBijp0u6iAEtAMGUu4FNWHCMYS4t2pcKDtzqf AU3Ij3tGpW5AFQR8IAJwYBnn4+Hzmt50d2LC5z8gifI5KmklJkGvZHas8NrV+olGk/p5FL LriLn0GQzY4TXcntNCd7kaJcoIJbhbZ294Bvzrc3ky8xiMDZZgm54g0x1x9suwG4gh47X0 FjLrlfpwzF8A/anTqPKB+MsUNJwtRsIOiXqCioWAq7LqbbMmdMqkhKN5zMP3qw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=eC9SBOOw; dkim=fail ("headers rsa verify failed") header.d=ultrarare.space header.s=dkim header.b=g3ZiN6Yj; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Seal: i=1; s=key1; d=yhetil.org; t=1731087955; a=rsa-sha256; cv=none; b=CuZcY8bCE4TxdobCnbpgP+9syO8DG7K4UCkR2j3lidWEU4BQ6nQd28aU7wYuNNGuiP/9yr iX7lzGX5Jr6aTLZFnDTqFYDMRqlzka4y91r5ECW1dOk0cAzE4E69X0TB+c3ovtaG65xTqq 8i20Tx9JcIZAuXVk62h6G1EsLKn4d7SDVKGMdOlpE+U1URSZpAzD08jCASyOq7mWGrj0hu hbr6YTUs6l6MOJIjBp7CZQRekzeNXmEJfDmQyJuKLxsIXmGizO3COaSth3K+poYLTpTzNc D4/GY20A7VBCFHnqxdgTNx1QcWTy5RMpYhQLkH2InUczPTquGfXdtRf8wywTsw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A6D1181320 for ; Fri, 08 Nov 2024 18:45:55 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t9T2s-0005IU-3N; Fri, 08 Nov 2024 12:45:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t9T2f-0005BI-T4 for bug-guix@gnu.org; Fri, 08 Nov 2024 12:45:06 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t9T2e-0008Mk-03 for bug-guix@gnu.org; Fri, 08 Nov 2024 12:45:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=BR5zMJrzWGzum5ceUW2ib55K6AConScSaX29qBdVwx8=; b=eC9SBOOwjX144Hy1nztOftjdID6yhkfGNYd0dNp0HonnbYhdmMt7c2WHIXoNXqnpJOwF+E5MtOSpx4UtLG1lBZ8hoHZfkychSQ6MQW76X+6xLQknGc2ya8dGe4nvxQgVAowmZ4At4vpZg1xJtz89Wh/bEbMehlyLfYAYPBMECs1ExqrDWrtBVtgJ8XTfP4oY5Rzk5/xLnrweJjp8bA9Ny274w4WykgQ1ESwAIjTYwntGqYslRbdlE0YKqwJRsdTRMEFbML4QS8cUwCx/2zXGecyYRw7HkljREeYQzTYr84g8Mo0RKMMtBXsLu6uKCN7kdr10rqNmJ18cXEUCCjf0lQ==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t9T2c-0001Ro-Re; Fri, 08 Nov 2024 12:45:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#74217: [PATCH 1/2] gnu: Add zig-0.10.0-610-bootstrap. Resent-From: Hilton Chain Original-Sender: "Debbugs-submit" Resent-CC: ekaitz@elenq.tech, hako@ultrarare.space, noe@xn--no-cja.eu, bug-guix@gnu.org, Ekaitz Zarraga Resent-Date: Fri, 08 Nov 2024 17:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74217 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 74217@debbugs.gnu.org Cc: Hilton Chain , Ekaitz Zarraga , Hilton Chain , =?UTF-8?Q?No=C3=A9?= Lopez X-Debbugs-Original-Xcc: Ekaitz Zarraga , Hilton Chain , =?UTF-8?Q?No=C3=A9?= Lopez Received: via spool by 74217-submit@debbugs.gnu.org id=B74217.17310878745480 (code B ref 74217); Fri, 08 Nov 2024 17:45:02 +0000 Received: (at 74217) by debbugs.gnu.org; 8 Nov 2024 17:44:34 +0000 Received: from localhost ([127.0.0.1]:51948 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9T29-0001QJ-Di for submit@debbugs.gnu.org; Fri, 08 Nov 2024 12:44:34 -0500 Received: from mail.boiledscript.com ([144.168.59.46]:51258) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t9T27-0001Q2-Ez for 74217@debbugs.gnu.org; Fri, 08 Nov 2024 12:44:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ultrarare.space; s=dkim; t=1731087865; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BR5zMJrzWGzum5ceUW2ib55K6AConScSaX29qBdVwx8=; b=g3ZiN6Yjbb9B8CVHfeWHbhZ6xAiQFovqllt1CJQOaB14pnnO431b8KHYTgZ7DX+/HbwOYU euDAMYgSVqmnAUb6eR5hvXo9/8vhXsKHZkjJxvZshi0tvlpR1UCLL3x5H1d+OVng2Lok6V EIMXuFyR6+2+FMaH4UdeuC3dlZ48sKaND/1sUWdGLztz745Cvlw1BSA5/IjPv7hWpzJDNX 5HCK1kHh607zrQfWQzKw0UXi+9T08Qo5GgFf9khHUcfF9unksHpfVezfI3ihAJVdzAT7ue 6Kmokiisp/T8O0ZgBWaHSMp+pfhU9GE4rWYBxr66pey+tlDIWS/Yjj3eJCOXmw== Date: Sat, 9 Nov 2024 01:44:06 +0800 Message-ID: <81bba1694a0f1ff48967727855b158487340deb9.1731084096.git.hako@ultrarare.space> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spamd-Bar: ----- X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Hilton Chain From: Hilton Chain via Bug reports for GNU Guix Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx11.migadu.com X-Migadu-Spam-Score: 2.07 X-Spam-Score: 2.07 X-Migadu-Queue-Id: A6D1181320 X-TUID: mEFG349ruRZS * 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-bootstrap): New variables. Change-Id: I132bbad34f40b919b4573e02d0f40eb4a007a26c --- gnu/local.mk | 1 + ...10.0-610-bootstrap-resolve-conflicts.patch | 87 +++++++++++++++ gnu/packages/zig.scm | 105 +++++++++++++++++- 3 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 gnu/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch diff --git a/gnu/local.mk b/gnu/local.mk index ae902a5ab2..2cc2ea4c81 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2358,6 +2358,7 @@ dist_patch_DATA = \ %D%/packages/patches/xygrib-newer-proj.patch \ %D%/packages/patches/yggdrasil-extra-config.patch \ %D%/packages/patches/zig-0.9-riscv-support.patch \ + %D%/packages/patches/zig-0.10.0-610-bootstrap-resolve-conflicts.patch \ %D%/packages/patches/zig-use-baseline-cpu-by-default.patch \ %D%/packages/patches/zig-use-system-paths.patch \ %D%/packages/patches/zsh-egrep-failing-test.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 6994d48818..68907fd04e 100644 --- a/gnu/packages/zig.scm +++ b/gnu/packages/zig.scm @@ -23,13 +23,15 @@ (define-module (gnu packages zig) #: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-public zig-0.9 (package @@ -196,4 +198,105 @@ (define-public zig-0.10 (properties `((max-silent-time . 9600) ,@(clang-compiler-cpu-architectures "15"))))) +(define zig-0.10.0-538-source + ;; "std: added eql to DynamicBitSet and DynamicBitSetUnmanaged" + (let ((commit "bf316e550671cc71eb498b3cf799493627bb0fdc") + (revision "538")) + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ziglang/zig") + (commit commit))) + (file-name (git-file-name "zig" (git-version "0.10" revision commit))) + (sha256 + (base32 "1dchc2bp842jlw0byssqzindv8cigpqcj2hk3752667jrrww13vv"))))) + +(define zig-0.10.0-539-patch + ;; "remove `-fstage1` option" + (let ((commit "28514476ef8c824c3d189d98f23d0f8d23e496ea")) + (origin + (method url-fetch) + (uri (string-append + "https://github.com/ziglang/zig/commit/" commit ".patch")) + (sha256 + (base32 "0qxxiafg2sd5rr4xhw0c12rygd7zh1rmf3x8hfialyxmsbi5pfxp"))))) + +(define zig-0.10.0-542-patch + ;; "actually remove stage1" + (let ((commit "3ba916584db5485c38ebf2390e8d22bc6d81bf8e")) + (origin + (method url-fetch) + (uri (string-append + "https://github.com/ziglang/zig/commit/" commit ".patch")) + (sha256 + (base32 "1l09gmbr3vqzinb63kvaskgs1d0mvm1m7w3ai3ngwg5zlabyya35"))))) + +;; Build zig1.wasm from source. +(define zig-0.10.0-610-bootstrap + (let ((commit "e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118") + (revision "610")) + (package + (inherit zig-0.10) + (name "zig") + (version (git-version "0.10.0" revision commit)) + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ziglang/zig") + (commit commit))) + (file-name (git-file-name name version)) + (modules '((guix build utils))) + (snippet '(delete-file "stage1/zig1.wasm.zst")) + (sha256 + (base32 + "08pm3f4hh6djl3szhqgm7fa3qisdl2xh9jrp18m0z7bk2vd0bzw7")))) + (arguments + (substitute-keyword-arguments (package-arguments zig-0.10) + ((#:phases phases '%standard-phases) + #~(modify-phases #$phases + (add-after 'unpack 'prepare-source + (lambda* (#:key native-inputs inputs #:allow-other-keys) + (copy-recursively "." "../source-backup") + ;; 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 'build-zig1 + (lambda _ + (copy-recursively "../source-backup" ".") + (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")))) + (replace 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + (invoke (string-append #$output "/bin/zig") + "test" "-I" "test" "test/behavior.zig")))))))) + (native-inputs + (modify-inputs (package-native-inputs zig-0.10) + (prepend binaryen))) + (outputs '("out" "zig1"))))) + (define-public zig zig-0.10) -- 2.46.0