authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-22 15:09:29-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-03-22 15:09:29-04:00
log23c263776c448a7ffc7e03d1b8528a4b5761f289
treeae5e59800427ce54ba36f0ef1ece96d36131eaf9
parent53b5aa812bd9c0229054121a1c196c9b18994d64
parenta8fa1ecd89eebd444736d73da4ebf24af74daea8
signaturelock-open Commit is signed but in an unrecognized format.

Merge remote-tracking branch 'origin/master' into llvm10


29 files changed, 459 insertions(+), 93 deletions(-)

CMakeLists.txt-1
...@@ -430,7 +430,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"...@@ -430,7 +430,6 @@ set(BUILD_LIBSTAGE2_ARGS "build-lib"
430 --cache on430 --cache on
431 --output-dir "${CMAKE_BINARY_DIR}"431 --output-dir "${CMAKE_BINARY_DIR}"
432 ${LIBSTAGE2_RELEASE_ARG}432 ${LIBSTAGE2_RELEASE_ARG}
433 --disable-gen-h
434 --bundle-compiler-rt433 --bundle-compiler-rt
435 -fPIC434 -fPIC
436 -lc435 -lc
build.zig+2-1
...@@ -135,7 +135,8 @@ pub fn build(b: *Builder) !void {...@@ -135,7 +135,8 @@ pub fn build(b: *Builder) !void {
135 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));135 test_step.dependOn(tests.addRuntimeSafetyTests(b, test_filter, modes));
136 test_step.dependOn(tests.addTranslateCTests(b, test_filter));136 test_step.dependOn(tests.addTranslateCTests(b, test_filter));
137 test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter));137 test_step.dependOn(tests.addRunTranslatedCTests(b, test_filter));
138 test_step.dependOn(tests.addGenHTests(b, test_filter));138 // tests for this feature are disabled until we have the self-hosted compiler available
139 //test_step.dependOn(tests.addGenHTests(b, test_filter));
139 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));140 test_step.dependOn(tests.addCompileErrorTests(b, test_filter, modes));
140 test_step.dependOn(docs_step);141 test_step.dependOn(docs_step);
141}142}
ci/drone/linux_script+2-1
...@@ -26,7 +26,8 @@ make -j$(nproc) install...@@ -26,7 +26,8 @@ make -j$(nproc) install
26# TODO test-cli is hitting https://github.com/ziglang/zig/issues/352626# TODO test-cli is hitting https://github.com/ziglang/zig/issues/3526
27./zig build test-asm-link test-runtime-safety27./zig build test-asm-link test-runtime-safety
28# TODO test-translate-c is hitting https://github.com/ziglang/zig/issues/352628# TODO test-translate-c is hitting https://github.com/ziglang/zig/issues/3526
29./zig build test-gen-h29# TODO disabled until we are shipping self-hosted
30#./zig build test-gen-h
30# TODO test-compile-errors is hitting https://github.com/ziglang/zig/issues/352631# TODO test-compile-errors is hitting https://github.com/ziglang/zig/issues/3526
31# TODO building docs is hitting https://github.com/ziglang/zig/issues/352632# TODO building docs is hitting https://github.com/ziglang/zig/issues/3526
3233
ci/srht/freebsd_script+2-1
...@@ -42,7 +42,8 @@ release/bin/zig build test-asm-link...@@ -42,7 +42,8 @@ release/bin/zig build test-asm-link
42release/bin/zig build test-runtime-safety42release/bin/zig build test-runtime-safety
43release/bin/zig build test-translate-c43release/bin/zig build test-translate-c
44release/bin/zig build test-run-translated-c44release/bin/zig build test-run-translated-c
45release/bin/zig build test-gen-h45# TODO disabled until we are shipping self-hosted
46#release/bin/zig build test-gen-h
46release/bin/zig build test-compile-errors47release/bin/zig build test-compile-errors
47release/bin/zig build docs48release/bin/zig build docs
4849
lib/libc/glibc/abi.txt+135
...@@ -193,6 +193,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -193,6 +193,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
193193
194194
1952919529
196
1962919729
197198
1982919929
...@@ -514,6 +515,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -514,6 +515,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
5142951529
5152951629
5162951729
51829
517519
5182952029
519521
...@@ -697,6 +699,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -697,6 +699,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
6972969929
6982970029
6992970129
702
7002970329
7012970429
7022970529
...@@ -819,6 +822,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -819,6 +822,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
8192982229
8202982329
8212982429
82529
822826
8232982729
8242982829
...@@ -904,6 +908,9 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -904,6 +908,9 @@ aarch64-linux-gnu aarch64_be-linux-gnu
9042990829
9052990929
9062991029
91129
912
913
9072991429
9082991529
9092991629
...@@ -1004,6 +1011,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -1004,6 +1011,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
100429101129
100529101229
100629101329
101429
10071015
100829101629
100929101729
...@@ -1033,6 +1041,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu...@@ -1033,6 +1041,7 @@ aarch64-linux-gnu aarch64_be-linux-gnu
103329104129
103429104229
103529104329
104429
10361045
103729104629
103829104729
...@@ -3920,6 +3929,7 @@ s390x-linux-gnu...@@ -3920,6 +3929,7 @@ s390x-linux-gnu
39203929
39213930
3922539315
3932
392327393327
39243934
392527393527
...@@ -4241,6 +4251,7 @@ s390x-linux-gnu...@@ -4241,6 +4251,7 @@ s390x-linux-gnu
4241542515
4242542525
4243542535
42545
424411425511
424527425627
42464257
...@@ -4424,6 +4435,7 @@ s390x-linux-gnu...@@ -4424,6 +4435,7 @@ s390x-linux-gnu
442419443519
442519443619
4426544375
4438
4427544395
4428544405
442928444128
...@@ -4543,6 +4555,7 @@ s390x-linux-gnu...@@ -4543,6 +4555,7 @@ s390x-linux-gnu
454327455527
45444556
454516455716
4558
4546545595
4547545605
454815456115
...@@ -4631,6 +4644,9 @@ s390x-linux-gnu...@@ -4631,6 +4644,9 @@ s390x-linux-gnu
463116464416
4632546455
4633546465
4647
4648
464912
4634546505
4635546515
4636546525
...@@ -4731,6 +4747,7 @@ s390x-linux-gnu...@@ -4731,6 +4747,7 @@ s390x-linux-gnu
4731547475
4732547485
4733547495
47505
47344751
4735547525
4736547535
...@@ -4756,6 +4773,7 @@ s390x-linux-gnu...@@ -4756,6 +4773,7 @@ s390x-linux-gnu
4756547735
4757547745
4758547755
47765
475931 5477731 5
476024 5 12 16477824 5 12 16
476124 5 12 16477924 5 12 16
...@@ -7645,6 +7663,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -7645,6 +7663,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
76457663
76467664
76477665
7666
76487667
76497668
765027766927
...@@ -7968,6 +7987,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -7968,6 +7987,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
796816798716
796916798816
797016798916
799016
79717991
797227799227
79737993
...@@ -8151,6 +8171,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -8151,6 +8171,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
815119817119
815219817219
815316817316
8174
815416817516
815516817616
815628817728
...@@ -8273,6 +8294,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -8273,6 +8294,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
827316829416
827416829516
827516829616
829716
82768298
827716829916
827816830016
...@@ -8358,6 +8380,9 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -8358,6 +8380,9 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
835816838016
835916838116
836016838216
838316
8384
8385
836116838616
836216838716
836316838816
...@@ -8458,6 +8483,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -8458,6 +8483,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
845816848316
845916848416
846016848516
848616
84618487
846216848816
846316848916
...@@ -8484,6 +8510,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf...@@ -8484,6 +8510,7 @@ arm-linux-gnueabi armeb-linux-gnueabi arm-linux-gnueabihf armeb-linux-gnueabihf
848416851016
848516851116
848616851216
851316
848724 16851424 16
848824 16851524 16
848916851616
...@@ -11374,6 +11401,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11374,6 +11401,7 @@ sparc-linux-gnu sparcel-linux-gnu
1137411401
1137511402
113760114030
11404
11377271140527
1137811406
11379271140727
...@@ -11693,6 +11721,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11693,6 +11721,7 @@ sparc-linux-gnu sparcel-linux-gnu
116930117210
116940117220
116951117231
117241
116960117250
116970117260
116983 11117273 11
...@@ -11878,6 +11907,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11878,6 +11907,7 @@ sparc-linux-gnu sparcel-linux-gnu
11878191190719
11879191190819
118800119090
11910
118810119110
118821119121
11883281191328
...@@ -11997,6 +12027,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -11997,6 +12027,7 @@ sparc-linux-gnu sparcel-linux-gnu
11997331202733
1199812028
11999161202916
12030
120005120315
120010120320
12002151203315
...@@ -12085,6 +12116,9 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -12085,6 +12116,9 @@ sparc-linux-gnu sparcel-linux-gnu
12085161211616
120860121170
120870121180
1211912
12120
12121
120881121221
120891121231
120901121241
...@@ -12183,6 +12217,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -12183,6 +12217,7 @@ sparc-linux-gnu sparcel-linux-gnu
121831122171
121841122181
121851122191
122201
121860122210
121870122220
1218812223
...@@ -12207,6 +12242,7 @@ sparc-linux-gnu sparcel-linux-gnu...@@ -12207,6 +12242,7 @@ sparc-linux-gnu sparcel-linux-gnu
122070122420
122080122430
122090122440
122450
122105122465
122110122470
122120122480
...@@ -15101,6 +15137,7 @@ sparcv9-linux-gnu...@@ -15101,6 +15137,7 @@ sparcv9-linux-gnu
151015151375
151025151385
1510315139
15140
15104271514127
1510515142
15106271514327
...@@ -15422,6 +15459,7 @@ sparcv9-linux-gnu...@@ -15422,6 +15459,7 @@ sparcv9-linux-gnu
154225154595
154235154605
154245154615
154625
15425111546311
15426271546427
1542715465
...@@ -15605,6 +15643,7 @@ sparcv9-linux-gnu...@@ -15605,6 +15643,7 @@ sparcv9-linux-gnu
15605191564319
15606191564419
156075156455
15646
156085156475
156095156485
15610281564928
...@@ -15724,6 +15763,7 @@ sparcv9-linux-gnu...@@ -15724,6 +15763,7 @@ sparcv9-linux-gnu
15724271576327
1572515764
15726161576516
15766
157275157675
157285157685
15729151576915
...@@ -15812,6 +15852,9 @@ sparcv9-linux-gnu...@@ -15812,6 +15852,9 @@ sparcv9-linux-gnu
15812161585216
158135158535
158145158545
1585512
15856
15857
158155158585
158165158595
158175158605
...@@ -15912,6 +15955,7 @@ sparcv9-linux-gnu...@@ -15912,6 +15955,7 @@ sparcv9-linux-gnu
159125159555
159135159565
159145159575
159585
1591515959
159165159605
159175159615
...@@ -15938,6 +15982,7 @@ sparcv9-linux-gnu...@@ -15938,6 +15982,7 @@ sparcv9-linux-gnu
159385159825
159395159835
159405159845
159855
1594124 28 5 12 161598624 28 5 12 16
1594224 28 5 12 161598724 28 5 12 16
159435 14159885 14
...@@ -18828,6 +18873,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -18828,6 +18873,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
1882818873
1882918874
188300188750
18876
18831271887727
1883218878
18833271887927
...@@ -19147,6 +19193,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19147,6 +19193,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
191470191930
191480191940
191495191955
191965
191500191970
191510191980
19152111919911
...@@ -19332,6 +19379,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19332,6 +19379,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
19332191937919
19333191938019
193340193810
19382
193350193830
193365193845
19337281938528
...@@ -19450,6 +19498,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19450,6 +19498,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
19450271949827
19451271949927
1945219500
1950116
19453161950216
194545195035
194550195040
...@@ -19539,6 +19588,9 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19539,6 +19588,9 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
19539161958816
195400195890
195410195900
1959112
19592
19593
195425195945
195435195955
195445195965
...@@ -19637,6 +19689,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19637,6 +19689,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
196375196895
196385196905
196395196915
196925
196400196930
196410196940
196420196950
...@@ -19661,6 +19714,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64...@@ -19661,6 +19714,7 @@ mips64el-linux-gnuabi64 mips64-linux-gnuabi64
196610197140
196620197150
196630197160
197170
196645197185
196650197190
196660197200
...@@ -22555,6 +22609,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -22555,6 +22609,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
2255522609
2255622610
225570226110
22612
22558272261327
2255922614
22560272261527
...@@ -22874,6 +22929,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -22874,6 +22929,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
228740229290
228750229300
228765229315
229325
228770229330
228780229340
22879112293511
...@@ -23059,6 +23115,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -23059,6 +23115,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
23059192311519
23060192311619
230610231170
23118
230620231190
230635231205
23064282312128
...@@ -23177,6 +23234,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -23177,6 +23234,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
23177272323427
23178272323527
2317923236
2323716
23180162323816
231815232395
231820232400
...@@ -23266,6 +23324,9 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -23266,6 +23324,9 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
23266162332416
232670233250
232680233260
2332712
23328
23329
232695233305
232705233315
232715233325
...@@ -23364,6 +23425,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -23364,6 +23425,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
233645234255
233655234265
233665234275
234285
233670234290
233680234300
233690234310
...@@ -23388,6 +23450,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32...@@ -23388,6 +23450,7 @@ mips64el-linux-gnuabin32 mips64-linux-gnuabin32
233880234500
233890234510
233900234520
234530
233915234545
233920234550
233930234560
...@@ -26282,6 +26345,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26282,6 +26345,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
2628226345
2628326346
262840263470
26348
26285272634927
2628626350
26287272635127
...@@ -26601,6 +26665,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26601,6 +26665,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
266010266650
266020266660
266035266675
266685
266040266690
266050266700
26606112667111
...@@ -26786,6 +26851,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26786,6 +26851,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
26786192685119
26787192685219
267880268530
26854
267890268550
267905268565
26791282685728
...@@ -26904,6 +26970,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26904,6 +26970,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
26904272697027
2690526971
2690626972
2697316
26907162697416
269085269755
269090269760
...@@ -26993,6 +27060,9 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -26993,6 +27060,9 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
26993162706016
269940270610
269950270620
2706312
27064
27065
269965270665
269975270675
269985270685
...@@ -27091,6 +27161,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -27091,6 +27161,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
270915271615
270925271625
270935271635
271645
270940271650
270950271660
270960271670
...@@ -27115,6 +27186,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf...@@ -27115,6 +27186,7 @@ mipsel-linux-gnueabihf mips-linux-gnueabihf
271150271860
271160271870
271170271880
271890
271185271905
271190271910
271200271920
...@@ -30009,6 +30081,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30009,6 +30081,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
3000930081
3001030082
300110300830
30084
30012273008527
3001330086
30014273008727
...@@ -30328,6 +30401,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30328,6 +30401,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
303280304010
303290304020
303305304035
304045
303310304050
303320304060
30333113040711
...@@ -30513,6 +30587,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30513,6 +30587,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
30513193058719
30514193058819
305150305890
30590
305160305910
305175305925
30518283059328
...@@ -30631,6 +30706,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30631,6 +30706,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
30631273070627
3063230707
3063330708
3070916
30634163071016
306355307115
306360307120
...@@ -30720,6 +30796,9 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30720,6 +30796,9 @@ mipsel-linux-gnueabi mips-linux-gnueabi
30720163079616
307210307970
307220307980
3079912
30800
30801
307235308025
307245308035
307255308045
...@@ -30818,6 +30897,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30818,6 +30897,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
308185308975
308195308985
308205308995
309005
308210309010
308220309020
308230309030
...@@ -30842,6 +30922,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi...@@ -30842,6 +30922,7 @@ mipsel-linux-gnueabi mips-linux-gnueabi
308420309220
308430309230
308440309240
309250
308455309265
308460309270
308470309280
...@@ -33734,6 +33815,7 @@ x86_64-linux-gnu...@@ -33734,6 +33815,7 @@ x86_64-linux-gnu
3373433815
3373533816
3373633817
33818
3373733819
3373833820
33739273382127
...@@ -34057,6 +34139,7 @@ x86_64-linux-gnu...@@ -34057,6 +34139,7 @@ x86_64-linux-gnu
34057103413910
34058103414010
34059103414110
3414210
34060113414311
34061273414427
34062363414536
...@@ -34240,6 +34323,7 @@ x86_64-linux-gnu...@@ -34240,6 +34323,7 @@ x86_64-linux-gnu
34240193432319
34241193432419
34242103432510
34326
34243103432710
34244103432810
34245283432928
...@@ -34359,6 +34443,7 @@ x86_64-linux-gnu...@@ -34359,6 +34443,7 @@ x86_64-linux-gnu
34359273444327
3436034444
34361163444516
34446
34362103444710
34363103444810
34364153444915
...@@ -34447,6 +34532,9 @@ x86_64-linux-gnu...@@ -34447,6 +34532,9 @@ x86_64-linux-gnu
34447163453216
34448103453310
34449103453410
3453512
34536
34537
34450103453810
34451103453910
34452103454010
...@@ -34547,6 +34635,7 @@ x86_64-linux-gnu...@@ -34547,6 +34635,7 @@ x86_64-linux-gnu
34547103463510
34548103463610
34549103463710
3463810
3455034639
34551103464010
34552103464110
...@@ -34573,6 +34662,7 @@ x86_64-linux-gnu...@@ -34573,6 +34662,7 @@ x86_64-linux-gnu
34573103466210
34574103466310
34575103466410
3466510
3457624 10 12 163466624 10 12 16
3457724 10 12 163466724 10 12 16
3457810 143466810 14
...@@ -37461,6 +37551,7 @@ x86_64-linux-gnux32...@@ -37461,6 +37551,7 @@ x86_64-linux-gnux32
3746137551
3746237552
3746337553
37554
3746437555
3746537556
37466283755728
...@@ -37784,6 +37875,7 @@ x86_64-linux-gnux32...@@ -37784,6 +37875,7 @@ x86_64-linux-gnux32
37784283787528
37785283787628
37786283787728
3787828
3778737879
37788283788028
37789363788136
...@@ -37967,6 +38059,7 @@ x86_64-linux-gnux32...@@ -37967,6 +38059,7 @@ x86_64-linux-gnux32
37967283805928
37968283806028
37969283806128
38062
37970283806328
37971283806428
37972283806528
...@@ -38086,6 +38179,7 @@ x86_64-linux-gnux32...@@ -38086,6 +38179,7 @@ x86_64-linux-gnux32
38086283817928
3808738180
38088283818128
38182
38089283818328
38090283818428
38091283818528
...@@ -38174,6 +38268,9 @@ x86_64-linux-gnux32...@@ -38174,6 +38268,9 @@ x86_64-linux-gnux32
38174283826828
38175283826928
38176283827028
3827128
38272
38273
38177283827428
38178283827528
38179283827628
...@@ -38274,6 +38371,7 @@ x86_64-linux-gnux32...@@ -38274,6 +38371,7 @@ x86_64-linux-gnux32
38274283837128
38275283837228
38276283837328
3837428
3827738375
38278283837628
38279283837728
...@@ -38303,6 +38401,7 @@ x86_64-linux-gnux32...@@ -38303,6 +38401,7 @@ x86_64-linux-gnux32
38303283840128
38304283840228
38305283840328
3840428
3830638405
38307283840628
38308283840728
...@@ -41190,6 +41289,7 @@ i386-linux-gnu...@@ -41190,6 +41289,7 @@ i386-linux-gnu
4119041289
4119141290
411920412910
4129212
41193274129327
41194364129436
41195274129527
...@@ -41509,6 +41609,7 @@ i386-linux-gnu...@@ -41509,6 +41609,7 @@ i386-linux-gnu
415090416090
415100416100
415111416111
416121
415120416130
415130416140
415143 11416153 11
...@@ -41694,6 +41795,7 @@ i386-linux-gnu...@@ -41694,6 +41795,7 @@ i386-linux-gnu
41694194179519
41695194179619
416960417970
41798
416970417990
416981418001
41699284180128
...@@ -41813,6 +41915,7 @@ i386-linux-gnu...@@ -41813,6 +41915,7 @@ i386-linux-gnu
41813274191527
4181441916
41815164191716
41918
418165419195
418170419200
41818154192115
...@@ -41901,6 +42004,9 @@ i386-linux-gnu...@@ -41901,6 +42004,9 @@ i386-linux-gnu
41901164200416
419020420050
419030420060
4200712
42008
42009
419041420101
419051420111
419061420121
...@@ -41999,6 +42105,7 @@ i386-linux-gnu...@@ -41999,6 +42105,7 @@ i386-linux-gnu
419991421051
420001421061
420011421071
421081
420020421090
420030421100
4200442111
...@@ -42023,6 +42130,7 @@ i386-linux-gnu...@@ -42023,6 +42130,7 @@ i386-linux-gnu
420230421300
420240421310
420250421320
421330
420265421345
420270421350
420280421360
...@@ -44915,6 +45023,7 @@ powerpc64le-linux-gnu...@@ -44915,6 +45023,7 @@ powerpc64le-linux-gnu
4491545023
4491645024
4491745025
45026
4491845027
4491945028
44920294502929
...@@ -45238,6 +45347,7 @@ powerpc64le-linux-gnu...@@ -45238,6 +45347,7 @@ powerpc64le-linux-gnu
45238294534729
45239294534829
45240294534929
4535029
4524145351
45242294535229
45243364535336
...@@ -45421,6 +45531,7 @@ powerpc64le-linux-gnu...@@ -45421,6 +45531,7 @@ powerpc64le-linux-gnu
45421294553129
45422294553229
45423294553329
4553433
45424294553529
45425294553629
45426294553729
...@@ -45540,6 +45651,7 @@ powerpc64le-linux-gnu...@@ -45540,6 +45651,7 @@ powerpc64le-linux-gnu
45540294565129
4554145652
45542294565329
45654
45543294565529
45544294565629
45545294565729
...@@ -45628,6 +45740,9 @@ powerpc64le-linux-gnu...@@ -45628,6 +45740,9 @@ powerpc64le-linux-gnu
45628294574029
45629294574129
45630294574229
4574329
4574432
45745
45631294574629
45632294574729
45633294574829
...@@ -45728,6 +45843,7 @@ powerpc64le-linux-gnu...@@ -45728,6 +45843,7 @@ powerpc64le-linux-gnu
45728294584329
45729294584429
45730294584529
4584629
4573145847
45732294584829
45733294584929
...@@ -45757,6 +45873,7 @@ powerpc64le-linux-gnu...@@ -45757,6 +45873,7 @@ powerpc64le-linux-gnu
45757294587329
45758294587429
45759294587529
4587629
4576045877
45761294587829
45762294587929
...@@ -48642,6 +48759,7 @@ powerpc64-linux-gnu...@@ -48642,6 +48759,7 @@ powerpc64-linux-gnu
4864248759
4864348760
4864448761
48762
4864548763
4864648764
48647274876527
...@@ -48965,6 +49083,7 @@ powerpc64-linux-gnu...@@ -48965,6 +49083,7 @@ powerpc64-linux-gnu
48965124908312
48966124908412
48967124908512
4908612
4896849087
48969274908827
4897049089
...@@ -49148,6 +49267,7 @@ powerpc64-linux-gnu...@@ -49148,6 +49267,7 @@ powerpc64-linux-gnu
49148194926719
49149194926819
49150124926912
4927033
49151124927112
49152124927212
49153284927328
...@@ -49267,6 +49387,7 @@ powerpc64-linux-gnu...@@ -49267,6 +49387,7 @@ powerpc64-linux-gnu
49267274938727
4926849388
49269164938916
49390
49270124939112
49271124939212
49272154939315
...@@ -49355,6 +49476,9 @@ powerpc64-linux-gnu...@@ -49355,6 +49476,9 @@ powerpc64-linux-gnu
49355164947616
49356124947712
49357124947812
4947912
4948032
49481
49358124948212
49359124948312
49360124948412
...@@ -49455,6 +49579,7 @@ powerpc64-linux-gnu...@@ -49455,6 +49579,7 @@ powerpc64-linux-gnu
49455124957912
49456124958012
49457124958112
4958212
4945849583
49459124958412
49460124958512
...@@ -49480,6 +49605,7 @@ powerpc64-linux-gnu...@@ -49480,6 +49605,7 @@ powerpc64-linux-gnu
49480124960512
49481124960612
49482124960712
4960812
4948312 154960912 15
4948424 12 164961024 12 16
4948524 12 164961124 12 16
...@@ -52369,6 +52495,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52369,6 +52495,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
5236952495
5237052496
5237152497
52498
5237252499
5237352500
52374275250127
...@@ -52690,6 +52817,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52690,6 +52817,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
526900528170
526910528180
526921528191
528201
526930528210
526940528220
526953 11528233 11
...@@ -52875,6 +53003,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52875,6 +53003,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
52875195300319
52876195300419
528770530050
5300633
528780530070
528791530081
52880285300928
...@@ -52994,6 +53123,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -52994,6 +53123,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
52994275312327
52995135312413
52996165312516
53126
529975531275
529980531280
52999155312915
...@@ -53082,6 +53212,9 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -53082,6 +53212,9 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
53082165321216
530830532130
530840532140
5321512
5321632
53217
530851532181
530861532191
530871532201
...@@ -53180,6 +53313,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -53180,6 +53313,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
531801533131
531811533141
531821533151
533161
531830533170
531840533180
5318553319
...@@ -53204,6 +53338,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf...@@ -53204,6 +53338,7 @@ powerpc-linux-gnueabi powerpc-linux-gnueabihf
532040533380
532050533390
532060533400
533410
532075533425
532080533430
532090533440
lib/libc/glibc/fns.txt+9
...@@ -192,6 +192,7 @@ _Qp_uitoq c...@@ -192,6 +192,7 @@ _Qp_uitoq c
192_Qp_uxtoq c192_Qp_uxtoq c
193_Qp_xtoq c193_Qp_xtoq c
194___brk_addr c194___brk_addr c
195___tls_get_addr ld
195__acos_finite m196__acos_finite m
196__acosf128_finite m197__acosf128_finite m
197__acosf_finite m198__acosf_finite m
...@@ -511,6 +512,7 @@ __libc_memalign c...@@ -511,6 +512,7 @@ __libc_memalign c
511__libc_pvalloc c512__libc_pvalloc c
512__libc_realloc c513__libc_realloc c
513__libc_sa_len c514__libc_sa_len c
515__libc_stack_end ld
514__libc_start_main c516__libc_start_main c
515__libc_valloc c517__libc_valloc c
516__libpthread_version_placeholder pthread518__libpthread_version_placeholder pthread
...@@ -696,6 +698,7 @@ __open_2 c...@@ -696,6 +698,7 @@ __open_2 c
696__openat64_2 c698__openat64_2 c
697__openat_2 c699__openat_2 c
698__overflow c700__overflow c
701__parse_hwcap_and_convert_at_platform ld
699__pipe c702__pipe c
700__poll c703__poll c
701__poll_chk c704__poll_chk c
...@@ -815,6 +818,7 @@ __sqrtf_finite m...@@ -815,6 +818,7 @@ __sqrtf_finite m
815__sqrtl_finite m818__sqrtl_finite m
816__sqrtsf2 c819__sqrtsf2 c
817__stack_chk_fail c820__stack_chk_fail c
821__stack_chk_guard ld
818__statfs c822__statfs c
819__stpcpy c823__stpcpy c
820__stpcpy_chk c824__stpcpy_chk c
...@@ -903,6 +907,9 @@ __sysctl c...@@ -903,6 +907,9 @@ __sysctl c
903__syslog_chk c907__syslog_chk c
904__sysv_signal c908__sysv_signal c
905__timezone c909__timezone c
910__tls_get_addr ld
911__tls_get_addr_opt ld
912__tls_get_offset ld
906__toascii_l c913__toascii_l c
907__tolower_l c914__tolower_l c
908__toupper_l c915__toupper_l c
...@@ -999,6 +1006,7 @@ __ynf128_finite m...@@ -999,6 +1006,7 @@ __ynf128_finite m
999__ynf_finite m1006__ynf_finite m
1000__ynl_finite m1007__ynl_finite m
1001_authenticate c1008_authenticate c
1009_dl_mcount ld
1002_dl_mcount_wrapper c1010_dl_mcount_wrapper c
1003_dl_mcount_wrapper_check c1011_dl_mcount_wrapper_check c
1004_environ c1012_environ c
...@@ -1024,6 +1032,7 @@ _pthread_cleanup_pop pthread...@@ -1024,6 +1032,7 @@ _pthread_cleanup_pop pthread
1024_pthread_cleanup_pop_restore pthread1032_pthread_cleanup_pop_restore pthread
1025_pthread_cleanup_push pthread1033_pthread_cleanup_push pthread
1026_pthread_cleanup_push_defer pthread1034_pthread_cleanup_push_defer pthread
1035_r_debug ld
1027_res c1036_res c
1028_res_hconf c1037_res_hconf c
1029_rpc_dtablesize c1038_rpc_dtablesize c
lib/std/build.zig+9-11
...@@ -1121,7 +1121,7 @@ pub const LibExeObjStep = struct {...@@ -1121,7 +1121,7 @@ pub const LibExeObjStep = struct {
1121 emit_llvm_ir: bool = false,1121 emit_llvm_ir: bool = false,
1122 emit_asm: bool = false,1122 emit_asm: bool = false,
1123 emit_bin: bool = true,1123 emit_bin: bool = true,
1124 disable_gen_h: bool,1124 emit_h: bool = false,
1125 bundle_compiler_rt: bool,1125 bundle_compiler_rt: bool,
1126 disable_stack_probing: bool,1126 disable_stack_probing: bool,
1127 disable_sanitize_c: bool,1127 disable_sanitize_c: bool,
...@@ -1281,7 +1281,6 @@ pub const LibExeObjStep = struct {...@@ -1281,7 +1281,6 @@ pub const LibExeObjStep = struct {
1281 .exec_cmd_args = null,1281 .exec_cmd_args = null,
1282 .name_prefix = "",1282 .name_prefix = "",
1283 .filter = null,1283 .filter = null,
1284 .disable_gen_h = false,
1285 .bundle_compiler_rt = false,1284 .bundle_compiler_rt = false,
1286 .disable_stack_probing = false,1285 .disable_stack_probing = false,
1287 .disable_sanitize_c = false,1286 .disable_sanitize_c = false,
...@@ -1600,8 +1599,9 @@ pub const LibExeObjStep = struct {...@@ -1600,8 +1599,9 @@ pub const LibExeObjStep = struct {
1600 self.main_pkg_path = dir_path;1599 self.main_pkg_path = dir_path;
1601 }1600 }
16021601
1603 pub fn setDisableGenH(self: *LibExeObjStep, value: bool) void {1602 /// Deprecated; just set the field directly.
1604 self.disable_gen_h = value;1603 pub fn setDisableGenH(self: *LibExeObjStep, is_disabled: bool) void {
1604 self.emit_h = !is_disabled;
1605 }1605 }
16061606
1607 pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void {1607 pub fn setLibCFile(self: *LibExeObjStep, libc_file: ?[]const u8) void {
...@@ -1632,7 +1632,7 @@ pub const LibExeObjStep = struct {...@@ -1632,7 +1632,7 @@ pub const LibExeObjStep = struct {
1632 /// the make step, from a step that has declared a dependency on this one.1632 /// the make step, from a step that has declared a dependency on this one.
1633 pub fn getOutputHPath(self: *LibExeObjStep) []const u8 {1633 pub fn getOutputHPath(self: *LibExeObjStep) []const u8 {
1634 assert(self.kind != Kind.Exe);1634 assert(self.kind != Kind.Exe);
1635 assert(!self.disable_gen_h);1635 assert(self.emit_h);
1636 return fs.path.join(1636 return fs.path.join(
1637 self.builder.allocator,1637 self.builder.allocator,
1638 &[_][]const u8{ self.output_dir.?, self.out_h_filename },1638 &[_][]const u8{ self.output_dir.?, self.out_h_filename },
...@@ -1679,7 +1679,7 @@ pub const LibExeObjStep = struct {...@@ -1679,7 +1679,7 @@ pub const LibExeObjStep = struct {
1679 }1679 }
16801680
1681 pub fn addBuildOption(self: *LibExeObjStep, comptime T: type, name: []const u8, value: T) void {1681 pub fn addBuildOption(self: *LibExeObjStep, comptime T: type, name: []const u8, value: T) void {
1682 const out = &std.io.BufferOutStream.init(&self.build_options_contents).stream;1682 const out = self.build_options_contents.outStream();
1683 out.print("pub const {} = {};\n", .{ name, value }) catch unreachable;1683 out.print("pub const {} = {};\n", .{ name, value }) catch unreachable;
1684 }1684 }
16851685
...@@ -1884,6 +1884,7 @@ pub const LibExeObjStep = struct {...@@ -1884,6 +1884,7 @@ pub const LibExeObjStep = struct {
1884 if (self.emit_llvm_ir) try zig_args.append("-femit-llvm-ir");1884 if (self.emit_llvm_ir) try zig_args.append("-femit-llvm-ir");
1885 if (self.emit_asm) try zig_args.append("-femit-asm");1885 if (self.emit_asm) try zig_args.append("-femit-asm");
1886 if (!self.emit_bin) try zig_args.append("-fno-emit-bin");1886 if (!self.emit_bin) try zig_args.append("-fno-emit-bin");
1887 if (self.emit_h) try zig_args.append("-femit-h");
18871888
1888 if (self.strip) {1889 if (self.strip) {
1889 try zig_args.append("--strip");1890 try zig_args.append("--strip");
...@@ -1929,9 +1930,6 @@ pub const LibExeObjStep = struct {...@@ -1929,9 +1930,6 @@ pub const LibExeObjStep = struct {
1929 if (self.is_dynamic) {1930 if (self.is_dynamic) {
1930 try zig_args.append("-dynamic");1931 try zig_args.append("-dynamic");
1931 }1932 }
1932 if (self.disable_gen_h) {
1933 try zig_args.append("--disable-gen-h");
1934 }
1935 if (self.bundle_compiler_rt) {1933 if (self.bundle_compiler_rt) {
1936 try zig_args.append("--bundle-compiler-rt");1934 try zig_args.append("--bundle-compiler-rt");
1937 }1935 }
...@@ -2069,7 +2067,7 @@ pub const LibExeObjStep = struct {...@@ -2069,7 +2067,7 @@ pub const LibExeObjStep = struct {
2069 try zig_args.append("-isystem");2067 try zig_args.append("-isystem");
2070 try zig_args.append(self.builder.pathFromRoot(include_path));2068 try zig_args.append(self.builder.pathFromRoot(include_path));
2071 },2069 },
2072 .OtherStep => |other| if (!other.disable_gen_h) {2070 .OtherStep => |other| if (other.emit_h) {
2073 const h_path = other.getOutputHPath();2071 const h_path = other.getOutputHPath();
2074 try zig_args.append("-isystem");2072 try zig_args.append("-isystem");
2075 try zig_args.append(fs.path.dirname(h_path).?);2073 try zig_args.append(fs.path.dirname(h_path).?);
...@@ -2209,7 +2207,7 @@ const InstallArtifactStep = struct {...@@ -2209,7 +2207,7 @@ const InstallArtifactStep = struct {
2209 break :blk InstallDir.Lib;2207 break :blk InstallDir.Lib;
2210 }2208 }
2211 } else null,2209 } else null,
2212 .h_dir = if (artifact.kind == .Lib and !artifact.disable_gen_h) .Header else null,2210 .h_dir = if (artifact.kind == .Lib and artifact.emit_h) .Header else null,
2213 };2211 };
2214 self.step.dependOn(&artifact.step);2212 self.step.dependOn(&artifact.step);
2215 artifact.install_step = self;2213 artifact.install_step = self;
lib/std/debug.zig+44-11
...@@ -235,9 +235,17 @@ pub fn panic(comptime format: []const u8, args: var) noreturn {...@@ -235,9 +235,17 @@ pub fn panic(comptime format: []const u8, args: var) noreturn {
235 panicExtra(null, first_trace_addr, format, args);235 panicExtra(null, first_trace_addr, format, args);
236}236}
237237
238/// TODO multithreaded awareness238/// Non-zero whenever the program triggered a panic.
239/// The counter is incremented/decremented atomically.
239var panicking: u8 = 0;240var panicking: u8 = 0;
240241
242// Locked to avoid interleaving panic messages from multiple threads.
243var panic_mutex = std.Mutex.init();
244
245/// Counts how many times the panic handler is invoked by this thread.
246/// This is used to catch and handle panics triggered by the panic handler.
247threadlocal var panic_stage: usize = 0;
248
241pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: var) noreturn {249pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, comptime format: []const u8, args: var) noreturn {
242 @setCold(true);250 @setCold(true);
243251
...@@ -247,25 +255,50 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c...@@ -247,25 +255,50 @@ pub fn panicExtra(trace: ?*const builtin.StackTrace, first_trace_addr: ?usize, c
247 resetSegfaultHandler();255 resetSegfaultHandler();
248 }256 }
249257
250 switch (@atomicRmw(u8, &panicking, .Add, 1, .SeqCst)) {258 switch (panic_stage) {
251 0 => {259 0 => {
252 const stderr = getStderrStream();260 panic_stage = 1;
253 noasync stderr.print(format ++ "\n", args) catch os.abort();261
254 if (trace) |t| {262 _ = @atomicRmw(u8, &panicking, .Add, 1, .SeqCst);
255 dumpStackTrace(t.*);263
264 // Make sure to release the mutex when done
265 {
266 const held = panic_mutex.acquire();
267 defer held.release();
268
269 const stderr = getStderrStream();
270 noasync stderr.print(format ++ "\n", args) catch os.abort();
271 if (trace) |t| {
272 dumpStackTrace(t.*);
273 }
274 dumpCurrentStackTrace(first_trace_addr);
275 }
276
277 if (@atomicRmw(u8, &panicking, .Sub, 1, .SeqCst) != 1) {
278 // Another thread is panicking, wait for the last one to finish
279 // and call abort()
280
281 // Sleep forever without hammering the CPU
282 var event = std.ResetEvent.init();
283 event.wait();
284
285 unreachable;
256 }286 }
257 dumpCurrentStackTrace(first_trace_addr);
258 },287 },
259 1 => {288 1 => {
260 // TODO detect if a different thread caused the panic, because in that case289 panic_stage = 2;
261 // we would want to return here instead of calling abort, so that the thread290
262 // which first called panic can finish printing a stack trace.291 // A panic happened while trying to print a previous panic message,
263 warn("Panicked during a panic. Aborting.\n", .{});292 // we're still holding the mutex but that's fine as we're going to
293 // call abort()
294 const stderr = getStderrStream();
295 noasync stderr.print("Panicked during a panic. Aborting.\n", .{}) catch os.abort();
264 },296 },
265 else => {297 else => {
266 // Panicked while printing "Panicked during a panic."298 // Panicked while printing "Panicked during a panic."
267 },299 },
268 }300 }
301
269 os.abort();302 os.abort();
270}303}
271304
lib/std/net.zig+2-2
...@@ -820,7 +820,7 @@ fn linuxLookupNameFromHosts(...@@ -820,7 +820,7 @@ fn linuxLookupNameFromHosts(
820 // Skip to the delimiter in the stream, to fix parsing820 // Skip to the delimiter in the stream, to fix parsing
821 try stream.skipUntilDelimiterOrEof('\n');821 try stream.skipUntilDelimiterOrEof('\n');
822 // Use the truncated line. A truncated comment or hostname will be handled correctly.822 // Use the truncated line. A truncated comment or hostname will be handled correctly.
823 break :blk @as([]u8, &line_buf); // TODO the cast should not be necessary823 break :blk &line_buf;
824 },824 },
825 else => |e| return e,825 else => |e| return e,
826 }) |line| {826 }) |line| {
...@@ -1017,7 +1017,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {...@@ -1017,7 +1017,7 @@ fn getResolvConf(allocator: *mem.Allocator, rc: *ResolvConf) !void {
1017 // Skip to the delimiter in the stream, to fix parsing1017 // Skip to the delimiter in the stream, to fix parsing
1018 try stream.skipUntilDelimiterOrEof('\n');1018 try stream.skipUntilDelimiterOrEof('\n');
1019 // Give an empty line to the while loop, which will be skipped.1019 // Give an empty line to the while loop, which will be skipped.
1020 break :blk @as([]u8, line_buf[0..0]); // TODO the cast should not be necessary1020 break :blk line_buf[0..0];
1021 },1021 },
1022 else => |e| return e,1022 else => |e| return e,
1023 }) |line| {1023 }) |line| {
lib/std/start.zig+4
...@@ -41,6 +41,10 @@ fn _DllMainCRTStartup(...@@ -41,6 +41,10 @@ fn _DllMainCRTStartup(
41 fdwReason: std.os.windows.DWORD,41 fdwReason: std.os.windows.DWORD,
42 lpReserved: std.os.windows.LPVOID,42 lpReserved: std.os.windows.LPVOID,
43) callconv(.Stdcall) std.os.windows.BOOL {43) callconv(.Stdcall) std.os.windows.BOOL {
44 if (!builtin.single_threaded) {
45 _ = @import("start_windows_tls.zig");
46 }
47
44 if (@hasDecl(root, "DllMain")) {48 if (@hasDecl(root, "DllMain")) {
45 return root.DllMain(hinstDLL, fdwReason, lpReserved);49 return root.DllMain(hinstDLL, fdwReason, lpReserved);
46 }50 }
lib/std/zig/ast.zig+3-4
...@@ -1035,6 +1035,7 @@ pub const Node = struct {...@@ -1035,6 +1035,7 @@ pub const Node = struct {
1035 pub const Defer = struct {1035 pub const Defer = struct {
1036 base: Node = Node{ .id = .Defer },1036 base: Node = Node{ .id = .Defer },
1037 defer_token: TokenIndex,1037 defer_token: TokenIndex,
1038 payload: ?*Node,
1038 expr: *Node,1039 expr: *Node,
10391040
1040 pub fn iterate(self: *Defer, index: usize) ?*Node {1041 pub fn iterate(self: *Defer, index: usize) ?*Node {
...@@ -1836,8 +1837,7 @@ pub const Node = struct {...@@ -1836,8 +1837,7 @@ pub const Node = struct {
1836 var i = index;1837 var i = index;
18371838
1838 switch (self.kind) {1839 switch (self.kind) {
1839 .Break,1840 .Break, .Continue => |maybe_label| {
1840 .Continue => |maybe_label| {
1841 if (maybe_label) |label| {1841 if (maybe_label) |label| {
1842 if (i < 1) return label;1842 if (i < 1) return label;
1843 i -= 1;1843 i -= 1;
...@@ -1864,8 +1864,7 @@ pub const Node = struct {...@@ -1864,8 +1864,7 @@ pub const Node = struct {
1864 }1864 }
18651865
1866 switch (self.kind) {1866 switch (self.kind) {
1867 .Break,1867 .Break, .Continue => |maybe_label| {
1868 .Continue => |maybe_label| {
1869 if (maybe_label) |label| {1868 if (maybe_label) |label| {
1870 return label.lastToken();1869 return label.lastToken();
1871 }1870 }
lib/std/zig/parse.zig+6-1
...@@ -465,7 +465,7 @@ fn parseContainerField(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No...@@ -465,7 +465,7 @@ fn parseContainerField(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*No
465/// / KEYWORD_noasync BlockExprStatement465/// / KEYWORD_noasync BlockExprStatement
466/// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)466/// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)
467/// / KEYWORD_defer BlockExprStatement467/// / KEYWORD_defer BlockExprStatement
468/// / KEYWORD_errdefer BlockExprStatement468/// / KEYWORD_errdefer Payload? BlockExprStatement
469/// / IfStatement469/// / IfStatement
470/// / LabeledStatement470/// / LabeledStatement
471/// / SwitchExpr471/// / SwitchExpr
...@@ -526,6 +526,10 @@ fn parseStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) Error!?*No...@@ -526,6 +526,10 @@ fn parseStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) Error!?*No
526526
527 const defer_token = eatToken(it, .Keyword_defer) orelse eatToken(it, .Keyword_errdefer);527 const defer_token = eatToken(it, .Keyword_defer) orelse eatToken(it, .Keyword_errdefer);
528 if (defer_token) |token| {528 if (defer_token) |token| {
529 const payload = if (tree.tokens.at(token).id == .Keyword_errdefer)
530 try parsePayload(arena, it, tree)
531 else
532 null;
529 const expr_node = try expectNode(arena, it, tree, parseBlockExprStatement, .{533 const expr_node = try expectNode(arena, it, tree, parseBlockExprStatement, .{
530 .ExpectedBlockOrExpression = .{ .token = it.index },534 .ExpectedBlockOrExpression = .{ .token = it.index },
531 });535 });
...@@ -533,6 +537,7 @@ fn parseStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) Error!?*No...@@ -533,6 +537,7 @@ fn parseStatement(arena: *Allocator, it: *TokenIterator, tree: *Tree) Error!?*No
533 node.* = .{537 node.* = .{
534 .defer_token = token,538 .defer_token = token,
535 .expr = expr_node,539 .expr = expr_node,
540 .payload = payload,
536 };541 };
537 return &node.base;542 return &node.base;
538 }543 }
lib/std/zig/parser_test.zig+13
...@@ -1,3 +1,16 @@...@@ -1,3 +1,16 @@
1test "zig fmt: errdefer with payload" {
2 try testCanonical(
3 \\pub fn main() anyerror!void {
4 \\ errdefer |a| x += 1;
5 \\ errdefer |a| {}
6 \\ errdefer |a| {
7 \\ x += 1;
8 \\ }
9 \\}
10 \\
11 );
12}
13
1test "zig fmt: noasync block" {14test "zig fmt: noasync block" {
2 try testCanonical(15 try testCanonical(
3 \\pub fn main() anyerror!void {16 \\pub fn main() anyerror!void {
lib/std/zig/render.zig+3
...@@ -376,6 +376,9 @@ fn renderExpression(...@@ -376,6 +376,9 @@ fn renderExpression(
376 const defer_node = @fieldParentPtr(ast.Node.Defer, "base", base);376 const defer_node = @fieldParentPtr(ast.Node.Defer, "base", base);
377377
378 try renderToken(tree, stream, defer_node.defer_token, indent, start_col, Space.Space);378 try renderToken(tree, stream, defer_node.defer_token, indent, start_col, Space.Space);
379 if (defer_node.payload) |payload| {
380 try renderExpression(allocator, stream, tree, indent, start_col, payload, Space.Space);
381 }
379 return renderExpression(allocator, stream, tree, indent, start_col, defer_node.expr, space);382 return renderExpression(allocator, stream, tree, indent, start_col, defer_node.expr, space);
380 },383 },
381 .Comptime => {384 .Comptime => {
src-self-hosted/stage2.zig+8
...@@ -909,6 +909,7 @@ const Stage2Target = extern struct {...@@ -909,6 +909,7 @@ const Stage2Target = extern struct {
909 os_builtin_str: ?[*:0]const u8,909 os_builtin_str: ?[*:0]const u8,
910910
911 dynamic_linker: ?[*:0]const u8,911 dynamic_linker: ?[*:0]const u8,
912 standard_dynamic_linker_path: ?[*:0]const u8,
912913
913 fn fromTarget(self: *Stage2Target, cross_target: CrossTarget) !void {914 fn fromTarget(self: *Stage2Target, cross_target: CrossTarget) !void {
914 const allocator = std.heap.c_allocator;915 const allocator = std.heap.c_allocator;
...@@ -1119,6 +1120,12 @@ const Stage2Target = extern struct {...@@ -1119,6 +1120,12 @@ const Stage2Target = extern struct {
1119 }1120 }
1120 };1121 };
11211122
1123 const std_dl = target.standardDynamicLinkerPath();
1124 const std_dl_z = if (std_dl.get()) |dl|
1125 (try mem.dupeZ(std.heap.c_allocator, u8, dl)).ptr
1126 else
1127 null;
1128
1122 const cache_hash_slice = cache_hash.toOwnedSlice();1129 const cache_hash_slice = cache_hash.toOwnedSlice();
1123 self.* = .{1130 self.* = .{
1124 .arch = @enumToInt(target.cpu.arch) + 1, // skip over ZigLLVM_UnknownArch1131 .arch = @enumToInt(target.cpu.arch) + 1, // skip over ZigLLVM_UnknownArch
...@@ -1134,6 +1141,7 @@ const Stage2Target = extern struct {...@@ -1134,6 +1141,7 @@ const Stage2Target = extern struct {
1134 .is_native = cross_target.isNative(),1141 .is_native = cross_target.isNative(),
1135 .glibc_or_darwin_version = glibc_or_darwin_version,1142 .glibc_or_darwin_version = glibc_or_darwin_version,
1136 .dynamic_linker = dynamic_linker,1143 .dynamic_linker = dynamic_linker,
1144 .standard_dynamic_linker_path = std_dl_z,
1137 };1145 };
1138 }1146 }
1139};1147};
src/all_types.hpp+2
...@@ -744,6 +744,7 @@ struct AstNodeReturnExpr {...@@ -744,6 +744,7 @@ struct AstNodeReturnExpr {
744744
745struct AstNodeDefer {745struct AstNodeDefer {
746 ReturnKind kind;746 ReturnKind kind;
747 AstNode *err_payload;
747 AstNode *expr;748 AstNode *expr;
748749
749 // temporary data used in IR generation750 // temporary data used in IR generation
...@@ -2266,6 +2267,7 @@ struct CodeGen {...@@ -2266,6 +2267,7 @@ struct CodeGen {
2266 Buf *zig_lib_dir;2267 Buf *zig_lib_dir;
2267 Buf *zig_std_dir;2268 Buf *zig_std_dir;
2268 Buf *version_script_path;2269 Buf *version_script_path;
2270 Buf *override_soname;
22692271
2270 const char **llvm_argv;2272 const char **llvm_argv;
2271 size_t llvm_argv_len;2273 size_t llvm_argv_len;
src/codegen.cpp+1
...@@ -10504,6 +10504,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {...@@ -10504,6 +10504,7 @@ static Error check_cache(CodeGen *g, Buf *manifest_dir, Buf *digest) {
10504 cache_str(ch, g->libc->kernel32_lib_dir);10504 cache_str(ch, g->libc->kernel32_lib_dir);
10505 }10505 }
10506 cache_buf_opt(ch, g->version_script_path);10506 cache_buf_opt(ch, g->version_script_path);
10507 cache_buf_opt(ch, g->override_soname);
1050710508
10508 // gen_c_objects appends objects to g->link_objects which we want to include in the hash10509 // gen_c_objects appends objects to g->link_objects which we want to include in the hash
10509 gen_c_objects(g);10510 gen_c_objects(g);
src/glibc.cpp+10
...@@ -16,6 +16,7 @@ static const ZigGLibCLib glibc_libs[] = {...@@ -16,6 +16,7 @@ static const ZigGLibCLib glibc_libs[] = {
16 {"pthread", 0},16 {"pthread", 0},
17 {"dl", 2},17 {"dl", 2},
18 {"rt", 1},18 {"rt", 1},
19 {"ld", 2},
19};20};
2021
21Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbose) {22Error glibc_load_metadata(ZigGLibCAbi **out_result, Buf *zig_lib_dir, bool verbose) {
...@@ -330,6 +331,8 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -330,6 +331,8 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
330 return err;331 return err;
331 }332 }
332333
334 bool is_ld = (strcmp(lib->name, "ld") == 0);
335
333 CodeGen *child_gen = create_child_codegen(g, zig_file_path, OutTypeLib, nullptr, lib->name, progress_node);336 CodeGen *child_gen = create_child_codegen(g, zig_file_path, OutTypeLib, nullptr, lib->name, progress_node);
334 codegen_set_lib_version(child_gen, lib->sover, 0, 0);337 codegen_set_lib_version(child_gen, lib->sover, 0, 0);
335 child_gen->is_dynamic = true;338 child_gen->is_dynamic = true;
...@@ -337,6 +340,13 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con...@@ -337,6 +340,13 @@ Error glibc_build_dummies_and_maps(CodeGen *g, const ZigGLibCAbi *glibc_abi, con
337 child_gen->version_script_path = map_file_path;340 child_gen->version_script_path = map_file_path;
338 child_gen->enable_cache = false;341 child_gen->enable_cache = false;
339 child_gen->output_dir = dummy_dir;342 child_gen->output_dir = dummy_dir;
343 if (is_ld) {
344 assert(g->zig_target->standard_dynamic_linker_path != nullptr);
345 Buf *ld_basename = buf_alloc();
346 os_path_split(buf_create_from_str(g->zig_target->standard_dynamic_linker_path),
347 nullptr, ld_basename);
348 child_gen->override_soname = ld_basename;
349 }
340 codegen_build_and_link(child_gen);350 codegen_build_and_link(child_gen);
341 }351 }
342352
src/ir.cpp+101-30
...@@ -272,6 +272,10 @@ static ResultLoc *no_result_loc(void);...@@ -272,6 +272,10 @@ static ResultLoc *no_result_loc(void);
272static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, IrInstGen *value);272static IrInstGen *ir_analyze_test_non_null(IrAnalyze *ira, IrInst *source_inst, IrInstGen *value);
273static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, IrInst *source_instr);273static IrInstGen *ir_error_dependency_loop(IrAnalyze *ira, IrInst *source_instr);
274static IrInstGen *ir_const_undef(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty);274static IrInstGen *ir_const_undef(IrAnalyze *ira, IrInst *source_instruction, ZigType *ty);
275static ZigVar *ir_create_var(IrBuilderSrc *irb, AstNode *node, Scope *scope, Buf *name,
276 bool src_is_const, bool gen_is_const, bool is_shadowable, IrInstSrc *is_comptime);
277static void build_decl_var_and_init(IrBuilderSrc *irb, Scope *scope, AstNode *source_node, ZigVar *var,
278 IrInstSrc *init, const char *name_hint, IrInstSrc *is_comptime);
275279
276static void destroy_instruction_src(IrInstSrc *inst) {280static void destroy_instruction_src(IrInstSrc *inst) {
277 switch (inst->id) {281 switch (inst->id) {
...@@ -5011,39 +5015,73 @@ static IrInstSrc *ir_mark_gen(IrInstSrc *instruction) {...@@ -5011,39 +5015,73 @@ static IrInstSrc *ir_mark_gen(IrInstSrc *instruction) {
5011 return instruction;5015 return instruction;
5012}5016}
50135017
5014static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_scope, bool gen_error_defers) {5018static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope *outer_scope, bool *is_noreturn, IrInstSrc *err_value) {
5015 Scope *scope = inner_scope;5019 Scope *scope = inner_scope;
5016 bool is_noreturn = false;5020 if (is_noreturn != nullptr) *is_noreturn = false;
5017 while (scope != outer_scope) {5021 while (scope != outer_scope) {
5018 if (!scope)5022 if (!scope)
5019 return is_noreturn;5023 return true;
50205024
5021 switch (scope->id) {5025 switch (scope->id) {
5022 case ScopeIdDefer: {5026 case ScopeIdDefer: {
5023 AstNode *defer_node = scope->source_node;5027 AstNode *defer_node = scope->source_node;
5024 assert(defer_node->type == NodeTypeDefer);5028 assert(defer_node->type == NodeTypeDefer);
5025 ReturnKind defer_kind = defer_node->data.defer.kind;5029 ReturnKind defer_kind = defer_node->data.defer.kind;
5026 if (defer_kind == ReturnKindUnconditional ||5030 AstNode *defer_expr_node = defer_node->data.defer.expr;
5027 (gen_error_defers && defer_kind == ReturnKindError))5031 AstNode *defer_var_node = defer_node->data.defer.err_payload;
5028 {5032
5029 AstNode *defer_expr_node = defer_node->data.defer.expr;5033 if (defer_kind == ReturnKindError && err_value == nullptr) {
5030 Scope *defer_expr_scope = defer_node->data.defer.expr_scope;5034 // This is an `errdefer` but we're generating code for a
5031 IrInstSrc *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope);5035 // `return` that doesn't return an error, skip it
5032 if (defer_expr_value != irb->codegen->invalid_inst_src) {5036 scope = scope->parent;
5033 if (defer_expr_value->is_noreturn) {5037 continue;
5034 is_noreturn = true;5038 }
5035 } else {5039
5036 ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node,5040 Scope *defer_expr_scope = defer_node->data.defer.expr_scope;
5037 defer_expr_value));5041 if (defer_var_node != nullptr) {
5038 }5042 assert(defer_kind == ReturnKindError);
5043 assert(defer_var_node->type == NodeTypeSymbol);
5044 Buf *var_name = defer_var_node->data.symbol_expr.symbol;
5045
5046 if (defer_expr_node->type == NodeTypeUnreachable) {
5047 add_node_error(irb->codegen, defer_var_node,
5048 buf_sprintf("unused variable: '%s'", buf_ptr(var_name)));
5049 return false;
5050 }
5051
5052 IrInstSrc *is_comptime;
5053 if (ir_should_inline(irb->exec, defer_expr_scope)) {
5054 is_comptime = ir_build_const_bool(irb, defer_expr_scope,
5055 defer_expr_node, true);
5056 } else {
5057 is_comptime = ir_build_test_comptime(irb, defer_expr_scope,
5058 defer_expr_node, err_value);
5039 }5059 }
5060
5061 ZigVar *err_var = ir_create_var(irb, defer_var_node, defer_expr_scope,
5062 var_name, true, true, false, is_comptime);
5063 build_decl_var_and_init(irb, defer_expr_scope, defer_var_node, err_var, err_value,
5064 buf_ptr(var_name), is_comptime);
5065
5066 defer_expr_scope = err_var->child_scope;
5067 }
5068
5069 IrInstSrc *defer_expr_value = ir_gen_node(irb, defer_expr_node, defer_expr_scope);
5070 if (defer_expr_value == irb->codegen->invalid_inst_src)
5071 return irb->codegen->invalid_inst_src;
5072
5073 if (defer_expr_value->is_noreturn) {
5074 if (is_noreturn != nullptr) *is_noreturn = true;
5075 } else {
5076 ir_mark_gen(ir_build_check_statement_is_void(irb, defer_expr_scope, defer_expr_node,
5077 defer_expr_value));
5040 }5078 }
5041 scope = scope->parent;5079 scope = scope->parent;
5042 continue;5080 continue;
5043 }5081 }
5044 case ScopeIdDecls:5082 case ScopeIdDecls:
5045 case ScopeIdFnDef:5083 case ScopeIdFnDef:
5046 return is_noreturn;5084 return true;
5047 case ScopeIdBlock:5085 case ScopeIdBlock:
5048 case ScopeIdVarDecl:5086 case ScopeIdVarDecl:
5049 case ScopeIdLoop:5087 case ScopeIdLoop:
...@@ -5060,7 +5098,7 @@ static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope...@@ -5060,7 +5098,7 @@ static bool ir_gen_defers_for_block(IrBuilderSrc *irb, Scope *inner_scope, Scope
5060 zig_unreachable();5098 zig_unreachable();
5061 }5099 }
5062 }5100 }
5063 return is_noreturn;5101 return true;
5064}5102}
50655103
5066static void ir_set_cursor_at_end_gen(IrBuilderGen *irb, IrBasicBlockGen *basic_block) {5104static void ir_set_cursor_at_end_gen(IrBuilderGen *irb, IrBasicBlockGen *basic_block) {
...@@ -5146,7 +5184,8 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node,...@@ -5146,7 +5184,8 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node,
5146 bool have_err_defers = defer_counts[ReturnKindError] > 0;5184 bool have_err_defers = defer_counts[ReturnKindError] > 0;
5147 if (!have_err_defers && !irb->codegen->have_err_ret_tracing) {5185 if (!have_err_defers && !irb->codegen->have_err_ret_tracing) {
5148 // only generate unconditional defers5186 // only generate unconditional defers
5149 ir_gen_defers_for_block(irb, scope, outer_scope, false);5187 if (!ir_gen_defers_for_block(irb, scope, outer_scope, nullptr, nullptr))
5188 return irb->codegen->invalid_inst_src;
5150 IrInstSrc *result = ir_build_return_src(irb, scope, node, nullptr);5189 IrInstSrc *result = ir_build_return_src(irb, scope, node, nullptr);
5151 result_loc_ret->base.source_instruction = result;5190 result_loc_ret->base.source_instruction = result;
5152 return result;5191 return result;
...@@ -5169,14 +5208,16 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node,...@@ -5169,14 +5208,16 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node,
5169 IrBasicBlockSrc *ret_stmt_block = ir_create_basic_block(irb, scope, "RetStmt");5208 IrBasicBlockSrc *ret_stmt_block = ir_create_basic_block(irb, scope, "RetStmt");
51705209
5171 ir_set_cursor_at_end_and_append_block(irb, err_block);5210 ir_set_cursor_at_end_and_append_block(irb, err_block);
5172 ir_gen_defers_for_block(irb, scope, outer_scope, true);5211 if (!ir_gen_defers_for_block(irb, scope, outer_scope, nullptr, return_value))
5212 return irb->codegen->invalid_inst_src;
5173 if (irb->codegen->have_err_ret_tracing && !should_inline) {5213 if (irb->codegen->have_err_ret_tracing && !should_inline) {
5174 ir_build_save_err_ret_addr_src(irb, scope, node);5214 ir_build_save_err_ret_addr_src(irb, scope, node);
5175 }5215 }
5176 ir_build_br(irb, scope, node, ret_stmt_block, is_comptime);5216 ir_build_br(irb, scope, node, ret_stmt_block, is_comptime);
51775217
5178 ir_set_cursor_at_end_and_append_block(irb, ok_block);5218 ir_set_cursor_at_end_and_append_block(irb, ok_block);
5179 ir_gen_defers_for_block(irb, scope, outer_scope, false);5219 if (!ir_gen_defers_for_block(irb, scope, outer_scope, nullptr, nullptr))
5220 return irb->codegen->invalid_inst_src;
5180 ir_build_br(irb, scope, node, ret_stmt_block, is_comptime);5221 ir_build_br(irb, scope, node, ret_stmt_block, is_comptime);
51815222
5182 ir_set_cursor_at_end_and_append_block(irb, ret_stmt_block);5223 ir_set_cursor_at_end_and_append_block(irb, ret_stmt_block);
...@@ -5213,7 +5254,12 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node,...@@ -5213,7 +5254,12 @@ static IrInstSrc *ir_gen_return(IrBuilderSrc *irb, Scope *scope, AstNode *node,
5213 result_loc_ret->base.id = ResultLocIdReturn;5254 result_loc_ret->base.id = ResultLocIdReturn;
5214 ir_build_reset_result(irb, scope, node, &result_loc_ret->base);5255 ir_build_reset_result(irb, scope, node, &result_loc_ret->base);
5215 ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base);5256 ir_build_end_expr(irb, scope, node, err_val, &result_loc_ret->base);
5216 if (!ir_gen_defers_for_block(irb, scope, outer_scope, true)) {5257
5258 bool is_noreturn = false;
5259 if (!ir_gen_defers_for_block(irb, scope, outer_scope, &is_noreturn, err_val)) {
5260 return irb->codegen->invalid_inst_src;
5261 }
5262 if (!is_noreturn) {
5217 if (irb->codegen->have_err_ret_tracing && !should_inline) {5263 if (irb->codegen->have_err_ret_tracing && !should_inline) {
5218 ir_build_save_err_ret_addr_src(irb, scope, node);5264 ir_build_save_err_ret_addr_src(irb, scope, node);
5219 }5265 }
...@@ -5415,7 +5461,8 @@ static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode *...@@ -5415,7 +5461,8 @@ static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode *
54155461
5416 bool is_return_from_fn = block_node == irb->main_block_node;5462 bool is_return_from_fn = block_node == irb->main_block_node;
5417 if (!is_return_from_fn) {5463 if (!is_return_from_fn) {
5418 ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false);5464 if (!ir_gen_defers_for_block(irb, child_scope, outer_block_scope, nullptr, nullptr))
5465 return irb->codegen->invalid_inst_src;
5419 }5466 }
54205467
5421 IrInstSrc *result;5468 IrInstSrc *result;
...@@ -5440,7 +5487,8 @@ static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode *...@@ -5440,7 +5487,8 @@ static IrInstSrc *ir_gen_block(IrBuilderSrc *irb, Scope *parent_scope, AstNode *
5440 result_loc_ret->base.id = ResultLocIdReturn;5487 result_loc_ret->base.id = ResultLocIdReturn;
5441 ir_build_reset_result(irb, parent_scope, block_node, &result_loc_ret->base);5488 ir_build_reset_result(irb, parent_scope, block_node, &result_loc_ret->base);
5442 ir_mark_gen(ir_build_end_expr(irb, parent_scope, block_node, result, &result_loc_ret->base));5489 ir_mark_gen(ir_build_end_expr(irb, parent_scope, block_node, result, &result_loc_ret->base));
5443 ir_gen_defers_for_block(irb, child_scope, outer_block_scope, false);5490 if (!ir_gen_defers_for_block(irb, child_scope, outer_block_scope, nullptr, nullptr))
5491 return irb->codegen->invalid_inst_src;
5444 return ir_mark_gen(ir_build_return_src(irb, child_scope, result->base.source_node, result));5492 return ir_mark_gen(ir_build_return_src(irb, child_scope, result->base.source_node, result));
5445}5493}
54465494
...@@ -9207,7 +9255,8 @@ static IrInstSrc *ir_gen_return_from_block(IrBuilderSrc *irb, Scope *break_scope...@@ -9207,7 +9255,8 @@ static IrInstSrc *ir_gen_return_from_block(IrBuilderSrc *irb, Scope *break_scope
9207 }9255 }
92089256
9209 IrBasicBlockSrc *dest_block = block_scope->end_block;9257 IrBasicBlockSrc *dest_block = block_scope->end_block;
9210 ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false);9258 if (!ir_gen_defers_for_block(irb, break_scope, dest_block->scope, nullptr, nullptr))
9259 return irb->codegen->invalid_inst_src;
92119260
9212 block_scope->incoming_blocks->append(irb->current_basic_block);9261 block_scope->incoming_blocks->append(irb->current_basic_block);
9213 block_scope->incoming_values->append(result_value);9262 block_scope->incoming_values->append(result_value);
...@@ -9281,7 +9330,8 @@ static IrInstSrc *ir_gen_break(IrBuilderSrc *irb, Scope *break_scope, AstNode *n...@@ -9281,7 +9330,8 @@ static IrInstSrc *ir_gen_break(IrBuilderSrc *irb, Scope *break_scope, AstNode *n
9281 }9330 }
92829331
9283 IrBasicBlockSrc *dest_block = loop_scope->break_block;9332 IrBasicBlockSrc *dest_block = loop_scope->break_block;
9284 ir_gen_defers_for_block(irb, break_scope, dest_block->scope, false);9333 if (!ir_gen_defers_for_block(irb, break_scope, dest_block->scope, nullptr, nullptr))
9334 return irb->codegen->invalid_inst_src;
92859335
9286 loop_scope->incoming_blocks->append(irb->current_basic_block);9336 loop_scope->incoming_blocks->append(irb->current_basic_block);
9287 loop_scope->incoming_values->append(result_value);9337 loop_scope->incoming_values->append(result_value);
...@@ -9340,7 +9390,8 @@ static IrInstSrc *ir_gen_continue(IrBuilderSrc *irb, Scope *continue_scope, AstN...@@ -9340,7 +9390,8 @@ static IrInstSrc *ir_gen_continue(IrBuilderSrc *irb, Scope *continue_scope, AstN
9340 }9390 }
93419391
9342 IrBasicBlockSrc *dest_block = loop_scope->continue_block;9392 IrBasicBlockSrc *dest_block = loop_scope->continue_block;
9343 ir_gen_defers_for_block(irb, continue_scope, dest_block->scope, false);9393 if (!ir_gen_defers_for_block(irb, continue_scope, dest_block->scope, nullptr, nullptr))
9394 return irb->codegen->invalid_inst_src;
9344 return ir_mark_gen(ir_build_br(irb, continue_scope, node, dest_block, is_comptime));9395 return ir_mark_gen(ir_build_br(irb, continue_scope, node, dest_block, is_comptime));
9345}9396}
93469397
...@@ -12317,11 +12368,22 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT...@@ -12317,11 +12368,22 @@ static ZigType *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_node, ZigT
12317 prev_type->data.pointer.child_type->id == ZigTypeIdArray &&12368 prev_type->data.pointer.child_type->id == ZigTypeIdArray &&
12318 prev_type->data.pointer.ptr_len == PtrLenSingle &&12369 prev_type->data.pointer.ptr_len == PtrLenSingle &&
12319 ((cur_type->id == ZigTypeIdErrorUnion && is_slice(cur_type->data.error_union.payload_type)) ||12370 ((cur_type->id == ZigTypeIdErrorUnion && is_slice(cur_type->data.error_union.payload_type)) ||
12320 is_slice(cur_type)))12371 (cur_type->id == ZigTypeIdOptional && is_slice(cur_type->data.maybe.child_type)) ||
12372 is_slice(cur_type)))
12321 {12373 {
12322 ZigType *array_type = prev_type->data.pointer.child_type;12374 ZigType *array_type = prev_type->data.pointer.child_type;
12323 ZigType *slice_type = (cur_type->id == ZigTypeIdErrorUnion) ?12375 ZigType *slice_type;
12324 cur_type->data.error_union.payload_type : cur_type;12376 switch (cur_type->id) {
12377 case ZigTypeIdErrorUnion:
12378 slice_type = cur_type->data.error_union.payload_type;
12379 break;
12380 case ZigTypeIdOptional:
12381 slice_type = cur_type->data.maybe.child_type;
12382 break;
12383 default:
12384 slice_type = cur_type;
12385 break;
12386 }
12325 ZigType *slice_ptr_type = slice_type->data.structure.fields[slice_ptr_index]->type_entry;12387 ZigType *slice_ptr_type = slice_type->data.structure.fields[slice_ptr_index]->type_entry;
12326 if ((slice_ptr_type->data.pointer.is_const || array_type->data.array.len == 0 ||12388 if ((slice_ptr_type->data.pointer.is_const || array_type->data.array.len == 0 ||
12327 !prev_type->data.pointer.is_const) &&12389 !prev_type->data.pointer.is_const) &&
...@@ -16191,6 +16253,15 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i...@@ -16191,6 +16253,15 @@ static IrInstGen *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstSrcBinOp *bin_op_i
16191 IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2;16253 IrInstGen *union_val = op1->value->type->id == ZigTypeIdUnion ? op1 : op2;
16192 IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1;16254 IrInstGen *enum_val = op1->value->type->id == ZigTypeIdUnion ? op2 : op1;
1619316255
16256 if (!is_tagged_union(union_val->value->type)) {
16257 ErrorMsg *msg = ir_add_error_node(ira, source_node,
16258 buf_sprintf("comparison of union and enum literal is only valid for tagged union types"));
16259 add_error_note(ira->codegen, msg, union_val->value->type->data.unionation.decl_node,
16260 buf_sprintf("type %s is not a tagged union",
16261 buf_ptr(&union_val->value->type->name)));
16262 return ira->codegen->invalid_inst_gen;
16263 }
16264
16194 ZigType *tag_type = union_val->value->type->data.unionation.tag_type;16265 ZigType *tag_type = union_val->value->type->data.unionation.tag_type;
16195 assert(tag_type != nullptr);16266 assert(tag_type != nullptr);
1619616267
src/link.cpp+4-4
...@@ -1651,7 +1651,6 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -1651,7 +1651,6 @@ static void construct_linker_job_elf(LinkJob *lj) {
16511651
1652 bool is_lib = g->out_type == OutTypeLib;1652 bool is_lib = g->out_type == OutTypeLib;
1653 bool is_dyn_lib = g->is_dynamic && is_lib;1653 bool is_dyn_lib = g->is_dynamic && is_lib;
1654 Buf *soname = nullptr;
1655 if (!g->have_dynamic_link) {1654 if (!g->have_dynamic_link) {
1656 if (g->zig_target->arch == ZigLLVM_arm || g->zig_target->arch == ZigLLVM_armeb ||1655 if (g->zig_target->arch == ZigLLVM_arm || g->zig_target->arch == ZigLLVM_armeb ||
1657 g->zig_target->arch == ZigLLVM_thumb || g->zig_target->arch == ZigLLVM_thumbeb)1656 g->zig_target->arch == ZigLLVM_thumb || g->zig_target->arch == ZigLLVM_thumbeb)
...@@ -1662,15 +1661,13 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -1662,15 +1661,13 @@ static void construct_linker_job_elf(LinkJob *lj) {
1662 }1661 }
1663 } else if (is_dyn_lib) {1662 } else if (is_dyn_lib) {
1664 lj->args.append("-shared");1663 lj->args.append("-shared");
1665
1666 assert(buf_len(&g->bin_file_output_path) != 0);
1667 soname = buf_sprintf("lib%s.so.%" ZIG_PRI_usize, buf_ptr(g->root_out_name), g->version_major);
1668 }1664 }
16691665
1670 if (target_requires_pie(g->zig_target) && g->out_type == OutTypeExe) {1666 if (target_requires_pie(g->zig_target) && g->out_type == OutTypeExe) {
1671 lj->args.append("-pie");1667 lj->args.append("-pie");
1672 }1668 }
16731669
1670 assert(buf_len(&g->bin_file_output_path) != 0);
1674 lj->args.append("-o");1671 lj->args.append("-o");
1675 lj->args.append(buf_ptr(&g->bin_file_output_path));1672 lj->args.append(buf_ptr(&g->bin_file_output_path));
16761673
...@@ -1740,6 +1737,9 @@ static void construct_linker_job_elf(LinkJob *lj) {...@@ -1740,6 +1737,9 @@ static void construct_linker_job_elf(LinkJob *lj) {
1740 }1737 }
17411738
1742 if (is_dyn_lib) {1739 if (is_dyn_lib) {
1740 Buf *soname = (g->override_soname == nullptr) ?
1741 buf_sprintf("lib%s.so.%" ZIG_PRI_usize, buf_ptr(g->root_out_name), g->version_major) :
1742 g->override_soname;
1743 lj->args.append("-soname");1743 lj->args.append("-soname");
1744 lj->args.append(buf_ptr(soname));1744 lj->args.append(buf_ptr(soname));
17451745
src/main.cpp+10-6
...@@ -54,7 +54,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -54,7 +54,6 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
54 " --cache-dir [path] override the local cache directory\n"54 " --cache-dir [path] override the local cache directory\n"
55 " --cache [auto|off|on] build in cache, print output path to stdout\n"55 " --cache [auto|off|on] build in cache, print output path to stdout\n"
56 " --color [auto|off|on] enable or disable colored error messages\n"56 " --color [auto|off|on] enable or disable colored error messages\n"
57 " --disable-gen-h do not generate a C header file (.h)\n"
58 " --disable-valgrind omit valgrind client requests in debug builds\n"57 " --disable-valgrind omit valgrind client requests in debug builds\n"
59 " --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n"58 " --eh-frame-hdr enable C++ exception handling by passing --eh-frame-hdr to linker\n"
60 " --enable-valgrind include valgrind client requests release builds\n"59 " --enable-valgrind include valgrind client requests release builds\n"
...@@ -77,6 +76,8 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {...@@ -77,6 +76,8 @@ static int print_full_usage(const char *arg0, FILE *file, int return_code) {
77 " -fno-emit-asm (default) do not output .s (assembly code)\n"76 " -fno-emit-asm (default) do not output .s (assembly code)\n"
78 " -femit-llvm-ir produce a .ll file with LLVM IR\n"77 " -femit-llvm-ir produce a .ll file with LLVM IR\n"
79 " -fno-emit-llvm-ir (default) do not produce a .ll file with LLVM IR\n"78 " -fno-emit-llvm-ir (default) do not produce a .ll file with LLVM IR\n"
79 " -femit-h generate a C header file (.h)\n"
80 " -fno-emit-h (default) do not generate a C header file (.h)\n"
80 " --libc [file] Provide a file which specifies libc paths\n"81 " --libc [file] Provide a file which specifies libc paths\n"
81 " --name [name] override output name\n"82 " --name [name] override output name\n"
82 " --output-dir [dir] override output directory (defaults to cwd)\n"83 " --output-dir [dir] override output directory (defaults to cwd)\n"
...@@ -432,6 +433,7 @@ static int main0(int argc, char **argv) {...@@ -432,6 +433,7 @@ static int main0(int argc, char **argv) {
432 bool emit_bin = true;433 bool emit_bin = true;
433 bool emit_asm = false;434 bool emit_asm = false;
434 bool emit_llvm_ir = false;435 bool emit_llvm_ir = false;
436 bool emit_h = false;
435 const char *cache_dir = nullptr;437 const char *cache_dir = nullptr;
436 CliPkg *cur_pkg = heap::c_allocator.create<CliPkg>();438 CliPkg *cur_pkg = heap::c_allocator.create<CliPkg>();
437 BuildMode build_mode = BuildModeDebug;439 BuildMode build_mode = BuildModeDebug;
...@@ -440,7 +442,6 @@ static int main0(int argc, char **argv) {...@@ -440,7 +442,6 @@ static int main0(int argc, char **argv) {
440 bool system_linker_hack = false;442 bool system_linker_hack = false;
441 TargetSubsystem subsystem = TargetSubsystemAuto;443 TargetSubsystem subsystem = TargetSubsystemAuto;
442 bool want_single_threaded = false;444 bool want_single_threaded = false;
443 bool disable_gen_h = false;
444 bool bundle_compiler_rt = false;445 bool bundle_compiler_rt = false;
445 Buf *override_lib_dir = nullptr;446 Buf *override_lib_dir = nullptr;
446 Buf *main_pkg_path = nullptr;447 Buf *main_pkg_path = nullptr;
...@@ -661,9 +662,7 @@ static int main0(int argc, char **argv) {...@@ -661,9 +662,7 @@ static int main0(int argc, char **argv) {
661 } else if (strcmp(arg, "--system-linker-hack") == 0) {662 } else if (strcmp(arg, "--system-linker-hack") == 0) {
662 system_linker_hack = true;663 system_linker_hack = true;
663 } else if (strcmp(arg, "--single-threaded") == 0) {664 } else if (strcmp(arg, "--single-threaded") == 0) {
664 want_single_threaded = true;665 want_single_threaded = true;;
665 } else if (strcmp(arg, "--disable-gen-h") == 0) {
666 disable_gen_h = true;
667 } else if (strcmp(arg, "--bundle-compiler-rt") == 0) {666 } else if (strcmp(arg, "--bundle-compiler-rt") == 0) {
668 bundle_compiler_rt = true;667 bundle_compiler_rt = true;
669 } else if (strcmp(arg, "--test-cmd-bin") == 0) {668 } else if (strcmp(arg, "--test-cmd-bin") == 0) {
...@@ -720,6 +719,11 @@ static int main0(int argc, char **argv) {...@@ -720,6 +719,11 @@ static int main0(int argc, char **argv) {
720 emit_llvm_ir = true;719 emit_llvm_ir = true;
721 } else if (strcmp(arg, "-fno-emit-llvm-ir") == 0) {720 } else if (strcmp(arg, "-fno-emit-llvm-ir") == 0) {
722 emit_llvm_ir = false;721 emit_llvm_ir = false;
722 } else if (strcmp(arg, "-femit-h") == 0) {
723 emit_h = true;
724 } else if (strcmp(arg, "-fno-emit-h") == 0 || strcmp(arg, "--disable-gen-h") == 0) {
725 // the --disable-gen-h is there to support godbolt. once they upgrade to -fno-emit-h then we can remove this
726 emit_h = false;
723 } else if (str_starts_with(arg, "-mcpu=")) {727 } else if (str_starts_with(arg, "-mcpu=")) {
724 mcpu = arg + strlen("-mcpu=");728 mcpu = arg + strlen("-mcpu=");
725 } else if (i + 1 >= argc) {729 } else if (i + 1 >= argc) {
...@@ -1203,7 +1207,7 @@ static int main0(int argc, char **argv) {...@@ -1203,7 +1207,7 @@ static int main0(int argc, char **argv) {
1203 g->verbose_cc = verbose_cc;1207 g->verbose_cc = verbose_cc;
1204 g->verbose_llvm_cpu_features = verbose_llvm_cpu_features;1208 g->verbose_llvm_cpu_features = verbose_llvm_cpu_features;
1205 g->output_dir = output_dir;1209 g->output_dir = output_dir;
1206 g->disable_gen_h = disable_gen_h;1210 g->disable_gen_h = !emit_h;
1207 g->bundle_compiler_rt = bundle_compiler_rt;1211 g->bundle_compiler_rt = bundle_compiler_rt;
1208 codegen_set_errmsg_color(g, color);1212 codegen_set_errmsg_color(g, color);
1209 g->system_linker_hack = system_linker_hack;1213 g->system_linker_hack = system_linker_hack;
src/parser.cpp+9-2
...@@ -879,7 +879,7 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {...@@ -879,7 +879,7 @@ static AstNode *ast_parse_container_field(ParseContext *pc) {
879// / KEYWORD_noasync BlockExprStatement879// / KEYWORD_noasync BlockExprStatement
880// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)880// / KEYWORD_suspend (SEMICOLON / BlockExprStatement)
881// / KEYWORD_defer BlockExprStatement881// / KEYWORD_defer BlockExprStatement
882// / KEYWORD_errdefer BlockExprStatement882// / KEYWORD_errdefer Payload? BlockExprStatement
883// / IfStatement883// / IfStatement
884// / LabeledStatement884// / LabeledStatement
885// / SwitchExpr885// / SwitchExpr
...@@ -923,12 +923,18 @@ static AstNode *ast_parse_statement(ParseContext *pc) {...@@ -923,12 +923,18 @@ static AstNode *ast_parse_statement(ParseContext *pc) {
923 if (defer == nullptr)923 if (defer == nullptr)
924 defer = eat_token_if(pc, TokenIdKeywordErrdefer);924 defer = eat_token_if(pc, TokenIdKeywordErrdefer);
925 if (defer != nullptr) {925 if (defer != nullptr) {
926 Token *payload = (defer->id == TokenIdKeywordErrdefer) ?
927 ast_parse_payload(pc) : nullptr;
926 AstNode *statement = ast_expect(pc, ast_parse_block_expr_statement);928 AstNode *statement = ast_expect(pc, ast_parse_block_expr_statement);
927 AstNode *res = ast_create_node(pc, NodeTypeDefer, defer);929 AstNode *res = ast_create_node(pc, NodeTypeDefer, defer);
930
928 res->data.defer.kind = ReturnKindUnconditional;931 res->data.defer.kind = ReturnKindUnconditional;
929 res->data.defer.expr = statement;932 res->data.defer.expr = statement;
930 if (defer->id == TokenIdKeywordErrdefer)933 if (defer->id == TokenIdKeywordErrdefer) {
931 res->data.defer.kind = ReturnKindError;934 res->data.defer.kind = ReturnKindError;
935 if (payload != nullptr)
936 res->data.defer.err_payload = token_symbol(pc, payload);
937 }
932 return res;938 return res;
933 }939 }
934940
...@@ -3032,6 +3038,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont...@@ -3032,6 +3038,7 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont
3032 break;3038 break;
3033 case NodeTypeDefer:3039 case NodeTypeDefer:
3034 visit_field(&node->data.defer.expr, visit, context);3040 visit_field(&node->data.defer.expr, visit, context);
3041 visit_field(&node->data.defer.err_payload, visit, context);
3035 break;3042 break;
3036 case NodeTypeVariableDeclaration:3043 case NodeTypeVariableDeclaration:
3037 visit_field(&node->data.variable_declaration.type, visit, context);3044 visit_field(&node->data.variable_declaration.type, visit, context);
src/stage2.h+1
...@@ -291,6 +291,7 @@ struct ZigTarget {...@@ -291,6 +291,7 @@ struct ZigTarget {
291 size_t cache_hash_len;291 size_t cache_hash_len;
292 const char *os_builtin_str;292 const char *os_builtin_str;
293 const char *dynamic_linker;293 const char *dynamic_linker;
294 const char *standard_dynamic_linker_path;
294};295};
295296
296// ABI warning297// ABI warning
test/compile_errors.zig+23
...@@ -2,6 +2,29 @@ const tests = @import("tests.zig");...@@ -2,6 +2,29 @@ const tests = @import("tests.zig");
2const std = @import("std");2const std = @import("std");
33
4pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.addTest("unused variable error on errdefer",
6 \\fn foo() !void {
7 \\ errdefer |a| unreachable;
8 \\ return error.A;
9 \\}
10 \\export fn entry() void {
11 \\ foo() catch unreachable;
12 \\}
13 , &[_][]const u8{
14 "tmp.zig:2:15: error: unused variable: 'a'",
15 });
16
17 cases.addTest("comparison of non-tagged union and enum literal",
18 \\export fn entry() void {
19 \\ const U = union { A: u32, B: u64 };
20 \\ var u = U{ .A = 42 };
21 \\ var ok = u == .A;
22 \\}
23 , &[_][]const u8{
24 "tmp.zig:4:16: error: comparison of union and enum literal is only valid for tagged union types",
25 "tmp.zig:2:15: note: type U is not a tagged union",
26 });
27
5 cases.addTest("shift on type with non-power-of-two size",28 cases.addTest("shift on type with non-power-of-two size",
6 \\export fn entry() void {29 \\export fn entry() void {
7 \\ const S = struct {30 \\ const S = struct {
test/stage1/behavior/defer.zig+20-1
...@@ -1,4 +1,7 @@...@@ -1,4 +1,7 @@
1const expect = @import("std").testing.expect;1const std = @import("std");
2const expect = std.testing.expect;
3const expectEqual = std.testing.expectEqual;
4const expectError = std.testing.expectError;
25
3var result: [3]u8 = undefined;6var result: [3]u8 = undefined;
4var index: usize = undefined;7var index: usize = undefined;
...@@ -93,3 +96,19 @@ test "return variable while defer expression in scope to modify it" {...@@ -93,3 +96,19 @@ test "return variable while defer expression in scope to modify it" {
93 S.doTheTest();96 S.doTheTest();
94 comptime S.doTheTest();97 comptime S.doTheTest();
95}98}
99
100test "errdefer with payload" {
101 const S = struct {
102 fn foo() !i32 {
103 errdefer |a| {
104 expectEqual(error.One, a);
105 }
106 return error.One;
107 }
108 fn doTheTest() void {
109 expectError(error.One, foo());
110 }
111 };
112 S.doTheTest();
113 comptime S.doTheTest();
114}
test/stage1/behavior/slice.zig+8
...@@ -159,6 +159,7 @@ test "slice syntax resulting in pointer-to-array" {...@@ -159,6 +159,7 @@ test "slice syntax resulting in pointer-to-array" {
159 testSlice();159 testSlice();
160 testSliceZ();160 testSliceZ();
161 testSlice0();161 testSlice0();
162 testSliceOpt();
162 testSliceAlign();163 testSliceAlign();
163 }164 }
164165
...@@ -249,6 +250,13 @@ test "slice syntax resulting in pointer-to-array" {...@@ -249,6 +250,13 @@ test "slice syntax resulting in pointer-to-array" {
249 comptime expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8);250 comptime expect(@TypeOf(slice[1..3 :4]) == *[2:4]u8);
250 }251 }
251252
253 fn testSliceOpt() void {
254 var array: [2]u8 = [2]u8{ 1, 2 };
255 var slice: ?[]u8 = &array;
256 comptime expect(@TypeOf(&array, slice) == ?[]u8);
257 comptime expect(@TypeOf(slice.?[0..2]) == *[2]u8);
258 }
259
252 fn testSlice0() void {260 fn testSlice0() void {
253 {261 {
254 var array = [0]u8{};262 var array = [0]u8{};
test/standalone/mix_o_files/test.c+5-3
...@@ -1,10 +1,12 @@...@@ -1,10 +1,12 @@
1// This header is generated by zig from base64.zig
2#include "base64.h"
3
4#include <assert.h>1#include <assert.h>
5#include <string.h>2#include <string.h>
6#include <stdint.h>3#include <stdint.h>
74
5// TODO we would like to #include "base64.h" here but this feature has been disabled in
6// the stage1 compiler. Users will have to wait until self-hosted is available for
7// the "generate .h file" feature.
8size_t decode_base_64(uint8_t *dest_ptr, size_t dest_len, const uint8_t *source_ptr, size_t source_len);
9
8extern int *x_ptr;10extern int *x_ptr;
911
10int main(int argc, char **argv) {12int main(int argc, char **argv) {
test/standalone/shared_library/test.c+7-1
...@@ -1,6 +1,12 @@...@@ -1,6 +1,12 @@
1#include "mathtest.h"
2#include <assert.h>1#include <assert.h>
32
3// TODO we would like to #include "mathtest.h" here but this feature has been disabled in
4// the stage1 compiler. Users will have to wait until self-hosted is available for
5// the "generate .h file" feature.
6
7#include <stdint.h>
8int32_t add(int32_t a, int32_t b);
9
4int main(int argc, char **argv) {10int main(int argc, char **argv) {
5 assert(add(42, 1337) == 1379);11 assert(add(42, 1337) == 1379);
6 return 0;12 return 0;
tools/update_glibc.zig+16-13
...@@ -20,6 +20,7 @@ const lib_names = [_][]const u8{...@@ -20,6 +20,7 @@ const lib_names = [_][]const u8{
20 "m",20 "m",
21 "pthread",21 "pthread",
22 "rt",22 "rt",
23 "ld",
23};24};
2425
25// fpu/nofpu are hardcoded elsewhere, based on .gnueabi/.gnueabihf with an exception for .arm26// fpu/nofpu are hardcoded elsewhere, based on .gnueabi/.gnueabihf with an exception for .arm
...@@ -154,22 +155,24 @@ pub fn main() !void {...@@ -154,22 +155,24 @@ pub fn main() !void {
154 const fn_set = &target_funcs_gop.kv.value.list;155 const fn_set = &target_funcs_gop.kv.value.list;
155156
156 for (lib_names) |lib_name, lib_name_index| {157 for (lib_names) |lib_name, lib_name_index| {
157 const basename = try fmt.allocPrint(allocator, "lib{}.abilist", .{lib_name});158 const lib_prefix = if (std.mem.eql(u8, lib_name, "ld")) "" else "lib";
159 const basename = try fmt.allocPrint(allocator, "{}{}.abilist", .{ lib_prefix, lib_name });
158 const abi_list_filename = blk: {160 const abi_list_filename = blk: {
159 if (abi_list.targets[0].abi == .gnuabi64 and std.mem.eql(u8, lib_name, "c")) {161 const is_c = std.mem.eql(u8, lib_name, "c");
162 const is_m = std.mem.eql(u8, lib_name, "m");
163 const is_ld = std.mem.eql(u8, lib_name, "ld");
164 if (abi_list.targets[0].abi == .gnuabi64 and (is_c or is_ld)) {
160 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n64", basename });165 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n64", basename });
161 } else if (abi_list.targets[0].abi == .gnuabin32 and std.mem.eql(u8, lib_name, "c")) {166 } else if (abi_list.targets[0].abi == .gnuabin32 and (is_c or is_ld)) {
162 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n32", basename });167 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "n32", basename });
163 } else if (abi_list.targets[0].arch != .arm and168 } else if (abi_list.targets[0].arch != .arm and
164 abi_list.targets[0].abi == .gnueabihf and169 abi_list.targets[0].abi == .gnueabihf and
165 (std.mem.eql(u8, lib_name, "c") or170 (is_c or (is_m and abi_list.targets[0].arch == .powerpc)))
166 (std.mem.eql(u8, lib_name, "m") and abi_list.targets[0].arch == .powerpc)))
167 {171 {
168 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "fpu", basename });172 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "fpu", basename });
169 } else if (abi_list.targets[0].arch != .arm and173 } else if (abi_list.targets[0].arch != .arm and
170 abi_list.targets[0].abi == .gnueabi and174 abi_list.targets[0].abi == .gnueabi and
171 (std.mem.eql(u8, lib_name, "c") or175 (is_c or (is_m and abi_list.targets[0].arch == .powerpc)))
172 (std.mem.eql(u8, lib_name, "m") and abi_list.targets[0].arch == .powerpc)))
173 {176 {
174 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "nofpu", basename });177 break :blk try fs.path.join(allocator, &[_][]const u8{ prefix, abi_list.path, "nofpu", basename });
175 } else if (abi_list.targets[0].arch == .arm) {178 } else if (abi_list.targets[0].arch == .arm) {
...@@ -234,8 +237,8 @@ pub fn main() !void {...@@ -234,8 +237,8 @@ pub fn main() !void {
234 const vers_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "vers.txt" });237 const vers_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "vers.txt" });
235 const vers_txt_file = try fs.cwd().createFile(vers_txt_path, .{});238 const vers_txt_file = try fs.cwd().createFile(vers_txt_path, .{});
236 defer vers_txt_file.close();239 defer vers_txt_file.close();
237 var buffered = std.io.BufferedOutStream(fs.File.WriteError).init(&vers_txt_file.outStream().stream);240 var buffered = std.io.bufferedOutStream(vers_txt_file.outStream());
238 const vers_txt = &buffered.stream;241 const vers_txt = buffered.outStream();
239 for (global_ver_list) |name, i| {242 for (global_ver_list) |name, i| {
240 _ = global_ver_set.put(name, i) catch unreachable;243 _ = global_ver_set.put(name, i) catch unreachable;
241 try vers_txt.print("{}\n", .{name});244 try vers_txt.print("{}\n", .{name});
...@@ -246,8 +249,8 @@ pub fn main() !void {...@@ -246,8 +249,8 @@ pub fn main() !void {
246 const fns_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "fns.txt" });249 const fns_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "fns.txt" });
247 const fns_txt_file = try fs.cwd().createFile(fns_txt_path, .{});250 const fns_txt_file = try fs.cwd().createFile(fns_txt_path, .{});
248 defer fns_txt_file.close();251 defer fns_txt_file.close();
249 var buffered = std.io.BufferedOutStream(fs.File.WriteError).init(&fns_txt_file.outStream().stream);252 var buffered = std.io.bufferedOutStream(fns_txt_file.outStream());
250 const fns_txt = &buffered.stream;253 const fns_txt = buffered.outStream();
251 for (global_fn_list) |name, i| {254 for (global_fn_list) |name, i| {
252 const kv = global_fn_set.get(name).?;255 const kv = global_fn_set.get(name).?;
253 kv.value.index = i;256 kv.value.index = i;
...@@ -277,8 +280,8 @@ pub fn main() !void {...@@ -277,8 +280,8 @@ pub fn main() !void {
277 const abilist_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "abi.txt" });280 const abilist_txt_path = try fs.path.join(allocator, &[_][]const u8{ glibc_out_dir, "abi.txt" });
278 const abilist_txt_file = try fs.cwd().createFile(abilist_txt_path, .{});281 const abilist_txt_file = try fs.cwd().createFile(abilist_txt_path, .{});
279 defer abilist_txt_file.close();282 defer abilist_txt_file.close();
280 var buffered = std.io.BufferedOutStream(fs.File.WriteError).init(&abilist_txt_file.outStream().stream);283 var buffered = std.io.bufferedOutStream(abilist_txt_file.outStream());
281 const abilist_txt = &buffered.stream;284 const abilist_txt = buffered.outStream();
282285
283 // first iterate over the abi lists286 // first iterate over the abi lists
284 for (abi_lists) |*abi_list, abi_index| {287 for (abi_lists) |*abi_list, abi_index| {