@@ -752,6 +752,7 @@ pub const InitOptions = struct {
752752 version : ? std.builtin.Version = null ,
753753 libc_installation : ? * const LibCInstallation = null ,
754754 machine_code_model : std.builtin.CodeModel = .default ,
755+ target_abi : ? std.Target.TargetAbi ,
755756 clang_preprocessor_mode : ClangPreprocessorMode = .no ,
756757 /// This is for stage1 and should be deleted upon completion of self-hosting.
757758 color : @import ("main.zig" ).Color = .auto ,
@@ -1152,6 +1153,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
11521153 cache .hash .add (options .target .os .getVersionRange ());
11531154 cache .hash .add (options .is_native_os );
11541155 cache .hash .add (options .target .abi );
1156+ cache .hash .addBytes (if (options .target_abi ) | t | t .string () else "." );
11551157 cache .hash .add (ofmt );
11561158 cache .hash .add (pic );
11571159 cache .hash .add (pie );
@@ -1436,6 +1438,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation {
14361438 .single_threaded = single_threaded ,
14371439 .verbose_link = options .verbose_link ,
14381440 .machine_code_model = options .machine_code_model ,
1441+ .target_abi = options .target_abi ,
14391442 .dll_export_fns = dll_export_fns ,
14401443 .error_return_tracing = error_return_tracing ,
14411444 .llvm_cpu_features = llvm_cpu_features ,
@@ -3299,6 +3302,10 @@ pub fn addCCArgs(
32993302 try argv .append ("-mthumb" );
33003303 }
33013304
3305+ if (comp .bin_file .options .target_abi ) | target_abi | {
3306+ try argv .append (try std .fmt .allocPrint (arena , "-mabi={s}" , .{target_abi .string ()}));
3307+ }
3308+
33023309 if (comp .haveFramePointer ()) {
33033310 try argv .append ("-fno-omit-frame-pointer" );
33043311 } else {
@@ -3437,6 +3444,11 @@ pub fn addCCArgs(
34373444 // TODO
34383445 },
34393446 }
3447+
3448+ if (comp .bin_file .options .target_abi ) | target_abi | {
3449+ try argv .append (try std .fmt .allocPrint (arena , "-mabi={s}" , .{target_abi .string ()}));
3450+ }
3451+
34403452 if (target_util .clangAssemblerSupportsMcpuArg (target )) {
34413453 if (target .cpu .model .llvm_name ) | llvm_name | {
34423454 try argv .append (try std .fmt .allocPrint (arena , "-mcpu={s}" , .{llvm_name }));
@@ -4170,6 +4182,7 @@ fn buildOutputFromZig(
41704182 .strip = comp .compilerRtStrip (),
41714183 .is_native_os = comp .bin_file .options .is_native_os ,
41724184 .is_native_abi = comp .bin_file .options .is_native_abi ,
4185+ .target_abi = comp .bin_file .options .target_abi ,
41734186 .self_exe_path = comp .self_exe_path ,
41744187 .verbose_cc = comp .verbose_cc ,
41754188 .verbose_link = comp .bin_file .options .verbose_link ,
@@ -4357,6 +4370,7 @@ fn updateStage1Module(comp: *Compilation, main_progress_node: *std.Progress.Node
43574370 .is_native_cpu = false , // Only true when bootstrapping the compiler.
43584371 .llvm_cpu_name = if (target .cpu .model .llvm_name ) | s | s .ptr else null ,
43594372 .llvm_cpu_features = comp .bin_file .options .llvm_cpu_features .? ,
4373+ .llvm_target_abi = if (comp .bin_file .options .target_abi ) | t | t .string ().ptr else null ,
43604374 };
43614375
43624376 comp .stage1_cache_manifest = & man ;
@@ -4608,6 +4622,7 @@ pub fn build_crt_file(
46084622 .strip = comp .compilerRtStrip (),
46094623 .is_native_os = comp .bin_file .options .is_native_os ,
46104624 .is_native_abi = comp .bin_file .options .is_native_abi ,
4625+ .target_abi = comp .bin_file .options .target_abi ,
46114626 .self_exe_path = comp .self_exe_path ,
46124627 .c_source_files = c_source_files ,
46134628 .verbose_cc = comp .verbose_cc ,
0 commit comments