From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mBskKBOeOmEgCQAAgWs5BA (envelope-from ) for ; Fri, 10 Sep 2021 01:51:47 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id WB7jIxOeOmFfRQAA1q6Kng (envelope-from ) for ; Thu, 09 Sep 2021 23:51:47 +0000 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 E02BE520 for ; Fri, 10 Sep 2021 01:51:46 +0200 (CEST) Received: from localhost ([::1]:39318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOSqu-0006H2-DX for larch@yhetil.org; Thu, 09 Sep 2021 18:49:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOSpu-0005lI-L9 for guix-patches@gnu.org; Thu, 09 Sep 2021 18:48:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:53101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOSpu-0006zy-Dk for guix-patches@gnu.org; Thu, 09 Sep 2021 18:48:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOSpu-0002KU-9J for guix-patches@gnu.org; Thu, 09 Sep 2021 18:48:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47006] [WIP PATCH v2 2/2] gnu: Add zig. Resent-From: Liliana Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 09 Sep 2021 22:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47006 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: iskarian@mgsn.dev Cc: 47006@debbugs.gnu.org, maximedevos@telenet.be, efraim@flashner.co.il Received: via spool by 47006-submit@debbugs.gnu.org id=B47006.16312276628928 (code B ref 47006); Thu, 09 Sep 2021 22:48:02 +0000 Received: (at 47006) by debbugs.gnu.org; 9 Sep 2021 22:47:42 +0000 Received: from localhost ([127.0.0.1]:36414 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOSpZ-0002Jw-Eu for submit@debbugs.gnu.org; Thu, 09 Sep 2021 18:47:42 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:51949) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOSpY-0002Jj-1D for 47006@debbugs.gnu.org; Thu, 09 Sep 2021 18:47:40 -0400 Received: by mail-wm1-f68.google.com with SMTP id y132so2459576wmc.1 for <47006@debbugs.gnu.org>; Thu, 09 Sep 2021 15:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:in-reply-to:to :cc:content-transfer-encoding:mime-version; bh=e98Yf/BvncgRZJX5STZ/6akocRrpUdk5P7BX5mj7hjQ=; b=apXPqXXTRvx+TzvEfqNa0aLevCK/e4z5fh6HnpXnIM7/wQlTk48kKkxW5lGeqrOP6C XnlIjvaLX/a2+GMRDiEOP50io4LIK0v2n6x6/s9HZHL4gbI8WqSDV1/62qdpJk14FwlZ cvlrVOca7UxPNDHsiR61vMSd4O9tHfg0fTr2BT8AD2hRdMN8467T6oNllP3s3fQc9aZf h5tj7ElZbckk0f+lEVIT2MBLLbw86RqUJipynASCK7YrZM6EirJ6VyoEIlRFVj9OD92L x7y0dLs5MRRiuMZ+vSJ0ngXxViqv842SB1ELf4sAfB48YFEKs3uxK3pta19tsZk33NLp 6Gsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:in-reply-to:to:cc:content-transfer-encoding:mime-version; bh=e98Yf/BvncgRZJX5STZ/6akocRrpUdk5P7BX5mj7hjQ=; b=zrkvo02yGpQdhucJ/LX8r+5JPbWDhAENbhXbCgqOhtfNgQpGBBtzxVrC6A0Mrx/7PD UVq55cnbxjQ/uY6SexV2cm933SyUABiBx0p93N/F+lCntojqEtginhqGWr/7lduhPR1d cNGNuEUOanIfUFTkyiST5d3/2O8Dswh1DIp9cMte9BBlzFP9uCf0XX3Q4PaBX8S0o/HZ I558H+brLw4zhkJmpLGlwQuBtXVwD6gF2c4rmk0acWUNBmYM9+hNPLwJX3mI7/qq2/oS yR3XwVVE999LGYyjChppUYGkkE06QXAhGrR5cgHyPN5pEk3tekPqfB0k6eBXd09z4O8a M02w== X-Gm-Message-State: AOAM5329aN2n0/8NV1GGqhRTQhWC5kKA04+l2pEUgNQN0CCRAtm8+5NK 983WRhjEDUz/yQ8blzPmDns= X-Google-Smtp-Source: ABdhPJyFhVhIX8QYvSdwI5yqi6u8CE1PSfdbMNKnDo9rTbR/c9a/ipeyjTsxJJRL6iL2otG6GlZxCg== X-Received: by 2002:a05:600c:19d0:: with SMTP id u16mr5312645wmq.21.1631227653932; Thu, 09 Sep 2021 15:47:33 -0700 (PDT) Received: from nijino.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id q128sm3143652wma.27.2021.09.09.15.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 15:47:33 -0700 (PDT) Message-Id: In-Reply-To: <0f6c5b692df8d06a0d7adddc9e5abf93894a366f.1631226695.git.liliana.prikler@gmail.com> References: <0f6c5b692df8d06a0d7adddc9e5abf93894a366f.1631226695.git.liliana.prikler@gmail.com> From: Liliana Prikler Date: Thu, 9 Sep 2021 15:32:22 +0200 In-Reply-To: <86bl51mvnd.fsf@mgsn.dev> Content-Transfer-Encoding: 8bit MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631231507; h=from:from:sender:sender: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:in-reply-to:references:references:list-id: list-help:list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=e98Yf/BvncgRZJX5STZ/6akocRrpUdk5P7BX5mj7hjQ=; b=bQLJlNNnyibDwHytre1/mtW8AMLV+rIlsZdrQsSVHfMr1dInKi3E2NlNYVyYEtE1GZ8qbI Rv+ioHGWT7KUE12ccDkAG2B1P5lpt5+zZu9t8sLleNLKq+JXZ8AbjaDs1VcNOGMx0JLeSU TwANKI0XGuTocEjJKiFIvjDqyvJ7HC+d+HNFKz4JerZ0k5GiolRToojFfatYJGk9FRWDIL CdN3vP4ofbLRmpP6bdTKjxlyiE0t2QbrUCctSJQJj2js0hWgMrikO8wEYZb2IVkihmWl0e Z9iGygXE36PzzpROhf0vwC3m/IOpYNNvAcUiyncbY1VSj+fl5FFWT+m4EPyNpQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631231507; a=rsa-sha256; cv=none; b=mjK5gPAwgXEjYn/6+jYoIl6zY15HZydFhj7FlRFHJNk7r1mXW6wgdW7uKRN2BPgwpscOhF CWE8TkJE+mf7bbK/hkJEGiRBF4HpU2LeyCs3EZEaBhT02exo6ZMAWfb37/MRrp2ukPT+yV WjGU5wGMI+FRV6Bgdozc+4sMGywoCxBIO07jcmqG+y71PNILnGHMsX6Yw1GahFj/bo/bFI +xOImWHqC95GeAeRvsAXDDSZ1wspowwajxwGUisgFe+yz8MmKPy1ekgPVpXg2Z321hhCmK sTBNQwX0ExegOoQ497YkXsUGPFKBBWzJwRl/rX6zcRBOu4hy2l6CdrsvmLQ5mA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=apXPqXXT; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: 7.59 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=apXPqXXT; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: E02BE520 X-Spam-Score: 7.59 X-Migadu-Scanner: scn0.migadu.com X-TUID: 3+ezYtZODf0T * gnu/packages/patches/zig-use-explicit-paths.patch: New file. * gnu/packages/zig.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES, dist_patch_DATA): Adjust accordingly. --- I've added a patch to use explicit search paths rather than whatever Zig used before and tried fixing some (syntactic) errors with the tests, but was unsuccesful, as there appear to be failing tests in the suite itself. Could you have a look at the revised patch and check what flags you could add to the check phase to make it meaningful? Btw. I haven't checked whether my cosmetic changes to #:configure-flags break things or not. The end of the build phase puts a large amount of stress onto my system that I'd like to avoid at this hour. gnu/local.mk | 2 + .../patches/zig-use-explicit-paths.patch | 132 ++++++++++++++++++ gnu/packages/zig.scm | 100 +++++++++++++ 3 files changed, 234 insertions(+) create mode 100644 gnu/packages/patches/zig-use-explicit-paths.patch create mode 100644 gnu/packages/zig.scm diff --git a/gnu/local.mk b/gnu/local.mk index 2a56c4a9e2..4503b4b2e2 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -598,6 +598,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/xdisorg.scm \ %D%/packages/xorg.scm \ %D%/packages/xfce.scm \ + %D%/packages/zig.scm \ %D%/packages/zile.scm \ %D%/packages/zwave.scm \ \ @@ -1903,6 +1904,7 @@ dist_patch_DATA = \ %D%/packages/patches/ytfzf-updates.patch \ %D%/packages/patches/ytnef-CVE-2021-3403.patch \ %D%/packages/patches/ytnef-CVE-2021-3404.patch \ + %D%/packages/patches/zig-use-explicit-paths.patch \ %D%/packages/patches/zstd-CVE-2021-24031_CVE-2021-24032.patch \ %D%/packages/patches/zziplib-CVE-2018-16548.patch diff --git a/gnu/packages/patches/zig-use-explicit-paths.patch b/gnu/packages/patches/zig-use-explicit-paths.patch new file mode 100644 index 0000000000..ab0d2c7f8b --- /dev/null +++ b/gnu/packages/patches/zig-use-explicit-paths.patch @@ -0,0 +1,132 @@ +This patch replaces the OS-specific detection mechanism by one that solely +relies on environment variables. This has the benefit that said environment +variables can be used as search paths in Guix. + +Index: zig-0.8.1/lib/std/zig/system.zig +=================================================================== +--- zig-0.8.1.orig/lib/std/zig/system.zig ++++ zig-0.8.1/lib/std/zig/system.zig +@@ -39,101 +39,44 @@ pub const NativePaths = struct { + }; + errdefer self.deinit(); + +- var is_nix = false; +- if (process.getEnvVarOwned(allocator, "NIX_CFLAGS_COMPILE")) |nix_cflags_compile| { +- defer allocator.free(nix_cflags_compile); +- +- is_nix = true; +- var it = mem.tokenize(nix_cflags_compile, " "); ++ // TODO: Support cross-compile paths? ++ if (process.getEnvVarOwned(allocator, "ZIG_INCLUDE_DIRS")) |zig_include_dirs| { ++ defer allocator.free(zig_include_dirs); ++ var it = mem.tokenize(zig_include_dirs, ":"); + while (true) { +- const word = it.next() orelse break; +- if (mem.eql(u8, word, "-isystem")) { +- const include_path = it.next() orelse { +- try self.addWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE"); +- break; +- }; +- try self.addIncludeDir(include_path); +- } else { +- if (mem.startsWith(u8, word, "-frandom-seed=")) { +- continue; +- } +- try self.addWarningFmt("Unrecognized C flag from NIX_CFLAGS_COMPILE: {s}", .{word}); +- } ++ const dir = it.next() orelse break; ++ try self.addIncludeDir(dir); + } + } else |err| switch (err) { + error.InvalidUtf8 => {}, + error.EnvironmentVariableNotFound => {}, + error.OutOfMemory => |e| return e, + } +- if (process.getEnvVarOwned(allocator, "NIX_LDFLAGS")) |nix_ldflags| { +- defer allocator.free(nix_ldflags); + +- is_nix = true; +- var it = mem.tokenize(nix_ldflags, " "); ++ if (process.getEnvVarOwned(allocator, "ZIG_LIB_DIRS")) |zig_lib_dirs| { ++ defer allocator.free(zig_lib_dirs); ++ var it = mem.tokenize(zig_lib_dirs, ":"); + while (true) { +- const word = it.next() orelse break; +- if (mem.eql(u8, word, "-rpath")) { +- const rpath = it.next() orelse { +- try self.addWarning("Expected argument after -rpath in NIX_LDFLAGS"); +- break; +- }; +- try self.addRPath(rpath); +- } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') { +- const lib_path = word[2..]; +- try self.addLibDir(lib_path); +- } else { +- try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word}); +- break; +- } ++ const dir = it.next() orelse break; ++ try self.addLibDir(dir); + } + } else |err| switch (err) { + error.InvalidUtf8 => {}, + error.EnvironmentVariableNotFound => {}, + error.OutOfMemory => |e| return e, + } +- if (is_nix) { +- return self; +- } +- +- if (comptime Target.current.isDarwin()) { +- try self.addIncludeDir("/usr/include"); +- try self.addIncludeDir("/usr/local/include"); +- +- try self.addLibDir("/usr/lib"); +- try self.addLibDir("/usr/local/lib"); +- +- try self.addFrameworkDir("/Library/Frameworks"); +- try self.addFrameworkDir("/System/Library/Frameworks"); +- +- return self; +- } +- +- if (native_target.os.tag != .windows) { +- const triple = try native_target.linuxTriple(allocator); +- const qual = native_target.cpu.arch.ptrBitWidth(); +- +- // TODO: $ ld --verbose | grep SEARCH_DIR +- // the output contains some paths that end with lib64, maybe include them too? +- // TODO: what is the best possible order of things? +- // TODO: some of these are suspect and should only be added on some systems. audit needed. + +- try self.addIncludeDir("/usr/local/include"); +- try self.addLibDirFmt("/usr/local/lib{d}", .{qual}); +- try self.addLibDir("/usr/local/lib"); +- +- try self.addIncludeDirFmt("/usr/include/{s}", .{triple}); +- try self.addLibDirFmt("/usr/lib/{s}", .{triple}); +- +- try self.addIncludeDir("/usr/include"); +- try self.addLibDirFmt("/lib{d}", .{qual}); +- try self.addLibDir("/lib"); +- try self.addLibDirFmt("/usr/lib{d}", .{qual}); +- try self.addLibDir("/usr/lib"); +- +- // example: on a 64-bit debian-based linux distro, with zlib installed from apt: +- // zlib.h is in /usr/include (added above) +- // libz.so.1 is in /lib/x86_64-linux-gnu (added here) +- try self.addLibDirFmt("/lib/{s}", .{triple}); ++ if (process.getEnvVarOwned(allocator, "ZIG_FRAMEWORK_DIRS")) |zig_framework_dirs| { ++ defer allocator.free(zig_framework_dirs); ++ var it = mem.tokenize(zig_framework_dirs, ":"); ++ while (true) { ++ const dir = it.next() orelse break; ++ try self.addFrameworkDir(dir); ++ } ++ } else |err| switch (err) { ++ error.InvalidUtf8 => {}, ++ error.EnvironmentVariableNotFound => {}, ++ error.OutOfMemory => |e| return e, + } + + return self; diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm new file mode 100644 index 0000000000..aae095b747 --- /dev/null +++ b/gnu/packages/zig.scm @@ -0,0 +1,100 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 Liliana Prikler +;;; Copyright © 2021 Sarah Morgensen +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu packages zig) + #:use-module (guix packages) + #: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 llvm)) + +(define-public zig + (package + (name "zig") + (version "0.8.1") + (source + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/ziglang/zig.git") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c")) + (patches + (search-patches + "zig-use-explicit-paths.patch")))) + (build-system cmake-build-system) + ;; Zig uses Clang and LLVM libraries, and (may) use LLVM to compile along + ;; with GCC. + (inputs + `(("clang" ,clang-12) + ("lld" ,lld-12) + ("llvm" ,llvm-12))) + (native-inputs + `(("llvm" ,llvm-12))) + (arguments + `(#:configure-flags + (list ,@(if (%current-target-system) + (string-append "-DZIG_TARGET_TRIPLE=" + (%current-target-system)) + '())) + #:tests? #f ;;; XXX: tests result in a FileNotFound + #:phases + (modify-phases %standard-phases + (add-after 'unpack 'save-unpack-dir + (lambda _ + ;; HACK: Passing unpacked source directory to 'check phase. + (setenv "ZIG_SOURCE_DIR" (getcwd)) + #t)) + (add-after 'configure 'set-home + (lambda _ + (setenv "HOME" (getcwd)) ; zig writes to $HOME/.cache + #t)) + (delete 'check) + (add-after 'install 'check + (lambda* (#:key outputs tests? #:allow-other-keys) + (when tests? + (with-directory-excursion (getenv "ZIG_SOURCE_DIR") + (invoke (string-append (assoc-ref outputs "out") "/bin/zig") + "build" "test")))))))) + (native-search-paths + (list + (search-path-specification + (variable "ZIG_INCLUDE_DIRS") + ;; XXX: It doesn't seem as though Zig can distinguish between C and C++ + ;; include paths, so provide both. + (files '("include/c++" "include"))) + (search-path-specification + (variable "ZIG_LIB_DIRS") + (files '("lib" "lib64"))))) + (synopsis "General purpose programming language and toolchain") + (description "Zig is a general-purpose programming language and +toolchain. Among other features it provides +@itemize +@item an Optional type instead of null pointers, +@item manual memory management, +@item generic data structures and functions, +@item compile-time reflection and compile-time code execution, +@item integration with C using zig as a C compiler, and +@item concurrency via async functions. +@end itemize") + (home-page "https://github.com/ziglang/zig") + (license license:expat))) -- 2.33.0