Skip to content

Commit

Permalink
update zig sources to 0.14.0-dev.2246+bfcf18c5a
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Nov 16, 2024
1 parent 66c0f7a commit 40817f9
Show file tree
Hide file tree
Showing 653 changed files with 24,982 additions and 23,343 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ to find and inspect the patch diffs.
* LLVM, LLD, Clang 19.1.0
* zlib 1.3.1
* zstd 1.5.2
* zig 0.14.0-dev.1876+41dbd0d0d
* zig 0.14.0-dev.2246+bfcf18c5a

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

Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TARGET="$1" # Example: riscv64-linux-gnu
MCPU="$2" # Examples: `baseline`, `native`, `generic+v7a`, or `arm1176jzf_s`

ROOTDIR="$(pwd)"
ZIG_VERSION="0.14.0-dev.1876+41dbd0d0d"
ZIG_VERSION="0.14.0-dev.2246+bfcf18c5a"

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

Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if "%VSCMD_ARG_HOST_ARCH%"=="x86" set OUTDIR=out-win-x86

set ROOTDIR=%~dp0
set "ROOTDIR_CMAKE=%ROOTDIR:\=/%"
set ZIG_VERSION="0.14.0-dev.1876+41dbd0d0d"
set ZIG_VERSION="0.14.0-dev.2246+bfcf18c5a"
set JOBS_ARG=

