aboutsummaryrefslogtreecommitdiff
path: root/src/Compilation.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-09-12 15:56:31 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-09-12 15:56:31 -0700
commitf79824f946995a050c261ee96a08e31ccf00a112 (patch)
tree354cab5f5640827e5fc85e15796ff250769a47c1 /src/Compilation.zig
parent6e3bbba9518b2efd789af94c89ae7712e011ed3b (diff)
downloadzig-f79824f946995a050c261ee96a08e31ccf00a112.tar.gz
zig-f79824f946995a050c261ee96a08e31ccf00a112.zip
libcxx: define _LIBCPP_ABI_VERSION and _LIBCPP_ABI_NAMESPACE
The changes from https://reviews.llvm.org/D119173 mean that __config no longer defaults the libc++ ABI to 1, relying on external configuration. This means Zig must provide the external configuration. This fixes static libraries built with zig with -lc++ to have the standard __1 namespace prefix, which had previously regressed in the llvm15 branch.
Diffstat (limited to 'src/Compilation.zig')
-rw-r--r--src/Compilation.zig11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index 5a1abcb52b..18dab183a5 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -154,6 +154,8 @@ owned_link_dir: ?std.fs.Dir,
/// Don't use this for anything other than stage1 compatibility.
color: Color = .auto,
+libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
+
/// This mutex guards all `Compilation` mutable state.
mutex: std.Thread.Mutex = .{},
@@ -950,6 +952,7 @@ pub const InitOptions = struct {
headerpad_max_install_names: bool = false,
/// (Darwin) remove dylibs that are unreachable by the entry point or exported symbols
dead_strip_dylibs: bool = false,
+ libcxx_abi_version: libcxx.AbiVersion = libcxx.AbiVersion.default,
};
fn addPackageTableToCacheHash(
@@ -1843,6 +1846,7 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
.test_evented_io = options.test_evented_io,
.debug_compiler_runtime_libs = options.debug_compiler_runtime_libs,
.debug_compile_errors = options.debug_compile_errors,
+ .libcxx_abi_version = options.libcxx_abi_version,
};
break :comp comp;
};
@@ -4026,6 +4030,13 @@ pub fn addCCArgs(
if (comp.bin_file.options.single_threaded) {
try argv.append("-D_LIBCPP_HAS_NO_THREADS");
}
+
+ try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_VERSION={d}", .{
+ @enumToInt(comp.libcxx_abi_version),
+ }));
+ try argv.append(try std.fmt.allocPrint(arena, "-D_LIBCPP_ABI_NAMESPACE=__{d}", .{
+ @enumToInt(comp.libcxx_abi_version),
+ }));
}
if (comp.bin_file.options.link_libunwind) {