@@ -1467,6 +1467,7 @@ pub fn updateExports(
14671467 }
14681468
14691469 const ip = & mod .intern_pool ;
1470+ const target = self .base .comp .root_mod .resolved_target .result ;
14701471
14711472 if (self .base .options .use_llvm ) {
14721473 // Even in the case of LLVM, we need to notice certain exported symbols in order to
@@ -1478,7 +1479,7 @@ pub fn updateExports(
14781479 };
14791480 const exported_decl = mod .declPtr (exported_decl_index );
14801481 if (exported_decl .getOwnedFunction (mod ) == null ) continue ;
1481- const winapi_cc = switch (self . base . options . target .cpu .arch ) {
1482+ const winapi_cc = switch (target .cpu .arch ) {
14821483 .x86 = > std .builtin .CallingConvention .Stdcall ,
14831484 else = > std .builtin .CallingConvention .C ,
14841485 };
@@ -1487,7 +1488,7 @@ pub fn updateExports(
14871488 self .base .options .link_libc )
14881489 {
14891490 mod .stage1_flags .have_c_main = true ;
1490- } else if (decl_cc == winapi_cc and self . base . options . target .os .tag == .windows ) {
1491+ } else if (decl_cc == winapi_cc and target .os .tag == .windows ) {
14911492 if (ip .stringEqlSlice (exp .opts .name , "WinMain" )) {
14921493 mod .stage1_flags .have_winmain = true ;
14931494 } else if (ip .stringEqlSlice (exp .opts .name , "wWinMain" )) {
@@ -2200,6 +2201,7 @@ fn writeDataDirectoriesHeaders(self: *Coff) !void {
22002201}
22012202
22022203fn writeHeader (self : * Coff ) ! void {
2204+ const target = self .base .comp .root_mod .resolved_target .result ;
22032205 const gpa = self .base .comp .gpa ;
22042206 var buffer = std .ArrayList (u8 ).init (gpa );
22052207 defer buffer .deinit ();
@@ -2225,7 +2227,7 @@ fn writeHeader(self: *Coff) !void {
22252227 const timestamp = std .time .timestamp ();
22262228 const size_of_optional_header = @as (u16 , @intCast (self .getOptionalHeaderSize () + self .getDataDirectoryHeadersSize ()));
22272229 var coff_header = coff.CoffHeader {
2228- .machine = coff .MachineType .fromTargetCpuArch (self . base . options . target .cpu .arch ),
2230+ .machine = coff .MachineType .fromTargetCpuArch (target .cpu .arch ),
22292231 .number_of_sections = @as (u16 , @intCast (self .sections .slice ().len )), // TODO what if we prune a section
22302232 .time_date_stamp = @as (u32 , @truncate (@as (u64 , @bitCast (timestamp )))),
22312233 .pointer_to_symbol_table = self .strtab_offset orelse 0 ,
@@ -2451,8 +2453,9 @@ pub fn getEntryPoint(self: Coff) ?SymbolWithLoc {
24512453}
24522454
24532455pub fn getImageBase (self : Coff ) u64 {
2456+ const target = self .base .comp .root_mod .resolved_target .result ;
24542457 const image_base : u64 = self .base .options .image_base_override orelse switch (self .base .comp .config .output_mode ) {
2455- .Exe = > switch (self . base . options . target .cpu .arch ) {
2458+ .Exe = > switch (target .cpu .arch ) {
24562459 .aarch64 = > @as (u64 , 0x140000000 ),
24572460 .x86_64 , .x86 = > 0x400000 ,
24582461 else = > unreachable , // unsupported target architecture
0 commit comments