@@ -152,9 +152,6 @@ libunwind_static_lib: ?CRTFile = null,
152152/// Populated when we build the TSAN static library. A Job to build this is placed in the queue
153153/// and resolved before calling linker.flush().
154154tsan_static_lib : ? CRTFile = null ,
155- /// Populated when we build the libssp static library. A Job to build this is placed in the queue
156- /// and resolved before calling linker.flush().
157- libssp_static_lib : ? CRTFile = null ,
158155/// Populated when we build the libc static library. A Job to build this is placed in the queue
159156/// and resolved before calling linker.flush().
160157libc_static_lib : ? CRTFile = null ,
@@ -286,7 +283,6 @@ const Job = union(enum) {
286283 libcxx : void ,
287284 libcxxabi : void ,
288285 libtsan : void ,
289- libssp : void ,
290286 /// needed when not linking libc and using LLVM for code generation because it generates
291287 /// calls to, for example, memcpy and memset.
292288 zig_libc : void ,
@@ -683,7 +679,6 @@ pub const MiscTask = enum {
683679 libtsan ,
684680 wasi_libc_crt_file ,
685681 compiler_rt ,
686- libssp ,
687682 zig_libc ,
688683 analyze_mod ,
689684
@@ -1353,10 +1348,14 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
13531348 if (stack_check and ! target_util .supportsStackProbing (options .target ))
13541349 return error .StackCheckUnsupportedByTarget ;
13551350
1356- const capable_of_building_ssp = canBuildLibSsp (options .target , use_llvm );
1357-
1358- const stack_protector : u32 = options .want_stack_protector orelse b : {
1359- if (! target_util .supportsStackProtector (options .target )) break :b @as (u32 , 0 );
1351+ const stack_protector : u32 = sp : {
1352+ const zig_backend = zigBackend (options .target , use_llvm );
1353+ if (! target_util .supportsStackProtector (options .target , zig_backend )) {
1354+ if (options .want_stack_protector ) | x | {
1355+ if (x > 0 ) return error .StackProtectorUnsupportedByTarget ;
1356+ }
1357+ break :sp 0 ;
1358+ }
13601359
13611360 // This logic is checking for linking libc because otherwise our start code
13621361 // which is trying to set up TLS (i.e. the fs/gs registers) but the stack
@@ -1365,19 +1364,17 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
13651364 // as being exempt from stack protection checks, we could change this logic
13661365 // to supporting stack protection even when not linking libc.
13671366 // TODO file issue about this
1368- if (! link_libc ) break :b 0 ;
1369- if (! capable_of_building_ssp ) break :b 0 ;
1370- if (is_safe_mode ) break :b default_stack_protector_buffer_size ;
1371- break :b 0 ;
1367+ if (! link_libc ) {
1368+ if (options .want_stack_protector ) | x | {
1369+ if (x > 0 ) return error .StackProtectorUnavailableWithoutLibC ;
1370+ }
1371+ break :sp 0 ;
1372+ }
1373+
1374+ if (options .want_stack_protector ) | x | break :sp x ;
1375+ if (is_safe_mode ) break :sp default_stack_protector_buffer_size ;
1376+ break :sp 0 ;
13721377 };
1373- if (stack_protector != 0 ) {
1374- if (! target_util .supportsStackProtector (options .target ))
1375- return error .StackProtectorUnsupportedByTarget ;
1376- if (! capable_of_building_ssp )
1377- return error .StackProtectorUnsupportedByBackend ;
1378- if (! link_libc )
1379- return error .StackProtectorUnavailableWithoutLibC ;
1380- }
13811378
13821379 const include_compiler_rt = options .want_compiler_rt orelse
13831380 (! options .skip_linker_dependencies and is_exe_or_dyn_lib );
@@ -2195,24 +2192,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
21952192 comp .job_queued_compiler_rt_obj = true ;
21962193 }
21972194 }
2198- if (needsCSymbols (
2199- options .skip_linker_dependencies ,
2200- options .output_mode ,
2201- options .link_mode ,
2202- options .target ,
2203- comp .bin_file .options .use_llvm ,
2204- )) {
2205- // Related: https://github.com/ziglang/zig/issues/7265.
2206- if (comp .bin_file .options .stack_protector != 0 and
2207- (! comp .bin_file .options .link_libc or
2208- ! target_util .libcProvidesStackProtector (target )))
2209- {
2210- try comp .work_queue .writeItem (.{ .libssp = {} });
2211- }
22122195
2213- if (! comp .bin_file .options .link_libc and capable_of_building_zig_libc ) {
2214- try comp .work_queue .writeItem (.{ .zig_libc = {} });
2215- }
2196+ if (! comp .bin_file .options .skip_linker_dependencies and is_exe_or_dyn_lib and
2197+ ! comp .bin_file .options .link_libc and capable_of_building_zig_libc )
2198+ {
2199+ try comp .work_queue .writeItem (.{ .zig_libc = {} });
22162200 }
22172201 }
22182202
@@ -2258,9 +2242,6 @@ pub fn destroy(self: *Compilation) void {
22582242 if (self .compiler_rt_obj ) | * crt_file | {
22592243 crt_file .deinit (gpa );
22602244 }
2261- if (self .libssp_static_lib ) | * crt_file | {
2262- crt_file .deinit (gpa );
2263- }
22642245 if (self .libc_static_lib ) | * crt_file | {
22652246 crt_file .deinit (gpa );
22662247 }
@@ -4027,26 +4008,6 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
40274008 );
40284009 };
40294010 },
4030- .libssp = > {
4031- const named_frame = tracy .namedFrame ("libssp" );
4032- defer named_frame .end ();
4033-
4034- comp .buildOutputFromZig (
4035- "ssp.zig" ,
4036- .Lib ,
4037- & comp .libssp_static_lib ,
4038- .libssp ,
4039- prog_node ,
4040- ) catch | err | switch (err ) {
4041- error .OutOfMemory = > return error .OutOfMemory ,
4042- error .SubCompilationFailed = > return , // error reported already
4043- else = > comp .lockAndSetMiscFailure (
4044- .libssp ,
4045- "unable to build libssp: {s}" ,
4046- .{@errorName (err )},
4047- ),
4048- };
4049- },
40504011 .zig_libc = > {
40514012 const named_frame = tracy .namedFrame ("zig_libc" );
40524013 defer named_frame .end ();
@@ -6531,21 +6492,6 @@ fn canBuildLibCompilerRt(target: std.Target, use_llvm: bool) bool {
65316492 };
65326493}
65336494
6534- fn canBuildLibSsp (target : std.Target , use_llvm : bool ) bool {
6535- switch (target .os .tag ) {
6536- .plan9 = > return false ,
6537- else = > {},
6538- }
6539- switch (target .cpu .arch ) {
6540- .spirv32 , .spirv64 = > return false ,
6541- else = > {},
6542- }
6543- return switch (zigBackend (target , use_llvm )) {
6544- .stage2_llvm = > true ,
6545- else = > build_options .have_llvm ,
6546- };
6547- }
6548-
65496495/// Not to be confused with canBuildLibC, which builds musl, glibc, and similar.
65506496/// This one builds lib/c.zig.
65516497fn canBuildZigLibC (target : std.Target , use_llvm : bool ) bool {
@@ -6585,29 +6531,6 @@ fn zigBackend(target: std.Target, use_llvm: bool) std.builtin.CompilerBackend {
65856531 };
65866532}
65876533
6588- fn needsCSymbols (
6589- skip_linker_dependencies : bool ,
6590- output_mode : std.builtin.OutputMode ,
6591- link_mode : ? std.builtin.LinkMode ,
6592- target : std.Target ,
6593- use_llvm : bool ,
6594- ) bool {
6595- if (skip_linker_dependencies )
6596- return false ;
6597-
6598- switch (output_mode ) {
6599- .Obj = > return false ,
6600- .Lib = > if (link_mode != .Dynamic ) return false ,
6601- .Exe = > {},
6602- }
6603-
6604- // LLVM might generate calls to libc symbols.
6605- if (zigBackend (target , use_llvm ) == .stage2_llvm )
6606- return true ;
6607-
6608- return false ;
6609- }
6610-
66116534pub fn generateBuiltinZigSource (comp : * Compilation , allocator : Allocator ) Allocator.Error ! [:0 ]u8 {
66126535 const tracy_trace = trace (@src ());
66136536 defer tracy_trace .end ();
0 commit comments