Skip to content

Commit

Permalink
update zig sources to 0.14.0-dev.1294+df6907f60
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Aug 23, 2024
1 parent ca5f172 commit 6bcacb4
Show file tree
Hide file tree
Showing 171 changed files with 13,891 additions and 7,893 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 18.1.8
* zlib 1.3.1
* zstd 1.5.2
* zig 0.14.0-dev.1078+0f0f543a9
* zig 0.14.0-dev.1294+df6907f60

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.1078+0f0f543a9"
ZIG_VERSION="0.14.0-dev.1294+df6907f60"

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.1078+0f0f543a9"
set ZIG_VERSION="0.14.0-dev.1294+df6907f60"
set JOBS_ARG=

pushd %ROOTDIR%
Expand Down
18 changes: 11 additions & 7 deletions zig/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,25 @@ This produces a `zig2` executable in the current working directory. This is a
[without LLVM extensions](https://github.com/ziglang/zig/issues/16270), and is
therefore lacking these features:
- Release mode optimizations
- aarch64 machine code backend
- `@cImport` / `zig translate-c`
- Ability to compile C files
- Ability to compile assembly files
- [aarch64 machine code backend](https://github.com/ziglang/zig/issues/21172)
- [@cImport](https://github.com/ziglang/zig/issues/20630)
- [zig translate-c](https://github.com/ziglang/zig/issues/20875)
- [Ability to compile assembly files](https://github.com/ziglang/zig/issues/21169)
- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
- [Automatic importlib file generation for Windows DLLs](https://github.com/ziglang/zig/issues/17753)
- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
- Ability to compile C++, Objective-C, and Objective-C++ files
- Ability to compile C, C++, Objective-C, and Objective-C++ files

However, a compiler built this way does provide a C backend, which may be
useful for creating system packages of Zig projects using the system C
toolchain. In such case, LLVM is not needed!
toolchain. **In this case, LLVM is not needed!**

Furthermore, a compiler built this way provides an LLVM backend that produces
bitcode files, which may be compiled into object files via a system Clang
package. This can be used to produce system packages of Zig applications
without the Zig package dependency on LLVM.

## Contributing

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.1078+0f0f543a9";
const char *zig_version = "0.14.0-dev.1294+df6907f60";

int written = fprintf(f,
"pub const have_llvm = false;\n"
Expand Down
71 changes: 48 additions & 23 deletions zig/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ pub fn build(b: *std.Build) !void {
}

const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
const test_target_filters = b.option([]const []const u8, "test-target-filter", "Skip tests whose target triple do not match any filter") orelse &[0][]const u8{};
const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false;

const test_cases_options = b.addOptions();

Expand Down Expand Up @@ -455,8 +457,12 @@ pub fn build(b: *std.Build) !void {
});
test_step.dependOn(test_cases_step);

test_step.dependOn(tests.addModuleTests(b, .{
const test_modules_step = b.step("test-modules", "Run the per-target module tests");

test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "test/behavior.zig",
.name = "behavior",
.desc = "Run the behavior tests",
Expand All @@ -468,8 +474,10 @@ pub fn build(b: *std.Build) !void {
.max_rss = 1 * 1024 * 1024 * 1024,
}));

test_step.dependOn(tests.addModuleTests(b, .{
test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "test/c_import.zig",
.name = "c-import",
.desc = "Run the @cImport tests",
Expand All @@ -480,8 +488,10 @@ pub fn build(b: *std.Build) !void {
.skip_libc = skip_libc,
}));

test_step.dependOn(tests.addModuleTests(b, .{
test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/compiler_rt.zig",
.name = "compiler-rt",
.desc = "Run the compiler_rt tests",
Expand All @@ -493,8 +503,10 @@ pub fn build(b: *std.Build) !void {
.no_builtin = true,
}));

test_step.dependOn(tests.addModuleTests(b, .{
test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/c.zig",
.name = "universal-libc",
.desc = "Run the universal libc tests",
Expand All @@ -506,6 +518,24 @@ pub fn build(b: *std.Build) !void {
.no_builtin = true,
}));

test_modules_step.dependOn(tests.addModuleTests(b, .{
.test_filters = test_filters,
.test_target_filters = test_target_filters,
.test_slow_targets = test_slow_targets,
.root_src = "lib/std/std.zig",
.name = "std",
.desc = "Run the standard library tests",
.optimize_modes = optimization_modes,
.include_paths = &.{},
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_libc = skip_libc,
// I observed a value of 4572626944 on the M2 CI.
.max_rss = 5029889638,
}));

test_step.dependOn(test_modules_step);

test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addStandaloneTests(
b,
Expand All @@ -519,39 +549,34 @@ pub fn build(b: *std.Build) !void {
test_step.dependOn(tests.addStackTraceTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addCliTests(b));
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filters, optimization_modes));
test_step.dependOn(tests.addModuleTests(b, .{
if (tests.addDebuggerTests(b, .{
.test_filters = test_filters,
.root_src = "lib/std/std.zig",
.name = "std",
.desc = "Run the standard library tests",
.gdb = b.option([]const u8, "gdb", "path to gdb binary"),
.lldb = b.option([]const u8, "lldb", "path to lldb binary"),
.optimize_modes = optimization_modes,
.include_paths = &.{},
.skip_single_threaded = skip_single_threaded,
.skip_non_native = skip_non_native,
.skip_libc = skip_libc,
// I observed a value of 4572626944 on the M2 CI.
.max_rss = 5029889638,
}));
})) |test_debugger_step| test_step.dependOn(test_debugger_step);

try addWasiUpdateStep(b, version);

const update_mingw_step = b.step("update-mingw", "Update zig's bundled mingw");
const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory");
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.graph.host,
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(b.path("lib"));
if (opt_mingw_src_path) |mingw_src_path| {
const update_mingw_exe = b.addExecutable(.{
.name = "update_mingw",
.target = b.graph.host,
.root_source_file = b.path("tools/update_mingw.zig"),
});
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
update_mingw_run.addDirectoryArg(b.path("lib"));
update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });

update_mingw_step.dependOn(&update_mingw_run.step);
} else {
// Intentionally cause an error if this build step is requested.
update_mingw_run.addArg("--missing-mingw-source-directory");
update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step);
}

update_mingw_step.dependOn(&update_mingw_run.step);
}

fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
Expand Down
1 change: 1 addition & 0 deletions zig/cmake/Findclang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if(${LLVM_LINK_MODE} STREQUAL "shared")
find_library(CLANG_LIBRARIES
NAMES
libclang-cpp.so.18
libclang-cpp.so.18.1
clang-cpp-18.0
clang-cpp180
clang-cpp
Expand Down
2 changes: 1 addition & 1 deletion zig/lib/compiler/aro/aro/Builtins/Builtin.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ const dafsa = [_]Node{
.{ .char = 'e', .end_of_word = false, .end_of_list = true, .number = 1, .child_index = 4913 },
};
pub const data = blk: {
@setEvalBranchQuota(3986);
@setEvalBranchQuota(30_000);
break :blk [_]@This(){
// _Block_object_assign
.{ .tag = @enumFromInt(0), .properties = .{ .param_str = "vv*vC*iC", .header = .blocks, .attributes = .{ .lib_function_without_prefix = true } } },
Expand Down
1 change: 0 additions & 1 deletion zig/lib/compiler/aro/aro/Compilation.zig
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ fn generateDateAndTime(w: anytype, timestamp: u47) !void {
});

const day_names = [_][]const u8{ "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
// days since Thu Oct 1 1970
const day_name = day_names[@intCast((epoch_day.day + 3) % 7)];
try w.print("#define __TIMESTAMP__ \"{s} {s} {d: >2} {d:0>2}:{d:0>2}:{d:0>2} {d}\"\n", .{
day_name,
Expand Down
2 changes: 2 additions & 0 deletions zig/lib/compiler/aro/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4802,6 +4802,7 @@ const CallExpr = union(enum) {
}

fn shouldPromoteVarArg(self: CallExpr, arg_idx: u32) bool {
@setEvalBranchQuota(2000);
return switch (self) {
.standard => true,
.builtin => |builtin| switch (builtin.tag) {
Expand Down Expand Up @@ -4902,6 +4903,7 @@ const CallExpr = union(enum) {
}

fn returnType(self: CallExpr, p: *Parser, callable_ty: Type) Type {
@setEvalBranchQuota(6000);
return switch (self) {
.standard => callable_ty.returnType(),
.builtin => |builtin| switch (builtin.tag) {
Expand Down
2 changes: 1 addition & 1 deletion zig/lib/compiler/aro/backend/Object/Elf.zig
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ pub fn finish(elf: *Elf, file: std.fs.File) !void {
const elf_header = std.elf.Elf64_Ehdr{
.e_ident = .{ 0x7F, 'E', 'L', 'F', 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
.e_type = std.elf.ET.REL, // we only produce relocatables
.e_machine = elf.obj.target.cpu.arch.toElfMachine(),
.e_machine = elf.obj.target.toElfMachine(),
.e_version = 1,
.e_entry = 0, // linker will handle this
.e_phoff = 0, // no program header
Expand Down
7 changes: 4 additions & 3 deletions zig/lib/compiler/objcopy.zig
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ fn cmdObjCopy(
if (seen_update) fatal("zig objcopy only supports 1 update for now", .{});
seen_update = true;

try server.serveEmitBinPath(output, .{
.flags = .{ .cache_hit = false },
});
// The build system already knows what the output is at this point, we
// only need to communicate that the process has finished.
// Use the empty error bundle to indicate that the update is done.
try server.serveErrorBundle(std.zig.ErrorBundle.empty);
},
else => fatal("unsupported message: {s}", .{@tagName(hdr.tag)}),
}
Expand Down
40 changes: 8 additions & 32 deletions zig/lib/compiler/std-docs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,16 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void {
},
},
});
const w = response.writer();

var std_dir = try context.lib_dir.openDir("std", .{ .iterate = true });
defer std_dir.close();

var walker = try std_dir.walk(gpa);
defer walker.deinit();

var archiver = std.tar.writer(response.writer());
archiver.prefix = "std";

while (try walker.next()) |entry| {
switch (entry.kind) {
.file => {
Expand All @@ -199,47 +201,21 @@ fn serveSourcesTar(request: *std.http.Server.Request, context: *Context) !void {
},
else => continue,
}

var file = try std_dir.openFile(entry.path, .{});
var file = try entry.dir.openFile(entry.basename, .{});
defer file.close();

const stat = try file.stat();
const padding = p: {
const remainder = stat.size % 512;
break :p if (remainder > 0) 512 - remainder else 0;
};

var file_header = std.tar.output.Header.init();
file_header.typeflag = .regular;
try file_header.setPath("std", entry.path);
try file_header.setSize(stat.size);
try file_header.updateChecksum();
try w.writeAll(std.mem.asBytes(&file_header));
try w.writeFile(file);
try w.writeByteNTimes(0, padding);
try archiver.writeFile(entry.path, file);
}

{
// Since this command is JIT compiled, the builtin module available in
// this source file corresponds to the user's host system.
const builtin_zig = @embedFile("builtin");

var file_header = std.tar.output.Header.init();
file_header.typeflag = .regular;
try file_header.setPath("builtin", "builtin.zig");
try file_header.setSize(builtin_zig.len);
try file_header.updateChecksum();
try w.writeAll(std.mem.asBytes(&file_header));
try w.writeAll(builtin_zig);
const padding = p: {
const remainder = builtin_zig.len % 512;
break :p if (remainder > 0) 512 - remainder else 0;
};
try w.writeByteNTimes(0, padding);
archiver.prefix = "builtin";
try archiver.writeFileBytes("builtin.zig", builtin_zig, .{});
}

// intentionally omitting the pointless trailer
//try w.writeByteNTimes(0, 512 * 2);
//try archiver.finish();
try response.end();
}

Expand Down
2 changes: 1 addition & 1 deletion zig/lib/init/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test "simple test" {
}

test "fuzz example" {
// Try passing `--fuzz` to `zig build` and see if it manages to fail this test case!
// Try passing `--fuzz` to `zig build test` and see if it manages to fail this test case!
const input_bytes = std.testing.fuzzInput(.{});
try std.testing.expect(!std.mem.eql(u8, "canyoufindme", input_bytes));
}
14 changes: 14 additions & 0 deletions zig/lib/libc/glibc/sysdeps/unix/sysv/linux/alpha/xstatver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Versions of the 'struct stat' data structure used in compatibility xstat
functions. */
#define _STAT_VER_KERNEL 0
#define _STAT_VER_GLIBC2 1
#define _STAT_VER_GLIBC2_1 2
#define _STAT_VER_KERNEL64 3
#define _STAT_VER_GLIBC2_3_4 3
#define _STAT_VER_LINUX 3
#define _STAT_VER _STAT_VER_LINUX

/* Versions of the 'xmknod' interface used in compatibility xmknod
functions. */
#define _MKNOD_VER_LINUX 0
#define _MKNOD_VER _MKNOD_VER_LINUX
13 changes: 13 additions & 0 deletions zig/lib/libc/glibc/sysdeps/unix/sysv/linux/arm/xstatver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Versions of the 'struct stat' data structure used in compatibility xstat
functions. */
#define _STAT_VER_LINUX_OLD 1
#define _STAT_VER_KERNEL 1
#define _STAT_VER_SVR4 2
#define _STAT_VER_LINUX 3
#define _STAT_VER _STAT_VER_LINUX

/* Versions of the 'xmknod' interface used in compatibility xmknod
functions. */
#define _MKNOD_VER_LINUX 1
#define _MKNOD_VER_SVR4 2
#define _MKNOD_VER _MKNOD_VER_LINUX
13 changes: 13 additions & 0 deletions zig/lib/libc/glibc/sysdeps/unix/sysv/linux/hppa/xstatver.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Versions of the 'struct stat' data structure used in compatibility xstat
functions. */
#define _STAT_VER_LINUX_OLD 1
#define _STAT_VER_KERNEL 1
#define _STAT_VER_SVR4 2
#define _STAT_VER_LINUX 3
#define _STAT_VER _STAT_VER_LINUX

/* Versions of the 'xmknod' interface used in compatibility xmknod
functions. */
#define _MKNOD_VER_LINUX 1
#define _MKNOD_VER_SVR4 2
#define _MKNOD_VER _MKNOD_VER_LINUX
Loading

0 comments on commit 6bcacb4

Please sign in to comment.