haiku: fix linking issues

This commit is contained in:
Jacob Young 2024-04-07 21:19:12 -04:00
parent 0c83fa2fd0
commit fcdb7027e9
4 changed files with 22 additions and 2 deletions

View file

@ -747,6 +747,9 @@ fn addCmakeCfgOptionsToExe(
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
},
.haiku => {
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
},
else => {},
}
}

View file

@ -2740,6 +2740,13 @@ pub fn is_libc_lib_name(target: std.Target, name: []const u8) bool {
return true;
}
if (target.os.tag == .haiku) {
if (eqlIgnoreCase(ignore_case, name, "root"))
return true;
if (eqlIgnoreCase(ignore_case, name, "network"))
return true;
}
return false;
}

View file

@ -105,6 +105,13 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {
return self;
}
if (builtin.os.tag == .haiku) {
try self.addLibDir("/system/non-packaged/lib");
try self.addLibDir("/system/develop/lib");
try self.addLibDir("/system/lib");
return self;
}
if (builtin.os.tag != .windows and builtin.os.tag != .wasi) {
const triple = try native_target.linuxTriple(arena);

View file

@ -1517,7 +1517,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
if (self.base.isStatic()) {
try argv.append("-static");
} else if (self.base.isDynLib()) {
} else if (self.base.isDynLib() or (target.os.tag == .haiku and self.base.isExe())) {
try argv.append("-shared");
}
@ -2469,7 +2469,10 @@ fn linkWithLLD(self: *Elf, arena: Allocator, prog_node: *std.Progress.Node) !voi
} else {
try argv.append("-static");
}
} else if (is_dyn_lib) {
} else if (switch (target.os.tag) {
else => is_dyn_lib,
.haiku => is_exe_or_dyn_lib,
}) {
try argv.append("-shared");
}