authorgravatar for Emil.Tywoniak@hightec-rt.comEmil Tywoniak <Emil.Tywoniak@hightec-rt.com> 2024-01-18 14:16:52+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-18 21:37:41-08:00
logb80cad24840700ead20b59734916bf3d4d4ba87c
treea8a54d2a6c8a1a3950f5694f542d488c4591e2aa
parent9b714e019c1c26143112ee1e7930a95cd94797f4

libcxx: fix C++ builds with glibc <2.16 without aligned_alloc


1 files changed, 14 insertions(+), 0 deletions(-)

src/libcxx.zig+14
...@@ -233,6 +233,13 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -233,6 +233,13 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: *std.Progress.Node) !void {
233 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");233 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
234 }234 }
235235
236 if (target.isGnuLibC()) {
237 // glibc 2.16 introduced aligned_alloc
238 if (target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
239 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
240 }
241 }
242
236 if (target.os.tag == .wasi) {243 if (target.os.tag == .wasi) {
237 // WASI doesn't support exceptions yet.244 // WASI doesn't support exceptions yet.
238 try cflags.append("-fno-exceptions");245 try cflags.append("-fno-exceptions");
...@@ -433,6 +440,13 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {...@@ -433,6 +440,13 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: *std.Progress.Node) !void {
433 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");440 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
434 }441 }
435442
443 if (target.isGnuLibC()) {
444 // glibc 2.16 introduced aligned_alloc
445 if (target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 16, .patch = 0 }) == .lt) {
446 try cflags.append("-D_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION");
447 }
448 }
449
436 if (target_util.supports_fpic(target)) {450 if (target_util.supports_fpic(target)) {
437 try cflags.append("-fPIC");451 try cflags.append("-fPIC");
438 }452 }