authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-04 12:25:05+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-05-05 14:34:05+02:00
log7401f06f99ac93aa479dcde2b6e17e2cdbf34a60
tree1fd9b23d298fc98b2431099c65fae8e77b5afbfe
parentf0feda820e678a7a8f7c2716b515145f4b9a5303

compiler: Set libc++ ABI version to 2 for Emscripten.

It remains 1 everywhere else. Also remove some code that allowed setting the libc++ ABI version on the Compilation since there are no current plans to actually expose this in the CLI.

2 files changed, 3 insertions(+), 13 deletions(-)

src/Compilation.zig-4
......@@ -259,8 +259,6 @@ crt_files: std.StringHashMapUnmanaged(CrtFile) = .empty,
259259/// Null means only show snippet on first error.
260260reference_trace: ?u32 = null,
261261
262libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
263
264262/// This mutex guards all `Compilation` mutable state.
265263/// Disabled in single-threaded mode because the thread pool spawns in the same thread.
266264mutex: if (builtin.single_threaded) struct {
......@@ -1171,7 +1169,6 @@ pub const CreateOptions = struct {
11711169 force_load_objc: bool = false,
11721170 /// Whether local symbols should be discarded from the symbol table.
11731171 discard_local_symbols: bool = false,
1174 libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
11751172 /// (Windows) PDB source path prefix to instruct the linker how to resolve relative
11761173 /// paths when consolidating CodeView streams into a single PDB file.
11771174 pdb_source_path: ?[]const u8 = null,
......@@ -1555,7 +1552,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
15551552 .debug_compiler_runtime_libs = options.debug_compiler_runtime_libs,
15561553 .debug_compile_errors = options.debug_compile_errors,
15571554 .incremental = options.incremental,
1558 .libcxx_abi_version = options.libcxx_abi_version,
15591555 .root_name = root_name,
15601556 .sysroot = sysroot,
15611557 .windows_libs = windows_libs,
src/libcxx.zig+3-9
......@@ -8,13 +8,6 @@ const build_options = @import("build_options");
88const trace = @import("tracy.zig").trace;
99const Module = @import("Package/Module.zig");
1010
11pub const AbiVersion = enum(u2) {
12 @"1" = 1,
13 @"2" = 2,
14
15 pub const default: AbiVersion = .@"1";
16};
17
1811const libcxxabi_files = [_][]const u8{
1912 "src/abort_message.cpp",
2013 "src/cxa_aux_runtime.cpp",
......@@ -535,11 +528,12 @@ pub fn addCxxArgs(
535528 const target = comp.getTarget();
536529 const optimize_mode = comp.compilerRtOptMode();
537530
531 const abi_version: u2 = if (target.os.tag == .emscripten) 2 else 1;
538532 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
539 @intFromEnum(comp.libcxx_abi_version),
533 abi_version,
540534 }));
541535 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
542 @intFromEnum(comp.libcxx_abi_version),
536 abi_version,
543537 }));
544538 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{
545539 if (!comp.config.any_non_single_threaded) "NO_" else "",