pushd %ROOTDIR%
Expand Down
22 changes: 5 additions & 17 deletions zig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
lib/std/Target.zig
lib/std/Target/Query.zig
lib/std/Target/aarch64.zig
lib/std/Target/amdgpu.zig
lib/std/Target/amdgcn.zig
lib/std/Target/arm.zig
lib/std/Target/avr.zig
lib/std/Target/bpf.zig
Expand Down Expand Up @@ -522,6 +522,7 @@ set(ZIG_STAGE2_SOURCES
src/Sema.zig
src/Sema/bitcast.zig
src/Sema/comptime_ptr_access.zig
src/ThreadSafeQueue.zig
src/Type.zig
src/Value.zig
src/Zcu.zig
Expand Down Expand Up @@ -591,30 +592,25 @@ set(ZIG_STAGE2_SOURCES
src/link.zig
src/link/C.zig
src/link/Coff.zig
src/link/Coff/Atom.zig
src/link/Coff/ImportTable.zig
src/link/Coff/Object.zig
src/link/Coff/Relocation.zig
src/link/Coff/lld.zig
src/link/Dwarf.zig
src/link/Elf.zig
src/link/Elf/Archive.zig
src/link/Elf/Atom.zig
src/link/Elf/AtomList.zig
src/link/Elf/LdScript.zig
src/link/Elf/LinkerDefined.zig
src/link/Elf/Merge.zig
src/link/Elf/Object.zig
src/link/Elf/SharedObject.zig
src/link/Elf/Symbol.zig
src/link/Elf/Thunk.zig
src/link/Elf/ZigObject.zig
src/link/Elf/eh_frame.zig
src/link/Elf/file.zig
src/link/Elf/gc.zig
src/link/Elf/merge_section.zig
src/link/Elf/relocatable.zig
src/link/Elf/relocation.zig
src/link/Elf/synthetic_sections.zig
src/link/Elf/Thunk.zig
src/link/LdScript.zig
src/link/MachO.zig
src/link/MachO/Archive.zig
src/link/MachO/Atom.zig
Expand Down Expand Up @@ -652,12 +648,9 @@ set(ZIG_STAGE2_SOURCES
src/link/StringTable.zig
src/link/Wasm.zig
src/link/Wasm/Archive.zig
src/link/Wasm/Atom.zig
src/link/Wasm/Object.zig
src/link/Wasm/Symbol.zig
src/link/Wasm/ZigObject.zig
src/link/Wasm/file.zig
src/link/Wasm/types.zig
src/link/aarch64.zig
src/link/riscv.zig
src/link/table_section.zig
Expand Down Expand Up @@ -834,11 +827,6 @@ else()
endif()
endif()

option(ZIG2_NO_RTLIB "Build zig2 without linking to a compiler runtime library (for `zig cc` only)" OFF)
if(ZIG2_NO_RTLIB)
set(ZIG2_LINK_FLAGS "${ZIG2_LINK_FLAGS} -rtlib=none")
endif()

set(ZIG1_WASM_MODULE "${PROJECT_SOURCE_DIR}/stage1/zig1.wasm")
set(ZIG1_C_SOURCE "${PROJECT_BINARY_DIR}/zig1.c")
set(ZIG2_C_SOURCE "${PROJECT_BINARY_DIR}/zig2.c")
Expand Down
2 changes: 1 addition & 1 deletion zig/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int main(int argc, char **argv) {
if (f == NULL)
panic("unable to open config.zig for writing");

const char *zig_version = "0.14.0-dev.1876+41dbd0d0d";
const char *zig_version = "0.14.0-dev.2246+bfcf18c5a";

int written = fprintf(f,
"pub const have_llvm = false;\n"
Expand Down
31 changes: 14 additions & 17 deletions zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,17 @@ pub fn build(b: *std.Build) !void {
const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
const enable_tidy = b.option(bool, "enable-tidy", "Check langref output HTML validity") orelse false;
const enable_superhtml = b.option(bool, "enable-superhtml", "Check langref output HTML validity") orelse false;

const langref_file = generateLangRef(b);
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
const check_langref = tidyCheck(b, langref_file);
if (enable_tidy) install_langref.step.dependOn(check_langref);
// Checking autodocs is disabled because tidy gives a false positive:
// line 304 column 9 - Warning: moved <style> tag to <head>! fix-style-tags: no to avoid.
// I noticed that `--show-warnings no` still incorrectly causes exit code 1.
// I was unable to find an alternative to tidy.
//const check_autodocs = tidyCheck(b, b.path("lib/docs/index.html"));
if (enable_tidy) {
const check_langref = superHtmlCheck(b, langref_file);
if (enable_superhtml) install_langref.step.dependOn(check_langref);

const check_autodocs = superHtmlCheck(b, b.path("lib/docs/index.html"));
if (enable_superhtml) {
test_step.dependOn(check_langref);
//test_step.dependOn(check_autodocs);
test_step.dependOn(check_autodocs);
}
if (!skip_install_langref) {
b.getInstallStep().dependOn(&install_langref.step);
Expand Down Expand Up @@ -647,7 +644,7 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
.root_source_file = b.path("src/main.zig"),
.target = options.target,
.optimize = options.optimize,
.max_rss = 7_500_000_000,
.max_rss = 7_800_000_000,
.strip = options.strip,
.sanitize_thread = options.sanitize_thread,
.single_threaded = options.single_threaded,
Expand Down Expand Up @@ -1358,11 +1355,11 @@ fn generateLangRef(b: *std.Build) std.Build.LazyPath {
return docgen_cmd.addOutputFileArg("langref.html");
}

fn tidyCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
const run_tidy = b.addSystemCommand(&.{
"tidy", "--drop-empty-elements", "no", "-qe",
fn superHtmlCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
const run_superhtml = b.addSystemCommand(&.{
"superhtml", "check",
});
run_tidy.addFileArg(html_file);
run_tidy.expectExitCode(0);
return &run_tidy.step;
run_superhtml.addFileArg(html_file);
run_superhtml.expectExitCode(0);
return &run_superhtml.step;
}
37 changes: 22 additions & 15 deletions zig/doc/langref.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -2190,6 +2190,7 @@ or
<li>An {#link|enum#} field uses exactly the bit width of its integer tag type.</li>
<li>A {#link|packed union#} field uses exactly the bit width of the union field with
the largest bit width.</li>
<li>Packed structs support equality operators.</li>
</ul>
<p>
This means that a {#syntax#}packed struct{#endsyntax#} can participate
Expand Down Expand Up @@ -2240,6 +2241,12 @@ or
</p>
{#code|test_aligned_struct_fields.zig#}

<p>
Equating packed structs results in a comparison of the backing integer,
and only works for the `==` and `!=` operators.
</p>
{#code|test_packed_struct_equality.zig#}

<p>
Using packed structs with {#link|volatile#} is problematic, and may be a compile error in the future.
For details on this subscribe to
Expand Down Expand Up @@ -4616,7 +4623,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_close#}

{#header_open|@compileLog#}
<pre>{#syntax#}@compileLog(args: ...) void{#endsyntax#}</pre>
<pre>{#syntax#}@compileLog(...) void{#endsyntax#}</pre>
<p>
This function prints the arguments passed to it at compile-time.
</p>
Expand Down Expand Up @@ -4872,6 +4879,13 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
</p>
{#header_close#}

{#header_open|@FieldType#}
<pre>{#syntax#}@FieldType(comptime Type: type, comptime field_name: []const u8) type{#endsyntax#}</pre>
<p>
Given a type and the name of one of its fields, returns the type of that field.
</p>
{#header_close#}

{#header_open|@floatCast#}
<pre>{#syntax#}@floatCast(value: anytype) anytype{#endsyntax#}</pre>
<p>
Expand Down Expand Up @@ -5054,12 +5068,12 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_close#}

{#header_open|@max#}
<pre>{#syntax#}@max(a: T, b: T) T{#endsyntax#}</pre>
<pre>{#syntax#}@max(...) T{#endsyntax#}</pre>
<p>
Returns the maximum value of {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#}. This builtin accepts integers, floats, and vectors of either. In the latter case, the operation is performed element wise.
Takes two or more arguments and returns the biggest value included (the maximum). This builtin accepts integers, floats, and vectors of either. In the latter case, the operation is performed element wise.
</p>
<p>
NaNs are handled as follows: if one of the operands of a (pairwise) operation is NaN, the other operand is returned. If both operands are NaN, NaN is returned.
NaNs are handled as follows: return the biggest non-NaN value included. If all operands are NaN, return NaN.
</p>
{#see_also|@min|Vectors#}
{#header_close#}
Expand Down Expand Up @@ -5093,12 +5107,12 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_close#}

{#header_open|@min#}
<pre>{#syntax#}@min(a: T, b: T) T{#endsyntax#}</pre>
<pre>{#syntax#}@min(...) T{#endsyntax#}</pre>
<p>
Returns the minimum value of {#syntax#}a{#endsyntax#} and {#syntax#}b{#endsyntax#}. This builtin accepts integers, floats, and vectors of either. In the latter case, the operation is performed element wise.
Takes two or more arguments and returns the smallest value included (the minimum). This builtin accepts integers, floats, and vectors of either. In the latter case, the operation is performed element wise.
</p>
<p>
NaNs are handled as follows: if one of the operands of a (pairwise) operation is NaN, the other operand is returned. If both operands are NaN, NaN is returned.
NaNs are handled as follows: return the smallest non-NaN value included. If all operands are NaN, return NaN.
</p>
{#see_also|@max|Vectors#}
{#header_close#}
Expand Down Expand Up @@ -5281,13 +5295,6 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#see_also|Vectors#}
{#header_close#}

{#header_open|@setAlignStack#}
<pre>{#syntax#}@setAlignStack(comptime alignment: u29) void{#endsyntax#}</pre>
<p>
Ensures that a function will have a stack alignment of at least {#syntax#}alignment{#endsyntax#} bytes.
</p>
{#header_close#}

{#header_open|@setEvalBranchQuota#}
<pre>{#syntax#}@setEvalBranchQuota(comptime new_quota: u32) void{#endsyntax#}</pre>
<p>
Expand Down Expand Up @@ -5781,7 +5788,7 @@ fn cmpxchgWeakButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_val
{#header_open|@TypeOf#}
<pre>{#syntax#}@TypeOf(...) type{#endsyntax#}</pre>
<p>
{#syntax#}@TypeOf{#endsyntax#} is a special builtin function that takes any (nonzero) number of expressions
{#syntax#}@TypeOf{#endsyntax#} is a special builtin function that takes any (non-zero) number of expressions
as parameters and returns the type of the result, using {#link|Peer Type Resolution#}.
</p>
<p>
Expand Down
2 changes: 1 addition & 1 deletion zig/doc/langref/builtin.CallModifier struct.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub const CallModifier = enum {
/// If this is not possible, a compile error is emitted instead.
always_tail,

/// Guarantees that the call will inlined at the callsite.
/// Guarantees that the call will be inlined at the callsite.
/// If this is not possible, a compile error is emitted instead.
always_inline,

Expand Down
3 changes: 2 additions & 1 deletion zig/doc/langref/enum_export_error.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ export fn entry(foo: Foo) void {
_ = foo;
}

// obj=parameter of type 'enum_export_error.Foo' not allowed in function with calling convention 'C'
// obj=parameter of type 'enum_export_error.Foo' not allowed in function with calling convention 'x86_64_sysv'
// target=x86_64-linux
14 changes: 14 additions & 0 deletions zig/doc/langref/test_packed_struct_equality.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const std = @import("std");
const expect = std.testing.expect;

test "packed struct equality" {
const S = packed struct {
a: u4,
b: u4,
};
const x: S = .{ .a = 1, .b = 2 };
const y: S = .{ .b = 2, .a = 1 };
try expect(x == y);
}

// test
36 changes: 10 additions & 26 deletions zig/doc/langref/test_structs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,13 @@ const Point = struct {
y: f32,
};

// Maybe we want to pass it to OpenGL so we want to be particular about
// how the bytes are arranged.
const Point2 = packed struct {
x: f32,
y: f32,
};

// Declare an instance of a struct.
const p = Point{
const p: Point = .{
.x = 0.12,
.y = 0.34,
};

// Maybe we're not ready to fill out some of the fields.
var p2 = Point{
.x = 0.12,
.y = undefined,
};

// Structs can have methods
// Struct methods are not special, they are only namespaced
// functions that you can call with dot syntax.
// Functions in the struct's namespace can be called with dot syntax.
const Vec3 = struct {
x: f32,
y: f32,
Expand All @@ -46,7 +31,6 @@ const Vec3 = struct {
}
};

const expect = @import("std").testing.expect;
test "dot product" {
const v1 = Vec3.init(1.0, 0.0, 0.0);
const v2 = Vec3.init(0.0, 1.0, 0.0);
Expand All @@ -67,14 +51,14 @@ test "struct namespaced variable" {
try expect(Empty.PI == 3.14);
try expect(@sizeOf(Empty) == 0);

// you can still instantiate an empty struct
const does_nothing = Empty{};
// Empty structs can be instantiated the same as usual.
const does_nothing: Empty = .{};

_ = does_nothing;
}

// struct field order is determined by the compiler for optimal performance.
// however, you can still calculate a struct base pointer given a field pointer:
// Struct field order is determined by the compiler, however, a base pointer
// can be computed from a field pointer:
fn setYBasedOnX(x: *f32, y: f32) void {
const point: *Point = @fieldParentPtr("x", x);
point.y = y;
Expand All @@ -88,8 +72,7 @@ test "field parent pointer" {
try expect(point.y == 0.9);
}

// You can return a struct from a function. This is how we do generics
// in Zig:
// Structs can be returned from functions.
fn LinkedList(comptime T: type) type {
return struct {
pub const Node = struct {
Expand All @@ -105,8 +88,7 @@ fn LinkedList(comptime T: type) type {
}

test "linked list" {
// Functions called at compile-time are memoized. This means you can
// do this:
// Functions called at compile-time are memoized.
try expect(LinkedList(i32) == LinkedList(i32));

const list = LinkedList(i32){
Expand Down Expand Up @@ -139,4 +121,6 @@ test "linked list" {
// instead of try expect(list2.first.?.*.data == 1234);
}

const expect = @import("std").testing.expect;

// test
Loading

0 comments on commit 40817f9

Please sign in to comment.