authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-05-24 13:58:02-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2021-05-24 13:58:02-04:00
log8c5d4295e5f6459ba99d219c1922a30ec6da24bf
tree7ce5d2a943c9cec38f508c0f34dfcb2e5e7d8e37
parent8275c771c8f525b7f2917d1f4ade9b5e684d0a12
parenta6e65f3a0ea4f8315be50f91338e4526b006f9d8
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #8876 from xxxbxxx/cxx-lto

build libc++ with lto and function-sections

2 files changed, 12 insertions(+), 1 deletions(-)

src/libcxx.zig+8-1
...@@ -129,6 +129,8 @@ pub fn buildLibCXX(comp: *Compilation) !void {...@@ -129,6 +129,8 @@ pub fn buildLibCXX(comp: *Compilation) !void {
129 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");129 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
130 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");130 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
131 try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");131 try cflags.append("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS");
132 try cflags.append("-fvisibility=hidden");
133 try cflags.append("-fvisibility-inlines-hidden");
132134
133 if (target.abi.isMusl()) {135 if (target.abi.isMusl()) {
134 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");136 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
...@@ -144,7 +146,6 @@ pub fn buildLibCXX(comp: *Compilation) !void {...@@ -144,7 +146,6 @@ pub fn buildLibCXX(comp: *Compilation) !void {
144 try cflags.append("-fPIC");146 try cflags.append("-fPIC");
145 }147 }
146 try cflags.append("-nostdinc++");148 try cflags.append("-nostdinc++");
147 try cflags.append("-fvisibility-inlines-hidden");
148 try cflags.append("-std=c++14");149 try cflags.append("-std=c++14");
149 try cflags.append("-Wno-user-defined-literals");150 try cflags.append("-Wno-user-defined-literals");
150151
...@@ -174,6 +175,8 @@ pub fn buildLibCXX(comp: *Compilation) !void {...@@ -174,6 +175,8 @@ pub fn buildLibCXX(comp: *Compilation) !void {
174 .want_tsan = comp.bin_file.options.tsan,175 .want_tsan = comp.bin_file.options.tsan,
175 .want_pic = comp.bin_file.options.pic,176 .want_pic = comp.bin_file.options.pic,
176 .want_pie = comp.bin_file.options.pie,177 .want_pie = comp.bin_file.options.pie,
178 .want_lto = comp.bin_file.options.lto,
179 .function_sections = comp.bin_file.options.function_sections,
177 .emit_h = null,180 .emit_h = null,
178 .strip = comp.compilerRtStrip(),181 .strip = comp.compilerRtStrip(),
179 .is_native_os = comp.bin_file.options.is_native_os,182 .is_native_os = comp.bin_file.options.is_native_os,
...@@ -247,6 +250,8 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {...@@ -247,6 +250,8 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {
247 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");250 try cflags.append("-D_LIBCXXABI_BUILDING_LIBRARY");
248 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");251 try cflags.append("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS");
249 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");252 try cflags.append("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS");
253 try cflags.append("-fvisibility=hidden");
254 try cflags.append("-fvisibility-inlines-hidden");
250255
251 if (target.abi.isMusl()) {256 if (target.abi.isMusl()) {
252 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");257 try cflags.append("-D_LIBCPP_HAS_MUSL_LIBC");
...@@ -292,6 +297,8 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {...@@ -292,6 +297,8 @@ pub fn buildLibCXXABI(comp: *Compilation) !void {
292 .want_tsan = comp.bin_file.options.tsan,297 .want_tsan = comp.bin_file.options.tsan,
293 .want_pic = comp.bin_file.options.pic,298 .want_pic = comp.bin_file.options.pic,
294 .want_pie = comp.bin_file.options.pie,299 .want_pie = comp.bin_file.options.pie,
300 .want_lto = comp.bin_file.options.lto,
301 .function_sections = comp.bin_file.options.function_sections,
295 .emit_h = null,302 .emit_h = null,
296 .strip = comp.compilerRtStrip(),303 .strip = comp.compilerRtStrip(),
297 .is_native_os = comp.bin_file.options.is_native_os,304 .is_native_os = comp.bin_file.options.is_native_os,
src/libunwind.zig+4
...@@ -69,6 +69,8 @@ pub fn buildStaticLib(comp: *Compilation) !void {...@@ -69,6 +69,8 @@ pub fn buildStaticLib(comp: *Compilation) !void {
69 }69 }
70 try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS");70 try cflags.append("-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS");
71 try cflags.append("-Wa,--noexecstack");71 try cflags.append("-Wa,--noexecstack");
72 try cflags.append("-fvisibility=hidden");
73 try cflags.append("-fvisibility-inlines-hidden");
7274
73 // This is intentionally always defined because the macro definition means, should it only75 // This is intentionally always defined because the macro definition means, should it only
74 // build for the target specified by compiler defines. Since we pass -target the compiler76 // build for the target specified by compiler defines. Since we pass -target the compiler
...@@ -113,6 +115,8 @@ pub fn buildStaticLib(comp: *Compilation) !void {...@@ -113,6 +115,8 @@ pub fn buildStaticLib(comp: *Compilation) !void {
113 .want_tsan = false,115 .want_tsan = false,
114 .want_pic = comp.bin_file.options.pic,116 .want_pic = comp.bin_file.options.pic,
115 .want_pie = comp.bin_file.options.pie,117 .want_pie = comp.bin_file.options.pie,
118 .want_lto = comp.bin_file.options.lto,
119 .function_sections = comp.bin_file.options.function_sections,
116 .emit_h = null,120 .emit_h = null,
117 .strip = comp.compilerRtStrip(),121 .strip = comp.compilerRtStrip(),
118 .is_native_os = comp.bin_file.options.is_native_os,122 .is_native_os = comp.bin_file.options.is_native_os,