Skip to content

Commit 080c0e3

Browse files
committed
update zig sources to 0.15.0-dev.622+55848363f
1 parent c80963c commit 080c0e3

File tree

4,840 files changed

+810849
-66021
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

4,840 files changed

+810849
-66021
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ to find and inspect the patch diffs.
1111
* LLVM, LLD, Clang 20.1.2
1212
* zlib 1.3.1
1313
* zstd 1.5.2
14-
* zig 0.15.0-dev.317+fa5915389
14+
* zig 0.15.0-dev.622+55848363f
1515

1616
For other versions, check the git tags of this repository.
1717

build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TARGET="$1" # Example: riscv64-linux-gnu
77
MCPU="$2" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`
88

99
ROOTDIR="$(pwd)"
10-
ZIG_VERSION="0.15.0-dev.317+fa5915389"
10+
ZIG_VERSION="0.15.0-dev.622+55848363f"
1111

1212
TARGET_OS_AND_ABI=${TARGET#*-} # Example: linux-gnu
1313

build.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if "%VSCMD_ARG_HOST_ARCH%"=="x86" set OUTDIR=out-win-x86
3636

3737
set ROOTDIR=%~dp0
3838
set "ROOTDIR_CMAKE=%ROOTDIR:\=/%"
39-
set ZIG_VERSION="0.15.0-dev.317+fa5915389"
39+
set ZIG_VERSION="0.15.0-dev.622+55848363f"
4040
set JOBS_ARG=
4141

4242
pushd %ROOTDIR%

zig/CMakeLists.txt

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ set(ZIG_STATIC_LLVM ${ZIG_STATIC} CACHE BOOL "Prefer linking against static LLVM
9090
set(ZIG_STATIC_ZLIB ${ZIG_STATIC} CACHE BOOL "Prefer linking against static zlib")
9191
set(ZIG_STATIC_ZSTD ${ZIG_STATIC} CACHE BOOL "Prefer linking against static zstd")
9292
set(ZIG_STATIC_CURSES OFF CACHE BOOL "Enable static linking against curses")
93+
set(ZIG_STATIC_LIBXML2 OFF CACHE BOOL "Enable static linking against libxml2")
9394

9495
if (ZIG_SHARED_LLVM AND ZIG_STATIC_LLVM)
9596
message(SEND_ERROR "-DZIG_SHARED_LLVM and -DZIG_STATIC_LLVM cannot both be enabled simultaneously")
@@ -167,6 +168,12 @@ if(ZIG_STATIC_CURSES)
167168
list(APPEND LLVM_LIBRARIES "${CURSES}")
168169
endif()
169170

171+
if(ZIG_STATIC_LIBXML2)
172+
list(REMOVE_ITEM LLVM_LIBRARIES "-lxml2")
173+
find_library(LIBXML2 NAMES libxml2.a NAMES_PER_DIR)
174+
list(APPEND LLVM_LIBRARIES "${LIBXML2}")
175+
endif()
176+
170177
find_package(Threads)
171178

172179
set(ZIG_CONFIG_H_OUT "${PROJECT_BINARY_DIR}/config.h")
@@ -536,6 +543,7 @@ set(ZIG_STAGE2_SOURCES
536543
src/arch/arm/Mir.zig
537544
src/arch/arm/abi.zig
538545
src/arch/arm/bits.zig
546+
src/arch/powerpc/CodeGen.zig
539547
src/arch/riscv64/abi.zig
540548
src/arch/riscv64/bits.zig
541549
src/arch/riscv64/CodeGen.zig
@@ -579,11 +587,13 @@ set(ZIG_STAGE2_SOURCES
579587
src/codegen/spirv/spec.zig
580588
src/crash_report.zig
581589
src/dev.zig
582-
src/glibc.zig
590+
src/libs/freebsd.zig
591+
src/libs/glibc.zig
592+
src/libs/netbsd.zig
583593
src/introspect.zig
584-
src/libcxx.zig
585-
src/libtsan.zig
586-
src/libunwind.zig
594+
src/libs/libcxx.zig
595+
src/libs/libtsan.zig
596+
src/libs/libunwind.zig
587597
src/link.zig
588598
src/link/C.zig
589599
src/link/Coff.zig
@@ -605,6 +615,7 @@ set(ZIG_STAGE2_SOURCES
605615
src/link/Elf/relocatable.zig
606616
src/link/Elf/relocation.zig
607617
src/link/Elf/synthetic_sections.zig
618+
src/link/Goff.zig
608619
src/link/LdScript.zig
609620
src/link/MachO.zig
610621
src/link/MachO/Archive.zig
@@ -632,7 +643,6 @@ set(ZIG_STAGE2_SOURCES
632643
src/link/MachO/synthetic.zig
633644
src/link/MachO/Thunk.zig
634645
src/link/MachO/uuid.zig
635-
src/link/NvPtx.zig
636646
src/link/Plan9.zig
637647
src/link/Plan9/aout.zig
638648
src/link/SpirV.zig
@@ -645,6 +655,7 @@ set(ZIG_STAGE2_SOURCES
645655
src/link/Wasm/Archive.zig
646656
src/link/Wasm/Flush.zig
647657
src/link/Wasm/Object.zig
658+
src/link/Xcoff.zig
648659
src/link/aarch64.zig
649660
src/link/riscv.zig
650661
src/link/table_section.zig
@@ -655,8 +666,8 @@ set(ZIG_STAGE2_SOURCES
655666
src/link/tapi/yaml.zig
656667
src/link/tapi/yaml/test.zig
657668
src/main.zig
658-
src/mingw.zig
659-
src/musl.zig
669+
src/libs/mingw.zig
670+
src/libs/musl.zig
660671
src/mutable_value.zig
661672
src/print_air.zig
662673
src/print_env.zig
@@ -667,7 +678,7 @@ set(ZIG_STAGE2_SOURCES
667678
src/target.zig
668679
src/tracy.zig
669680
src/translate_c.zig
670-
src/wasi_libc.zig
681+
src/libs/wasi_libc.zig
671682
)
672683

673684
if(MSVC)
@@ -944,12 +955,24 @@ if(ZIG_EXTRA_BUILD_ARGS)
944955
list(APPEND ZIG_BUILD_ARGS ${ZIG_EXTRA_BUILD_ARGS})
945956
endif()
946957

958+
set(ZIG_RELEASE_SAFE OFF CACHE BOOL "Build Zig as ReleaseSafe (with debug assertions on)")
959+
947960
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
948961
list(APPEND ZIG_BUILD_ARGS -Doptimize=Debug)
949-
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
950-
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
951962
else()
952-
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast -Dstrip)
963+
if("${CMAKE_BUILD_TYPE}" STREQUAL "MinSizeRel")
964+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSmall)
965+
else()
966+
# Release and RelWithDebInfo
967+
if(ZIG_RELEASE_SAFE)
968+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseSafe)
969+
else()
970+
list(APPEND ZIG_BUILD_ARGS -Doptimize=ReleaseFast)
971+
endif()
972+
if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
973+
list(APPEND ZIG_BUILD_ARGS -Dstrip)
974+
endif()
975+
endif()
953976
endif()
954977

955978
if(ZIG_STATIC AND NOT MSVC)

zig/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Ensure you have the required dependencies:
4747

4848
* CMake >= 3.15
4949
* System C/C++ Toolchain
50-
* LLVM, Clang, LLD development libraries == 19.x
50+
* LLVM, Clang, LLD development libraries == 20.x
5151

5252
Then it is the standard CMake build process:
5353

zig/bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ int main(int argc, char **argv) {
123123
if (f == NULL)
124124
panic("unable to open config.zig for writing");
125125

126-
const char *zig_version = "0.15.0-dev.317+fa5915389";
126+
const char *zig_version = "0.15.0-dev.622+55848363f";
127127

128128
int written = fprintf(f,
129129
"pub const have_llvm = false;\n"

zig/build.zig

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,6 @@ pub fn build(b: *std.Build) !void {
197197
exe.pie = pie;
198198
exe.entitlements = entitlements;
199199

200-
exe.build_id = b.option(
201-
std.zig.BuildId,
202-
"build-id",
203-
"Request creation of '.note.gnu.build-id' section",
204-
);
205-
206200
if (no_bin) {
207201
b.getInstallStep().dependOn(&exe.step);
208202
} else {
@@ -443,7 +437,8 @@ pub fn build(b: *std.Build) !void {
443437
.skip_non_native = skip_non_native,
444438
.skip_libc = skip_libc,
445439
.use_llvm = use_llvm,
446-
.max_rss = 2 * 1024 * 1024 * 1024,
440+
// 2262585344 was observed on an x86_64-linux-gnu host.
441+
.max_rss = 2488843878,
447442
}));
448443

449444
test_modules_step.dependOn(tests.addModuleTests(b, .{
@@ -482,8 +477,8 @@ pub fn build(b: *std.Build) !void {
482477
.test_target_filters = test_target_filters,
483478
.test_extra_targets = test_extra_targets,
484479
.root_src = "lib/c.zig",
485-
.name = "universal-libc",
486-
.desc = "Run the universal libc tests",
480+
.name = "zigc",
481+
.desc = "Run the zigc tests",
487482
.optimize_modes = optimization_modes,
488483
.include_paths = &.{},
489484
.skip_single_threaded = true,
@@ -514,18 +509,19 @@ pub fn build(b: *std.Build) !void {
514509
test_step.dependOn(unit_tests_step);
515510

516511
const unit_tests = b.addTest(.{
517-
.root_module = b.createModule(.{
518-
.root_source_file = b.path("src/main.zig"),
512+
.root_module = addCompilerMod(b, .{
519513
.optimize = optimize,
520514
.target = target,
521-
.link_libc = link_libc,
522515
.single_threaded = single_threaded,
523516
}),
524517
.filters = test_filters,
525518
.use_llvm = use_llvm,
526519
.use_lld = use_llvm,
527520
.zig_lib_dir = b.path("lib"),
528521
});
522+
if (link_libc) {
523+
unit_tests.root_module.link_libc = true;
524+
}
529525
unit_tests.root_module.addOptions("build_options", exe_options);
530526
unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step);
531527

@@ -556,6 +552,11 @@ pub fn build(b: *std.Build) !void {
556552
.skip_non_native = skip_non_native,
557553
.skip_libc = skip_libc,
558554
})) |test_debugger_step| test_step.dependOn(test_debugger_step);
555+
if (tests.addLlvmIrTests(b, .{
556+
.enable_llvm = enable_llvm,
557+
.test_filters = test_filters,
558+
.test_target_filters = test_target_filters,
559+
})) |test_llvm_ir_step| test_step.dependOn(test_llvm_ir_step);
559560

560561
try addWasiUpdateStep(b, version);
561562

@@ -651,7 +652,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
651652
update_zig1_step.dependOn(&copy_zig_h.step);
652653
}
653654

654-
const AddCompilerStepOptions = struct {
655+
const AddCompilerModOptions = struct {
655656
optimize: std.builtin.OptimizeMode,
656657
target: std.Build.ResolvedTarget,
657658
strip: ?bool = null,
@@ -660,7 +661,7 @@ const AddCompilerStepOptions = struct {
660661
single_threaded: ?bool = null,
661662
};
662663

663-
fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile {
664+
fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Module {
664665
const compiler_mod = b.createModule(.{
665666
.root_source_file = b.path("src/main.zig"),
666667
.target = options.target,
@@ -683,10 +684,14 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
683684
compiler_mod.addImport("aro", aro_mod);
684685
compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);
685686

687+
return compiler_mod;
688+
}
689+
690+
fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile {
686691
const exe = b.addExecutable(.{
687692
.name = "zig",
688693
.max_rss = 7_800_000_000,
689-
.root_module = compiler_mod,
694+
.root_module = addCompilerMod(b, options),
690695
});
691696
exe.stack_size = stack_size;
692697

zig/doc/langref.html.in

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,7 @@ unwrapped == 1234{#endsyntax#}</pre>
16491649
<li>{#link|Floats#}</li>
16501650
<li>{#link|bool|Primitive Types#}</li>
16511651
<li>{#link|type|Primitive Types#}</li>
1652+
<li>{#link|packed struct#}</li>
16521653
</ul>
16531654
</td>
16541655
<td>
@@ -2224,31 +2225,36 @@ or
22242225

22252226
{#header_open|packed struct#}
22262227
<p>
2227-
Unlike normal structs, {#syntax#}packed{#endsyntax#} structs have guaranteed in-memory layout:
2228+
{#syntax#}packed{#endsyntax#} structs, like {#syntax#}enum{#endsyntax#}, are based on the concept
2229+
of interpreting integers differently. All packed structs have a <strong>backing integer</strong>,
2230+
which is implicitly determined by the total bit count of fields, or explicitly specified.
2231+
Packed structs have well-defined memory layout - exactly the same ABI as their backing integer.
2232+
</p>
2233+
<p>
2234+
Each field of a packed struct is interpreted as a logical sequence of bits, arranged from
2235+
least to most significant. Allowed field types:
22282236
</p>
22292237
<ul>
2230-
<li>Fields remain in the order declared, least to most significant.</li>
2231-
<li>There is no padding between fields.</li>
2232-
<li>Zig supports arbitrary width {#link|Integers#} and although normally, integers with fewer
2233-
than 8 bits will still use 1 byte of memory, in packed structs, they use
2234-
exactly their bit width.
2235-
</li>
2236-
<li>{#syntax#}bool{#endsyntax#} fields use exactly 1 bit.</li>
2238+
<li>An {#link|integer|Integers#} field uses exactly as many bits as its
2239+
bit width. For example, a {#syntax#}u5{#endsyntax#} will use 5 bits of
2240+
the backing integer.</li>
2241+
<li>A {#link|bool|Primitive Types#} field uses exactly 1 bit.</li>
22372242
<li>An {#link|enum#} field uses exactly the bit width of its integer tag type.</li>
22382243
<li>A {#link|packed union#} field uses exactly the bit width of the union field with
22392244
the largest bit width.</li>
2240-
<li>Packed structs support equality operators.</li>
2245+
<li>A {#syntax#}packed struct{#endsyntax#} field uses the bits of its backing integer.</li>
22412246
</ul>
22422247
<p>
22432248
This means that a {#syntax#}packed struct{#endsyntax#} can participate
22442249
in a {#link|@bitCast#} or a {#link|@ptrCast#} to reinterpret memory.
22452250
This even works at {#link|comptime#}:
22462251
</p>
22472252
{#code|test_packed_structs.zig#}
2248-
22492253
<p>
2250-
The backing integer is inferred from the fields' total bit width.
2251-
Optionally, it can be explicitly provided and enforced at compile time:
2254+
The backing integer can be inferred or explicitly provided. When
2255+
inferred, it will be unsigned. When explicitly provided, its bit width
2256+
will be enforced at compile time to exactly match the total bit width of
2257+
the fields:
22522258
</p>
22532259
{#code|test_missized_packed_struct.zig#}
22542260

@@ -2290,18 +2296,18 @@ or
22902296

22912297
<p>
22922298
Equating packed structs results in a comparison of the backing integer,
2293-
and only works for the `==` and `!=` operators.
2299+
and only works for the {#syntax#}=={#endsyntax#} and {#syntax#}!={#endsyntax#} {#link|Operators#}.
22942300
</p>
22952301
{#code|test_packed_struct_equality.zig#}
22962302

22972303
<p>
2298-
Using packed structs with {#link|volatile#} is problematic, and may be a compile error in the future.
2299-
For details on this subscribe to
2300-
<a href="https://github.com/ziglang/zig/issues/1761">this issue</a>.
2301-
TODO update these docs with a recommendation on how to use packed structs with MMIO
2302-
(the use case for volatile packed structs) once this issue is resolved.
2303-
Don't worry, there will be a good solution for this use case in zig.
2304+
Field access and assignment can be understood as shorthand for bitshifts
2305+
on the backing integer. These operations are not {#link|atomic|Atomics#},
2306+
so beware using field access syntax when combined with memory-mapped
2307+
input-output (MMIO). Instead of field access on {#link|volatile#} {#link|Pointers#},
2308+
construct a fully-formed new value first, then write that value to the volatile pointer.
23042309
</p>
2310+
{#code|packed_struct_mmio.zig#}
23052311
{#header_close#}
23062312

23072313
{#header_open|Struct Naming#}
@@ -5143,6 +5149,23 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
51435149
{#syntax#}std.crypto.secureZero{#endsyntax#}</p>
51445150
{#header_close#}
51455151

5152+
{#header_open|@memmove#}
5153+
<pre>{#syntax#}@memmove(dest, source) void{#endsyntax#}</pre>
5154+
<p>This function copies bytes from one region of memory to another, but unlike
5155+
{#link|@memcpy#} the regions may overlap.</p>
5156+
<p>{#syntax#}dest{#endsyntax#} must be a mutable slice, a mutable pointer to an array, or
5157+
a mutable many-item {#link|pointer|Pointers#}. It may have any
5158+
alignment, and it may have any element type.</p>
5159+
<p>{#syntax#}source{#endsyntax#} must be a slice, a pointer to
5160+
an array, or a many-item {#link|pointer|Pointers#}. It may
5161+
have any alignment, and it may have any element type.</p>
5162+
<p>The {#syntax#}source{#endsyntax#} element type must have the same in-memory
5163+
representation as the {#syntax#}dest{#endsyntax#} element type.</p>
5164+
<p>Similar to {#link|for#} loops, at least one of {#syntax#}source{#endsyntax#} and
5165+
{#syntax#}dest{#endsyntax#} must provide a length, and if two lengths are provided,
5166+
they must be equal.</p>
5167+
{#header_close#}
5168+
51465169
{#header_open|@min#}
51475170
<pre>{#syntax#}@min(...) T{#endsyntax#}</pre>
51485171
<p>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pub const GpioRegister = packed struct(u8) {
2+
GPIO0: bool,
3+
GPIO1: bool,
4+
GPIO2: bool,
5+
GPIO3: bool,
6+
reserved: u4 = 0,
7+
};
8+
9+
const gpio: *volatile GpioRegister = @ptrFromInt(0x0123);
10+
11+
pub fn writeToGpio(new_states: GpioRegister) void {
12+
// Example of what not to do:
13+
// BAD! gpio.GPIO0 = true; BAD!
14+
15+
// Instead, do this:
16+
gpio.* = new_states;
17+
}
18+
19+
// syntax

0 commit comments

Comments
 (0)