forked from uber/hermetic_cc_toolchain
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailing-list-archive.mbox
17040 lines (15645 loc) · 744 KB
/
mailing-list-archive.mbox
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From MAILER-DAEMON Wed Mar 8 11:59:03 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
Status: RO
Content-Length: 4092
Lines: 104
+ ~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 Wed Mar 8 11:59:03 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"
Status: RO
Content-Length: 964
Lines: 24
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 Wed Mar 8 11:59:03 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>
Status: O
Content-Length: 891
Lines: 21
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 Wed Mar 8 11:59:03 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
Status: O
Content-Length: 3856
Lines: 124
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 Wed Mar 8 11:59:03 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
Status: O
Content-Length: 3822
Lines: 123
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 Wed Mar 8 11:59:03 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>
Status: O
Content-Length: 808
Lines: 20
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 Wed Mar 8 11:59:03 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>
Status: O
Content-Length: 1502
Lines: 36
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 Wed Mar 8 11:59:03 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
Status: O
Content-Length: 1921
Lines: 46
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 Wed Mar 8 11:59:03 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
Status: O
Content-Length: 2091
Lines: 63
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 Wed Mar 8 11:59:03 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