| ... | @@ -114,7 +114,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -114,7 +114,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 114 | var cflags = std.ArrayList([]const u8).init(arena); | 114 | var cflags = std.ArrayList([]const u8).init(arena); |
| 115 | | 115 | |
| 116 | if (target.os.tag == .windows or target.os.tag == .wasi) { | 116 | if (target.os.tag == .windows or target.os.tag == .wasi) { |
| 117 | // Filesystem stuff isn't supported on Windows and WASI. | 117 | // Filesystem stuff isn't supported on WASI and Windows. |
| 118 | if (std.mem.startsWith(u8, cxx_src, "src/filesystem/")) | 118 | if (std.mem.startsWith(u8, cxx_src, "src/filesystem/")) |
| 119 | continue; | 119 | continue; |
| 120 | } | 120 | } |
| ... | @@ -131,12 +131,18 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -131,12 +131,18 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 131 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | 131 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 132 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | 132 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 133 | try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); | 133 | try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); |
| 134 | try cflags.append("-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS"); | | |
| 135 | try cflags.append("-fvisibility=hidden"); | 134 | try cflags.append("-fvisibility=hidden"); |
| 136 | try cflags.append("-fvisibility-inlines-hidden"); | 135 | try cflags.append("-fvisibility-inlines-hidden"); |
| 137 | | 136 | |
| 138 | if (target.abi.isMusl() or target.os.tag == .wasi) { | 137 | if (target.abi.isMusl()) { |
| | 138 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); |
| | 139 | } |
| | 140 | |
| | 141 | if (target.os.tag == .wasi) { |
| 139 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); | 142 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); |
| | 143 | try cflags.append("-D_LIBCPP_HAS_NO_THREADS"); |
| | 144 | try cflags.append("-D_LIBCPP_ABI_VERSION=2"); |
| | 145 | try cflags.append("-fno-exceptions"); |
| 140 | } | 146 | } |
| 141 | | 147 | |
| 142 | try cflags.append("-I"); | 148 | try cflags.append("-I"); |
| ... | @@ -240,14 +246,29 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -240,14 +246,29 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 240 | | 246 | |
| 241 | const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" }); | 247 | const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" }); |
| 242 | const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); | 248 | const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); |
| | 249 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); |
| | 250 | try c_source_files.ensureCapacity(libcxxabi_files.len); |
| 243 | | 251 | |
| 244 | var c_source_files: [libcxxabi_files.len]Compilation.CSourceFile = undefined; | 252 | for (libcxxabi_files) |cxxabi_src| { |
| 245 | for (libcxxabi_files) |cxxabi_src, i| { | | |
| 246 | var cflags = std.ArrayList([]const u8).init(arena); | 253 | var cflags = std.ArrayList([]const u8).init(arena); |
| 247 | | 254 | |
| 248 | try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL"); | 255 | if (target.os.tag == .wasi) { |
| | 256 | if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp")) |
| | 257 | continue; |
| | 258 | |
| | 259 | if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_exception.cpp")) |
| | 260 | continue; |
| | 261 | |
| | 262 | if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_personality.cpp")) |
| | 263 | continue; |
| | 264 | |
| | 265 | try cflags.append("-fno-exceptions"); |
| | 266 | } else { |
| | 267 | try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL"); |
| | 268 | try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); |
| | 269 | } |
| | 270 | |
| 249 | try cflags.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE"); | 271 | try cflags.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE"); |
| 250 | try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); | | |
| 251 | try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY"); | 272 | try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY"); |
| 252 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | 273 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 253 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | 274 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); |
| ... | @@ -272,10 +293,10 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -272,10 +293,10 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 272 | try cflags.append("-funwind-tables"); | 293 | try cflags.append("-funwind-tables"); |
| 273 | try cflags.append("-std=c++11"); | 294 | try cflags.append("-std=c++11"); |
| 274 | | 295 | |
| 275 | c_source_files[i] = .{ | 296 | c_source_files.appendAssumeCapacity(.{ |
| 276 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }), | 297 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }), |
| 277 | .extra_flags = cflags.items, | 298 | .extra_flags = cflags.items, |
| 278 | }; | 299 | }); |
| 279 | } | 300 | } |
| 280 | | 301 | |
| 281 | const sub_compilation = try Compilation.create(comp.gpa, .{ | 302 | const sub_compilation = try Compilation.create(comp.gpa, .{ |
| ... | @@ -305,7 +326,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -305,7 +326,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 305 | .is_native_os = comp.bin_file.options.is_native_os, | 326 | .is_native_os = comp.bin_file.options.is_native_os, |
| 306 | .is_native_abi = comp.bin_file.options.is_native_abi, | 327 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 307 | .self_exe_path = comp.self_exe_path, | 328 | .self_exe_path = comp.self_exe_path, |
| 308 | .c_source_files = &c_source_files, | 329 | .c_source_files = c_source_files.items, |
| 309 | .verbose_cc = comp.verbose_cc, | 330 | .verbose_cc = comp.verbose_cc, |
| 310 | .verbose_link = comp.bin_file.options.verbose_link, | 331 | .verbose_link = comp.bin_file.options.verbose_link, |
| 311 | .verbose_air = comp.verbose_air, | 332 | .verbose_air = comp.verbose_air, |