| author | |
| committer | |
| log | 0edde40c25c033aec67f235365593ee26ff52740 |
| tree | dfdd8caf259e2d03ba89d4c0211d9cafb45c6064 |
| parent | 56c03881ebd8617e6506bfad01bf9cfdd4d3df7e |
| parent | 5b2a79848ced20db80f3f4ce46b3ef7f4a051d53 |
Merges #751116 files changed, 118 insertions(+), 30 deletions(-)
lib/std/build.zig+9| ... | @@ -1332,6 +1332,8 @@ pub const LibExeObjStep = struct { | ... | @@ -1332,6 +1332,8 @@ pub const LibExeObjStep = struct { |
| 1332 | /// Position Independent Executable | 1332 | /// Position Independent Executable |
| 1333 | pie: ?bool = null, | 1333 | pie: ?bool = null, |
| 1334 | 1334 | ||
| 1335 | red_zone: ?bool = null, | ||
| 1336 | |||
| 1335 | subsystem: ?builtin.SubSystem = null, | 1337 | subsystem: ?builtin.SubSystem = null, |
| 1336 | 1338 | ||
| 1337 | /// Overrides the default stack size | 1339 | /// Overrides the default stack size |
| ... | @@ -2260,6 +2262,13 @@ pub const LibExeObjStep = struct { | ... | @@ -2260,6 +2262,13 @@ pub const LibExeObjStep = struct { |
| 2260 | if (self.disable_stack_probing) { | 2262 | if (self.disable_stack_probing) { |
| 2261 | try zig_args.append("-fno-stack-check"); | 2263 | try zig_args.append("-fno-stack-check"); |
| 2262 | } | 2264 | } |
| 2265 | if (self.red_zone) |red_zone| { | ||
| 2266 | if (red_zone) { | ||
| 2267 | try zig_args.append("-mred-zone"); | ||
| 2268 | } else { | ||
| 2269 | try zig_args.append("-mno-red-zone"); | ||
| 2270 | } | ||
| 2271 | } | ||
| 2263 | if (self.disable_sanitize_c) { | 2272 | if (self.disable_sanitize_c) { |
| 2264 | try zig_args.append("-fno-sanitize-c"); | 2273 | try zig_args.append("-fno-sanitize-c"); |
| 2265 | } | 2274 | } |
src/Compilation.zig+13| ... | @@ -392,6 +392,7 @@ pub const InitOptions = struct { | ... | @@ -392,6 +392,7 @@ pub const InitOptions = struct { |
| 392 | want_pie: ?bool = null, | 392 | want_pie: ?bool = null, |
| 393 | want_sanitize_c: ?bool = null, | 393 | want_sanitize_c: ?bool = null, |
| 394 | want_stack_check: ?bool = null, | 394 | want_stack_check: ?bool = null, |
| 395 | want_red_zone: ?bool = null, | ||
| 395 | want_valgrind: ?bool = null, | 396 | want_valgrind: ?bool = null, |
| 396 | want_tsan: ?bool = null, | 397 | want_tsan: ?bool = null, |
| 397 | want_compiler_rt: ?bool = null, | 398 | want_compiler_rt: ?bool = null, |
| ... | @@ -743,6 +744,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -743,6 +744,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 743 | } else null; | 744 | } else null; |
| 744 | 745 | ||
| 745 | const strip = options.strip or !target_util.hasDebugInfo(options.target); | 746 | const strip = options.strip or !target_util.hasDebugInfo(options.target); |
| 747 | const red_zone = options.want_red_zone orelse target_util.hasRedZone(options.target); | ||
| 746 | 748 | ||
| 747 | // We put everything into the cache hash that *cannot be modified during an incremental update*. | 749 | // We put everything into the cache hash that *cannot be modified during an incremental update*. |
| 748 | // For example, one cannot change the target between updates, but one can change source files, | 750 | // For example, one cannot change the target between updates, but one can change source files, |
| ... | @@ -773,6 +775,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -773,6 +775,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 773 | cache.hash.add(pie); | 775 | cache.hash.add(pie); |
| 774 | cache.hash.add(tsan); | 776 | cache.hash.add(tsan); |
| 775 | cache.hash.add(stack_check); | 777 | cache.hash.add(stack_check); |
| 778 | cache.hash.add(red_zone); | ||
| 776 | cache.hash.add(link_mode); | 779 | cache.hash.add(link_mode); |
| 777 | cache.hash.add(options.function_sections); | 780 | cache.hash.add(options.function_sections); |
| 778 | cache.hash.add(strip); | 781 | cache.hash.add(strip); |
| ... | @@ -982,6 +985,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { | ... | @@ -982,6 +985,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 982 | .valgrind = valgrind, | 985 | .valgrind = valgrind, |
| 983 | .tsan = tsan, | 986 | .tsan = tsan, |
| 984 | .stack_check = stack_check, | 987 | .stack_check = stack_check, |
| 988 | .red_zone = red_zone, | ||
| 985 | .single_threaded = single_threaded, | 989 | .single_threaded = single_threaded, |
| 986 | .verbose_link = options.verbose_link, | 990 | .verbose_link = options.verbose_link, |
| 987 | .machine_code_model = options.machine_code_model, | 991 | .machine_code_model = options.machine_code_model, |
| ... | @@ -2256,6 +2260,12 @@ pub fn addCCArgs( | ... | @@ -2256,6 +2260,12 @@ pub fn addCCArgs( |
| 2256 | try argv.append("-fsanitize=thread"); | 2260 | try argv.append("-fsanitize=thread"); |
| 2257 | } | 2261 | } |
| 2258 | 2262 | ||
| 2263 | if (comp.bin_file.options.red_zone) { | ||
| 2264 | try argv.append("-mred-zone"); | ||
| 2265 | } else if (target_util.hasRedZone(target)) { | ||
| 2266 | try argv.append("-mno-red-zone"); | ||
| 2267 | } | ||
| 2268 | |||
| 2259 | switch (comp.bin_file.options.optimize_mode) { | 2269 | switch (comp.bin_file.options.optimize_mode) { |
| 2260 | .Debug => { | 2270 | .Debug => { |
| 2261 | // windows c runtime requires -D_DEBUG if using debug libraries | 2271 | // windows c runtime requires -D_DEBUG if using debug libraries |
| ... | @@ -2960,6 +2970,7 @@ fn buildOutputFromZig( | ... | @@ -2960,6 +2970,7 @@ fn buildOutputFromZig( |
| 2960 | .function_sections = true, | 2970 | .function_sections = true, |
| 2961 | .want_sanitize_c = false, | 2971 | .want_sanitize_c = false, |
| 2962 | .want_stack_check = false, | 2972 | .want_stack_check = false, |
| 2973 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 2963 | .want_valgrind = false, | 2974 | .want_valgrind = false, |
| 2964 | .want_tsan = false, | 2975 | .want_tsan = false, |
| 2965 | .want_pic = comp.bin_file.options.pic, | 2976 | .want_pic = comp.bin_file.options.pic, |
| ... | @@ -3198,6 +3209,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node | ... | @@ -3198,6 +3209,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node |
| 3198 | .tsan_enabled = comp.bin_file.options.tsan, | 3209 | .tsan_enabled = comp.bin_file.options.tsan, |
| 3199 | .function_sections = comp.bin_file.options.function_sections, | 3210 | .function_sections = comp.bin_file.options.function_sections, |
| 3200 | .enable_stack_probing = comp.bin_file.options.stack_check, | 3211 | .enable_stack_probing = comp.bin_file.options.stack_check, |
| 3212 | .red_zone = comp.bin_file.options.red_zone, | ||
| 3201 | .enable_time_report = comp.time_report, | 3213 | .enable_time_report = comp.time_report, |
| 3202 | .enable_stack_report = comp.stack_report, | 3214 | .enable_stack_report = comp.stack_report, |
| 3203 | .test_is_evented = comp.test_evented_io, | 3215 | .test_is_evented = comp.test_evented_io, |
| ... | @@ -3342,6 +3354,7 @@ pub fn build_crt_file( | ... | @@ -3342,6 +3354,7 @@ pub fn build_crt_file( |
| 3342 | .optimize_mode = comp.compilerRtOptMode(), | 3354 | .optimize_mode = comp.compilerRtOptMode(), |
| 3343 | .want_sanitize_c = false, | 3355 | .want_sanitize_c = false, |
| 3344 | .want_stack_check = false, | 3356 | .want_stack_check = false, |
| 3357 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 3345 | .want_valgrind = false, | 3358 | .want_valgrind = false, |
| 3346 | .want_tsan = false, | 3359 | .want_tsan = false, |
| 3347 | .want_pic = comp.bin_file.options.pic, | 3360 | .want_pic = comp.bin_file.options.pic, |
src/clang_options_data.zig+16-2| ... | @@ -3803,7 +3803,14 @@ flagpd1("mno-qpx"), | ... | @@ -3803,7 +3803,14 @@ flagpd1("mno-qpx"), |
| 3803 | flagpd1("mno-rdpid"), | 3803 | flagpd1("mno-rdpid"), |
| 3804 | flagpd1("mno-rdrnd"), | 3804 | flagpd1("mno-rdrnd"), |
| 3805 | flagpd1("mno-rdseed"), | 3805 | flagpd1("mno-rdseed"), |
| 3806 | flagpd1("mno-red-zone"), | 3806 | .{ |
| 3807 | .name = "mno-red-zone", | ||
| 3808 | .syntax = .flag, | ||
| 3809 | .zig_equivalent = .no_red_zone, | ||
| 3810 | .pd1 = true, | ||
| 3811 | .pd2 = false, | ||
| 3812 | .psl = false, | ||
| 3813 | }, | ||
| 3807 | flagpd1("mno-reference-types"), | 3814 | flagpd1("mno-reference-types"), |
| 3808 | flagpd1("mno-relax"), | 3815 | flagpd1("mno-relax"), |
| 3809 | flagpd1("mno-relax-all"), | 3816 | flagpd1("mno-relax-all"), |
| ... | @@ -3901,7 +3908,14 @@ flagpd1("mrdseed"), | ... | @@ -3901,7 +3908,14 @@ flagpd1("mrdseed"), |
| 3901 | flagpd1("mreassociate"), | 3908 | flagpd1("mreassociate"), |
| 3902 | flagpd1("mrecip"), | 3909 | flagpd1("mrecip"), |
| 3903 | flagpd1("mrecord-mcount"), | 3910 | flagpd1("mrecord-mcount"), |
| 3904 | flagpd1("mred-zone"), | 3911 | .{ |
| 3912 | .name = "mred-zone", | ||
| 3913 | .syntax = .flag, | ||
| 3914 | .zig_equivalent = .red_zone, | ||
| 3915 | .pd1 = true, | ||
| 3916 | .pd2 = false, | ||
| 3917 | .psl = false, | ||
| 3918 | }, | ||
| 3905 | flagpd1("mreference-types"), | 3919 | flagpd1("mreference-types"), |
| 3906 | sepd1("mregparm"), | 3920 | sepd1("mregparm"), |
| 3907 | flagpd1("mrelax"), | 3921 | flagpd1("mrelax"), |
src/glibc.zig+1| ... | @@ -934,6 +934,7 @@ fn buildSharedLib( | ... | @@ -934,6 +934,7 @@ fn buildSharedLib( |
| 934 | .optimize_mode = comp.compilerRtOptMode(), | 934 | .optimize_mode = comp.compilerRtOptMode(), |
| 935 | .want_sanitize_c = false, | 935 | .want_sanitize_c = false, |
| 936 | .want_stack_check = false, | 936 | .want_stack_check = false, |
| 937 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 937 | .want_valgrind = false, | 938 | .want_valgrind = false, |
| 938 | .want_tsan = false, | 939 | .want_tsan = false, |
| 939 | .emit_h = null, | 940 | .emit_h = null, |
src/libcxx.zig+2| ... | @@ -167,6 +167,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { | ... | @@ -167,6 +167,7 @@ pub fn buildLibCXX(comp: *Compilation) !void { |
| 167 | .link_mode = link_mode, | 167 | .link_mode = link_mode, |
| 168 | .want_sanitize_c = false, | 168 | .want_sanitize_c = false, |
| 169 | .want_stack_check = false, | 169 | .want_stack_check = false, |
| 170 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 170 | .want_valgrind = false, | 171 | .want_valgrind = false, |
| 171 | .want_tsan = comp.bin_file.options.tsan, | 172 | .want_tsan = comp.bin_file.options.tsan, |
| 172 | .want_pic = comp.bin_file.options.pic, | 173 | .want_pic = comp.bin_file.options.pic, |
| ... | @@ -284,6 +285,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { | ... | @@ -284,6 +285,7 @@ pub fn buildLibCXXABI(comp: *Compilation) !void { |
| 284 | .link_mode = link_mode, | 285 | .link_mode = link_mode, |
| 285 | .want_sanitize_c = false, | 286 | .want_sanitize_c = false, |
| 286 | .want_stack_check = false, | 287 | .want_stack_check = false, |
| 288 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 287 | .want_valgrind = false, | 289 | .want_valgrind = false, |
| 288 | .want_tsan = comp.bin_file.options.tsan, | 290 | .want_tsan = comp.bin_file.options.tsan, |
| 289 | .want_pic = comp.bin_file.options.pic, | 291 | .want_pic = comp.bin_file.options.pic, |
src/libunwind.zig+1| ... | @@ -108,6 +108,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { | ... | @@ -108,6 +108,7 @@ pub fn buildStaticLib(comp: *Compilation) !void { |
| 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, |
| 111 | .want_red_zone = comp.bin_file.options.red_zone, | ||
| 111 | .want_valgrind = false, | 112 | .want_valgrind = false, |
| 112 | .want_tsan = false, | 113 | .want_tsan = false, |
| 113 | .want_pic = comp.bin_file.options.pic, | 114 | .want_pic = comp.bin_file.options.pic, |
src/link.zig+1| ... | @@ -77,6 +77,7 @@ pub const Options = struct { | ... | @@ -77,6 +77,7 @@ pub const Options = struct { |
| 77 | valgrind: bool, | 77 | valgrind: bool, |
| 78 | tsan: bool, | 78 | tsan: bool, |
| 79 | stack_check: bool, | 79 | stack_check: bool, |
| 80 | red_zone: bool, | ||
| 80 | single_threaded: bool, | 81 | single_threaded: bool, |
| 81 | verbose_link: bool, | 82 | verbose_link: bool, |
| 82 | dll_export_fns: bool, | 83 | dll_export_fns: bool, |
src/main.zig+12| ... | @@ -267,6 +267,8 @@ const usage_build_generic = | ... | @@ -267,6 +267,8 @@ const usage_build_generic = |
| 267 | \\ -mcmodel=[default|tiny| Limit range of code and data virtual addresses | 267 | \\ -mcmodel=[default|tiny| Limit range of code and data virtual addresses |
| 268 | \\ small|kernel| | 268 | \\ small|kernel| |
| 269 | \\ medium|large] | 269 | \\ medium|large] |
| 270 | \\ -mred-zone Force-enable the "red-zone" | ||
| 271 | \\ -mno-red-zone Force-disable the "red-zone" | ||
| 270 | \\ --name [name] Override root name (not a file path) | 272 | \\ --name [name] Override root name (not a file path) |
| 271 | \\ -O [mode] Choose what to optimize for | 273 | \\ -O [mode] Choose what to optimize for |
| 272 | \\ Debug (default) Optimizations off, safety on | 274 | \\ Debug (default) Optimizations off, safety on |
| ... | @@ -505,6 +507,7 @@ fn buildOutputType( | ... | @@ -505,6 +507,7 @@ fn buildOutputType( |
| 505 | var want_pie: ?bool = null; | 507 | var want_pie: ?bool = null; |
| 506 | var want_sanitize_c: ?bool = null; | 508 | var want_sanitize_c: ?bool = null; |
| 507 | var want_stack_check: ?bool = null; | 509 | var want_stack_check: ?bool = null; |
| 510 | var want_red_zone: ?bool = null; | ||
| 508 | var want_valgrind: ?bool = null; | 511 | var want_valgrind: ?bool = null; |
| 509 | var want_tsan: ?bool = null; | 512 | var want_tsan: ?bool = null; |
| 510 | var want_compiler_rt: ?bool = null; | 513 | var want_compiler_rt: ?bool = null; |
| ... | @@ -843,6 +846,10 @@ fn buildOutputType( | ... | @@ -843,6 +846,10 @@ fn buildOutputType( |
| 843 | want_stack_check = true; | 846 | want_stack_check = true; |
| 844 | } else if (mem.eql(u8, arg, "-fno-stack-check")) { | 847 | } else if (mem.eql(u8, arg, "-fno-stack-check")) { |
| 845 | want_stack_check = false; | 848 | want_stack_check = false; |
| 849 | } else if (mem.eql(u8, arg, "-mred-zone")) { | ||
| 850 | want_red_zone = true; | ||
| 851 | } else if (mem.eql(u8, arg, "-mno-red-zone")) { | ||
| 852 | want_red_zone = false; | ||
| 846 | } else if (mem.eql(u8, arg, "-fsanitize-c")) { | 853 | } else if (mem.eql(u8, arg, "-fsanitize-c")) { |
| 847 | want_sanitize_c = true; | 854 | want_sanitize_c = true; |
| 848 | } else if (mem.eql(u8, arg, "-fno-sanitize-c")) { | 855 | } else if (mem.eql(u8, arg, "-fno-sanitize-c")) { |
| ... | @@ -1068,6 +1075,8 @@ fn buildOutputType( | ... | @@ -1068,6 +1075,8 @@ fn buildOutputType( |
| 1068 | .no_pic => want_pic = false, | 1075 | .no_pic => want_pic = false, |
| 1069 | .pie => want_pie = true, | 1076 | .pie => want_pie = true, |
| 1070 | .no_pie => want_pie = false, | 1077 | .no_pie => want_pie = false, |
| 1078 | .red_zone => want_red_zone = true, | ||
| 1079 | .no_red_zone => want_red_zone = false, | ||
| 1071 | .nostdlib => ensure_libc_on_non_freestanding = false, | 1080 | .nostdlib => ensure_libc_on_non_freestanding = false, |
| 1072 | .nostdlib_cpp => ensure_libcpp_on_non_freestanding = false, | 1081 | .nostdlib_cpp => ensure_libcpp_on_non_freestanding = false, |
| 1073 | .shared => { | 1082 | .shared => { |
| ... | @@ -1760,6 +1769,7 @@ fn buildOutputType( | ... | @@ -1760,6 +1769,7 @@ fn buildOutputType( |
| 1760 | .want_pie = want_pie, | 1769 | .want_pie = want_pie, |
| 1761 | .want_sanitize_c = want_sanitize_c, | 1770 | .want_sanitize_c = want_sanitize_c, |
| 1762 | .want_stack_check = want_stack_check, | 1771 | .want_stack_check = want_stack_check, |
| 1772 | .want_red_zone = want_red_zone, | ||
| 1763 | .want_valgrind = want_valgrind, | 1773 | .want_valgrind = want_valgrind, |
| 1764 | .want_tsan = want_tsan, | 1774 | .want_tsan = want_tsan, |
| 1765 | .want_compiler_rt = want_compiler_rt, | 1775 | .want_compiler_rt = want_compiler_rt, |
| ... | @@ -2969,6 +2979,8 @@ pub const ClangArgIterator = struct { | ... | @@ -2969,6 +2979,8 @@ pub const ClangArgIterator = struct { |
| 2969 | framework_dir, | 2979 | framework_dir, |
| 2970 | framework, | 2980 | framework, |
| 2971 | nostdlibinc, | 2981 | nostdlibinc, |
| 2982 | red_zone, | ||
| 2983 | no_red_zone, | ||
| 2972 | }; | 2984 | }; |
| 2973 | 2985 | ||
| 2974 | const Args = struct { | 2986 | const Args = struct { |
src/musl.zig+1| ... | @@ -206,6 +206,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { | ... | @@ -206,6 +206,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void { |
| 206 | .optimize_mode = comp.compilerRtOptMode(), | 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_red_zone = comp.bin_file.options.red_zone, | ||
| 209 | .want_valgrind = false, | 210 | .want_valgrind = false, |
| 210 | .want_tsan = false, | 211 | .want_tsan = false, |
| 211 | .emit_h = null, | 212 | .emit_h = null, |
src/stage1.zig+1| ... | @@ -119,6 +119,7 @@ pub const Module = extern struct { | ... | @@ -119,6 +119,7 @@ pub const Module = extern struct { |
| 119 | tsan_enabled: bool, | 119 | tsan_enabled: bool, |
| 120 | function_sections: bool, | 120 | function_sections: bool, |
| 121 | enable_stack_probing: bool, | 121 | enable_stack_probing: bool, |
| 122 | red_zone: bool, | ||
| 122 | enable_time_report: bool, | 123 | enable_time_report: bool, |
| 123 | enable_stack_report: bool, | 124 | enable_stack_report: bool, |
| 124 | test_is_evented: bool, | 125 | test_is_evented: bool, |
src/stage1/all_types.hpp+1| ... | @@ -2195,6 +2195,7 @@ struct CodeGen { | ... | @@ -2195,6 +2195,7 @@ struct CodeGen { |
| 2195 | bool link_mode_dynamic; | 2195 | bool link_mode_dynamic; |
| 2196 | bool dll_export_fns; | 2196 | bool dll_export_fns; |
| 2197 | bool have_stack_probing; | 2197 | bool have_stack_probing; |
| 2198 | bool red_zone; | ||
| 2198 | bool function_sections; | 2199 | bool function_sections; |
| 2199 | bool test_is_evented; | 2200 | bool test_is_evented; |
| 2200 | bool valgrind_enabled; | 2201 | bool valgrind_enabled; |
src/stage1/codegen.cpp+4| ... | @@ -514,6 +514,10 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { | ... | @@ -514,6 +514,10 @@ static LLVMValueRef make_fn_llvm_value(CodeGen *g, ZigFn *fn) { |
| 514 | maybe_import_dll(g, llvm_fn, linkage); | 514 | maybe_import_dll(g, llvm_fn, linkage); |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | if (!g->red_zone) { | ||
| 518 | addLLVMFnAttr(llvm_fn, "noredzone"); | ||
| 519 | } | ||
| 520 | |||
| 517 | if (fn->alignstack_value != 0) { | 521 | if (fn->alignstack_value != 0) { |
| 518 | addLLVMFnAttrInt(llvm_fn, "alignstack", fn->alignstack_value); | 522 | addLLVMFnAttrInt(llvm_fn, "alignstack", fn->alignstack_value); |
| 519 | } | 523 | } |
src/stage1/stage1.cpp+1| ... | @@ -91,6 +91,7 @@ void zig_stage1_build_object(struct ZigStage1 *stage1) { | ... | @@ -91,6 +91,7 @@ void zig_stage1_build_object(struct ZigStage1 *stage1) { |
| 91 | g->have_pic = stage1->pic; | 91 | g->have_pic = stage1->pic; |
| 92 | g->have_pie = stage1->pie; | 92 | g->have_pie = stage1->pie; |
| 93 | g->have_stack_probing = stage1->enable_stack_probing; | 93 | g->have_stack_probing = stage1->enable_stack_probing; |
| 94 | g->red_zone = stage1->red_zone; | ||
| 94 | g->is_single_threaded = stage1->is_single_threaded; | 95 | g->is_single_threaded = stage1->is_single_threaded; |
| 95 | g->valgrind_enabled = stage1->valgrind_enabled; | 96 | g->valgrind_enabled = stage1->valgrind_enabled; |
| 96 | g->tsan_enabled = stage1->tsan_enabled; | 97 | g->tsan_enabled = stage1->tsan_enabled; |
src/stage1/stage1.h+1| ... | @@ -188,6 +188,7 @@ struct ZigStage1 { | ... | @@ -188,6 +188,7 @@ struct ZigStage1 { |
| 188 | bool tsan_enabled; | 188 | bool tsan_enabled; |
| 189 | bool function_sections; | 189 | bool function_sections; |
| 190 | bool enable_stack_probing; | 190 | bool enable_stack_probing; |
| 191 | bool red_zone; | ||
| 191 | bool enable_time_report; | 192 | bool enable_time_report; |
| 192 | bool enable_stack_report; | 193 | bool enable_stack_report; |
| 193 | bool test_is_evented; | 194 | bool test_is_evented; |
src/target.zig+18| ... | @@ -349,3 +349,21 @@ pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode { | ... | @@ -349,3 +349,21 @@ pub fn defaultCompilerRtOptimizeMode(target: std.Target) std.builtin.Mode { |
| 349 | return .ReleaseFast; | 349 | return .ReleaseFast; |
| 350 | } | 350 | } |
| 351 | } | 351 | } |
| 352 | |||
| 353 | pub fn hasRedZone(target: std.Target) bool { | ||
| 354 | return switch (target.cpu.arch) { | ||
| 355 | .x86_64, | ||
| 356 | .i386, | ||
| 357 | .wasm32, | ||
| 358 | .wasm64, | ||
| 359 | .powerpc, | ||
| 360 | .powerpc64, | ||
| 361 | .powerpc64le, | ||
| 362 | .aarch64, | ||
| 363 | .aarch64_be, | ||
| 364 | .aarch64_32, | ||
| 365 | => true, | ||
| 366 | |||
| 367 | else => false, | ||
| 368 | }; | ||
| 369 | } |
tools/update_clang_options.zig+36-28| ... | @@ -248,6 +248,14 @@ const known_options = [_]KnownOpt{ | ... | @@ -248,6 +248,14 @@ const known_options = [_]KnownOpt{ |
| 248 | .name = "mtune", | 248 | .name = "mtune", |
| 249 | .ident = "mcpu", | 249 | .ident = "mcpu", |
| 250 | }, | 250 | }, |
| 251 | .{ | ||
| 252 | .name = "mred-zone", | ||
| 253 | .ident = "red_zone", | ||
| 254 | }, | ||
| 255 | .{ | ||
| 256 | .name = "mno-red-zone", | ||
| 257 | .ident = "no_red_zone", | ||
| 258 | }, | ||
| 251 | .{ | 259 | .{ |
| 252 | .name = "MD", | 260 | .name = "MD", |
| 253 | .ident = "dep_file", | 261 | .ident = "dep_file", |
| ... | @@ -340,9 +348,9 @@ pub fn main() anyerror!void { | ... | @@ -340,9 +348,9 @@ pub fn main() anyerror!void { |
| 340 | const child_args = [_][]const u8{ | 348 | const child_args = [_][]const u8{ |
| 341 | llvm_tblgen_exe, | 349 | llvm_tblgen_exe, |
| 342 | "--dump-json", | 350 | "--dump-json", |
| 343 | try std.fmt.allocPrint(allocator, "{}/clang/include/clang/Driver/Options.td", .{llvm_src_root}), | 351 | try std.fmt.allocPrint(allocator, "{s}/clang/include/clang/Driver/Options.td", .{llvm_src_root}), |
| 344 | try std.fmt.allocPrint(allocator, "-I={}/llvm/include", .{llvm_src_root}), | 352 | try std.fmt.allocPrint(allocator, "-I={s}/llvm/include", .{llvm_src_root}), |
| 345 | try std.fmt.allocPrint(allocator, "-I={}/clang/include/clang/Driver", .{llvm_src_root}), | 353 | try std.fmt.allocPrint(allocator, "-I={s}/clang/include/clang/Driver", .{llvm_src_root}), |
| 346 | }; | 354 | }; |
| 347 | 355 | ||
| 348 | const child_result = try std.ChildProcess.exec(.{ | 356 | const child_result = try std.ChildProcess.exec(.{ |
| ... | @@ -351,11 +359,11 @@ pub fn main() anyerror!void { | ... | @@ -351,11 +359,11 @@ pub fn main() anyerror!void { |
| 351 | .max_output_bytes = 100 * 1024 * 1024, | 359 | .max_output_bytes = 100 * 1024 * 1024, |
| 352 | }); | 360 | }); |
| 353 | 361 | ||
| 354 | std.debug.warn("{}\n", .{child_result.stderr}); | 362 | std.debug.warn("{s}\n", .{child_result.stderr}); |
| 355 | 363 | ||
| 356 | const json_text = switch (child_result.term) { | 364 | const json_text = switch (child_result.term) { |
| 357 | .Exited => |code| if (code == 0) child_result.stdout else { | 365 | .Exited => |code| if (code == 0) child_result.stdout else { |
| 358 | std.debug.warn("llvm-tblgen exited with code {}\n", .{code}); | 366 | std.debug.warn("llvm-tblgen exited with code {d}\n", .{code}); |
| 359 | std.process.exit(1); | 367 | std.process.exit(1); |
| 360 | }, | 368 | }, |
| 361 | else => { | 369 | else => { |
| ... | @@ -412,7 +420,7 @@ pub fn main() anyerror!void { | ... | @@ -412,7 +420,7 @@ pub fn main() anyerror!void { |
| 412 | } else if (std.mem.eql(u8, prefix, "/")) { | 420 | } else if (std.mem.eql(u8, prefix, "/")) { |
| 413 | pslash = true; | 421 | pslash = true; |
| 414 | } else { | 422 | } else { |
| 415 | std.debug.warn("{} has unrecognized prefix '{}'\n", .{ name, prefix }); | 423 | std.debug.warn("{s} has unrecognized prefix '{s}'\n", .{ name, prefix }); |
| 416 | std.process.exit(1); | 424 | std.process.exit(1); |
| 417 | } | 425 | } |
| 418 | } | 426 | } |
| ... | @@ -422,7 +430,7 @@ pub fn main() anyerror!void { | ... | @@ -422,7 +430,7 @@ pub fn main() anyerror!void { |
| 422 | // `-MT foo` is ambiguous because there is also an -MT flag | 430 | // `-MT foo` is ambiguous because there is also an -MT flag |
| 423 | // The canonical way to specify the flag is with `/MT` and so we make this | 431 | // The canonical way to specify the flag is with `/MT` and so we make this |
| 424 | // the only way. | 432 | // the only way. |
| 425 | try stdout.print("flagpsl(\"{}\"),\n", .{name}); | 433 | try stdout.print("flagpsl(\"{s}\"),\n", .{name}); |
| 426 | } else if (knownOption(name)) |ident| { | 434 | } else if (knownOption(name)) |ident| { |
| 427 | 435 | ||
| 428 | // Workaround the fact that in 'Options.td' -Ofast is listed as 'joined' | 436 | // Workaround the fact that in 'Options.td' -Ofast is listed as 'joined' |
| ... | @@ -430,34 +438,34 @@ pub fn main() anyerror!void { | ... | @@ -430,34 +438,34 @@ pub fn main() anyerror!void { |
| 430 | 438 | ||
| 431 | try stdout.print( | 439 | try stdout.print( |
| 432 | \\.{{ | 440 | \\.{{ |
| 433 | \\ .name = "{}", | 441 | \\ .name = "{s}", |
| 434 | \\ .syntax = {}, | 442 | \\ .syntax = {s}, |
| 435 | \\ .zig_equivalent = .{}, | 443 | \\ .zig_equivalent = .{s}, |
| 436 | \\ .pd1 = {}, | 444 | \\ .pd1 = {s}, |
| 437 | \\ .pd2 = {}, | 445 | \\ .pd2 = {s}, |
| 438 | \\ .psl = {}, | 446 | \\ .psl = {s}, |
| 439 | \\}}, | 447 | \\}}, |
| 440 | \\ | 448 | \\ |
| 441 | , .{ name, final_syntax, ident, pd1, pd2, pslash }); | 449 | , .{ name, final_syntax, ident, pd1, pd2, pslash }); |
| 442 | } else if (pd1 and !pd2 and !pslash and syntax == .flag) { | 450 | } else if (pd1 and !pd2 and !pslash and syntax == .flag) { |
| 443 | try stdout.print("flagpd1(\"{}\"),\n", .{name}); | 451 | try stdout.print("flagpd1(\"{s}\"),\n", .{name}); |
| 444 | } else if (!pd1 and !pd2 and pslash and syntax == .flag) { | 452 | } else if (!pd1 and !pd2 and pslash and syntax == .flag) { |
| 445 | try stdout.print("flagpsl(\"{}\"),\n", .{name}); | 453 | try stdout.print("flagpsl(\"{s}\"),\n", .{name}); |
| 446 | } else if (pd1 and !pd2 and !pslash and syntax == .joined) { | 454 | } else if (pd1 and !pd2 and !pslash and syntax == .joined) { |
| 447 | try stdout.print("joinpd1(\"{}\"),\n", .{name}); | 455 | try stdout.print("joinpd1(\"{s}\"),\n", .{name}); |
| 448 | } else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) { | 456 | } else if (pd1 and !pd2 and !pslash and syntax == .joined_or_separate) { |
| 449 | try stdout.print("jspd1(\"{}\"),\n", .{name}); | 457 | try stdout.print("jspd1(\"{s}\"),\n", .{name}); |
| 450 | } else if (pd1 and !pd2 and !pslash and syntax == .separate) { | 458 | } else if (pd1 and !pd2 and !pslash and syntax == .separate) { |
| 451 | try stdout.print("sepd1(\"{}\"),\n", .{name}); | 459 | try stdout.print("sepd1(\"{s}\"),\n", .{name}); |
| 452 | } else { | 460 | } else { |
| 453 | try stdout.print( | 461 | try stdout.print( |
| 454 | \\.{{ | 462 | \\.{{ |
| 455 | \\ .name = "{}", | 463 | \\ .name = "{s}", |
| 456 | \\ .syntax = {}, | 464 | \\ .syntax = {s}, |
| 457 | \\ .zig_equivalent = .other, | 465 | \\ .zig_equivalent = .other, |
| 458 | \\ .pd1 = {}, | 466 | \\ .pd1 = {s}, |
| 459 | \\ .pd2 = {}, | 467 | \\ .pd2 = {s}, |
| 460 | \\ .psl = {}, | 468 | \\ .psl = {s}, |
| 461 | \\}}, | 469 | \\}}, |
| 462 | \\ | 470 | \\ |
| 463 | , .{ name, syntax, pd1, pd2, pslash }); | 471 | , .{ name, syntax, pd1, pd2, pslash }); |
| ... | @@ -506,8 +514,8 @@ const Syntax = union(enum) { | ... | @@ -506,8 +514,8 @@ const Syntax = union(enum) { |
| 506 | out_stream: anytype, | 514 | out_stream: anytype, |
| 507 | ) !void { | 515 | ) !void { |
| 508 | switch (self) { | 516 | switch (self) { |
| 509 | .multi_arg => |n| return out_stream.print(".{{.{}={}}}", .{ @tagName(self), n }), | 517 | .multi_arg => |n| return out_stream.print(".{{.{s}={}}}", .{ @tagName(self), n }), |
| 510 | else => return out_stream.print(".{}", .{@tagName(self)}), | 518 | else => return out_stream.print(".{s}", .{@tagName(self)}), |
| 511 | } | 519 | } |
| 512 | } | 520 | } |
| 513 | }; | 521 | }; |
| ... | @@ -559,9 +567,9 @@ fn objSyntax(obj: *json.ObjectMap) Syntax { | ... | @@ -559,9 +567,9 @@ fn objSyntax(obj: *json.ObjectMap) Syntax { |
| 559 | return .flag; | 567 | return .flag; |
| 560 | } | 568 | } |
| 561 | const key = obj.get("!name").?.String; | 569 | const key = obj.get("!name").?.String; |
| 562 | std.debug.warn("{} (key {}) has unrecognized superclasses:\n", .{ name, key }); | 570 | std.debug.warn("{s} (key {s}) has unrecognized superclasses:\n", .{ name, key }); |
| 563 | for (obj.get("!superclasses").?.Array.items) |superclass_json| { | 571 | for (obj.get("!superclasses").?.Array.items) |superclass_json| { |
| 564 | std.debug.warn(" {}\n", .{superclass_json.String}); | 572 | std.debug.warn(" {s}\n", .{superclass_json.String}); |
| 565 | } | 573 | } |
| 566 | std.process.exit(1); | 574 | std.process.exit(1); |
| 567 | } | 575 | } |
| ... | @@ -612,7 +620,7 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { | ... | @@ -612,7 +620,7 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { |
| 612 | 620 | ||
| 613 | fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn { | 621 | fn usageAndExit(file: fs.File, arg0: []const u8, code: u8) noreturn { |
| 614 | file.writer().print( | 622 | file.writer().print( |
| 615 | \\Usage: {} /path/to/llvm-tblgen /path/to/git/llvm/llvm-project | 623 | \\Usage: {s} /path/to/llvm-tblgen /path/to/git/llvm/llvm-project |
| 616 | \\Alternative Usage: zig run /path/to/git/zig/tools/update_clang_options.zig -- /path/to/llvm-tblgen /path/to/git/llvm/llvm-project | 624 | \\Alternative Usage: zig run /path/to/git/zig/tools/update_clang_options.zig -- /path/to/llvm-tblgen /path/to/git/llvm/llvm-project |
| 617 | \\ | 625 | \\ |
| 618 | \\Prints to stdout Zig code which you can use to replace the file src/clang_options_data.zig. | 626 | \\Prints to stdout Zig code which you can use to replace the file src/clang_options_data.zig. |