Commit 9f669df1b3

Alex Rønne Petersen <alex@alexrp.com>
2024-08-24 00:45:00
libcxx: Synchronize some CXXFLAGS with upstream.
1 parent 1c8f0b8
Changed files (1)
src/libcxx.zig
@@ -237,19 +237,18 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
         try cflags.append("-DNDEBUG");
         try cflags.append(hardeningModeFlag(optimize_mode));
         try cflags.append("-D_LIBCPP_BUILDING_LIBRARY");
+        try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
         try cflags.append("-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER");
+        try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
         try cflags.append("-DLIBCXX_BUILDING_LIBCXXABI");
         try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
-        try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
-        try cflags.append("-D_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS");
-        try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
 
         // See libcxx/include/__algorithm/pstl_backends/cpu_backends/backend.h
         // for potentially enabling some fancy features here, which would
         // require corresponding changes in libcxx.zig, as well as
         // Compilation.addCCArgs. This option makes it use serial backend which
         // is simple and works everywhere.
-        try cflags.append("-D_LIBCPP_PSTL_CPU_BACKEND_SERIAL");
+        try cflags.append("-D_LIBCPP_PSTL_BACKEND_SERIAL");
 
         try cflags.append(abi_version_arg);
         try cflags.append(abi_namespace_arg);
@@ -283,8 +282,10 @@ pub fn buildLibCXX(comp: *Compilation, prog_node: std.Progress.Node) BuildError!
             try cflags.append("-fPIC");
         }
         try cflags.append("-nostdinc++");
-        try cflags.append("-std=c++20");
+        try cflags.append("-std=c++23");
         try cflags.append("-Wno-user-defined-literals");
+        try cflags.append("-Wno-covered-switch-default");
+        try cflags.append("-Wno-suggest-override");
 
         // These depend on only the zig lib directory file path, which is
         // purposefully either in the cache or not in the cache. The decision
@@ -476,19 +477,17 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
                 continue;
             }
             try cflags.append("-D_LIBCXXABI_HAS_NO_THREADS");
-            try cflags.append("-D_LIBCPP_HAS_NO_THREADS");
         } else if (target.abi.isGnu()) {
             if (target.os.tag != .linux or !(target.os.version_range.linux.glibc.order(.{ .major = 2, .minor = 18, .patch = 0 }) == .lt))
                 try cflags.append("-DHAVE___CXA_THREAD_ATEXIT_IMPL");
         }
 
-        try cflags.append("-D_LIBCPP_DISABLE_EXTERN_TEMPLATE");
-        try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
+        try cflags.append("-DNDEBUG");
+        try cflags.append(hardeningModeFlag(optimize_mode));
         try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
         try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
         try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
-        // This must be coordinated with the same flag in libcxx
-        try cflags.append("-D_LIBCPP_PSTL_CPU_BACKEND_SERIAL");
+        try cflags.append("-D_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS");
 
         try cflags.append(abi_version_arg);
         try cflags.append(abi_namespace_arg);
@@ -507,14 +506,15 @@ pub fn buildLibCXXABI(comp: *Compilation, prog_node: std.Progress.Node) BuildErr
             }
         }
 
-        try cflags.append(hardeningModeFlag(optimize_mode));
-
         if (target_util.supports_fpic(target)) {
             try cflags.append("-fPIC");
         }
         try cflags.append("-nostdinc++");
         try cflags.append("-fstrict-aliasing");
-        try cflags.append("-std=c++20");
+        try cflags.append("-std=c++23");
+        try cflags.append("-Wno-user-defined-literals");
+        try cflags.append("-Wno-covered-switch-default");
+        try cflags.append("-Wno-suggest-override");
 
         // These depend on only the zig lib directory file path, which is
         // purposefully either in the cache or not in the cache. The decision