| ... | @@ -113,11 +113,13 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -113,11 +113,13 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 113 | for (libcxx_files) |cxx_src| { | 113 | for (libcxx_files) |cxx_src| { |
| 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) { | 116 | if (target.os.tag == .windows or target.os.tag == .wasi) { |
| 117 | // Filesystem stuff isn't supported on Windows. | 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 | } else { | 120 | } |
| | 121 | |
| | 122 | if (target.os.tag != .windows) { |
| 121 | if (std.mem.startsWith(u8, cxx_src, "src/support/win32/")) | 123 | if (std.mem.startsWith(u8, cxx_src, "src/support/win32/")) |
| 122 | continue; | 124 | continue; |
| 123 | } | 125 | } |
| ... | @@ -129,7 +131,6 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -129,7 +131,6 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 129 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); | 131 | try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 130 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); | 132 | try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS"); |
| 131 | try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); | 133 | try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS"); |
| 132 | try cflags.append("-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS"); | | |
| 133 | try cflags.append("-fvisibility=hidden"); | 134 | try cflags.append("-fvisibility=hidden"); |
| 134 | try cflags.append("-fvisibility-inlines-hidden"); | 135 | try cflags.append("-fvisibility-inlines-hidden"); |
| 135 | | 136 | |
| ... | @@ -137,6 +138,12 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -137,6 +138,12 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 137 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); | 138 | try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); |
| 138 | } | 139 | } |
| 139 | | 140 | |
| | 141 | if (target.os.tag == .wasi) { |
| | 142 | // WASI doesn't support thread and exception yet. |
| | 143 | try cflags.append("-D_LIBCPP_HAS_NO_THREADS"); |
| | 144 | try cflags.append("-fno-exceptions"); |
| | 145 | } |
| | 146 | |
| 140 | try cflags.append("-I"); | 147 | try cflags.append("-I"); |
| 141 | try cflags.append(cxx_include_path); | 148 | try cflags.append(cxx_include_path); |
| 142 | | 149 | |
| ... | @@ -238,12 +245,24 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -238,12 +245,24 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 238 | | 245 | |
| 239 | const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" }); | 246 | const cxxabi_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", "include" }); |
| 240 | const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); | 247 | const cxx_include_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxx", "include" }); |
| | 248 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); |
| | 249 | try c_source_files.ensureCapacity(libcxxabi_files.len); |
| 241 | | 250 | |
| 242 | var c_source_files: [libcxxabi_files.len]Compilation.CSourceFile = undefined; | 251 | for (libcxxabi_files) |cxxabi_src| { |
| 243 | for (libcxxabi_files) |cxxabi_src, i| { | | |
| 244 | var cflags = std.ArrayList([]const u8).init(arena); | 252 | var cflags = std.ArrayList([]const u8).init(arena); |
| 245 | | 253 | |
| 246 | try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL"); | 254 | if (target.os.tag == .wasi) { |
| | 255 | // WASI doesn't support thread and exception yet. |
| | 256 | if (std.mem.startsWith(u8, cxxabi_src, "src/cxa_thread_atexit.cpp") or |
| | 257 | std.mem.startsWith(u8, cxxabi_src, "src/cxa_exception.cpp") or |
| | 258 | std.mem.startsWith(u8, cxxabi_src, "src/cxa_personality.cpp")) |
| | 259 | continue; |
| | 260 | try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS"); |
| | 261 | try cflags.append("-fno-exceptions"); |
| | 262 | } else { |
| | 263 | try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL"); |
| | 264 | } |
| | 265 | |
| 247 | try cflags.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE"); | 266 | try cflags.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE"); |
| 248 | try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); | 267 | try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS"); |
| 249 | try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY"); | 268 | try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY"); |
| ... | @@ -270,10 +289,10 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -270,10 +289,10 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 270 | try cflags.append("-funwind-tables"); | 289 | try cflags.append("-funwind-tables"); |
| 271 | try cflags.append("-std=c++11"); | 290 | try cflags.append("-std=c++11"); |
| 272 | | 291 | |
| 273 | c_source_files[i] = .{ | 292 | c_source_files.appendAssumeCapacity(.{ |
| 274 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }), | 293 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libcxxabi", cxxabi_src }), |
| 275 | .extra_flags = cflags.items, | 294 | .extra_flags = cflags.items, |
| 276 | }; | 295 | }); |
| 277 | } | 296 | } |
| 278 | | 297 | |
| 279 | const sub_compilation = try Compilation.create(comp.gpa, .{ | 298 | const sub_compilation = try Compilation.create(comp.gpa, .{ |
| ... | @@ -303,7 +322,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -303,7 +322,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 303 | .is_native_os = comp.bin_file.options.is_native_os, | 322 | .is_native_os = comp.bin_file.options.is_native_os, |
| 304 | .is_native_abi = comp.bin_file.options.is_native_abi, | 323 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 305 | .self_exe_path = comp.self_exe_path, | 324 | .self_exe_path = comp.self_exe_path, |
| 306 | .c_source_files = &c_source_files, | 325 | .c_source_files = c_source_files.items, |
| 307 | .verbose_cc = comp.verbose_cc, | 326 | .verbose_cc = comp.verbose_cc, |
| 308 | .verbose_link = comp.bin_file.options.verbose_link, | 327 | .verbose_link = comp.bin_file.options.verbose_link, |
| 309 | .verbose_air = comp.verbose_air, | 328 | .verbose_air = comp.verbose_air, |