diff options
| author | Emil Tywoniak <Emil.Tywoniak@hightec-rt.com> | 2024-01-18 14:16:52 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-18 21:37:41 -0800 |
| commit | b80cad24840700ead20b59734916bf3d4d4ba87c (patch) | |
| tree | a8a54d2a6c8a1a3950f5694f542d488c4591e2aa /src | |
| parent | 9b714e019c1c26143112ee1e7930a95cd94797f4 (diff) | |
| download | zig-b80cad24840700ead20b59734916bf3d4d4ba87c.tar.gz zig-b80cad24840700ead20b59734916bf3d4d4ba87c.zip | |
libcxx: fix C++ builds with glibc <2.16 without aligned_alloc
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcxx.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libcxx.zig b/src/libcxx.zig index 7b2e612838..d47ec71a64 100644 --- a/src/libcxx.zig +++ b/src/libcxx.zig @@ -233,6 +233,13 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void { try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); } + if (target.isGnuLibC()) { + // glibc 2.16 introduced aligned_alloc + if (target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { + try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION"); + } + } + if (target.os.tag == .wasi) { // WASI doesn't support exceptions yet. try cflags.append("-fno-exceptions"); @@ -433,6 +440,13 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void { try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC"); } + if (target.isGnuLibC()) { + // glibc 2.16 introduced aligned_alloc + if (target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) { + try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION"); + } + } + if (target_util.supports_fpic(target)) { try cflags.append("-fPIC"); } |
