1
hermetic_cc_toolchain/mailing-list-archive.mbox

16594 lines
745 KiB
Plaintext
Raw Permalink Normal View History

<
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=uber.com header.i=@uber.com
Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48])
by mail-b.sr.ht (Postfix) with ESMTPS id DDF2111EEC2
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Mon, 6 Sep 2021 05:14:56 +0000 (UTC)
Received: by mail-ed1-f48.google.com with SMTP id u19so7815945edb.3
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Sun, 05 Sep 2021 22:14:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=uber.com; s=google;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc:content-transfer-encoding;
bh=7Ep7iTYyg1DX8Hx9AdVtBxHJWPcMfNRMH8EVv7gJalA=;
b=0T3cef8TsPS2gcoAtVKBRrHY8D9aD8FJvFDsizN3PMB0F8l32dLdRv8+TvHspaJs5l
lJdSEzmJ6Hkn1T3DPxjr7qvm9s4+ThTSRkEwFtWerRuftLWxMlUml73Cs0fIhN7FohhH
LNbRleFGhs9sM2EueHyR7e7sc1qdxDd+644IQ=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc:content-transfer-encoding;
bh=7Ep7iTYyg1DX8Hx9AdVtBxHJWPcMfNRMH8EVv7gJalA=;
b=Nig0qyUf+TPvScOEAThWQagGYc0pZQnLXdiWR41czq9ODyMBe8281D+altQ/+U7QbU
6x+GKNecxPw/rLFsxDQ+FILzF4tRaV/oQ4nVBsq0ssVb1P4fY5IWlXSn2Rq3tZwSTKtP
Ax2Qz8BX72ywIcQo1ZM2JLhQF6UjvkbGBO0QyXiJT416xQLSjGQUB8arl+Q0fKNFcIJ9
UqwF8qkIyeMfjiL0faClIsNnXJhfa5qEyS6HwFDOdK7f344ExdzDmZNOxWnmhtZCIvpl
AU1dQ6HHK1qKY+VEbkvoq6w05PYihxHk7szMaahtw3USzpe6cF9YepAOxqZNyzM2NWWp
GUFg==
X-Gm-Message-State: AOAM530RHZDN0bVwF4byjoCILBF7XpLVHfGKWcrFVgSdkYjbhCtTeR6T
GY+hwcM4PIIVUci3xE6TPMfllXXNuws916eSE25Cew==
X-Google-Smtp-Source: ABdhPJx06von7JT53TGVZFlki01ijRhmL1GfVC0Mnhpi5vWifJyzoQeSjcDPzMuM5EjLg2LfBIJutd4b5I55Ak3kpsk=
X-Received: by 2002:a05:6402:6cf:: with SMTP id n15mr11581412edy.85.1630905295539;
Sun, 05 Sep 2021 22:14:55 -0700 (PDT)
MIME-Version: 1.0
References: <CAMEgGpyFHe3f=VZgFEDMivQ_rGCmHngBPH5MAC2Va5NvJmRo5g@mail.gmail.com>
<CAK+t98XUb0EmzKu-zOPpZxQM_jcWS=K3AJUuz9tB93COdtJqFw@mail.gmail.com>
<CAEZVCP5BMvXc2W5L0_fYGws8A_GgXwZ4mgtduS3qBzNP97nqSw@mail.gmail.com>
<CAK+t98UYm5FhQFit4vix_RTUzXBfeH+CGVM8-1vQFHtYfLcgXw@mail.gmail.com> <CANeNeVSkKdpeN8BnXciTXBQQhoLFLGKCAKNXCRYyh8ymppdkfg@mail.gmail.com>
In-Reply-To: <CANeNeVSkKdpeN8BnXciTXBQQhoLFLGKCAKNXCRYyh8ymppdkfg@mail.gmail.com>
From: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <motiejus@uber.com>
Date: Mon, 6 Sep 2021 08:14:46 +0300
Message-ID: <CAK+t98X2fo+_f+W1o8hzYX_CXmHVPMNfBN2CoM+soRGgMELOQQ@mail.gmail.com>
Subject: Re: Cross-compilation with zig
To: Adam Bouhenguel <adam@bouhenguel.com>, ~motiejus/bazel-zig-cc@lists.sr.ht
Cc: Steeve Morin <steeve.morin@gmail.com>, Zhongpeng Lin <zplin@uber.com>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
+ ~motiejus/bazel-zig-cc@lists.sr.ht (please subscribe[0]). Also
switching from top-down to bottom-up posting.
On Sun, Sep 5, 2021 at 10:14 PM Adam Bouhenguel <adam@bouhenguel.com> wrote=
:
>
> Thanks for adding me to the thread, Motiejus.
>
> Steeve, I'm very curious to hear how your investigation goes. Please keep=
me posted!
>
> I've been bitten a few times now by regressions in zig cc. Both 0.7.1 and=
0.9-dev have problems with C++ exceptions and break runtime behavior of th=
ird party libraries I'm using.
Zig 0.7.1 to zig 0.9-dev moved from clang-11 to clang-12, so, from the
surface, I would attribute behavior changes to this. Did you narrow
this down to something specific?
> Seems like the ability to build a set of specific projects in bazel (with=
a hermetic zig cc based toolchain) might be helpful for keeping everyone o=
n the same page.
Have you noticed regressions with `zig cc` when upgrading zig? Since
it is covered by "bug stability program[1]", I expect zig upstream to
be quite responsive with regressions there. If C++ behavior changes,
it's probably a fault of a new clang, which should be reported to
Apple (likely with help of zig developers, since they have done this
many times).
> To this end, what do you folks think about having a small suite of accept=
ance tests for the toolchain?
We already have //test:hello[2]. Feel free to add yours.
> As a bonus we might be able to use qemu to ensure that the cross-compiled=
artifacts actually work.
I am looking for multi-arch build support in sr.ht, which is "not yet
available"[3], which would be ideal.
Currently I am cross-compiling to a few architectures and checking
whether the resulting "file" command returns an expected string. I
agree qemu-system-<arch> is a good next step. What are your
architectures of interest?
Motiejus
[0]: https://lists.sr.ht/~motiejus/bazel-zig-cc
[1]: https://ziglang.org/download/0.8.0/release-notes.html#zig-cc
[2]: https://git.sr.ht/~motiejus/bazel-zig-cc/tree/main/item/test/BUILD
[3]: https://man.sr.ht/builds.sr.ht/compatibility.md
[4]: https://git.sr.ht/~motiejus/bazel-zig-cc/tree/main/item/.build.yml
> Cheers,
> Adam
>
> On Thu, Sep 2, 2021, 06:31 Motiejus Jak=C5=A1tys <motiejus@uber.com> wrot=
e:
>>
>> Let me know how it goes. I set up a mailing list on srht for patches, if=
any.
>>
>> On Thu, Sep 2, 2021, 15:42 Steeve Morin <steeve.morin@gmail.com> wrote:
>>>
>>> Hey Motiejus,
>>>
>>> Thank for working on that!
>>> I'll see if I can hack on it one weekend. What I'd like though is have =
the `zig cc` toolchain have the same level of features as the "host" toolch=
ain.
>>> And it feels to me that doing the toolchain.bzl file by hand isn't the =
right way to do it. I'm still looking into how bazel generates it and see i=
f we can let it do it.
>>>
>>> Steeve
>>>
>>>
>>> On Wed, 1 Sept 2021 at 21:03, Motiejus Jak=C5=A1tys <motiejus@uber.com>=
wrote:
>>>>
>>>> Zhongpeng, thank you for bringing the group together. +Adam, who creat=
ed the initial toolchain (mine is a fork of Adam's initial hard work), and =
he has obvious interest in the toolchain too.
>>>>
>>>> Steeve, my zig-cc toolchain is hosted here. I am obviously interested =
in solving all the outlined issues, and rules_go#2894 is one of them. I am =
currently very limited in capacity myself, but happy to merge improvements,=
either the mentioned issues or anything else you find reasonably necessary=
for usage of the toolchain.
>>>>
>>>> Motiejus
>>>>
>>>> On Wed, Sep 1, 2021 at 9:17 PM Zhongpeng Lin <zplin@uber.com> wrote:
>>>>>
>>>>> Hello Motiejus,
>>>>>
>>>>> In today's Bazel-Go maintainers meeting, Steeve (cc'ed) mentioned tha=
t he wanted to work on zig-based toolchain for rules_go. Steeve is also an =
expert in cgo support in rules_go. Checking the last email you sent, it see=
ms you've made good progress on that. Do you still need help on rules_go#28=
94? Steeve is probably the most knowledgeable person for you to talk to if =
you need.
>>>>>
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=uber.com header.i=@uber.com
Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176])
by mail-b.sr.ht (Postfix) with ESMTPS id 7F60211F01D
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Tue, 14 Sep 2021 12:18:17 +0000 (UTC)
Received: by mail-pf1-f176.google.com with SMTP id 18so11985902pfh.9
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Tue, 14 Sep 2021 05:18:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=uber.com; s=google;
h=mime-version:references:in-reply-to:from:date:message-id:subject:to
:cc;
bh=OrT2HLfEH5T84qiDOOT1fkL1jScAGScbvztl9Bh21pc=;
b=90ZPl0uDFnNAu2aY6Ya/MrR2y70iL0LQKpEOGY09XP+7MwX7/86CY6t52iN6YXoH2z
NyujV8NNjIvkDfTt9lTbuTlXfH6zw/zWuXooDeKhJ5F8EV51HksugrDVwRL7pnv8H7ir
a69BVlE46C9ZTXFo+uPGKG0LzUu/FB9bCESWQ=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:mime-version:references:in-reply-to:from:date
:message-id:subject:to:cc;
bh=OrT2HLfEH5T84qiDOOT1fkL1jScAGScbvztl9Bh21pc=;
b=Ce65X6V72tRXX3lsb+mUwj1Tl/p6n/UYy3NIcFZ4HyhO7r02nN9WV8dFapeKhWHcHq
aQUqblPaAUew8VnVJ76tt5ycFfyt0r+2uyq50xnoV6K6/1T3bvxJ6/KzUG2eEV/O7hVB
xkMaYXWM4X1d62n18Z0IYGwfH8oNvgS+gNjuaoPipRxDKW5oJ7/hNpWYNK3Bdg1klq0j
JcDZWDVt6Icz2V7bI/Hg5rm4jWjJT2UVhO2dU/ORhTei5G4x4bEB5K2vnBNnewmIZkla
aruAAoUK6ES8wGwDVEs4dkjrtcF4iG+Y+6VdNs7S4c/IK5YPqP3ZWnjiS9SYof/fx3hp
MjNg==
X-Gm-Message-State: AOAM530UpTvU3UcNBbcQR2g9AazB7DLWy/Efj1NzsIcbZOWRJyxpGydG
Oc79jHwoMosaawx9gQ4QRMbjlwM9ThZOelu/hmh05g==
X-Google-Smtp-Source: ABdhPJwrF4zc8+XPliKolcZkIgfEaf2EZWHhN4u3jxGdRRd12ErlTeUw0hq/4vbWlDizwNXDf/l1lw58uq4TfJsojxQ=
X-Received: by 2002:a62:8c08:0:b0:434:652b:1319 with SMTP id
m8-20020a628c08000000b00434652b1319mr4534198pfd.24.1631621895297; Tue, 14 Sep
2021 05:18:15 -0700 (PDT)
MIME-Version: 1.0
References: <CAMEgGpyFHe3f=VZgFEDMivQ_rGCmHngBPH5MAC2Va5NvJmRo5g@mail.gmail.com>
<CAK+t98XUb0EmzKu-zOPpZxQM_jcWS=K3AJUuz9tB93COdtJqFw@mail.gmail.com>
<CAEZVCP5BMvXc2W5L0_fYGws8A_GgXwZ4mgtduS3qBzNP97nqSw@mail.gmail.com>
<CAK+t98UYm5FhQFit4vix_RTUzXBfeH+CGVM8-1vQFHtYfLcgXw@mail.gmail.com>
<CANeNeVSkKdpeN8BnXciTXBQQhoLFLGKCAKNXCRYyh8ymppdkfg@mail.gmail.com>
<CAK+t98X2fo+_f+W1o8hzYX_CXmHVPMNfBN2CoM+soRGgMELOQQ@mail.gmail.com>
<CANeNeVTjtYd8vVzgprM7-LMBS67kugn_rvsocrP80W+rwvsUjQ@mail.gmail.com> <CAEZVCP4=r79nLRghL03Hi7CfKFjF2u3sL97hba9PHQzh7ZhFyg@mail.gmail.com>
In-Reply-To: <CAEZVCP4=r79nLRghL03Hi7CfKFjF2u3sL97hba9PHQzh7ZhFyg@mail.gmail.com>
From: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <motiejus@uber.com>
Date: Tue, 14 Sep 2021 15:18:04 +0300
Message-ID: <CAK+t98Ww6cWU+MRtaPQ=_WVe_mwYmf0h9HHj_O0D-yuXyvoS3A@mail.gmail.com>
Subject: Re: Cross-compilation with zig
To: Steeve Morin <steeve.morin@gmail.com>
Cc: Adam Bouhenguel <adam@bouhenguel.com>, ~motiejus/bazel-zig-cc@lists.sr.ht,
Zhongpeng Lin <zplin@uber.com>
Content-Type: text/plain; charset="UTF-8"
On Tue, Sep 14, 2021 at 2:21 AM Steeve Morin <steeve.morin@gmail.com> wrote:
>
> Alright you guys, I found a way to use bazel's auto toolchain configuration with zig!
> It's rather archaic for now, but it works, I got protoc compiled and running for both macos and linux.
>
> Still needs some love, I'll post updates in the next few days.
Looking forward to anything that will simplify it's setup/boilerplate.
> The main idea is to give to @bazel_tools//tools/cpp:unix_cc_configure.bzl configure_unix_toolchain() what it want, and that's it!
Interesting!
I have slightly updated the toolchain today:
- added support for darwin-arm64 and linux-arm64 host (though don't
have an arm64 machine to test this with).
- tried to upgrade zig itself, but cross-compilation to darwin-amd64
fails with it; there seems to be a regression somewhere. I will look
into it sometime soon.
... so please rebase before sending patches.
Regards,
Motiejus
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45])
by mail-b.sr.ht (Postfix) with ESMTPS id 7AA8311EF38
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Fri, 29 Oct 2021 04:45:34 +0000 (UTC)
Received: by mail-lf1-f45.google.com with SMTP id p16so18563959lfa.2
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Thu, 28 Oct 2021 21:45:34 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:cc:subject:message-id:references:mime-version
:content-disposition:content-transfer-encoding:in-reply-to;
bh=e1CN1JJJM9joKaUlYnsska9HvRy43YfFeSGJYgiQjQs=;
b=N7pGbkjAvxhSXwB+tTVrJHBV8BHUuBWcqQlTvb/BtI/Jc5fNEvIj/GA7D/AxiqmIR1
27T8aTQ1DlzX+OQOW406lwGXbvZZL3V0ehPNMd7iusogsbnKu2EHBr+ThWpVtedV7vPU
/9iK0Z4ZmfsEN7uJIfRUN7dG+A2YhndnNXTgPJ25NCCICu4PpIOqbgYjywgE1GiC0Hay
YZymEWSaVLn7vKlbEkbxhKZ+UztEBLATrHZRKj5RfKyaqp2tlWgH+0o3I/gLxrtZVcX+
TKhoRqrxjGjYZrkdYwrVpHQ3k2w9/PTe7fRODmp9cYS9PRwEQC30OFWWz3eXgps+DMc8
LPbw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:cc:subject:message-id
:references:mime-version:content-disposition
:content-transfer-encoding:in-reply-to;
bh=e1CN1JJJM9joKaUlYnsska9HvRy43YfFeSGJYgiQjQs=;
b=r89AESahTPDW+InsPvQBy5oShDlHrIWGg57AY8KjJBEXQgzGmw3EvmJjiLcsgSl+Wb
8zqr7NZ1dMcpon8GeT6jHeCKGHshHUqTFd6g52JIBGF/zUCVb56UUBDR3ioI7bGrPQxB
vPys0M00zxd8XxmgXoNXGlzsrPQb5Ey6G4c8LoGfByNU1MGq4QOeJalsLpZlqBRufnC8
KGaMUySwLmdUEJkvr6cwUVU0aH/NFH/a3SNJjqbErS7+BsG8L8c2mHfgXHRK5gKDSSW5
OeZFJhvSyckmkmydjakuc2ujue4AmXI0zHOqHG6x4BmRn9zLXGsubF3PTdnznc0FpSve
3QLw==
X-Gm-Message-State: AOAM530q79ok7W8D4VaBKIDpBl3HwOetwH0gt33opT4qmBP6+foicf1Z
2uv9qkI/iyrmnil6tOaY/QE=
X-Google-Smtp-Source: ABdhPJyuFdbOG4l8g9NVpT78xmShrZBBHNU8pGNzJkGl1MbHL1FDvr/UfAiOZ67yA0UmaKYiXhMxsQ==
X-Received: by 2002:a05:6512:33c2:: with SMTP id d2mr7692886lfg.182.1635482732884;
Thu, 28 Oct 2021 21:45:32 -0700 (PDT)
Received: from localhost ([88.223.105.24])
by smtp.gmail.com with ESMTPSA id e22sm493971lfr.237.2021.10.28.21.45.31
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 28 Oct 2021 21:45:32 -0700 (PDT)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Fri, 29 Oct 2021 07:45:31 +0300
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@uber.com>
Cc: Steeve Morin <steeve.morin@gmail.com>,
Adam Bouhenguel <adam@bouhenguel.com>,
~motiejus/bazel-zig-cc@lists.sr.ht, Zhongpeng Lin <zplin@uber.com>
Subject: Re: Cross-compilation with zig
Message-ID: <20211029044531.vvtv7btw2ur7u6zc@mtpad.i.jakstys.lt>
References: <CAMEgGpyFHe3f=VZgFEDMivQ_rGCmHngBPH5MAC2Va5NvJmRo5g@mail.gmail.com>
<CAK+t98XUb0EmzKu-zOPpZxQM_jcWS=K3AJUuz9tB93COdtJqFw@mail.gmail.com>
<CAEZVCP5BMvXc2W5L0_fYGws8A_GgXwZ4mgtduS3qBzNP97nqSw@mail.gmail.com>
<CAK+t98UYm5FhQFit4vix_RTUzXBfeH+CGVM8-1vQFHtYfLcgXw@mail.gmail.com>
<CANeNeVSkKdpeN8BnXciTXBQQhoLFLGKCAKNXCRYyh8ymppdkfg@mail.gmail.com>
<CAK+t98X2fo+_f+W1o8hzYX_CXmHVPMNfBN2CoM+soRGgMELOQQ@mail.gmail.com>
<CANeNeVTjtYd8vVzgprM7-LMBS67kugn_rvsocrP80W+rwvsUjQ@mail.gmail.com>
<CAEZVCP4=r79nLRghL03Hi7CfKFjF2u3sL97hba9PHQzh7ZhFyg@mail.gmail.com>
<CAK+t98Ww6cWU+MRtaPQ=_WVe_mwYmf0h9HHj_O0D-yuXyvoS3A@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <CAK+t98Ww6cWU+MRtaPQ=_WVe_mwYmf0h9HHj_O0D-yuXyvoS3A@mail.gmail.com>
On Tue, Sep 14, 2021 at 03:18:04PM +0300, Motiejus Jakštys wrote:
> On Tue, Sep 14, 2021 at 2:21 AM Steeve Morin <steeve.morin@gmail.com> wrote:
> >
> > Alright you guys, I found a way to use bazel's auto toolchain configuration with zig!
> > It's rather archaic for now, but it works, I got protoc compiled and running for both macos and linux.
> >
> > Still needs some love, I'll post updates in the next few days.
>
> Looking forward to anything that will simplify it's setup/boilerplate.
Hi all,
the way plans are panning out now, at some point in 2022H1 bazel-zig-cc
will be scrutinized by much more competent colleagues than myself,
before being moved to github.com/uber (or equivalent). After that major
changes will be much harder to make.
Steeve, if you are still considering on major changes in bazel-zig-cc,
this year is better than next year.
Motiejus
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=none
Received: from git.sr.ht (unknown [173.195.146.142])
by mail-b.sr.ht (Postfix) with ESMTPSA id 57B3B11EF37
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Fri, 5 Nov 2021 13:23:34 +0000 (UTC)
From: ~mjonaitis <mjonaitis@git.sr.ht>
Date: Thu, 04 Nov 2021 18:54:42 +0200
Subject: [PATCH bazel-zig-cc] add go_binary override
Message-ID: <163611861421.17091.108675275474200386-0@git.sr.ht>
X-Mailer: git.sr.ht
Reply-to: ~mjonaitis <mjonaitis@uber.com>
To: ~motiejus/bazel-zig-cc@lists.sr.ht
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
From: Mantas Jonaitis <mjonaitis@uber.com>
---
BUILD | 2 ++
README.md | 7 +++++++
rules/BUILD | 0
rules/go_binary_override.bzl | 27 +++++++++++++++++++++++++++
test/BUILD | 15 ++++-----------
5 files changed, 40 insertions(+), 11 deletions(-)
create mode 100644 rules/BUILD
create mode 100644 rules/go_binary_override.bzl
diff --git a/BUILD b/BUILD
index 07e6a04..a34acae 100644
--- a/BUILD
+++ b/BUILD
@@ -1,6 +1,8 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
=20
+# gazelle:map_kind go_binary go_binary //rules:go_binary_override.bzl
+
# gazelle:build_file_name BUILD
# gazelle:prefix github.com/motiejus/bazel-zig-cc
gazelle(name =3D "gazelle")
diff --git a/README.md b/README.md
index 8ae3935..7c83752 100644
--- a/README.md
+++ b/README.md
@@ -116,6 +116,13 @@ go_binary(
)
```
=20
+A workaround with [gazelle](https://github.com/bazelbuild/bazel-gazelle) `ma=
p_kind` directive is possible. This will override rules_go `go_binary` rule w=
ith `go_binary` which contains default `gc_linkopts` parameters. Add this lin=
e to your BUILD files (usually adding to root BUILD file will suffice) and ru=
n `gazelle` to automatically generate `load` statements.
+
+```
+# gazelle:map_kind go_binary go_binary @bazel-zig-cc//rules:go_binary_overri=
de.bzl
+```
+
+
## incorrect glibc version autodetection
=20
**Severity: Low**
diff --git a/rules/BUILD b/rules/BUILD
new file mode 100644
index 0000000..e69de29
diff --git a/rules/go_binary_override.bzl b/rules/go_binary_override.bzl
new file mode 100644
index 0000000..6ac14cf
--- /dev/null
+++ b/rules/go_binary_override.bzl
@@ -0,0 +1,27 @@
+load("@io_bazel_rules_go//go:def.bzl", go_binary_rule =3D "go_binary")
+
+"""
+go_binary overrides go_binary from rules_go and provides default
+gc_linkopts values that are needed to compile for macos target.
+To use it, add this map_kind gazelle directive to your BUILD.bazel files
+where target binary needs to be compiled with zig toolchain.
+
+Example: if this toolchain is registered as bazel-zig-cc in your WORKSPACE, =
add this to
+your root BUILD file
+# gazelle:map_kind go_binary go_binary @bazel-zig-cc//rules:go_binary_overri=
de.bzl
+"""
+def go_binary(**args):
+ new_args =3D {}
+ new_args["gc_linkopts"] =3D select({
+ "@platforms//os:macos": [
+ "-s",
+ "-w",
+ "-buildmode=3Dpie",
+ ],
+ "//conditions:default": [],
+ })
+ for k, v in args.items():
+ new_args[k] =3D v
+ print("Key: {}".format(k))
+ go_binary_rule(**new_args)
+
diff --git a/test/BUILD b/test/BUILD
index 133fe5a..415b9c2 100644
--- a/test/BUILD
+++ b/test/BUILD
@@ -1,4 +1,5 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+load("//rules:go_binary_override.bzl", "go_binary")
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
=20
go_library(
name =3D "hello_lib",
@@ -7,22 +8,14 @@ go_library(
importpath =3D "github.com/motiejus/bazel-zig-cc/test",
visibility =3D ["//visibility:private"],
deps =3D [
- "@com_github_datadog_zstd//:go_default_library",
- "@com_github_mattn_go_sqlite3//:go_default_library",
+ "@com_github_datadog_zstd//:zstd",
+ "@com_github_mattn_go_sqlite3//:go-sqlite3",
],
)
=20
go_binary(
name =3D "hello",
embed =3D [":hello_lib"],
- gc_linkopts =3D select({
- "@platforms//os:macos": [
- "-s",
- "-w",
- "-buildmode=3Dpie",
- ],
- "//conditions:default": [],
- }),
static =3D "on",
visibility =3D ["//visibility:public"],
)
--=20
2.32.0
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=none
Received: from git.sr.ht (unknown [173.195.146.142])
by mail-b.sr.ht (Postfix) with ESMTPSA id 3B44211EF37
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Fri, 5 Nov 2021 13:39:06 +0000 (UTC)
From: ~mjonaitis <mjonaitis@git.sr.ht>
Date: Thu, 04 Nov 2021 18:54:42 +0200
Subject: [PATCH bazel-zig-cc v2] add go_binary override
Message-ID: <163611954593.18596.9121656084211429991-0@git.sr.ht>
X-Mailer: git.sr.ht
Reply-to: ~mjonaitis <mjonaitis@uber.com>
To: ~motiejus/bazel-zig-cc@lists.sr.ht
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
From: Mantas Jonaitis <mjonaitis@uber.com>
---
BUILD | 2 ++
README.md | 7 +++++++
rules/BUILD | 0
rules/go_binary_override.bzl | 26 ++++++++++++++++++++++++++
test/BUILD | 15 ++++-----------
5 files changed, 39 insertions(+), 11 deletions(-)
create mode 100644 rules/BUILD
create mode 100644 rules/go_binary_override.bzl
diff --git a/BUILD b/BUILD
index 07e6a04..a34acae 100644
--- a/BUILD
+++ b/BUILD
@@ -1,6 +1,8 @@
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier")
=20
+# gazelle:map_kind go_binary go_binary //rules:go_binary_override.bzl
+
# gazelle:build_file_name BUILD
# gazelle:prefix github.com/motiejus/bazel-zig-cc
gazelle(name =3D "gazelle")
diff --git a/README.md b/README.md
index 8ae3935..7c83752 100644
--- a/README.md
+++ b/README.md
@@ -116,6 +116,13 @@ go_binary(
)
```
=20
+A workaround with [gazelle](https://github.com/bazelbuild/bazel-gazelle) `ma=
p_kind` directive is possible. This will override rules_go `go_binary` rule w=
ith `go_binary` which contains default `gc_linkopts` parameters. Add this lin=
e to your BUILD files (usually adding to root BUILD file will suffice) and ru=
n `gazelle` to automatically generate `load` statements.
+
+```
+# gazelle:map_kind go_binary go_binary @bazel-zig-cc//rules:go_binary_overri=
de.bzl
+```
+
+
## incorrect glibc version autodetection
=20
**Severity: Low**
diff --git a/rules/BUILD b/rules/BUILD
new file mode 100644
index 0000000..e69de29
diff --git a/rules/go_binary_override.bzl b/rules/go_binary_override.bzl
new file mode 100644
index 0000000..cb37807
--- /dev/null
+++ b/rules/go_binary_override.bzl
@@ -0,0 +1,26 @@
+load("@io_bazel_rules_go//go:def.bzl", go_binary_rule =3D "go_binary")
+
+"""
+go_binary overrides go_binary from rules_go and provides default
+gc_linkopts values that are needed to compile for macos target.
+To use it, add this map_kind gazelle directive to your BUILD.bazel files
+where target binary needs to be compiled with zig toolchain.
+
+Example: if this toolchain is registered as bazel-zig-cc in your WORKSPACE, =
add this to
+your root BUILD file
+# gazelle:map_kind go_binary go_binary @bazel-zig-cc//rules:go_binary_overri=
de.bzl
+"""
+def go_binary(**args):
+ new_args =3D {}
+ new_args["gc_linkopts"] =3D select({
+ "@platforms//os:macos": [
+ "-s",
+ "-w",
+ "-buildmode=3Dpie",
+ ],
+ "//conditions:default": [],
+ })
+ for k, v in args.items():
+ new_args[k] =3D v
+ go_binary_rule(**new_args)
+
diff --git a/test/BUILD b/test/BUILD
index 133fe5a..415b9c2 100644
--- a/test/BUILD
+++ b/test/BUILD
@@ -1,4 +1,5 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library")
+load("//rules:go_binary_override.bzl", "go_binary")
+load("@io_bazel_rules_go//go:def.bzl", "go_library")
=20
go_library(
name =3D "hello_lib",
@@ -7,22 +8,14 @@ go_library(
importpath =3D "github.com/motiejus/bazel-zig-cc/test",
visibility =3D ["//visibility:private"],
deps =3D [
- "@com_github_datadog_zstd//:go_default_library",
- "@com_github_mattn_go_sqlite3//:go_default_library",
+ "@com_github_datadog_zstd//:zstd",
+ "@com_github_mattn_go_sqlite3//:go-sqlite3",
],
)
=20
go_binary(
name =3D "hello",
embed =3D [":hello_lib"],
- gc_linkopts =3D select({
- "@platforms//os:macos": [
- "-s",
- "-w",
- "-buildmode=3Dpie",
- ],
- "//conditions:default": [],
- }),
static =3D "on",
visibility =3D ["//visibility:public"],
)
--=20
2.32.0
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50])
by mail-b.sr.ht (Postfix) with ESMTPS id 758F711EF37
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Fri, 5 Nov 2021 17:51:50 +0000 (UTC)
Received: by mail-wr1-f50.google.com with SMTP id b12so14932424wrh.4
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Fri, 05 Nov 2021 10:51:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:cc:subject:message-id:references:mime-version
:content-disposition:in-reply-to;
bh=7twJFp2dPdxRaWs/e7LS95o7UbEONAXKNGJm0Ob1Wjg=;
b=a1+afz8XHDlEPSMPQ1FTgCSKIt1O6BU6Rd4OMsdb+YfNN0HarXLbPXkX4nwcoQVJZl
x0TBYE3Lv3abwUPqgPzEvO2sLMXjYZr+ys2guFw/LE3OUQwzEaewfhGeM7mJKoc9wlcf
i5BNu3VV3MsDnylAcsasQ2W/9eEkhZbsQIILo+XOQjiBkEW7CmzR2aSg5bsTLYbGBjz5
4ERwpIY9uod2Z7w4cucD22+vJjRatF7upBT0EqPSw7Pkb5UUvac/z0u0tLh+uoIN+Xw9
d/X/U1GpLXoKyGTwMqq3JCNPXwaESWJdtRmzXXtW3fAC10J7Pa2a8suCwFYSiBOctRhd
wVXA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:cc:subject:message-id
:references:mime-version:content-disposition:in-reply-to;
bh=7twJFp2dPdxRaWs/e7LS95o7UbEONAXKNGJm0Ob1Wjg=;
b=LzlcGF6wJrQFFQM72QIjedm8gc+GZmW44ruRoyW2VSCL/XTPU47Ort7mBfXb51+d0/
HLI5U6348cQ393BjvT1Sl3xByrOLnM7E6rQLQ45WbTAjIbmXTKzOp3ngAAmeiSDuo9XN
IBZFmmu6Ztil9eyyBr1zN9u4yPyLS0OS44m1coDmUG7j4hqsWaUL/e6qZayoYMQyXBzI
g32V/kYSxO+2gcpzc2yI+xVewyST29fczusxH8F33q6ky3FK1nAgpTpSsOmpXQND9K3/
8+5lYmEXYeEIjmR73OlWwQ8qC4NJK6Q3vlaJf5ts7I8unS/E/mN6aNQyespWDRsEUZ4b
D9Aw==
X-Gm-Message-State: AOAM532XofickUl56P1GLD+NqdFHGBckg60NosiMHdXkJsbJ8j24RYrE
rXjKqltKIHdehkIOocslQnc=
X-Google-Smtp-Source: ABdhPJylZROyH/qdWll3OEJtLDTYrSm3ZUIC8mX0SUk/ck3AxLsAnvVQEyMX4exhznKgRF84qJrdFg==
X-Received: by 2002:a05:6000:143:: with SMTP id r3mr5508367wrx.236.1636134709441;
Fri, 05 Nov 2021 10:51:49 -0700 (PDT)
Received: from localhost ([195.235.63.50])
by smtp.gmail.com with ESMTPSA id n7sm8534493wro.68.2021.11.05.10.51.48
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 05 Nov 2021 10:51:48 -0700 (PDT)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Fri, 5 Nov 2021 19:51:54 +0200
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: ~mjonaitis <mjonaitis@uber.com>
Cc: ~motiejus/bazel-zig-cc@lists.sr.ht
Subject: Re: [PATCH bazel-zig-cc v2] add go_binary override
Message-ID: <20211105175154.bzfuu666zuaxyt27@mtpad.i.jakstys.lt>
References: <163611954593.18596.9121656084211429991-0@git.sr.ht>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
In-Reply-To: <163611954593.18596.9121656084211429991-0@git.sr.ht>
On Thu, Nov 04, 2021 at 06:54:42PM +0200, ~mjonaitis wrote:
> From: Mantas Jonaitis <mjonaitis@uber.com>
>
> ---
> BUILD | 2 ++
> README.md | 7 +++++++
> rules/BUILD | 0
> rules/go_binary_override.bzl | 26 ++++++++++++++++++++++++++
> test/BUILD | 15 ++++-----------
> 5 files changed, 39 insertions(+), 11 deletions(-)
> create mode 100644 rules/BUILD
> create mode 100644 rules/go_binary_override.bzl
Applied[1], thank you. Although I left only the acknowledgement in the
README; see [2] for why.
Motiejus
[1]: https://git.sr.ht/~motiejus/bazel-zig-cc/commit/523943bd35d33f96f946be653311787426149135
[2]: https://git.sr.ht/~motiejus/bazel-zig-cc/commit/22b5d3e8e38e762a35adbfd4e13bfe5c2fb07972
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45])
by mail-b.sr.ht (Postfix) with ESMTPS id 9413211EF81
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Mon, 6 Dec 2021 20:01:32 +0000 (UTC)
Received: by mail-lf1-f45.google.com with SMTP id n12so28168895lfe.1
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Mon, 06 Dec 2021 12:01:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:cc:subject:message-id:references:mime-version
:content-disposition:content-transfer-encoding:in-reply-to;
bh=XbmO1rVL6sHMTrVhfrqqOl/bwac3U2zY7lWAQ/rHyYI=;
b=Ui4E27zUkVkuxOSfzUqdvgjLvJt2zihUNYH6RF9nSLXybcoG1pmy2uszNB9mMp4OKE
cQuFWrQbItNulmWxf1DF3oAEgyKe7TzjEGgayv/9zDmBJzlYpVetrACw5cx1UZjxHK66
weYxKw7rBN4y9y9mADbf2HLqibIbE61Q2WRJ9N+q09jTqY3t5bOCQaN7NrTnXfvdrMHv
l2+1m2JnjwmHVWnpYNaKODmnO7yBl2G/JtBF7iaVx2gzP8oYtGHZREWaeYfHuAQJtaqB
53rMyZIceJJBpsNv0Od2W/gbBXEtiER5ESSg3zFwZySBYdF5KGfnsa3fclAAxZOKyEkc
n8jg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:cc:subject:message-id
:references:mime-version:content-disposition
:content-transfer-encoding:in-reply-to;
bh=XbmO1rVL6sHMTrVhfrqqOl/bwac3U2zY7lWAQ/rHyYI=;
b=xItNJQnvwvQPGYo/eRO3rcIcghIeEYeqaHhNjWXULh3N/u95sFwCOaPITMuXYQGi3Q
Ob4+R3CDSl54/jzyIM9UTdXO7l9Cjoc46/uE3PcTBxchclkg5wvlW+gf7qqcOPh1CT6N
2yOR9Zm0lm5SsekIu7TZ/i/bt0ki+xegDDLDIkfpaS6FMbAwxpsC8UTU0+Cjro+6z6/b
VeL4OKWI/brQARrFG3ou2k3SEH/5fGDDosuDXuvJLNxHfL19epeM1wRwKu5DNMCN0Xwf
a87rrTOyys46rLwxGIiMzJ774y6pUlTWWyw4Wats/CmugLFoaaAXWLBqIQdvkSuhJm+V
GtXw==
X-Gm-Message-State: AOAM530mwZuS8Zn37xIFZxYCoDokFqKGJTy4gP29snlm1IBQBAVALfoZ
gpL3eENl0BUbF1SG2YeWITc=
X-Google-Smtp-Source: ABdhPJzSblFiitOVK4mUPDvYX2C+QgZFR6SJ06DAAEp2kDJ1On6O52o6QBmThDQZbAdysSZh0aIlgQ==
X-Received: by 2002:a05:6512:2305:: with SMTP id o5mr37990569lfu.362.1638820890548;
Mon, 06 Dec 2021 12:01:30 -0800 (PST)
Received: from localhost ([88.223.105.24])
by smtp.gmail.com with ESMTPSA id q24sm1443528lfp.103.2021.12.06.12.01.29
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 06 Dec 2021 12:01:29 -0800 (PST)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Mon, 6 Dec 2021 22:01:28 +0200
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: Thomas Way <tway@cloudflare.com>
Cc: ~motiejus/bazel-zig-cc@lists.sr.ht
Subject: Re: bazel-zig-cc contributions
Message-ID: <20211206200128.vyx7b4r5h2moe5dk@mtpad.i.jakstys.lt>
References: <CAO8CkMSaFSeYVsgczJPStPz9M3LDZCUdABRo8Pk1+=U6v-NT0Q@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
In-Reply-To: <CAO8CkMSaFSeYVsgczJPStPz9M3LDZCUdABRo8Pk1+=U6v-NT0Q@mail.gmail.com>
On Mon, Dec 06, 2021 at 05:57:46PM +0000, Thomas Way wrote:
> Hey Motiejus!
> Thank you so much for your work on the Zig CC rules. They're been
> extremely helpful and a true gamechanger for the way we work with our
> repository.
> Per Zig's cache race conditions, we've made some changes to the rules and
> were wondering what the best way to contribute them would be?
Hi Thomas!
See [1]; I also recommend you to subscribe. I haven't heard of anyone
using bazel-zig-cc, so I guess I'll need to be more careful/upfront
about breaking changes.
> A quick summary:
> - Use an alias for the Go-style toolchain. This should be more efficient.
> - Some general cleanup of unused features (i.e unnecessary filegroups).
> - Most importantly: Use a cache location inside Bazel. We found that
> sometimes Zig's cache would become corrupt on the host and would become
> irrecoverable even after running `bazel clean --expunge`. Using a cache
> location inside Bazel fixes this issue and is good practise in general I
> believe.
These sound great, send them over!
> I look forward to hearing from you.
Have you found a need/way to specify a different default url for the zig
bundle? I've been playing with it[2], but unsatisfied with the API so
far.
Motiejus
[1]: https://sr.ht/~motiejus/bazel-zig-cc/#contribution-guidelines
[2]:
https://git.sr.ht/~motiejus/bazel-zig-cc/commit/8f5f249227aa6a9d3de441058eb9d3aae330620b
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42])
by mail-b.sr.ht (Postfix) with ESMTPS id 9975311EF93
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Fri, 10 Dec 2021 07:57:40 +0000 (UTC)
Received: by mail-lf1-f42.google.com with SMTP id m27so16481755lfj.12
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Thu, 09 Dec 2021 23:57:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:subject:message-id:mime-version
:content-disposition;
bh=HQ/hL64B6GWzGaNBVZUn4QLaOj38mBj6tYEQkF5T6Hc=;
b=HRbxSWHJkd1mlvqgFdlGyFOVOlXJr8/e2Tz9lm1YMGwoH50u/oTHT0Qv3csF9/DxXs
0vAyK8YeTncB6iGP/uyCF2mzrTRLsWaJXwYMmRGq0Q32iQkHjURwdbaruxZF/EAHx4V9
1O20KHVUapedNnIzdC940UhaYnwTolyUi7tHj6dQLPyA26ukzQK6TYjrlNRZa5qyogX5
W3OTN1Kk0mfU8IOWyCJocFb0sozLbzT//HP/L+UfXkid4IvtpuEfTLIkBr/Ez0fZEXtY
0HW3+PZKwNBV8A1eMNfmX+aW0XPfPpek8mCZ41iGi/5TEBdO2O75520iDnYXYqfc4VZ2
VuCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:subject:message-id
:mime-version:content-disposition;
bh=HQ/hL64B6GWzGaNBVZUn4QLaOj38mBj6tYEQkF5T6Hc=;
b=rgCpluQpBDnpflGkjPs3XJ4t/c293EfjPhwWqR6bwA+eGn12gq6HsZ8ZC+aPW2TBVX
rdcNzG6RWq4v4asAp8Ng3pDESOGLPADxlsLqS/RxW6pqTzZXNE67kCvoEDEzZ6mE8bIg
AK56XSqB6bfUkl9PJbd4R7l6O4EZjM/7AQGoSY3xW1OQ2XXvQ8PjMNWrSuF6rZVq02y6
MuxhGBzQer/LQmI8M6XL9lNAYKJzeimwG2zVzmGWX+d1cJig37qc3QF1HBK57PG6rxnw
gteWVE/yPY5J3ul1aBTW0VV3seXnb8KixoihOsvc7aH0/PqxjyV6Fga8WbFQvwpDat7c
JRhQ==
X-Gm-Message-State: AOAM533n1LpdCI+K//K6+CY/Cqn/Tw+F334UDBFn1SSG0G+TDXt+3kt+
8NFjbzbVpYsCB/CYuQVrhM+W99Yg5Ck=
X-Google-Smtp-Source: ABdhPJz07XVpRcQkYipcpP+OcZMq1nSXbEg5HLv7ziv6SBn8gWkNFCfBr4BGn3fJkpaD+Ur7p/dZpg==
X-Received: by 2002:ac2:5f85:: with SMTP id r5mr10983167lfe.566.1639123055422;
Thu, 09 Dec 2021 23:57:35 -0800 (PST)
Received: from localhost (m90-131-39-222.cust.tele2.lt. [90.131.39.222])
by smtp.gmail.com with ESMTPSA id a1sm262188lfb.190.2021.12.09.23.57.34
for <~motiejus/bazel-zig-cc@lists.sr.ht>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 09 Dec 2021 23:57:34 -0800 (PST)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Fri, 10 Dec 2021 09:57:33 +0200
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: ~motiejus/bazel-zig-cc@lists.sr.ht
Subject: recent changes in bazel-zig-cc
Message-ID: <20211210075733.ihb2b57lyges4l6d@mtpad.i.jakstys.lt>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Hi bazel-zig-cc users,
Due to a recent bug-fixing spree in zig, bazel-zig-cc improved quite a
bit:
- `zig c++` no longer errs with the dreaded FileNotFound[1]. This was
very prominent on many-core machines, and now unblocked larger-scale
tests.
- can compile Darwin again: x86_64[2] and aarch64[3]. Although if you
are interested in compiling for Darwin, Jakub's comments in [3] are
must-read.
My only short-term wish-list from Zig today is [4]: if Foundation
framework is requested, but zig doesn't find it, the compiler should
fail. Currently only a warning is emitted, and the binary is wedged with
a possibly "difficult to track runtime exception"[5]:
```
warning(link): framework not found for '-framework CoreFoundation'
warning(link): Framework search paths:
```
I added an Upcoming Wishlist category to the README[6], which is:
- Move Zig cache path to bazel root, so bazel clean --expunge clears the
zig cache.
- Provide a way to specify alternative URLs for the zig toolchain
(currently zig is downloaded from jakstys.lt, which is nuts).
- Rename @zig_sdk//:<toolchain>_toolchain to
@zig_sdk//toolchain:<toolchain> or similar; so the user-facing targets
are in their own namespace.
- Provide a way to specify sysroot for Darwin (OSX). See [#Compiling OS X
executables] for an ongoing discussion.
As bazel-zig-cc is only ~10% of my $dayjob, I am not planning to work on
the above any time soon. But it gives a nice starting point for a
question "how do I help/contribute"?
Zig 0.9.0 is 10 days away, I will cut bazel-zig-cc 0.4.0 once that
happens.
[1]: https://github.com/ziglang/zig/issues/9431
[2]: https://github.com/ziglang/zig/issues/10297
[3]: https://github.com/ziglang/zig/issues/10299
[4]: https://github.com/ziglang/zig/issues/10299#issuecomment-990404953
[5]: https://github.com/ziglang/zig/issues/10299#issuecomment-989153750
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177])
by mail-b.sr.ht (Postfix) with ESMTPS id 6E05E11EF94
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Mon, 13 Dec 2021 02:38:20 +0000 (UTC)
Received: by mail-lj1-f177.google.com with SMTP id bn20so21731895ljb.8
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Sun, 12 Dec 2021 18:38:20 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:subject:message-id:mime-version
:content-disposition;
bh=yoiGVjBHZN2xJAtcYYTqPfPA8yxvgKQ0VkBgA3ZSX20=;
b=f1258iMcV/Wbk9swTsCSoWGYASEwg9aI6PY4Ee8hYi1a6CQMkWzwFdEiaaYyCOpABn
4AtFWDrTM3fZ+ctksbg+tDl782Z9o929B/4SAcfXInX9oKHsobmzO0ChoS7QaFX3JK32
/sKmWTcN6rLg8BUSmN4D8EkIG3mJV48jx1VdbHKSZtlPxHLHIWMIWJCzsTr9ihVMCYkE
2lik9ffXQLWbQScNgwirCm14fb44rEBRQ3ooXYBG/wRsPyH+IP15/fZN47AF7kPrITU1
Pbg2s7PL8WxYNogXtD7f77UsfyN7/YrJOqUIlfe0yxQb1wtMXibAB7su9uSpKZ3/PoIU
q20w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:subject:message-id
:mime-version:content-disposition;
bh=yoiGVjBHZN2xJAtcYYTqPfPA8yxvgKQ0VkBgA3ZSX20=;
b=L9A3RyHTzHV+FMUGbXt87CW6BV9dZ7kcW4N2Y6v6EGeuaGYohH7qt5jGFHF3qL2+rk
lv3ZY/3cCaCgBq1G1QevpO40orf+7Ci4hLvL0YLC8MqI4QWzTemvMJsq3jb8aZ9lBMIs
HMXrqAuEhqatukjO/o5gykvb6oFhJF56HCwe3dIZgud75BaYNSKZKRvg/1X30S9EjBg3
+Y+qElbC26lKKpzvTnlG8VI4Gg+W1aMNeaa6gB/ybsddLGIss+jtoKWgI+Pey/P6b1bV
Hc0mwChymAeWPdIBlYD5cphbFMr9uPl4ceoQCw7l6+du+lI1M2/x5jFUV0taGLBTaHR2
FadA==
X-Gm-Message-State: AOAM532NYpPD+ClV9sorQ9xbOrDBd+RgPqTbGjWmHYTxFYWTzBlmr8Ae
f3Y9g5K1oa/cMkDMkzESuHr/EpL1yy4=
X-Google-Smtp-Source: ABdhPJwy5PDLB0wyelzZ7tpYgzeQzFLInozFHtZ4lQRvqE0cFrzbeHeXlgo/tK2Bzr/WRZea468KCA==
X-Received: by 2002:a05:651c:323:: with SMTP id b3mr26998720ljp.316.1639363097753;
Sun, 12 Dec 2021 18:38:17 -0800 (PST)
Received: from localhost ([88.223.105.24])
by smtp.gmail.com with ESMTPSA id z2sm1235075lfd.301.2021.12.12.18.38.16
for <~motiejus/bazel-zig-cc@lists.sr.ht>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 12 Dec 2021 18:38:17 -0800 (PST)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Mon, 13 Dec 2021 04:38:16 +0200
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: ~motiejus/bazel-zig-cc@lists.sr.ht
Subject: bazel-zig-cc v0.4.0-rc1
Message-ID: <20211213023816.obgjrpaxt445lzpn@mtpad.i.jakstys.lt>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Hi folks,
I released v0.4.0-rc1; notable changes from v0.3.4:
- upgrade to zig 0.9.0-dev.1950+a76910b69. Now compilation on Darwin
will fail if `-framework` was specified, but wasn't able to be
linked[1]. This happens on darwin/arm64, which I had to disable CI
for. A patch that passes `zig cc --sysroot=/path/to/sdk` is sought
for, if you care about darwin/arm64 (or darwin in general).
- remove default `-O3`[2]. This now re-enables UBSAN by default, which
is an important default in upstream[3].
v0.4.0 will be released when zig 0.9.0 is released, which is scheduled
for Dec 20.
About undefined behavior (removal of `-O3`)
-------------------------------------------
The second change broke my use of brotli, which relies on undefined
behaior[4]. This is my ugly way to mitigate it:
Project's WORKSPACE
```
BROTLI_COMMIT = "4ec67035c0d97c270c1c73038cc66fc5fcdfc120"
http_archive(
name = "brotli",
sha256 = "9f57c32e5903768a03900366d8a055d49c01ecbbded046dce47eae24115b58b8",
strip_prefix = "brotli-%s" % BROTLI_COMMIT,
urls = ["https://github.com/google/brotli/archive/%s.zip" % BROTLI_COMMIT],
patch_args = ["-p1"],
patches = [
"//patches:brotli-disable-undefined-behavior.patch",
],
)
```
And the patch:
```
diff --git a/BUILD b/BUILD
index 07a6793..2b4d1c1 100644
--- a/BUILD
+++ b/BUILD
@@ -43,7 +43,7 @@ config_setting(
create_msvc_config()
-STRICT_C_OPTIONS = select({
+STRICT_C_OPTIONS = ["-DBROTLI_BUILD_PORTABLE"] + select({
":msvc": [],
"//conditions:default": [
"--pedantic-errors",
```
If anyone has a better idea how to append a COPT to a downstream Bazel
project, I would be happy to learn from you.
Motiejus
[1]: https://github.com/ziglang/zig/pull/10312/
[2]: https://git.sr.ht/~motiejus/bazel-zig-cc/commit/985e26b474fb7594bb385ce9382def7c95373ca9
[3]: https://github.com/ziglang/zig/issues/4830#issuecomment-605491606
[4]: https://github.com/google/brotli/blob/ce222e317e36aa362e83fc50c7a6226d238e03fd/CMakeLists.txt#L104-L108
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172])
by mail-b.sr.ht (Postfix) with ESMTPS id 8F7BE11EFCB
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Wed, 15 Dec 2021 13:13:09 +0000 (UTC)
Received: by mail-lj1-f172.google.com with SMTP id z8so33239469ljz.9
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Wed, 15 Dec 2021 05:13:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:subject:message-id:mime-version
:content-disposition;
bh=Nd/WltjseH/65+GIHu93VIGVBFJcCg0jRhztUcKW+SU=;
b=YifS23k0ae73nB9jZrmpDfVWyVtYzoJdrWXc+5MNan5dueiYI+Pmjnkg9jxIEOwcnL
+VQHmcJ/Y9M6AdNgdKZwndRPHH0Czcw5mAcY0TeM47/bsU3T430BePLSIS5/O6p6JX/2
Hwxm8E9j6Z7zWCGPQZaZp+rFNsF2Zu9O26JiTRJQUhLsUysQG6FZknoPtpfX3BeZ+yoM
v2LcX8luagONzI+/x3P45oLzYKCDigtt18ZB3KRPNEshaf5dmN8RStVg1IDrw1FjUtRT
oL9zGkok8U8knDDek8p7lhB3MRboeGt594Ne5yQY/fbAJ2/X+Z1+xj7B4K6RRPlnHRXO
OAUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:subject:message-id
:mime-version:content-disposition;
bh=Nd/WltjseH/65+GIHu93VIGVBFJcCg0jRhztUcKW+SU=;
b=pf8ogSdB1vOvUEquKYzJlAQtWpqT33q/Bg6qFpxtPUo1WjfP9wQr2AaOrjf5vw6aop
xEwyTnjTlepxIE+vzRGJia9BFnl1521dGEJQEs3U1+oUsuBbVRakm8nHmW/nxOXuMJAY
5ZO5wINNUWWAXNCoqAt9IL+AwhgnPu2ywTUtB7U+lSp04UuiykNScGtuZJ2RUx5P+0aj
Fe0POq1r5B4A7Jd7CqsD1ScZryljzSpljtqAUoDyofvfGG9IThOIGh2/7CWvFFgJW8Ad
ZSHXjUYfzwt/y3MJLaJplBF5rsFzROStOsSGLx30sltzXSmCrrJYG1LtXuAIm5rgj1SJ
6rrw==
X-Gm-Message-State: AOAM533R97q6G/KfXwqKpV2oIKXGZVFqUK4F6MiTLkJRDOtDFFszGnUt
aYBdph3HB+26HO13BPLB93gvtQqpLtc=
X-Google-Smtp-Source: ABdhPJx3uV4VjLPjCmWnmHQG63N7zAf+Y2l6UqhNBFLQzu4Z0QoQypdM5i/S04/3RQt/gC2gd7mUZw==
X-Received: by 2002:a2e:7305:: with SMTP id o5mr10152834ljc.180.1639573987957;
Wed, 15 Dec 2021 05:13:07 -0800 (PST)
Received: from localhost ([88.223.105.24])
by smtp.gmail.com with ESMTPSA id o24sm316972lfr.117.2021.12.15.05.13.07
for <~motiejus/bazel-zig-cc@lists.sr.ht>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 15 Dec 2021 05:13:07 -0800 (PST)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Wed, 15 Dec 2021 15:13:06 +0200
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: ~motiejus/bazel-zig-cc@lists.sr.ht
Subject: bazel-zig-cc v0.4.0-rc2
Message-ID: <20211215131306.toz7czanzdhhukbe@mtpad.i.jakstys.lt>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Hi folks,
I released v0.4.0-rc2, this time only upgrading zig to
0.9.0-dev.1968+ff93486d0 (from 1950). Two notable changes with regards
to `zig cc`:
- [darwin] zig cc will now fail hard if `-framework` is specified, but
not found. It used to produce a strange-looking, likely-unworkable
binary.
- glibc stubs are fixed[2]. I have been waiting for this for a long
time. More on this in HN[3].
These resolve the last known high-severity issues. Thanks zig team! As I
am not expecting any final-day fixes in zig itself, there likely won't
be an rc3. A few weeks after 0.9.0 is released, I am planning to remove
the dev versions from my mirror[4].
Tip of the day
--------------
This is helpful in `.bazelrc`:
build --compilation_mode=opt
This makes non-tests to be compiled with -O2. Tests will be compiled
without optimizations, making compilation faster, and retaining
UBSAN[5].
Open questions
--------------
The question from last week[6] still holds: how to adjust CFLAGS for an
external Bazel project?
Motiejus
[1]: https://github.com/ziglang/zig/pull/10312
[2]: https://github.com/ziglang/zig/pull/10330
[3]: https://news.ycombinator.com/item?id=29538264
[4]: https://dl.jakstys.lt/zig/
[5]: https://github.com/ziglang/zig/issues/4830#issuecomment-605491606
[6]: https://lists.sr.ht/~motiejus/bazel-zig-cc/%3C20211213023816.obgjrpaxt445lzpn%40mtpad.i.jakstys.lt%3E
From MAILER-DAEMON Mon Apr 24 14:05:40 2023
Authentication-Results: mail-b.sr.ht; dkim=pass header.d=gmail.com header.i=@gmail.com
Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177])
by mail-b.sr.ht (Postfix) with ESMTPS id E229D11EF12
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Mon, 27 Dec 2021 08:41:55 +0000 (UTC)
Received: by mail-lj1-f177.google.com with SMTP id i11so12257671ljm.13
for <~motiejus/bazel-zig-cc@lists.sr.ht>; Mon, 27 Dec 2021 00:41:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20210112;
h=sender:date:from:to:subject:message-id:mime-version
:content-disposition;
bh=wbwsWNmX9ACiddCLR8HrD69hw93GH+pGJxzcr23R6rM=;
b=dJQmTKPHoBlHHAkyWNFHks9q1bXMAkrYrZl5scATSk3Njq3uDtNg6ZePXJE2E52O8j
5t3SLmKPiCE4cljIPqMwljlWHrKZZJ3kc4a6cnGGGdXhOV53CHBYg/ox7Ck8f06/v6Ja
Rnw3hk5ExzZdfNIpieCztf5pAczKs+EJ83cxoJOR0KvGdof0gWsOop2M59eFpIEDuBzn
wlgxkVdd3zwmO2lOS7QUwosUkIbOyZkqY7JooI6WvL6GNcxeZdzGZrGy79F2oy1Y9cNc
pxAU1lr/REJg05oAR2T4pnRE5CKu2IEcxQhrj93Ev6xMxsvoNBl+1lPBGRoQjN0mH53i
bD1w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=x-gm-message-state:sender:date:from:to:subject:message-id
:mime-version:content-disposition;
bh=wbwsWNmX9ACiddCLR8HrD69hw93GH+pGJxzcr23R6rM=;
b=0a0GA3vwn7I9H5bZ+7j9JKANjBci6Cy6bVy2w2CwnWwTaa7DFuQtq3WPn1ew623EN3
0MOuhwhGNKATpe2xicuCNX0bGAYcdELucvNqCRgtJmCCemuvpNhft+iqNFqbikUU104R
MXZJ4umCMwL7q9qFSHFZ2ss7yzsOpPipUsEx8vUfzbWDK+t/C0k8TbqPYu9J5GxTM0Ij
pykyVmYm1dZgTnZ2/MnnTupfSVB0lyT1IVCaKlcShPKNoZBMVVoGlSPC9OcwrxvFmCyO
/1VVlw3/SSvaDsubVmRRLygqLzc2g+u4u4qvhgFm6jIwycYgUMQmftvWCpg+byXQi1w2
+YIw==
X-Gm-Message-State: AOAM53232Y6heOR1VRU9KAEewm/STKfMJjfFhmrKpvp33SRSRIjhReRT
MzLK1b9lTWFqiutkuzy6t/tEP8Xd2Nw=
X-Google-Smtp-Source: ABdhPJx6ysrzoYMTFmAldsjWAd2AmWOnspuGaPYDfO1NywR7rTlaoEe1V3yyloNzmWWczgMgR9EN1A==
X-Received: by 2002:a05:651c:12c3:: with SMTP id 3mr13364719lje.311.1640594514193;
Mon, 27 Dec 2021 00:41:54 -0800 (PST)
Received: from localhost ([88.223.105.24])
by smtp.gmail.com with ESMTPSA id z17sm1581748lfu.128.2021.12.27.00.41.53
for <~motiejus/bazel-zig-cc@lists.sr.ht>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 27 Dec 2021 00:41:53 -0800 (PST)
Sender: =?UTF-8?Q?Motiejus_Jak=C5=A1tys?= <desired.mta@gmail.com>
Date: Mon, 27 Dec 2021 10:41:52 +0200
From: Motiejus =?utf-8?Q?Jak=C5=A1tys?= <motiejus@jakstys.lt>
To: ~motiejus/bazel-zig-cc@lists.sr.ht
Subject: upcoming bazel-zig-cc 0.4.0
Message-ID: <20211227084152.mjkx33nbxhnls5qz@mtpad.i.jakstys.lt>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Hi folks,
I cannot yet release bazel-zig-cc 0.4.0, because there is a regression
in `zig c++`; you may follow along here[1].
I am happy bazel-zig-cc CI caught this[2]; this regression was quite
easy to trigger.
I accidentally pushed 0.4.0 a few days ago, but promptly deleted the
tag. If you managed to catch 0.4.0 (it was there for <1 hour), please
remove the tag. My mistake, I will try harder not to do this again.
Note that this affects only glibc targets; I am successfully using zig
0.9.0 with a musl target (0.4.0-rc2 with a custom zig version).
Regards,
Motiejus
[1]: https://github.com/ziglang/zig/issues/10386
[2]: https://builds.sr.ht/~motiejus/job/654617