Skip to content

Commit

Permalink
update zig sources to 0.14.0-dev.2253+3a6a8b8aa
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Nov 18, 2024
1 parent 899ddbe commit dbbe0b3
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 15 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.2246+bfcf18c5a
* zig 0.14.0-dev.2253+3a6a8b8aa

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.2246+bfcf18c5a"
ZIG_VERSION="0.14.0-dev.2253+3a6a8b8aa"

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.2246+bfcf18c5a"
set ZIG_VERSION="0.14.0-dev.2253+3a6a8b8aa"
set JOBS_ARG=

pushd %ROOTDIR%
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.2246+bfcf18c5a";
const char *zig_version = "0.14.0-dev.2253+3a6a8b8aa";

int written = fprintf(f,
"pub const have_llvm = false;\n"
Expand Down
1 change: 1 addition & 0 deletions zig/lib/std/c.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7028,6 +7028,7 @@ pub const pthread_attr_t = switch (native_os) {

pub const pthread_key_t = switch (native_os) {
.linux, .emscripten => c_uint,
.macos, .ios, .tvos, .watchos, .visionos => c_ulong,
.openbsd, .solaris, .illumos => c_int,
else => void,
};
Expand Down
78 changes: 78 additions & 0 deletions zig/lib/std/os/linux.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2065,6 +2065,84 @@ pub fn fremovexattr(fd: usize, name: [*:0]const u8) usize {
return syscall2(.fremovexattr, fd, @intFromPtr(name));
}

pub const sched_param = extern struct {
priority: i32,
};

pub const SCHED = packed struct(i32) {
pub const Mode = enum(u3) {
/// normal multi-user scheduling
NORMAL = 0,
/// FIFO realtime scheduling
FIFO = 1,
/// Round-robin realtime scheduling
RR = 2,
/// For "batch" style execution of processes
BATCH = 3,
/// Low latency scheduling
IDLE = 5,
/// Sporadic task model deadline scheduling
DEADLINE = 6,
};
mode: Mode, //bits [0, 2]
_3: u27 = 0, //bits [3, 29]
/// set to true to stop children from inheriting policies
RESET_ON_FORK: bool = false, //bit 30
_31: u1 = 0, //bit 31
};

pub fn sched_setparam(pid: pid_t, param: *const sched_param) usize {
return syscall2(.sched_setparam, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(param));
}

pub fn sched_getparam(pid: pid_t, param: *sched_param) usize {
return syscall2(.sched_getparam, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(param));
}

pub fn sched_setscheduler(pid: pid_t, policy: SCHED, param: *const sched_param) usize {
return syscall3(.sched_setscheduler, @as(usize, @bitCast(@as(isize, pid))), @intCast(@as(u32, @bitCast(policy))), @intFromPtr(param));
}

pub fn sched_getscheduler(pid: pid_t) usize {
return syscall1(.sched_getscheduler, @as(usize, @bitCast(@as(isize, pid))));
}

pub fn sched_get_priority_max(policy: SCHED) usize {
return syscall1(.sched_get_priority_max, @intCast(@as(u32, @bitCast(policy))));
}

pub fn sched_get_priority_min(policy: SCHED) usize {
return syscall1(.sched_get_priority_min, @intCast(@as(u32, @bitCast(policy))));
}

pub fn getcpu(cpu: ?*usize, node: ?*usize) usize {
return syscall2(.getcpu, @intFromPtr(cpu), @intFromPtr(node));
}

pub const sched_attr = extern struct {
size: u32 = 48, // Size of this structure
policy: u32 = 0, // Policy (SCHED_*)
flags: u64 = 0, // Flags
nice: u32 = 0, // Nice value (SCHED_OTHER, SCHED_BATCH)
priority: u32 = 0, // Static priority (SCHED_FIFO, SCHED_RR)
// Remaining fields are for SCHED_DEADLINE
runtime: u64 = 0,
deadline: u64 = 0,
period: u64 = 0,
};

pub fn sched_setattr(pid: pid_t, attr: *const sched_attr, flags: usize) usize {
return syscall3(.sched_setattr, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(attr), flags);
}

pub fn sched_getattr(pid: pid_t, attr: *sched_attr, size: usize, flags: usize) usize {
return syscall4(.sched_getattr, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(attr), size, flags);
}

pub fn sched_rr_get_interval(pid: pid_t, tp: *timespec) usize {
return syscall2(.sched_rr_get_interval, @as(usize, @bitCast(@as(isize, pid))), @intFromPtr(tp));
}

pub fn sched_yield() usize {
return syscall0(.sched_yield);
}
Expand Down
7 changes: 7 additions & 0 deletions zig/src/Compilation/Config.zig
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ pub fn resolve(options: Options) ResolveError!Config {
if (options.lto) |x| break :b x;
if (!options.any_c_source_files) break :b false;

// https://github.com/llvm/llvm-project/pull/116537
if (target.cpu.arch.isMIPS64()) switch (target.abi) {
.gnuabin32, .muslabin32 => break :b false,
else => {},
};

if (target.cpu.arch.isRISCV()) {
// Clang and LLVM currently don't support RISC-V target-abi for LTO.
// Compiling with LTO may fail or produce undesired results.
Expand Down Expand Up @@ -433,6 +439,7 @@ pub fn resolve(options: Options) ResolveError!Config {

const debug_format: DebugFormat = b: {
if (root_strip and !options.any_non_stripped) break :b .strip;
if (options.debug_format) |x| break :b x;
break :b switch (target.ofmt) {
.elf, .goff, .macho, .wasm, .xcoff => .{ .dwarf = .@"32" },
.coff => .code_view,
Expand Down
4 changes: 3 additions & 1 deletion zig/src/dev.zig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub const Env = enum {
sema,

/// - sema
/// - `zig build-* -fno-llvm -fno-lld -target x86_64-linux`
/// - `zig build-* -fincremental -fno-llvm -fno-lld -target x86_64-linux --listen=-`
@"x86_64-linux",

/// - sema
Expand Down Expand Up @@ -130,6 +130,8 @@ pub const Env = enum {
else => Env.ast_gen.supports(feature),
},
.@"x86_64-linux" => switch (feature) {
.stdio_listen,
.incremental,
.x86_64_backend,
.elf_linker,
=> true,
Expand Down
9 changes: 5 additions & 4 deletions zig/src/link/Elf/ZigObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ pub fn updateFunc(
});
defer gpa.free(name);
const osec = if (self.text_index) |sect_sym_index|
self.atom(self.symbol(sect_sym_index).ref.index).?.output_section_index
self.symbol(sect_sym_index).output_section_index
else osec: {
const osec = try elf_file.addSection(.{
.name = try elf_file.insertShString(".text"),
Expand Down Expand Up @@ -1896,12 +1896,13 @@ pub fn deleteExport(
} orelse return;
const zcu = elf_file.base.comp.zcu.?;
const exp_name = name.toSlice(&zcu.intern_pool);
const esym_index = metadata.@"export"(self, exp_name) orelse return;
const sym_index = metadata.@"export"(self, exp_name) orelse return;
log.debug("deleting export '{s}'", .{exp_name});
const esym = &self.symtab.items(.elf_sym)[esym_index.*];
const esym_index = self.symbol(sym_index.*).esym_index;
const esym = &self.symtab.items(.elf_sym)[esym_index];
_ = self.globals_lookup.remove(esym.st_name);
esym.* = Elf.null_sym;
self.symtab.items(.shndx)[esym_index.*] = elf.SHN_UNDEF;
self.symtab.items(.shndx)[esym_index] = elf.SHN_UNDEF;
}

pub fn getGlobalSymbol(self: *ZigObject, elf_file: *Elf, name: []const u8, lib_name: ?[]const u8) !u32 {
Expand Down
3 changes: 1 addition & 2 deletions zig/test/incremental/add_decl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Disabled on self-hosted due to linker crash
// #target=x86_64-linux-selfhosted
#target=x86_64-linux-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#update=initial version
Expand Down
3 changes: 1 addition & 2 deletions zig/test/incremental/fix_astgen_failure
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Disabled on self-hosted due to linker crash
// #target=x86_64-linux-selfhosted
#target=x86_64-linux-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#update=initial version with error
Expand Down
2 changes: 1 addition & 1 deletion zig/test/incremental/function_becomes_inline
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#target=x86_64-linux-selfhosted
#target=x86_64-linux-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#update=non-inline version
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//#target=x86_64-linux-selfhosted
#target=x86_64-linux-selfhosted
#target=x86_64-linux-cbe
#target=x86_64-windows-cbe
#update=initial version
Expand Down

0 comments on commit dbbe0b3

Please sign in to comment.