Commit a6e65f3a0e

xavier <xavierb@gmail.com>
2021-05-23 16:53:47
keep statically linked libc++ symbols hidden.
1 parent 40d8518
Changed files (2)
src/libcxx.zig
@@ -129,6 +129,8 @@ pub fn buildLibCXX(comp: *Compilation) !void {
         try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
         try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
         try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
+        try cflags.append("-fvisibility=hidden");
+        try cflags.append("-fvisibility-inlines-hidden");
 
         if (target.abi.isMusl()) {
             try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
@@ -144,7 +146,6 @@ pub fn buildLibCXX(comp: *Compilation) !void {
             try cflags.append("-fPIC");
         }
         try cflags.append("-nostdinc++");
-        try cflags.append("-fvisibility-inlines-hidden");
         try cflags.append("-std=c++14");
         try cflags.append("-Wno-user-defined-literals");
 
@@ -249,6 +250,8 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {
         try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
         try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
         try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
+        try cflags.append("-fvisibility=hidden");
+        try cflags.append("-fvisibility-inlines-hidden");
 
         if (target.abi.isMusl()) {
             try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
src/libunwind.zig
@@ -69,6 +69,8 @@ pub fn buildStaticLib(comp: *Compilation) !void {
         }
         try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS");
         try cflags.append("-Wa,--noexecstack");
+        try cflags.append("-fvisibility=hidden");
+        try cflags.append("-fvisibility-inlines-hidden");
 
         // This is intentionally always defined because the macro definition means, should it only
         // build for the target specified by compiler defines. Since we pass -target the compiler