Merge pull request #14799 from ziglang/update-zig1

`@trap` fixups
This commit is contained in:
Andrew Kelley 2023-03-06 01:29:56 -05:00 committed by GitHub
commit ac1b0e832b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1865 additions and 916 deletions

View File

@ -9403,7 +9403,7 @@ fn List(comptime T: type) type {
Unlike for {#syntax#}@breakpoint(){#endsyntax#}, execution does not continue after this point.
</p>
<p>
This function is only valid within function scope.
Outside function scope, this builtin causes a compile error.
</p>
{#see_also|@breakpoint#}
{#header_close#}

View File

@ -575,22 +575,12 @@ pub fn abort() noreturn {
raise(SIG.KILL) catch {};
exit(127); // Pid 1 might not be signalled in some containers.
}
if (builtin.os.tag == .uefi) {
exit(0); // TODO choose appropriate exit code
switch (builtin.os.tag) {
.uefi, .wasi, .cuda => @trap(),
else => system.abort(),
}
if (builtin.os.tag == .wasi) {
exit(1);
}
if (builtin.os.tag == .cuda) {
// TODO: introduce `@trap` instead of abusing https://github.com/ziglang/zig/issues/2291
@"llvm.trap"();
}
system.abort();
}
extern fn @"llvm.trap"() noreturn;
pub const RaiseError = UnexpectedError;
pub fn raise(sig: u8) RaiseError!void {

View File

@ -193,7 +193,7 @@ typedef char bool;
#elif defined(__i386__) || defined(__x86_64__)
#define zig_trap() __asm__ volatile("ud2");
#else
#define zig_trap() raise(SIGILL)
#define zig_trap() raise(SIGTRAP)
#endif
#if zig_has_builtin(debugtrap)

View File

@ -3528,6 +3528,7 @@ pub fn astGenFile(mod: *Module, file: *File) !void {
const digest = hash: {
var path_hash: Cache.HashHelper = .{};
path_hash.addBytes(build_options.version);
path_hash.add(builtin.zig_backend);
if (!want_local_cache) {
path_hash.addOptionalBytes(file.pkg.root_src_directory.path);
}

View File

@ -8261,6 +8261,7 @@ pub const FuncGen = struct {
_ = inst;
const llvm_fn = self.getIntrinsic("llvm.trap", &.{});
_ = self.builder.buildCall(llvm_fn.globalGetValueType(), llvm_fn, undefined, 0, .Cold, .Auto, "");
_ = self.builder.buildUnreachable();
return null;
}

File diff suppressed because it is too large Load Diff

Binary file not shown.