Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug.zig: Make it build with 'other' target OS #20845

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/std/debug.zig
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ pub fn defaultPanic(
}

switch (builtin.os.tag) {
.freestanding => {
.freestanding, .other => {
@trap();
},
.uefi => {
Expand Down
2 changes: 1 addition & 1 deletion lib/std/debug/MemoryAccessor.zig
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub fn load(ma: *MemoryAccessor, comptime Type: type, address: usize) ?Type {

pub fn isValidMemory(address: usize) bool {
// We are unable to determine validity of memory for freestanding targets
if (native_os == .freestanding or native_os == .uefi) return true;
if (native_os == .freestanding or native_os == .other or native_os == .uefi) return true;

const aligned_address = address & ~@as(usize, @intCast((page_size - 1)));
if (aligned_address == 0) return false;
Expand Down
5 changes: 3 additions & 2 deletions test/standalone/stack_iterator/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,14 @@ pub fn build(b: *std.Build) void {
// Unwinding without libc/posix
//
// No "getcontext" or "ucontext_t"
{
const no_os_targets = [_]std.Target.Os.Tag{ .freestanding, .other };
inline for (no_os_targets) |os_tag| {
const exe = b.addExecutable(.{
.name = "unwind_freestanding",
.root_source_file = b.path("unwind_freestanding.zig"),
.target = b.resolveTargetQuery(.{
.cpu_arch = .x86_64,
.os_tag = .freestanding,
.os_tag = os_tag,
}),
.optimize = optimize,
.unwind_tables = null,
Expand Down
7 changes: 4 additions & 3 deletions test/standalone/stack_iterator/unwind_freestanding.zig
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ noinline fn frame0(expected: *[4]usize, unwound: *[4]usize) void {
frame1(expected, unwound);
}

// Freestanding entrypoint
// No-OS entrypoint
export fn _start() callconv(.C) noreturn {
var expected: [4]usize = undefined;
var unwound: [4]usize = undefined;
Expand All @@ -50,8 +50,9 @@ export fn _start() callconv(.C) noreturn {
}
}

// Need to compile as "freestanding" to exercise the StackIterator code, but when run as a
// regression test need to actually exit. So assume we're running on x86_64-linux ...
// Need to compile with the target OS as "freestanding" or "other" to
// exercise the StackIterator code, but when run as a regression test
// need to actually exit. So assume we're running on x86_64-linux ...
asm volatile (
\\movl $60, %%eax
\\syscall
Expand Down
Loading