| ... | ... | @@ -5,6 +5,7 @@ const builtin = @import("builtin"); |
| 5 | 5 | const is_darwin = builtin.target.os.tag.isDarwin(); |
| 6 | 6 | const is_windows = builtin.target.os.tag == .windows; |
| 7 | 7 | const is_haiku = builtin.target.os.tag == .haiku; |
| 8 | const is_serenity = builtin.target.os.tag == .serenity; |
| 8 | 9 | |
| 9 | 10 | const std = @import("std"); |
| 10 | 11 | const Io = std.Io; |
| ... | ... | @@ -112,7 +113,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const |
| 112 | 113 | return error.ParseError; |
| 113 | 114 | } |
| 114 | 115 | |
| 115 | | if (self.gcc_dir == null and os_tag == .haiku) { |
| 116 | if (self.gcc_dir == null and (os_tag == .haiku or os_tag == .serenity)) { |
| 116 | 117 | log.err("gcc_dir may not be empty for {s}", .{@tagName(os_tag)}); |
| 117 | 118 | return error.ParseError; |
| 118 | 119 | } |
| ... | ... | @@ -207,8 +208,12 @@ pub fn findNative(gpa: Allocator, io: Io, args: FindNativeOptions) FindError!Lib |
| 207 | 208 | try self.findNativeCrtDirWindows(gpa, io, args.target, sdk); |
| 208 | 209 | } else if (is_haiku) { |
| 209 | 210 | try self.findNativeIncludeDirPosix(gpa, io, args); |
| 210 | | try self.findNativeGccDirHaiku(gpa, io, args); |
| 211 | try self.findNativeGccDirPosix(gpa, io, args); |
| 211 | 212 | self.crt_dir = try gpa.dupe(u8, "/system/develop/lib"); |
| 213 | } else if (is_serenity) { |
| 214 | try self.findNativeIncludeDirPosix(gpa, io, args); |
| 215 | try self.findNativeGccDirPosix(gpa, io, args); |
| 216 | self.crt_dir = try gpa.dupe(u8, "/usr/lib"); |
| 212 | 217 | } else if (builtin.target.os.tag == .illumos) { |
| 213 | 218 | // There is only one libc, and its headers/libraries are always in the same spot. |
| 214 | 219 | self.include_dir = try gpa.dupe(u8, "/usr/include"); |
| ... | ... | @@ -314,7 +319,7 @@ fn findNativeIncludeDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, ar |
| 314 | 319 | const include_dir_example_file = if (is_haiku) "posix/stdlib.h" else "stdlib.h"; |
| 315 | 320 | const sys_include_dir_example_file = if (is_windows) |
| 316 | 321 | "sys\\types.h" |
| 317 | | else if (is_haiku) |
| 322 | else if (is_haiku or is_serenity) |
| 318 | 323 | "errno.h" |
| 319 | 324 | else |
| 320 | 325 | "sys/errno.h"; |
| ... | ... | @@ -457,7 +462,7 @@ fn findNativeCrtDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: |
| 457 | 462 | }); |
| 458 | 463 | } |
| 459 | 464 | |
| 460 | | fn findNativeGccDirHaiku(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void { |
| 465 | fn findNativeGccDirPosix(self: *LibCInstallation, gpa: Allocator, io: Io, args: FindNativeOptions) FindError!void { |
| 461 | 466 | self.gcc_dir = try ccPrintFileName(gpa, io, .{ |
| 462 | 467 | .environ_map = args.environ_map, |
| 463 | 468 | .search_basename = "crtbeginS.o", |
| ... | ... | @@ -949,6 +954,22 @@ pub const CrtBasenames = struct { |
| 949 | 954 | }, |
| 950 | 955 | .static_exe, .static_pie => .{}, |
| 951 | 956 | }, |
| 957 | .serenity => switch (mode) { |
| 958 | .dynamic_lib => .{ |
| 959 | .crtbegin = "crtbeginS.o", |
| 960 | .crtend = "crtendS.o", |
| 961 | }, |
| 962 | .dynamic_exe, .static_exe => .{ |
| 963 | .crt0 = "crt0.o", |
| 964 | .crtbegin = "crtbegin.o", |
| 965 | .crtend = "crtend.o", |
| 966 | }, |
| 967 | .dynamic_pie, .static_pie => .{ |
| 968 | .crt0 = "crt0.o", |
| 969 | .crtbegin = "crtbeginS.o", |
| 970 | .crtend = "crtendS.o", |
| 971 | }, |
| 972 | }, |
| 952 | 973 | else => .{}, |
| 953 | 974 | }; |
| 954 | 975 | } |
| ... | ... | @@ -993,7 +1014,7 @@ pub fn resolveCrtPaths( |
| 993 | 1014 | .crtn = if (crt_basenames.crtn) |basename| try crt_dir_path.join(arena, basename) else null, |
| 994 | 1015 | }; |
| 995 | 1016 | }, |
| 996 | | .haiku => { |
| 1017 | .haiku, .serenity => { |
| 997 | 1018 | const gcc_dir_path: Path = .{ |
| 998 | 1019 | .root_dir = std.Build.Cache.Directory.cwd(), |
| 999 | 1020 | .sub_path = lci.gcc_dir orelse return error.LibCInstallationMissingCrtDir, |