@@ -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 ,
@@ -412,7 +408,6 @@ pub const MiscTask = enum {
412408 libtsan ,
413409 wasi_libc_crt_file ,
414410 compiler_rt ,
415- libssp ,
416411 zig_libc ,
417412 analyze_mod ,
418413
@@ -1082,10 +1077,14 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
10821077 if (stack_check and ! target_util .supportsStackProbing (options .target ))
10831078 return error .StackCheckUnsupportedByTarget ;
10841079
1085- const capable_of_building_ssp = canBuildLibSsp (options .target , use_llvm );
1086-
1087- const stack_protector : u32 = options .want_stack_protector orelse b : {
1088- if (! target_util .supportsStackProtector (options .target )) break :b @as (u32 , 0 );
1080+ const stack_protector : u32 = sp : {
1081+ const zig_backend = zigBackend (options .target , use_llvm );
1082+ if (! target_util .supportsStackProtector (options .target , zig_backend )) {
1083+ if (options .want_stack_protector ) | x | {
1084+ if (x > 0 ) return error .StackProtectorUnsupportedByTarget ;
1085+ }
1086+ break :sp 0 ;
1087+ }
10891088
10901089 // This logic is checking for linking libc because otherwise our start code
10911090 // which is trying to set up TLS (i.e. the fs/gs registers) but the stack
@@ -1094,19 +1093,17 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
10941093 // as being exempt from stack protection checks, we could change this logic
10951094 // to supporting stack protection even when not linking libc.
10961095 // TODO file issue about this
1097- if (! link_libc ) break :b 0 ;
1098- if (! capable_of_building_ssp ) break :b 0 ;
1099- if (is_safe_mode ) break :b default_stack_protector_buffer_size ;
1100- break :b 0 ;
1096+ if (! link_libc ) {
1097+ if (options .want_stack_protector ) | x | {
1098+ if (x > 0 ) return error .StackProtectorUnavailableWithoutLibC ;
1099+ }
1100+ break :sp 0 ;
1101+ }
1102+
1103+ if (options .want_stack_protector ) | x | break :sp x ;
1104+ if (is_safe_mode ) break :sp default_stack_protector_buffer_size ;
1105+ break :sp 0 ;
11011106 };
1102- if (stack_protector != 0 ) {
1103- if (! target_util .supportsStackProtector (options .target ))
1104- return error .StackProtectorUnsupportedByTarget ;
1105- if (! capable_of_building_ssp )
1106- return error .StackProtectorUnsupportedByBackend ;
1107- if (! link_libc )
1108- return error .StackProtectorUnavailableWithoutLibC ;
1109- }
11101107
11111108 const include_compiler_rt = options .want_compiler_rt orelse
11121109 (! options .skip_linker_dependencies and is_exe_or_dyn_lib );
@@ -1924,24 +1921,11 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
19241921 comp .job_queued_compiler_rt_obj = true ;
19251922 }
19261923 }
1927- if (needsCSymbols (
1928- options .skip_linker_dependencies ,
1929- options .output_mode ,
1930- options .link_mode ,
1931- options .target ,
1932- comp .bin_file .options .use_llvm ,
1933- )) {
1934- // Related: https://github.com/ziglang/zig/issues/7265.
1935- if (comp .bin_file .options .stack_protector != 0 and
1936- (! comp .bin_file .options .link_libc or
1937- ! target_util .libcProvidesStackProtector (target )))
1938- {
1939- try comp .work_queue .writeItem (.{ .libssp = {} });
1940- }
19411924
1942- if (! comp .bin_file .options .link_libc and capable_of_building_zig_libc ) {
1943- try comp .work_queue .writeItem (.{ .zig_libc = {} });
1944- }
1925+ if (! comp .bin_file .options .skip_linker_dependencies and is_exe_or_dyn_lib and
1926+ ! comp .bin_file .options .link_libc and capable_of_building_zig_libc )
1927+ {
1928+ try comp .work_queue .writeItem (.{ .zig_libc = {} });
19451929 }
19461930 }
19471931
@@ -1987,9 +1971,6 @@ pub fn destroy(self: *Compilation) void {
19871971 if (self .compiler_rt_obj ) | * crt_file | {
19881972 crt_file .deinit (gpa );
19891973 }
1990- if (self .libssp_static_lib ) | * crt_file | {
1991- crt_file .deinit (gpa );
1992- }
19931974 if (self .libc_static_lib ) | * crt_file | {
19941975 crt_file .deinit (gpa );
19951976 }
@@ -3768,26 +3749,6 @@ fn processOneJob(comp: *Compilation, job: Job, prog_node: *std.Progress.Node) !v
37683749 );
37693750 };
37703751 },
3771- .libssp = > {
3772- const named_frame = tracy .namedFrame ("libssp" );
3773- defer named_frame .end ();
3774-
3775- comp .buildOutputFromZig (
3776- "ssp.zig" ,
3777- .Lib ,
3778- & comp .libssp_static_lib ,
3779- .libssp ,
3780- prog_node ,
3781- ) catch | err | switch (err ) {
3782- error .OutOfMemory = > return error .OutOfMemory ,
3783- error .SubCompilationFailed = > return , // error reported already
3784- else = > comp .lockAndSetMiscFailure (
3785- .libssp ,
3786- "unable to build libssp: {s}" ,
3787- .{@errorName (err )},
3788- ),
3789- };
3790- },
37913752 .zig_libc = > {
37923753 const named_frame = tracy .namedFrame ("zig_libc" );
37933754 defer named_frame .end ();
@@ -6271,21 +6232,6 @@ fn canBuildLibCompilerRt(target: std.Target, use_llvm: bool) bool {
62716232 };
62726233}
62736234
6274- fn canBuildLibSsp (target : std.Target , use_llvm : bool ) bool {
6275- switch (target .os .tag ) {
6276- .plan9 = > return false ,
6277- else = > {},
6278- }
6279- switch (target .cpu .arch ) {
6280- .spirv32 , .spirv64 = > return false ,
6281- else = > {},
6282- }
6283- return switch (zigBackend (target , use_llvm )) {
6284- .stage2_llvm = > true ,
6285- else = > build_options .have_llvm ,
6286- };
6287- }
6288-
62896235/// Not to be confused with canBuildLibC, which builds musl, glibc, and similar.
62906236/// This one builds lib/c.zig.
62916237fn canBuildZigLibC (target : std.Target , use_llvm : bool ) bool {
@@ -6325,29 +6271,6 @@ fn zigBackend(target: std.Target, use_llvm: bool) std.builtin.CompilerBackend {
63256271 };
63266272}
63276273
6328- fn needsCSymbols (
6329- skip_linker_dependencies : bool ,
6330- output_mode : std.builtin.OutputMode ,
6331- link_mode : ? std.builtin.LinkMode ,
6332- target : std.Target ,
6333- use_llvm : bool ,
6334- ) bool {
6335- if (skip_linker_dependencies )
6336- return false ;
6337-
6338- switch (output_mode ) {
6339- .Obj = > return false ,
6340- .Lib = > if (link_mode != .Dynamic ) return false ,
6341- .Exe = > {},
6342- }
6343-
6344- // LLVM might generate calls to libc symbols.
6345- if (zigBackend (target , use_llvm ) == .stage2_llvm )
6346- return true ;
6347-
6348- return false ;
6349- }
6350-
63516274pub fn generateBuiltinZigSource (comp : * Compilation , allocator : Allocator ) Allocator.Error ! [:0 ]u8 {
63526275 const tracy_trace = trace (@src ());
63536276 defer tracy_trace .end ();
0 commit comments