| author | |
| committer | |
| log | 6ab9268a9024fe8e9076f07cb207107d2cad0876 |
| tree | 64269aabb1a50ba35b9ac0951d9c365d2916be2e |
| parent | 894434988d96f3246e0525000f281563c1febb73 |
Previously Zig would need to recompile runtime libs if you changed the
values of --strip or -O. Now, unless the `debug_compiler_runtime_libs`
flag is set (which is currently not exposed to the CLI), Zig will always
choose ReleaseFast or ReleaseSmall for compiler runtime libraries.
When the main application chooses ReleaseFast or ReleaseSmall, that
value is propagated to compiler runtime libraries. Otherwise a decision
is made based on the target, which is currently ReleaseSmall for
freestanding WebAssembly and ReleaseFast for everything else.
Ultimately the purpose of this commit is to have Debug and ReleaseSafe
builds of applications still get optimized builds of, e.g. libcxx and
libunwind, as well as to spend less time unnecessarily rebuilding compiler
runtime libraries.8 files changed, 50 insertions(+), 58 deletions(-)
src/Compilation.zig+30-12| ... | @@ -131,6 +131,7 @@ mutex: std.Mutex = .{}, | ... | @@ -131,6 +131,7 @@ mutex: std.Mutex = .{}, |
| 131 | test_filter: ?[]const u8, | 131 | test_filter: ?[]const u8, |
| 132 | test_name_prefix: ?[]const u8, | 132 | test_name_prefix: ?[]const u8, |
| 133 | test_evented_io: bool, | 133 | test_evented_io: bool, |
| 134 | debug_compiler_runtime_libs: bool, | ||
| 134 | 135 | ||
| 135 | emit_asm: ?EmitLoc, | 136 | emit_asm: ?EmitLoc, |
| 136 | emit_llvm_ir: ?EmitLoc, | 137 | emit_llvm_ir: ?EmitLoc, |
| ... | @@ -429,6 +430,7 @@ pub const InitOptions = struct { | ... | @@ -429,6 +430,7 @@ pub const InitOptions = struct { |
| 429 | verbose_llvm_cpu_features: bool = false, | 430 | verbose_llvm_cpu_features: bool = false, |
| 430 | is_test: bool = false, | 431 | is_test: bool = false, |
| 431 | test_evented_io: bool = false, | 432 | test_evented_io: bool = false, |
| 433 | debug_compiler_runtime_libs: bool = false, | ||
| 432 | /// Normally when you create a `Compilation`, Zig will automatically build | 434 | /// Normally when you create a `Compilation`, Zig will automatically build |
| 433 | /// and link in required dependencies, such as compiler-rt and libc. When | 435 | /// and link in required dependencies, such as compiler-rt and libc. When |
| 434 | /// building such dependencies themselves, this flag must be set to avoid | 436 | /// building such dependencies themselves, this flag must be set to avoid |
| ... | @@ -1025,6 +1027,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -1025,6 +1027,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 1025 | .test_filter = options.test_filter, | 1027 | .test_filter = options.test_filter, |
| 1026 | .test_name_prefix = options.test_name_prefix, | 1028 | .test_name_prefix = options.test_name_prefix, |
| 1027 | .test_evented_io = options.test_evented_io, | 1029 | .test_evented_io = options.test_evented_io, |
| 1030 | .debug_compiler_runtime_libs = options.debug_compiler_runtime_libs, | ||
| 1028 | .work_queue_wait_group = undefined, | 1031 | .work_queue_wait_group = undefined, |
| 1029 | }; | 1032 | }; |
| 1030 | break :comp comp; | 1033 | break :comp comp; |
| ... | @@ -2891,14 +2894,6 @@ fn buildOutputFromZig( | ... | @@ -2891,14 +2894,6 @@ fn buildOutputFromZig( |
| 2891 | .directory = null, // Put it in the cache directory. | 2894 | .directory = null, // Put it in the cache directory. |
| 2892 | .basename = bin_basename, | 2895 | .basename = bin_basename, |
| 2893 | }; | 2896 | }; |
| 2894 | const optimize_mode: std.builtin.Mode = blk: { | ||
| 2895 | if (comp.bin_file.options.is_test) | ||
| 2896 | break :blk comp.bin_file.options.optimize_mode; | ||
| 2897 | switch (comp.bin_file.options.optimize_mode) { | ||
| 2898 | .Debug, .ReleaseFast, .ReleaseSafe => break :blk .ReleaseFast, | ||
| 2899 | .ReleaseSmall => break :blk .ReleaseSmall, | ||
| 2900 | } | ||
| 2901 | }; | ||
| 2902 | const sub_compilation = try Compilation.create(comp.gpa, .{ | 2897 | const sub_compilation = try Compilation.create(comp.gpa, .{ |
| 2903 | .global_cache_directory = comp.global_cache_directory, | 2898 | .global_cache_directory = comp.global_cache_directory, |
| 2904 | .local_cache_directory = comp.global_cache_directory, | 2899 | .local_cache_directory = comp.global_cache_directory, |
| ... | @@ -2910,7 +2905,7 @@ fn buildOutputFromZig( | ... | @@ -2910,7 +2905,7 @@ fn buildOutputFromZig( |
| 2910 | .thread_pool = comp.thread_pool, | 2905 | .thread_pool = comp.thread_pool, |
| 2911 | .libc_installation = comp.bin_file.options.libc_installation, | 2906 | .libc_installation = comp.bin_file.options.libc_installation, |
| 2912 | .emit_bin = emit_bin, | 2907 | .emit_bin = emit_bin, |
| 2913 | .optimize_mode = optimize_mode, | 2908 | .optimize_mode = comp.compilerRtOptMode(), |
| 2914 | .link_mode = .Static, | 2909 | .link_mode = .Static, |
| 2915 | .function_sections = true, | 2910 | .function_sections = true, |
| 2916 | .want_sanitize_c = false, | 2911 | .want_sanitize_c = false, |
| ... | @@ -2920,7 +2915,7 @@ fn buildOutputFromZig( | ... | @@ -2920,7 +2915,7 @@ fn buildOutputFromZig( |
| 2920 | .want_pic = comp.bin_file.options.pic, | 2915 | .want_pic = comp.bin_file.options.pic, |
| 2921 | .want_pie = comp.bin_file.options.pie, | 2916 | .want_pie = comp.bin_file.options.pie, |
| 2922 | .emit_h = null, | 2917 | .emit_h = null, |
| 2923 | .strip = comp.bin_file.options.strip, | 2918 | .strip = comp.compilerRtStrip(), |
| 2924 | .is_native_os = comp.bin_file.options.is_native_os, | 2919 | .is_native_os = comp.bin_file.options.is_native_os, |
| 2925 | .is_native_abi = comp.bin_file.options.is_native_abi, | 2920 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 2926 | .self_exe_path = comp.self_exe_path, | 2921 | .self_exe_path = comp.self_exe_path, |
| ... | @@ -3289,7 +3284,7 @@ pub fn build_crt_file( | ... | @@ -3289,7 +3284,7 @@ pub fn build_crt_file( |
| 3289 | .thread_pool = comp.thread_pool, | 3284 | .thread_pool = comp.thread_pool, |
| 3290 | .libc_installation = comp.bin_file.options.libc_installation, | 3285 | .libc_installation = comp.bin_file.options.libc_installation, |
| 3291 | .emit_bin = emit_bin, | 3286 | .emit_bin = emit_bin, |
| 3292 | .optimize_mode = comp.bin_file.options.optimize_mode, | 3287 | .optimize_mode = comp.compilerRtOptMode(), |
| 3293 | .want_sanitize_c = false, | 3288 | .want_sanitize_c = false, |
| 3294 | .want_stack_check = false, | 3289 | .want_stack_check = false, |
| 3295 | .want_valgrind = false, | 3290 | .want_valgrind = false, |
| ... | @@ -3297,7 +3292,7 @@ pub fn build_crt_file( | ... | @@ -3297,7 +3292,7 @@ pub fn build_crt_file( |
| 3297 | .want_pic = comp.bin_file.options.pic, | 3292 | .want_pic = comp.bin_file.options.pic, |
| 3298 | .want_pie = comp.bin_file.options.pie, | 3293 | .want_pie = comp.bin_file.options.pie, |
| 3299 | .emit_h = null, | 3294 | .emit_h = null, |
| 3300 | .strip = comp.bin_file.options.strip, | 3295 | .strip = comp.compilerRtStrip(), |
| 3301 | .is_native_os = comp.bin_file.options.is_native_os, | 3296 | .is_native_os = comp.bin_file.options.is_native_os, |
| 3302 | .is_native_abi = comp.bin_file.options.is_native_abi, | 3297 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 3303 | .self_exe_path = comp.self_exe_path, | 3298 | .self_exe_path = comp.self_exe_path, |
| ... | @@ -3344,3 +3339,26 @@ pub fn stage1AddLinkLib(comp: *Compilation, lib_name: []const u8) !void { | ... | @@ -3344,3 +3339,26 @@ pub fn stage1AddLinkLib(comp: *Compilation, lib_name: []const u8) !void { |
| 3344 | }); | 3339 | }); |
| 3345 | } | 3340 | } |
| 3346 | } | 3341 | } |
| 3342 | |||
| 3343 | /// This decides the optimization mode for all zig-provided libraries, including | ||
| 3344 | /// compiler-rt, libcxx, libc, libunwind, etc. | ||
| 3345 | pub fn compilerRtOptMode(comp: Compilation) std.builtin.Mode { | ||
| 3346 | if (comp.debug_compiler_runtime_libs) { | ||
| 3347 | return comp.bin_file.options.optimize_mode; | ||
| 3348 | } | ||
| 3349 | switch (comp.bin_file.options.optimize_mode) { | ||
| 3350 | .Debug, .ReleaseSafe => return target_util.defaultCompilerRtOptimizeMode(comp.getTarget()), | ||
| 3351 | .ReleaseFast => return .ReleaseFast, | ||
| 3352 | .ReleaseSmall => return .ReleaseSmall, | ||
| 3353 | } | ||
| 3354 | } | ||
| 3355 | |||
| 3356 | /// This decides whether to strip debug info for all zig-provided libraries, including | ||
| 3357 | /// compiler-rt, libcxx, libc, libunwind, etc. | ||
| 3358 | pub fn compilerRtStrip(comp: Compilation) bool { | ||
| 3359 | if (comp.debug_compiler_runtime_libs) { | ||
| 3360 | return comp.bin_file.options.strip; | ||
| 3361 | } else { | ||
| 3362 | return true; | ||
| 3363 | } | ||
| 3364 | } |
src/glibc.zig+2-10| ... | @@ -271,7 +271,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -271,7 +271,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 271 | try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), | 271 | try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), |
| 272 | "-DTOP_NAMESPACE=glibc", | 272 | "-DTOP_NAMESPACE=glibc", |
| 273 | "-DASSEMBLER", | 273 | "-DASSEMBLER", |
| 274 | "-g", | ||
| 275 | "-Wa,--noexecstack", | 274 | "-Wa,--noexecstack", |
| 276 | }); | 275 | }); |
| 277 | return comp.build_crt_file("crti", .Obj, &[1]Compilation.CSourceFile{ | 276 | return comp.build_crt_file("crti", .Obj, &[1]Compilation.CSourceFile{ |
| ... | @@ -291,7 +290,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -291,7 +290,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 291 | try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), | 290 | try lib_path(comp, arena, lib_libc_glibc ++ "include" ++ path.sep_str ++ "libc-symbols.h"), |
| 292 | "-DTOP_NAMESPACE=glibc", | 291 | "-DTOP_NAMESPACE=glibc", |
| 293 | "-DASSEMBLER", | 292 | "-DASSEMBLER", |
| 294 | "-g", | ||
| 295 | "-Wa,--noexecstack", | 293 | "-Wa,--noexecstack", |
| 296 | }); | 294 | }); |
| 297 | return comp.build_crt_file("crtn", .Obj, &[1]Compilation.CSourceFile{ | 295 | return comp.build_crt_file("crtn", .Obj, &[1]Compilation.CSourceFile{ |
| ... | @@ -317,7 +315,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -317,7 +315,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 317 | "-DSHARED", | 315 | "-DSHARED", |
| 318 | "-DTOP_NAMESPACE=glibc", | 316 | "-DTOP_NAMESPACE=glibc", |
| 319 | "-DASSEMBLER", | 317 | "-DASSEMBLER", |
| 320 | "-g", | ||
| 321 | "-Wa,--noexecstack", | 318 | "-Wa,--noexecstack", |
| 322 | }); | 319 | }); |
| 323 | break :blk .{ | 320 | break :blk .{ |
| ... | @@ -337,7 +334,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -337,7 +334,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 337 | "-DMODULE_NAME=libc", | 334 | "-DMODULE_NAME=libc", |
| 338 | "-DTOP_NAMESPACE=glibc", | 335 | "-DTOP_NAMESPACE=glibc", |
| 339 | "-DASSEMBLER", | 336 | "-DASSEMBLER", |
| 340 | "-g", | ||
| 341 | "-Wa,--noexecstack", | 337 | "-Wa,--noexecstack", |
| 342 | }); | 338 | }); |
| 343 | break :blk .{ | 339 | break :blk .{ |
| ... | @@ -372,8 +368,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -372,8 +368,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 372 | try args.appendSlice(&[_][]const u8{ | 368 | try args.appendSlice(&[_][]const u8{ |
| 373 | "-std=gnu11", | 369 | "-std=gnu11", |
| 374 | "-fgnu89-inline", | 370 | "-fgnu89-inline", |
| 375 | "-g", | ||
| 376 | "-O2", | ||
| 377 | "-fmerge-all-constants", | 371 | "-fmerge-all-constants", |
| 378 | "-fno-stack-protector", | 372 | "-fno-stack-protector", |
| 379 | "-fmath-errno", | 373 | "-fmath-errno", |
| ... | @@ -409,8 +403,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -409,8 +403,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 409 | try args.appendSlice(&[_][]const u8{ | 403 | try args.appendSlice(&[_][]const u8{ |
| 410 | "-std=gnu11", | 404 | "-std=gnu11", |
| 411 | "-fgnu89-inline", | 405 | "-fgnu89-inline", |
| 412 | "-g", | ||
| 413 | "-O2", | ||
| 414 | "-fmerge-all-constants", | 406 | "-fmerge-all-constants", |
| 415 | "-fno-stack-protector", | 407 | "-fno-stack-protector", |
| 416 | "-fmath-errno", | 408 | "-fmath-errno", |
| ... | @@ -939,13 +931,13 @@ fn buildSharedLib( | ... | @@ -939,13 +931,13 @@ fn buildSharedLib( |
| 939 | .thread_pool = comp.thread_pool, | 931 | .thread_pool = comp.thread_pool, |
| 940 | .libc_installation = comp.bin_file.options.libc_installation, | 932 | .libc_installation = comp.bin_file.options.libc_installation, |
| 941 | .emit_bin = emit_bin, | 933 | .emit_bin = emit_bin, |
| 942 | .optimize_mode = comp.bin_file.options.optimize_mode, | 934 | .optimize_mode = comp.compilerRtOptMode(), |
| 943 | .want_sanitize_c = false, | 935 | .want_sanitize_c = false, |
| 944 | .want_stack_check = false, | 936 | .want_stack_check = false, |
| 945 | .want_valgrind = false, | 937 | .want_valgrind = false, |
| 946 | .want_tsan = false, | 938 | .want_tsan = false, |
| 947 | .emit_h = null, | 939 | .emit_h = null, |
| 948 | .strip = comp.bin_file.options.strip, | 940 | .strip = comp.compilerRtStrip(), |
| 949 | .is_native_os = false, | 941 | .is_native_os = false, |
| 950 | .is_native_abi = false, | 942 | .is_native_abi = false, |
| 951 | .self_exe_path = comp.self_exe_path, | 943 | .self_exe_path = comp.self_exe_path, |
src/libcxx.zig+4-9| ... | @@ -138,7 +138,6 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -138,7 +138,6 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 138 | try cflags.append("-I"); | 138 | try cflags.append("-I"); |
| 139 | try cflags.append(cxxabi_include_path); | 139 | try cflags.append(cxxabi_include_path); |
| 140 | 140 | ||
| 141 | try cflags.append("-O3"); | ||
| 142 | if (target_util.supports_fpic(target)) { | 141 | if (target_util.supports_fpic(target)) { |
| 143 | try cflags.append("-fPIC"); | 142 | try cflags.append("-fPIC"); |
| 144 | } | 143 | } |
| ... | @@ -164,7 +163,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -164,7 +163,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 164 | .thread_pool = comp.thread_pool, | 163 | .thread_pool = comp.thread_pool, |
| 165 | .libc_installation = comp.bin_file.options.libc_installation, | 164 | .libc_installation = comp.bin_file.options.libc_installation, |
| 166 | .emit_bin = emit_bin, | 165 | .emit_bin = emit_bin, |
| 167 | .optimize_mode = comp.bin_file.options.optimize_mode, | 166 | .optimize_mode = comp.compilerRtOptMode(), |
| 168 | .link_mode = link_mode, | 167 | .link_mode = link_mode, |
| 169 | .want_sanitize_c = false, | 168 | .want_sanitize_c = false, |
| 170 | .want_stack_check = false, | 169 | .want_stack_check = false, |
| ... | @@ -173,7 +172,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -173,7 +172,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 173 | .want_pic = comp.bin_file.options.pic, | 172 | .want_pic = comp.bin_file.options.pic, |
| 174 | .want_pie = comp.bin_file.options.pie, | 173 | .want_pie = comp.bin_file.options.pie, |
| 175 | .emit_h = null, | 174 | .emit_h = null, |
| 176 | .strip = comp.bin_file.options.strip, | 175 | .strip = comp.compilerRtStrip(), |
| 177 | .is_native_os = comp.bin_file.options.is_native_os, | 176 | .is_native_os = comp.bin_file.options.is_native_os, |
| 178 | .is_native_abi = comp.bin_file.options.is_native_abi, | 177 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 179 | .self_exe_path = comp.self_exe_path, | 178 | .self_exe_path = comp.self_exe_path, |
| ... | @@ -256,16 +255,12 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -256,16 +255,12 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 256 | try cflags.append("-I"); | 255 | try cflags.append("-I"); |
| 257 | try cflags.append(cxx_include_path); | 256 | try cflags.append(cxx_include_path); |
| 258 | 257 | ||
| 259 | try cflags.append("-O3"); | ||
| 260 | try cflags.append("-DNDEBUG"); | ||
| 261 | if (target_util.supports_fpic(target)) { | 258 | if (target_util.supports_fpic(target)) { |
| 262 | try cflags.append("-fPIC"); | 259 | try cflags.append("-fPIC"); |
| 263 | } | 260 | } |
| 264 | try cflags.append("-nostdinc++"); | 261 | try cflags.append("-nostdinc++"); |
| 265 | try cflags.append("-fstrict-aliasing"); | 262 | try cflags.append("-fstrict-aliasing"); |
| 266 | try cflags.append("-funwind-tables"); | 263 | try cflags.append("-funwind-tables"); |
| 267 | try cflags.append("-D_DEBUG"); | ||
| 268 | try cflags.append("-UNDEBUG"); | ||
| 269 | try cflags.append("-std=c++11"); | 264 | try cflags.append("-std=c++11"); |
| 270 | 265 | ||
| 271 | c_source_files[i] = .{ | 266 | c_source_files[i] = .{ |
| ... | @@ -285,7 +280,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -285,7 +280,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 285 | .thread_pool = comp.thread_pool, | 280 | .thread_pool = comp.thread_pool, |
| 286 | .libc_installation = comp.bin_file.options.libc_installation, | 281 | .libc_installation = comp.bin_file.options.libc_installation, |
| 287 | .emit_bin = emit_bin, | 282 | .emit_bin = emit_bin, |
| 288 | .optimize_mode = comp.bin_file.options.optimize_mode, | 283 | .optimize_mode = comp.compilerRtOptMode(), |
| 289 | .link_mode = link_mode, | 284 | .link_mode = link_mode, |
| 290 | .want_sanitize_c = false, | 285 | .want_sanitize_c = false, |
| 291 | .want_stack_check = false, | 286 | .want_stack_check = false, |
| ... | @@ -294,7 +289,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -294,7 +289,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 294 | .want_pic = comp.bin_file.options.pic, | 289 | .want_pic = comp.bin_file.options.pic, |
| 295 | .want_pie = comp.bin_file.options.pie, | 290 | .want_pie = comp.bin_file.options.pie, |
| 296 | .emit_h = null, | 291 | .emit_h = null, |
| 297 | .strip = comp.bin_file.options.strip, | 292 | .strip = comp.compilerRtStrip(), |
| 298 | .is_native_os = comp.bin_file.options.is_native_os, | 293 | .is_native_os = comp.bin_file.options.is_native_os, |
| 299 | .is_native_abi = comp.bin_file.options.is_native_abi, | 294 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 300 | .self_exe_path = comp.self_exe_path, | 295 | .self_exe_path = comp.self_exe_path, |
src/libtsan.zig+2-14| ... | @@ -43,8 +43,6 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -43,8 +43,6 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 43 | try cflags.append("-I"); | 43 | try cflags.append("-I"); |
| 44 | try cflags.append(tsan_include_path); | 44 | try cflags.append(tsan_include_path); |
| 45 | 45 | ||
| 46 | try cflags.append("-O3"); | ||
| 47 | try cflags.append("-DNDEBUG"); | ||
| 48 | try cflags.append("-nostdinc++"); | 46 | try cflags.append("-nostdinc++"); |
| 49 | try cflags.append("-fvisibility-inlines-hidden"); | 47 | try cflags.append("-fvisibility-inlines-hidden"); |
| 50 | try cflags.append("-std=c++14"); | 48 | try cflags.append("-std=c++14"); |
| ... | @@ -67,8 +65,6 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -67,8 +65,6 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 67 | try cflags.append("-I"); | 65 | try cflags.append("-I"); |
| 68 | try cflags.append(tsan_include_path); | 66 | try cflags.append(tsan_include_path); |
| 69 | 67 | ||
| 70 | try cflags.append("-O3"); | ||
| 71 | try cflags.append("-DNDEBUG"); | ||
| 72 | try cflags.append("-nostdinc++"); | 68 | try cflags.append("-nostdinc++"); |
| 73 | try cflags.append("-fvisibility-inlines-hidden"); | 69 | try cflags.append("-fvisibility-inlines-hidden"); |
| 74 | try cflags.append("-std=c++14"); | 70 | try cflags.append("-std=c++14"); |
| ... | @@ -110,8 +106,6 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -110,8 +106,6 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 110 | try cflags.append("-I"); | 106 | try cflags.append("-I"); |
| 111 | try cflags.append(sanitizer_common_include_path); | 107 | try cflags.append(sanitizer_common_include_path); |
| 112 | 108 | ||
| 113 | try cflags.append("-O3"); | ||
| 114 | try cflags.append("-DNDEBUG"); | ||
| 115 | try cflags.append("-nostdinc++"); | 109 | try cflags.append("-nostdinc++"); |
| 116 | try cflags.append("-fvisibility-inlines-hidden"); | 110 | try cflags.append("-fvisibility-inlines-hidden"); |
| 117 | try cflags.append("-std=c++14"); | 111 | try cflags.append("-std=c++14"); |
| ... | @@ -136,8 +130,6 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -136,8 +130,6 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 136 | try cflags.append("-I"); | 130 | try cflags.append("-I"); |
| 137 | try cflags.append(sanitizer_common_include_path); | 131 | try cflags.append(sanitizer_common_include_path); |
| 138 | 132 | ||
| 139 | try cflags.append("-O3"); | ||
| 140 | try cflags.append("-DNDEBUG"); | ||
| 141 | try cflags.append("-nostdinc++"); | 133 | try cflags.append("-nostdinc++"); |
| 142 | try cflags.append("-fvisibility-inlines-hidden"); | 134 | try cflags.append("-fvisibility-inlines-hidden"); |
| 143 | try cflags.append("-std=c++14"); | 135 | try cflags.append("-std=c++14"); |
| ... | @@ -158,8 +150,6 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -158,8 +150,6 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 158 | try cflags.append("-I"); | 150 | try cflags.append("-I"); |
| 159 | try cflags.append(tsan_include_path); | 151 | try cflags.append(tsan_include_path); |
| 160 | 152 | ||
| 161 | try cflags.append("-O3"); | ||
| 162 | try cflags.append("-DNDEBUG"); | ||
| 163 | try cflags.append("-nostdinc++"); | 153 | try cflags.append("-nostdinc++"); |
| 164 | try cflags.append("-fvisibility-inlines-hidden"); | 154 | try cflags.append("-fvisibility-inlines-hidden"); |
| 165 | try cflags.append("-std=c++14"); | 155 | try cflags.append("-std=c++14"); |
| ... | @@ -188,8 +178,6 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -188,8 +178,6 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 188 | try cflags.append("-I"); | 178 | try cflags.append("-I"); |
| 189 | try cflags.append(tsan_include_path); | 179 | try cflags.append(tsan_include_path); |
| 190 | 180 | ||
| 191 | try cflags.append("-O3"); | ||
| 192 | try cflags.append("-DNDEBUG"); | ||
| 193 | try cflags.append("-nostdinc++"); | 181 | try cflags.append("-nostdinc++"); |
| 194 | try cflags.append("-fvisibility-inlines-hidden"); | 182 | try cflags.append("-fvisibility-inlines-hidden"); |
| 195 | try cflags.append("-std=c++14"); | 183 | try cflags.append("-std=c++14"); |
| ... | @@ -218,7 +206,7 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -218,7 +206,7 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 218 | .thread_pool = comp.thread_pool, | 206 | .thread_pool = comp.thread_pool, |
| 219 | .libc_installation = comp.bin_file.options.libc_installation, | 207 | .libc_installation = comp.bin_file.options.libc_installation, |
| 220 | .emit_bin = emit_bin, | 208 | .emit_bin = emit_bin, |
| 221 | .optimize_mode = comp.bin_file.options.optimize_mode, | 209 | .optimize_mode = comp.compilerRtOptMode(), |
| 222 | .link_mode = link_mode, | 210 | .link_mode = link_mode, |
| 223 | .want_sanitize_c = false, | 211 | .want_sanitize_c = false, |
| 224 | .want_stack_check = false, | 212 | .want_stack_check = false, |
| ... | @@ -227,7 +215,7 @@ pub fn buildTsan(comp: *Compilation) !void { | ... | @@ -227,7 +215,7 @@ pub fn buildTsan(comp: *Compilation) !void { |
| 227 | .want_pic = true, | 215 | .want_pic = true, |
| 228 | .want_pie = true, | 216 | .want_pie = true, |
| 229 | .emit_h = null, | 217 | .emit_h = null, |
| 230 | .strip = comp.bin_file.options.strip, | 218 | .strip = comp.compilerRtStrip(), |
| 231 | .is_native_os = comp.bin_file.options.is_native_os, | 219 | .is_native_os = comp.bin_file.options.is_native_os, |
| 232 | .is_native_abi = comp.bin_file.options.is_native_abi, | 220 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 233 | .self_exe_path = comp.self_exe_path, | 221 | .self_exe_path = comp.self_exe_path, |
src/libunwind.zig+2-2| ... | @@ -104,7 +104,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { | ... | @@ -104,7 +104,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { |
| 104 | .thread_pool = comp.thread_pool, | 104 | .thread_pool = comp.thread_pool, |
| 105 | .libc_installation = comp.bin_file.options.libc_installation, | 105 | .libc_installation = comp.bin_file.options.libc_installation, |
| 106 | .emit_bin = emit_bin, | 106 | .emit_bin = emit_bin, |
| 107 | .optimize_mode = comp.bin_file.options.optimize_mode, | 107 | .optimize_mode = comp.compilerRtOptMode(), |
| 108 | .link_mode = link_mode, | 108 | .link_mode = link_mode, |
| 109 | .want_sanitize_c = false, | 109 | .want_sanitize_c = false, |
| 110 | .want_stack_check = false, | 110 | .want_stack_check = false, |
| ... | @@ -113,7 +113,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { | ... | @@ -113,7 +113,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { |
| 113 | .want_pic = comp.bin_file.options.pic, | 113 | .want_pic = comp.bin_file.options.pic, |
| 114 | .want_pie = comp.bin_file.options.pie, | 114 | .want_pie = comp.bin_file.options.pie, |
| 115 | .emit_h = null, | 115 | .emit_h = null, |
| 116 | .strip = comp.bin_file.options.strip, | 116 | .strip = comp.compilerRtStrip(), |
| 117 | .is_native_os = comp.bin_file.options.is_native_os, | 117 | .is_native_os = comp.bin_file.options.is_native_os, |
| 118 | .is_native_abi = comp.bin_file.options.is_native_abi, | 118 | .is_native_abi = comp.bin_file.options.is_native_abi, |
| 119 | .self_exe_path = comp.self_exe_path, | 119 | .self_exe_path = comp.self_exe_path, |
src/mingw.zig-9| ... | @@ -91,8 +91,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -91,8 +91,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 91 | "-D_CRTBLD", | 91 | "-D_CRTBLD", |
| 92 | "-D_WIN32_WINNT=0x0f00", | 92 | "-D_WIN32_WINNT=0x0f00", |
| 93 | "-D__MSVCRT_VERSION__=0x700", | 93 | "-D__MSVCRT_VERSION__=0x700", |
| 94 | "-g", | ||
| 95 | "-O2", | ||
| 96 | }); | 94 | }); |
| 97 | c_source_files[i] = .{ | 95 | c_source_files[i] = .{ |
| 98 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ | 96 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | @@ -119,9 +117,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -119,9 +117,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 119 | 117 | ||
| 120 | "-isystem", | 118 | "-isystem", |
| 121 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }), | 119 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }), |
| 122 | |||
| 123 | "-g", | ||
| 124 | "-O2", | ||
| 125 | }); | 120 | }); |
| 126 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); | 121 | var c_source_files = std.ArrayList(Compilation.CSourceFile).init(arena); |
| 127 | 122 | ||
| ... | @@ -167,8 +162,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -167,8 +162,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 167 | "-D_CRTBLD", | 162 | "-D_CRTBLD", |
| 168 | "-D_WIN32_WINNT=0x0f00", | 163 | "-D_WIN32_WINNT=0x0f00", |
| 169 | "-D__MSVCRT_VERSION__=0x700", | 164 | "-D__MSVCRT_VERSION__=0x700", |
| 170 | "-g", | ||
| 171 | "-O2", | ||
| 172 | 165 | ||
| 173 | "-isystem", | 166 | "-isystem", |
| 174 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }), | 167 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ "libc", "include", "any-windows-any" }), |
| ... | @@ -233,8 +226,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -233,8 +226,6 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 233 | "-D_CRTBLD", | 226 | "-D_CRTBLD", |
| 234 | "-D_WIN32_WINNT=0x0f00", | 227 | "-D_WIN32_WINNT=0x0f00", |
| 235 | "-D__MSVCRT_VERSION__=0x700", | 228 | "-D__MSVCRT_VERSION__=0x700", |
| 236 | "-g", | ||
| 237 | "-O2", | ||
| 238 | 229 | ||
| 239 | "-isystem", | 230 | "-isystem", |
| 240 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ | 231 | try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
src/musl.zig+2-2| ... | @@ -203,13 +203,13 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -203,13 +203,13 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 203 | .thread_pool = comp.thread_pool, | 203 | .thread_pool = comp.thread_pool, |
| 204 | .libc_installation = comp.bin_file.options.libc_installation, | 204 | .libc_installation = comp.bin_file.options.libc_installation, |
| 205 | .emit_bin = Compilation.EmitLoc{ .directory = null, .basename = "libc.so" }, | 205 | .emit_bin = Compilation.EmitLoc{ .directory = null, .basename = "libc.so" }, |
| 206 | .optimize_mode = comp.bin_file.options.optimize_mode, | 206 | .optimize_mode = comp.compilerRtOptMode(), |
| 207 | .want_sanitize_c = false, | 207 | .want_sanitize_c = false, |
| 208 | .want_stack_check = false, | 208 | .want_stack_check = false, |
| 209 | .want_valgrind = false, | 209 | .want_valgrind = false, |
| 210 | .want_tsan = false, | 210 | .want_tsan = false, |
| 211 | .emit_h = null, | 211 | .emit_h = null, |
| 212 | .strip = comp.bin_file.options.strip, | 212 | .strip = comp.compilerRtStrip(), |
| 213 | .is_native_os = false, | 213 | .is_native_os = false, |
| 214 | .is_native_abi = false, | 214 | .is_native_abi = false, |
| 215 | .self_exe_path = comp.self_exe_path, | 215 | .self_exe_path = comp.self_exe_path, |
src/target.zig+8| ... | @@ -344,3 +344,11 @@ pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { | ... | @@ -344,3 +344,11 @@ pub fn is_libcpp_lib_name(target: std.Target, name: []const u8) bool { |
| 344 | pub fn hasDebugInfo(target: std.Target) bool { | 344 | pub fn hasDebugInfo(target: std.Target) bool { |
| 345 | return !target.cpu.arch.isWasm(); | 345 | return !target.cpu.arch.isWasm(); |
| 346 | } | 346 | } |
| 347 | |||
| 348 | pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode { | ||
| 349 | if (target.cpu.arch.isWasm() and target.os.tag == .freestanding) { | ||
| 350 | return .ReleaseSmall; | ||
| 351 | } else { | ||
| 352 | return .ReleaseFast; | ||
| 353 | } | ||
| 354 | } |