From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 5idLJsN8PGFAOQEAgWs5BA (envelope-from ) for ; Sat, 11 Sep 2021 11:54:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id qPluIcN8PGHUJwAAbx9fmQ (envelope-from ) for ; Sat, 11 Sep 2021 09:54:11 +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 1F96F254F9 for ; Sat, 11 Sep 2021 11:54:10 +0200 (CEST) Received: from localhost ([::1]:42850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mOzi4-0003eb-Tw for larch@yhetil.org; Sat, 11 Sep 2021 05:54:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:56970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mOzhy-0003eN-04 for guix-patches@gnu.org; Sat, 11 Sep 2021 05:54:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:56253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mOzhx-0001jL-MX for guix-patches@gnu.org; Sat, 11 Sep 2021 05:54:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mOzhx-0002HX-I9 for guix-patches@gnu.org; Sat, 11 Sep 2021 05:54:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#47006] [WIP PATCH v2 2/2] gnu: Add zig. Resent-From: iskarian@mgsn.dev Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 11 Sep 2021 09:54:01 +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: "Liliana Prikler" Cc: 47006@debbugs.gnu.org, maximedevos@telenet.be, efraim@flashner.co.il Received: via spool by 47006-submit@debbugs.gnu.org id=B47006.16313539858615 (code B ref 47006); Sat, 11 Sep 2021 09:54:01 +0000 Received: (at 47006) by debbugs.gnu.org; 11 Sep 2021 09:53:05 +0000 Received: from localhost ([127.0.0.1]:39566 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOzh2-0002Eo-87 for submit@debbugs.gnu.org; Sat, 11 Sep 2021 05:53:05 -0400 Received: from out0.migadu.com ([94.23.1.103]:43157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mOzgy-0002Dy-9B for 47006@debbugs.gnu.org; Sat, 11 Sep 2021 05:53:02 -0400 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mgsn.dev; s=key1; t=1631353978; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cekJLv60k+ZHHyzaV0iDDBJ1FlnNB7Qr3OK+0BHeHdg=; b=VhhusQXkmtApnHMeM7VAflw+L9JuCb8bi4ePlN14+Zs5TOrWyUnKyLf1YL2+rH6TIuMtXo EDXaojAaOj/lT6jlWoN9NGkZ2BrcDGvlzn1Hd9A3c1CkxUYFLDBfp/fm8yGQN/yS2aZuqd 4/6xCZd9IrlQFsqP6HMAfNTwvcGP2B4= Date: Sat, 11 Sep 2021 09:52:57 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: iskarian@mgsn.dev Message-ID: <0ad1eb5e0efefae06cfd0d5ab20ba13d@mgsn.dev> In-Reply-To: References: <0f6c5b692df8d06a0d7adddc9e5abf93894a366f.1631226695.git.liliana.prikler@gmail.com> 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=1631354051; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: 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=cekJLv60k+ZHHyzaV0iDDBJ1FlnNB7Qr3OK+0BHeHdg=; b=Z405BtU77fCkWWLX0qBNgRRzTWns24jGSi2WLIjjJ8rgF/0Swg15U9RQ1+c8ISB8B9o7Ay YIf61BMIKEGQynAIwxCJXl1Y9+kLGsplJkKcqlSQgfqQB7Z6LjlJ0I5oX7tKv/7rUOkAWC ytMa5BMbrVvxhhEKeuPzDccSmlomSHnawl7Sqwah+KVAY7b0jfxn9vzRTul1JgKKCiBAIe V7nNMx9XQ3bmNC+yHVFzPjmwH19fCuAALgXqZTxxuuTRo0dlV3bYtVDWjfbN/ojZIq+FtN QjOramAMptF+sZf0xG0Yc8j6NUY59BhqODHSTBy//NgcDGlRkvpZ+rb/+Mv1vA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631354051; a=rsa-sha256; cv=none; b=Tu46vRluM9Hbkp/6WX3nCEbMIiHh5PC5pXmzy8tldhOUli52kZEHf5lM7F0asZ1zlqQSrg VYnK+Wpqx9+Ni6uxsCrSKPVgUMjH5bRQosoem7tGwpXPA1Wt07DDmq363AswjlaCHeovJl XkCoj37qudAEnYjdi2nrgyM7tdCSmaojDt8BvnC5qN6MYD0j2myTlrmQ0255rGcIeNOink qDypaYgdYO2x9ZcLr9fFIREYt15JwCxWQwEIzYzcLNMI/y0pIt7V+x8fuFPwQynVazrqTh zBrfC4HFfaMYl1mrQ9gBGyJtO/hOp3YPcyanZ//qw62ia39e+NCKHLLE8rFMkA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=VhhusQXk; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (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: 0.19 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mgsn.dev header.s=key1 header.b=VhhusQXk; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mgsn.dev (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: 1F96F254F9 X-Spam-Score: 0.19 X-Migadu-Scanner: scn0.migadu.com X-TUID: qKALmRQpoADT Hi Liliana,=0A=0ASeptember 9, 2021 6:32 AM, "Liliana Prikler" wrote:=0A=0A> I've added a patch to use explicit search = paths rather than whatever Zig used=0A> before and tried fixing some (syn= tactic) errors with the tests, but was=0A> unsuccesful, as there appear t= o be failing tests in the suite itself. Could=0A> you have a look at the = revised patch and check what flags you could add to=0A> the check phase t= o make it meaningful?=0A=0AI'm=0A=0A> Btw. I haven't checked whether my c= osmetic changes to #:configure-flags break=0A> things or not. The end of = the build phase puts a large amount of stress onto=0A> my system that I'd= like to avoid at this hour.=0A> =0A> gnu/local.mk | 2 +=0A> .../patches/= zig-use-explicit-paths.patch | 132 ++++++++++++++++++=0A> gnu/packages/zi= g.scm | 100 +++++++++++++=0A> 3 files changed, 234 insertions(+)=0A> crea= te mode 100644 gnu/packages/patches/zig-use-explicit-paths.patch=0A> crea= te mode 100644 gnu/packages/zig.scm=0A> =0A> diff --git a/gnu/local.mk b/= gnu/local.mk=0A> index 2a56c4a9e2..4503b4b2e2 100644=0A> --- a/gnu/local.= mk=0A> +++ b/gnu/local.mk=0A> @@ -598,6 +598,7 @@ GNU_SYSTEM_MODULES =3D = \=0A> %D%/packages/xdisorg.scm \=0A> %D%/packages/xorg.scm \=0A> %D%/pack= ages/xfce.scm \=0A> + %D%/packages/zig.scm \=0A> %D%/packages/zile.scm \= =0A> %D%/packages/zwave.scm \=0A> \=0A> @@ -1903,6 +1904,7 @@ dist_patch_= DATA =3D \=0A> %D%/packages/patches/ytfzf-updates.patch \=0A> %D%/package= s/patches/ytnef-CVE-2021-3403.patch \=0A> %D%/packages/patches/ytnef-CVE-= 2021-3404.patch \=0A> + %D%/packages/patches/zig-use-explicit-paths.patch= \=0A> %D%/packages/patches/zstd-CVE-2021-24031_CVE-2021-24032.patch \=0A= > %D%/packages/patches/zziplib-CVE-2018-16548.patch=0A> =0A> diff --git a= /gnu/packages/patches/zig-use-explicit-paths.patch=0A> b/gnu/packages/pat= ches/zig-use-explicit-paths.patch=0A> new file mode 100644=0A> index 0000= 000000..ab0d2c7f8b=0A> --- /dev/null=0A> +++ b/gnu/packages/patches/zig-u= se-explicit-paths.patch=0A> @@ -0,0 +1,132 @@=0A> +This patch replaces th= e OS-specific detection mechanism by one that solely=0A> +relies on envir= onment variables. This has the benefit that said environment=0A> +variabl= es can be used as search paths in Guix.=0A> +=0A> +Index: zig-0.8.1/lib/s= td/zig/system.zig=0A> +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=0A> +--- zig-0.8.1.orig/lib/std/zig/system.zig=0A> ++++ zig-0.8= .1/lib/std/zig/system.zig=0A> +@@ -39,101 +39,44 @@ pub const NativePaths= =3D struct {=0A> + };=0A> + errdefer self.deinit();=0A> +=0A> +- var is_= nix =3D false;=0A> +- if (process.getEnvVarOwned(allocator, "NIX_CFLAGS_C= OMPILE")) |nix_cflags_compile| {=0A> +- defer allocator.free(nix_cflags_c= ompile);=0A> +-=0A> +- is_nix =3D true;=0A> +- var it =3D mem.tokenize(ni= x_cflags_compile, " ");=0A> ++ // TODO: Support cross-compile paths?=0A> = ++ if (process.getEnvVarOwned(allocator, "ZIG_INCLUDE_DIRS")) |zig_includ= e_dirs| {=0A> ++ defer allocator.free(zig_include_dirs);=0A> ++ var it = =3D mem.tokenize(zig_include_dirs, ":");=0A> + while (true) {=0A> +- cons= t word =3D it.next() orelse break;=0A> +- if (mem.eql(u8, word, "-isystem= ")) {=0A> +- const include_path =3D it.next() orelse {=0A> +- try self.ad= dWarning("Expected argument after -isystem in NIX_CFLAGS_COMPILE");=0A> += - break;=0A> +- };=0A> +- try self.addIncludeDir(include_path);=0A> +- } = else {=0A> +- if (mem.startsWith(u8, word, "-frandom-seed=3D")) {=0A> +- = continue;=0A> +- }=0A> +- try self.addWarningFmt("Unrecognized C flag fro= m NIX_CFLAGS_COMPILE: {s}", .{word});=0A> +- }=0A> ++ const dir =3D it.ne= xt() orelse break;=0A> ++ try self.addIncludeDir(dir);=0A> + }=0A> + } el= se |err| switch (err) {=0A> + error.InvalidUtf8 =3D> {},=0A> + error.Envi= ronmentVariableNotFound =3D> {},=0A> + error.OutOfMemory =3D> |e| return = e,=0A> + }=0A> +- if (process.getEnvVarOwned(allocator, "NIX_LDFLAGS")) |= nix_ldflags| {=0A> +- defer allocator.free(nix_ldflags);=0A> +=0A> +- is_= nix =3D true;=0A> +- var it =3D mem.tokenize(nix_ldflags, " ");=0A> ++ if= (process.getEnvVarOwned(allocator, "ZIG_LIB_DIRS")) |zig_lib_dirs| {=0A>= ++ defer allocator.free(zig_lib_dirs);=0A> ++ var it =3D mem.tokenize(zi= g_lib_dirs, ":");=0A> + while (true) {=0A> +- const word =3D it.next() or= else break;=0A> +- if (mem.eql(u8, word, "-rpath")) {=0A> +- const rpath = =3D it.next() orelse {=0A> +- try self.addWarning("Expected argument afte= r -rpath in NIX_LDFLAGS");=0A> +- break;=0A> +- };=0A> +- try self.addRPa= th(rpath);=0A> +- } else if (word.len > 2 and word[0] =3D=3D '-' and word= [1] =3D=3D 'L') {=0A> +- const lib_path =3D word[2..];=0A> +- try self.ad= dLibDir(lib_path);=0A> +- } else {=0A> +- try self.addWarningFmt("Unrecog= nized C flag from NIX_LDFLAGS: {s}", .{word});=0A> +- break;=0A> +- }=0A>= ++ const dir =3D it.next() orelse break;=0A> ++ try self.addLibDir(dir);= =0A> + }=0A> + } else |err| switch (err) {=0A> + error.InvalidUtf8 =3D> {= },=0A> + error.EnvironmentVariableNotFound =3D> {},=0A> + error.OutOfMemo= ry =3D> |e| return e,=0A> + }=0A> +- if (is_nix) {=0A> +- return self;=0A= > +- }=0A> +-=0A> +- if (comptime Target.current.isDarwin()) {=0A> +- try= self.addIncludeDir("/usr/include");=0A> +- try self.addIncludeDir("/usr/= local/include");=0A> +-=0A> +- try self.addLibDir("/usr/lib");=0A> +- try= self.addLibDir("/usr/local/lib");=0A> +-=0A> +- try self.addFrameworkDir= ("/Library/Frameworks");=0A> +- try self.addFrameworkDir("/System/Library= /Frameworks");=0A> +-=0A> +- return self;=0A> +- }=0A> +-=0A> +- if (nati= ve_target.os.tag !=3D .windows) {=0A> +- const triple =3D try native_targ= et.linuxTriple(allocator);=0A> +- const qual =3D native_target.cpu.arch.p= trBitWidth();=0A> +-=0A> +- // TODO: $ ld --verbose | grep SEARCH_DIR=0A>= +- // the output contains some paths that end with lib64, maybe include = them too?=0A> +- // TODO: what is the best possible order of things?=0A> = +- // TODO: some of these are suspect and should only be added on some sy= stems. audit needed.=0A> +=0A> +- try self.addIncludeDir("/usr/local/incl= ude");=0A> +- try self.addLibDirFmt("/usr/local/lib{d}", .{qual});=0A> +-= try self.addLibDir("/usr/local/lib");=0A> +-=0A> +- try self.addIncludeD= irFmt("/usr/include/{s}", .{triple});=0A> +- try self.addLibDirFmt("/usr/= lib/{s}", .{triple});=0A> +-=0A> +- try self.addIncludeDir("/usr/include"= );=0A> +- try self.addLibDirFmt("/lib{d}", .{qual});=0A> +- try self.addL= ibDir("/lib");=0A> +- try self.addLibDirFmt("/usr/lib{d}", .{qual});=0A> = +- try self.addLibDir("/usr/lib");=0A> +-=0A> +- // example: on a 64-bit = debian-based linux distro, with zlib installed from apt:=0A> +- // zlib.h= is in /usr/include (added above)=0A> +- // libz.so.1 is in /lib/x86_64-l= inux-gnu (added here)=0A> +- try self.addLibDirFmt("/lib/{s}", .{triple})= ;=0A> ++ if (process.getEnvVarOwned(allocator, "ZIG_FRAMEWORK_DIRS")) |zi= g_framework_dirs| {=0A> ++ defer allocator.free(zig_framework_dirs);=0A> = ++ var it =3D mem.tokenize(zig_framework_dirs, ":");=0A> ++ while (true) = {=0A> ++ const dir =3D it.next() orelse break;=0A> ++ try self.addFramewo= rkDir(dir);=0A> ++ }=0A> ++ } else |err| switch (err) {=0A> ++ error.Inva= lidUtf8 =3D> {},=0A> ++ error.EnvironmentVariableNotFound =3D> {},=0A> ++= error.OutOfMemory =3D> |e| return e,=0A> + }=0A> +=0A> + return self;=0A= > diff --git a/gnu/packages/zig.scm b/gnu/packages/zig.scm=0A> new file m= ode 100644=0A> index 0000000000..aae095b747=0A> --- /dev/null=0A> +++ b/g= nu/packages/zig.scm=0A> @@ -0,0 +1,100 @@=0A> +;;; GNU Guix --- Functiona= l package management for GNU=0A> +;;; Copyright =C2=A9 2021 Liliana Prikl= er =0A> +;;; Copyright =C2=A9 2021 Sarah Morge= nsen =0A> +;;;=0A> +;;; This file is part of GNU Guix.= =0A> +;;;=0A> +;;; GNU Guix is free software; you can redistribute it and= /or modify it=0A> +;;; under the terms of the GNU General Public License = as published by=0A> +;;; the Free Software Foundation; either version 3 o= f the License, or (at=0A> +;;; your option) any later version.=0A> +;;;= =0A> +;;; GNU Guix is distributed in the hope that it will be useful, but= =0A> +;;; WITHOUT ANY WARRANTY; without even the implied warranty of=0A> = +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A> +;;= ; GNU General Public License for more details.=0A> +;;;=0A> +;;; You shou= ld have received a copy of the GNU General Public License=0A> +;;; along = with GNU Guix. If not, see .=0A> +=0A> +(def= ine-module (gnu packages zig)=0A> + #:use-module (guix packages)=0A> + #:= use-module (guix git-download)=0A> + #:use-module ((guix licenses) #:pref= ix license:)=0A> + #:use-module (guix build-system cmake)=0A> + #:use-mod= ule (gnu packages)=0A> + #:use-module (gnu packages llvm))=0A> +=0A> +(de= fine-public=20zig=0A> + (package=0A> + (name "zig")=0A> + (version "0.8.1= ")=0A> + (source=0A> + (origin=0A> + (method git-fetch)=0A> + (uri (git-r= eference=0A> + (url "https://github.com/ziglang/zig.git")=0A> + (commit v= ersion)))=0A> + (file-name (git-file-name name version))=0A> + (sha256=0A= > + (base32 "147qx7xgj0r353wh5ragzn6kmm1vrf31i8038z3zqwjnqqgqxi6c"))=0A> = + (patches=0A> + (search-patches=0A> + "zig-use-explicit-paths.patch"))))= =0A> + (build-system cmake-build-system)=0A> + ;; Zig uses Clang and LLVM= libraries, and (may) use LLVM to compile along=0A> + ;; with GCC.=0A> + = (inputs=0A> + `(("clang" ,clang-12)=0A> + ("lld" ,lld-12)=0A> + ("llvm" ,= llvm-12)))=0A> + (native-inputs=0A> + `(("llvm" ,llvm-12)))=0A> + (argume= nts=0A> + `(#:configure-flags=0A> + (list ,@(if (%current-target-system)= =0A> + (string-append "-DZIG_TARGET_TRIPLE=3D"=0A> + (%current-target-sys= tem))=0A> + '()))=0A> + #:tests? #f ;;; XXX: tests result in a FileNotFou= nd=0A> + #:phases=0A> + (modify-phases %standard-phases=0A> + (add-after = 'unpack 'save-unpack-dir=0A> + (lambda _=0A> + ;; HACK: Passing unpacked = source directory to 'check phase.=0A> + (setenv "ZIG_SOURCE_DIR" (getcwd)= )=0A> + #t))=0A> + (add-after 'configure 'set-home=0A> + (lambda _=0A> + = (setenv "HOME" (getcwd)) ; zig writes to $HOME/.cache=0A> + #t))=0A> + (d= elete 'check)=0A> + (add-after 'install 'check=0A> + (lambda* (#:key outp= uts tests? #:allow-other-keys)=0A> + (when tests?=0A> + (with-directory-e= xcursion (getenv "ZIG_SOURCE_DIR")=0A> + (invoke (string-append (assoc-re= f outputs "out") "/bin/zig")=0A> + "build" "test"))))))))=0A> + (native-s= earch-paths=0A> + (list=0A> + (search-path-specification=0A> + (variable = "ZIG_INCLUDE_DIRS")=0A> + ;; XXX: It doesn't seem as though Zig can disti= nguish between C and C++=0A> + ;; include paths, so provide both.=0A> + (= files '("include/c++" "include")))=0A> + (search-path-specification=0A> += (variable "ZIG_LIB_DIRS")=0A> + (files '("lib" "lib64")))))=0A> + (synop= sis "General purpose programming language and toolchain")=0A> + (descript= ion "Zig is a general-purpose programming language and=0A> +toolchain. Am= ong other features it provides=0A> +@itemize=0A> +@item an Optional type = instead of null pointers,=0A> +@item manual memory management,=0A> +@item= generic data structures and functions,=0A> +@item compile-time reflectio= n and compile-time code execution,=0A> +@item integration with C using zi= g as a C compiler, and=0A> +@item concurrency via async functions.=0A> +@= end itemize")=0A> + (home-page "https://github.com/ziglang/zig")=0A> + (l= icense license:expat)))=0A> --=0A> 2.33.0