| ... | @@ -847,7 +847,7 @@ pub const Object = struct { | ... | @@ -847,7 +847,7 @@ pub const Object = struct { |
| 847 | return diags.fail("emitting without libllvm not implemented", .{}); | 847 | return diags.fail("emitting without libllvm not implemented", .{}); |
| 848 | } | 848 | } |
| 849 | | 849 | |
| 850 | initializeLLVMTarget(comp.root_mod.resolved_target.result.cpu.arch); | 850 | initializeLLVMTarget(io, comp.root_mod.resolved_target.result.cpu.arch); |
| 851 | | 851 | |
| 852 | const context: *bindings.Context = .create(); | 852 | const context: *bindings.Context = .create(); |
| 853 | errdefer context.dispose(); | 853 | errdefer context.dispose(); |
| ... | @@ -4811,7 +4811,14 @@ const struct_layout_version = 2; | ... | @@ -4811,7 +4811,14 @@ const struct_layout_version = 2; |
| 4811 | // https://github.com/llvm/llvm-project/issues/56585/ is fixed | 4811 | // https://github.com/llvm/llvm-project/issues/56585/ is fixed |
| 4812 | pub const optional_layout_version = 3; | 4812 | pub const optional_layout_version = 3; |
| 4813 | | 4813 | |
| 4814 | pub fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { | 4814 | var target_registry_mutex: std.Io.Mutex = .init; |
| | 4815 | |
| | 4816 | pub fn initializeLLVMTarget(io: Io, arch: std.Target.Cpu.Arch) void { |
| | 4817 | // Repeated initialization is safe, as targets which have already been registered will be skipped. |
| | 4818 | // It is however the client's responsibility to synchronize registry access. |
| | 4819 | target_registry_mutex.lockUncancelable(io); |
| | 4820 | defer target_registry_mutex.unlock(io); |
| | 4821 | |
| 4815 | switch (arch) { | 4822 | switch (arch) { |
| 4816 | .aarch64, .aarch64_be => { | 4823 | .aarch64, .aarch64_be => { |
| 4817 | bindings.LLVMInitializeAArch64Target(); | 4824 | bindings.LLVMInitializeAArch64Target(); |