diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-12-13 15:19:51 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-01 17:51:19 -0700 |
| commit | bc4d2b646d5d09ecb86a3806886fed37e522fdc9 (patch) | |
| tree | b476088e3785c0f2820a5fc1fee3bc880310bc71 /src/arch/x86_64/CodeGen.zig | |
| parent | 1642c003b4bab4a53b6094b42d10f6934896801e (diff) | |
| download | zig-bc4d2b646d5d09ecb86a3806886fed37e522fdc9.tar.gz zig-bc4d2b646d5d09ecb86a3806886fed37e522fdc9.zip | |
compiler: update references to target
Diffstat (limited to 'src/arch/x86_64/CodeGen.zig')
| -rw-r--r-- | src/arch/x86_64/CodeGen.zig | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 9a4c73c74d..b3c5df02d9 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -795,22 +795,20 @@ pub fn generate( code: *std.ArrayList(u8), debug_output: DebugInfoOutput, ) CodeGenError!Result { - if (build_options.skip_non_native and builtin.cpu.arch != bin_file.options.target.cpu.arch) { - @panic("Attempted to compile for architecture that was disabled by build configuration"); - } - const mod = bin_file.comp.module.?; const func = mod.funcInfo(func_index); const fn_owner_decl = mod.declPtr(func.owner_decl); assert(fn_owner_decl.has_tv); const fn_type = fn_owner_decl.ty; + const namespace = mod.namespacePtr(fn_owner_decl.src_namespace); + const target = namespace.file_scope.mod.target; const gpa = bin_file.allocator; var function = Self{ .gpa = gpa, .air = air, .liveness = liveness, - .target = &bin_file.options.target, + .target = target, .bin_file = bin_file, .debug_output = debug_output, .owner = .{ .func_index = func_index }, @@ -882,7 +880,7 @@ pub fn generate( .size = Type.usize.abiSize(mod), .alignment = Alignment.min( call_info.stack_align, - Alignment.fromNonzeroByteUnits(bin_file.options.target.stackAlignment()), + Alignment.fromNonzeroByteUnits(target.stackAlignment()), ), })); function.frame_allocs.set( @@ -967,11 +965,16 @@ pub fn generateLazy( debug_output: DebugInfoOutput, ) CodeGenError!Result { const gpa = bin_file.allocator; + const zcu = bin_file.comp.module.?; + const decl_index = lazy_sym.ty.getOwnerDecl(zcu); + const decl = zcu.declPtr(decl_index); + const namespace = zcu.namespacePtr(decl.src_namespace); + const target = namespace.file_scope.mod.target; var function = Self{ .gpa = gpa, .air = undefined, .liveness = undefined, - .target = &bin_file.options.target, + .target = target, .bin_file = bin_file, .debug_output = debug_output, .owner = .{ .lazy_sym = lazy_sym }, |
