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,...@@ -259,8 +259,6 @@ crt_files: std.StringHashMapUnmanaged(CrtFile) = .empty,
259/// Null means only show snippet on first error.259/// Null means only show snippet on first error.
260reference_trace: ?u32 = null,260reference_trace: ?u32 = null,
261261
262libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
263
264/// This mutex guards all `Compilation` mutable state.262/// This mutex guards all `Compilation` mutable state.
265/// Disabled in single-threaded mode because the thread pool spawns in the same thread.263/// Disabled in single-threaded mode because the thread pool spawns in the same thread.
266mutex: if (builtin.single_threaded) struct {264mutex: if (builtin.single_threaded) struct {
...@@ -1171,7 +1169,6 @@ pub const CreateOptions = struct {...@@ -1171,7 +1169,6 @@ pub const CreateOptions = struct {
1171 force_load_objc: bool = false,1169 force_load_objc: bool = false,
1172 /// Whether local symbols should be discarded from the symbol table.1170 /// Whether local symbols should be discarded from the symbol table.
1173 discard_local_symbols: bool = false,1171 discard_local_symbols: bool = false,
1174 libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
1175 /// (Windows) PDB source path prefix to instruct the linker how to resolve relative1172 /// (Windows) PDB source path prefix to instruct the linker how to resolve relative
1176 /// paths when consolidating CodeView streams into a single PDB file.1173 /// paths when consolidating CodeView streams into a single PDB file.
1177 pdb_source_path: ?[]const u8 = null,1174 pdb_source_path: ?[]const u8 = null,
...@@ -1555,7 +1552,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil...@@ -1555,7 +1552,6 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1555 .debug_compiler_runtime_libs = options.debug_compiler_runtime_libs,1552 .debug_compiler_runtime_libs = options.debug_compiler_runtime_libs,
1556 .debug_compile_errors = options.debug_compile_errors,1553 .debug_compile_errors = options.debug_compile_errors,
1557 .incremental = options.incremental,1554 .incremental = options.incremental,
1558 .libcxx_abi_version = options.libcxx_abi_version,
1559 .root_name = root_name,1555 .root_name = root_name,
1560 .sysroot = sysroot,1556 .sysroot = sysroot,
1561 .windows_libs = windows_libs,1557 .windows_libs = windows_libs,
src/libcxx.zig+3-9
...@@ -8,13 +8,6 @@ const build_options = @import("build_options");...@@ -8,13 +8,6 @@ const build_options = @import("build_options");
8const trace = @import("tracy.zig").trace;8const trace = @import("tracy.zig").trace;
9const Module = @import("Package/Module.zig");9const 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
18const libcxxabi_files = [_][]const u8{11const libcxxabi_files = [_][]const u8{
19 "src/abort_message.cpp",12 "src/abort_message.cpp",
20 "src/cxa_aux_runtime.cpp",13 "src/cxa_aux_runtime.cpp",
...@@ -535,11 +528,12 @@ pub fn addCxxArgs(...@@ -535,11 +528,12 @@ pub fn addCxxArgs(
535 const target = comp.getTarget();528 const target = comp.getTarget();
536 const optimize_mode = comp.compilerRtOptMode();529 const optimize_mode = comp.compilerRtOptMode();
537530
531 const abi_version: u2 = if (target.os.tag == .emscripten) 2 else 1;
538 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{532 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
539 @intFromEnum(comp.libcxx_abi_version),533 abi_version,
540 }));534 }));
541 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{535 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
542 @intFromEnum(comp.libcxx_abi_version),536 abi_version,
543 }));537 }));
544 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{538 try cflags.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_HAS_{s}THREADS", .{
545 if (!comp.config.any_non_single_threaded) "NO_" else "",539 if (!comp.config.any_non_single_threaded) "NO_" else "",