@@ -224,6 +224,8 @@ compiler_rt_lib: ?CrtFile = null,
224
224
/// Populated when we build the compiler_rt_obj object. A Job to build this is indicated
225
225
/// by setting `queued_jobs.compiler_rt_obj` and resolved before calling linker.flush().
226
226
compiler_rt_obj : ? CrtFile = null ,
227
+ /// hack for stage2_x86_64 + coff
228
+ compiler_rt_dyn_lib : ? CrtFile = null ,
227
229
/// Populated when we build the libfuzzer static library. A Job to build this
228
230
/// is indicated by setting `queued_jobs.fuzzer_lib` and resolved before
229
231
/// calling linker.flush().
@@ -291,6 +293,8 @@ emit_llvm_bc: ?[]const u8,
291
293
emit_docs : ? []const u8 ,
292
294
293
295
const QueuedJobs = struct {
296
+ /// hack for stage2_x86_64 + coff
297
+ compiler_rt_dyn_lib : bool = false ,
294
298
compiler_rt_lib : bool = false ,
295
299
compiler_rt_obj : bool = false ,
296
300
ubsan_rt_lib : bool = false ,
@@ -1753,7 +1757,7 @@ fn addModuleTableToCacheHash(
1753
1757
}
1754
1758
}
1755
1759
1756
- const RtStrat = enum { none , lib , obj , zcu };
1760
+ const RtStrat = enum { none , lib , obj , zcu , dyn_lib };
1757
1761
1758
1762
pub fn create (gpa : Allocator , arena : Allocator , options : CreateOptions ) ! * Compilation {
1759
1763
const output_mode = options .config .output_mode ;
@@ -1816,7 +1820,11 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
1816
1820
if (options .skip_linker_dependencies ) break :s .none ;
1817
1821
const want = options .want_compiler_rt orelse is_exe_or_dyn_lib ;
1818
1822
if (! want ) break :s .none ;
1819
- if (have_zcu and output_mode == .Obj ) break :s .zcu ;
1823
+ if (have_zcu ) {
1824
+ if (output_mode == .Obj ) break :s .zcu ;
1825
+ if (target .ofmt == .coff and target_util .zigBackend (target , use_llvm ) == .stage2_x86_64 )
1826
+ break :s if (is_exe_or_dyn_lib ) .dyn_lib else .zcu ;
1827
+ }
1820
1828
if (is_exe_or_dyn_lib ) break :s .lib ;
1821
1829
break :s .obj ;
1822
1830
};
@@ -2436,6 +2444,11 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil
2436
2444
// for a compiler-rt object to put in it.
2437
2445
comp .queued_jobs .compiler_rt_obj = true ;
2438
2446
comp .link_task_queue .pending_prelink_tasks += 1 ;
2447
+ } else if (comp .compiler_rt_strat == .dyn_lib ) {
2448
+ // hack for stage2_x86_64 + coff
2449
+ log .debug ("queuing a job to build compiler_rt_dyn_lib" , .{});
2450
+ comp .queued_jobs .compiler_rt_dyn_lib = true ;
2451
+ comp .link_task_queue .pending_prelink_tasks += 1 ;
2439
2452
}
2440
2453
2441
2454
if (comp .ubsan_rt_strat == .lib ) {
@@ -4233,6 +4246,7 @@ fn performAllTheWork(
4233
4246
"compiler_rt.zig" ,
4234
4247
"compiler_rt" ,
4235
4248
.Lib ,
4249
+ .static ,
4236
4250
.compiler_rt ,
4237
4251
main_progress_node ,
4238
4252
RtOptions {
@@ -4249,6 +4263,7 @@ fn performAllTheWork(
4249
4263
"compiler_rt.zig" ,
4250
4264
"compiler_rt" ,
4251
4265
.Obj ,
4266
+ .static ,
4252
4267
.compiler_rt ,
4253
4268
main_progress_node ,
4254
4269
RtOptions {
@@ -4259,12 +4274,31 @@ fn performAllTheWork(
4259
4274
});
4260
4275
}
4261
4276
4277
+ // hack for stage2_x86_64 + coff
4278
+ if (comp .queued_jobs .compiler_rt_dyn_lib and comp .compiler_rt_dyn_lib == null ) {
4279
+ comp .link_task_wait_group .spawnManager (buildRt , .{
4280
+ comp ,
4281
+ "compiler_rt.zig" ,
4282
+ "compiler_rt" ,
4283
+ .Lib ,
4284
+ .dynamic ,
4285
+ .compiler_rt ,
4286
+ main_progress_node ,
4287
+ RtOptions {
4288
+ .checks_valgrind = true ,
4289
+ .allow_lto = false ,
4290
+ },
4291
+ & comp .compiler_rt_dyn_lib ,
4292
+ });
4293
+ }
4294
+
4262
4295
if (comp .queued_jobs .fuzzer_lib and comp .fuzzer_lib == null ) {
4263
4296
comp .link_task_wait_group .spawnManager (buildRt , .{
4264
4297
comp ,
4265
4298
"fuzzer.zig" ,
4266
4299
"fuzzer" ,
4267
4300
.Lib ,
4301
+ .static ,
4268
4302
.libfuzzer ,
4269
4303
main_progress_node ,
4270
4304
RtOptions {},
@@ -4278,6 +4312,7 @@ fn performAllTheWork(
4278
4312
"ubsan_rt.zig" ,
4279
4313
"ubsan_rt" ,
4280
4314
.Lib ,
4315
+ .static ,
4281
4316
.libubsan ,
4282
4317
main_progress_node ,
4283
4318
RtOptions {
@@ -4293,6 +4328,7 @@ fn performAllTheWork(
4293
4328
"ubsan_rt.zig" ,
4294
4329
"ubsan_rt" ,
4295
4330
.Obj ,
4331
+ .static ,
4296
4332
.libubsan ,
4297
4333
main_progress_node ,
4298
4334
RtOptions {
@@ -5369,6 +5405,7 @@ fn buildRt(
5369
5405
root_source_name : []const u8 ,
5370
5406
root_name : []const u8 ,
5371
5407
output_mode : std.builtin.OutputMode ,
5408
+ link_mode : std.builtin.LinkMode ,
5372
5409
misc_task : MiscTask ,
5373
5410
prog_node : std.Progress.Node ,
5374
5411
options : RtOptions ,
@@ -5378,6 +5415,7 @@ fn buildRt(
5378
5415
root_source_name ,
5379
5416
root_name ,
5380
5417
output_mode ,
5418
+ link_mode ,
5381
5419
misc_task ,
5382
5420
prog_node ,
5383
5421
options ,
@@ -5533,6 +5571,7 @@ fn buildLibZigC(comp: *Compilation, prog_node: std.Progress.Node) void {
5533
5571
"c.zig" ,
5534
5572
"zigc" ,
5535
5573
.Lib ,
5574
+ .static ,
5536
5575
.libzigc ,
5537
5576
prog_node ,
5538
5577
.{},
@@ -7210,6 +7249,7 @@ fn buildOutputFromZig(
7210
7249
src_basename : []const u8 ,
7211
7250
root_name : []const u8 ,
7212
7251
output_mode : std.builtin.OutputMode ,
7252
+ link_mode : std.builtin.LinkMode ,
7213
7253
misc_task_tag : MiscTask ,
7214
7254
prog_node : std.Progress.Node ,
7215
7255
options : RtOptions ,
@@ -7230,7 +7270,7 @@ fn buildOutputFromZig(
7230
7270
7231
7271
const config = try Config .resolve (.{
7232
7272
.output_mode = output_mode ,
7233
- .link_mode = .static ,
7273
+ .link_mode = link_mode ,
7234
7274
.resolved_target = comp .root_mod .resolved_target ,
7235
7275
.is_test = false ,
7236
7276
.have_zcu = true ,
0 commit comments