mirror of
https://github.com/ziglang/zig.git
synced 2025-01-22 01:46:29 +00:00
stage2: update LLVM backend to for LLVM 13
There was some new code in master branch enumerating all the targets and a new target was added so we needed to add the glue code. This commit also introduces some build options to support experimental LLVM targets.
This commit is contained in:
parent
7efca2e6f5
commit
77516af118
28
build.zig
28
build.zig
@ -64,6 +64,26 @@ pub fn build(b: *Builder) !void {
|
||||
const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false;
|
||||
const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false;
|
||||
const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm);
|
||||
const llvm_has_m68k = b.option(
|
||||
bool,
|
||||
"llvm-has-m68k",
|
||||
"Whether LLVM has the experimental target m68k enabled",
|
||||
) orelse false;
|
||||
const llvm_has_csky = b.option(
|
||||
bool,
|
||||
"llvm-has-csky",
|
||||
"Whether LLVM has the experimental target csky enabled",
|
||||
) orelse false;
|
||||
const llvm_has_ve = b.option(
|
||||
bool,
|
||||
"llvm-has-ve",
|
||||
"Whether LLVM has the experimental target ve enabled",
|
||||
) orelse false;
|
||||
const llvm_has_arc = b.option(
|
||||
bool,
|
||||
"llvm-has-arc",
|
||||
"Whether LLVM has the experimental target arc enabled",
|
||||
) orelse false;
|
||||
const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse false;
|
||||
const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h");
|
||||
|
||||
@ -115,6 +135,10 @@ pub fn build(b: *Builder) !void {
|
||||
exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames);
|
||||
exe_options.addOption(bool, "skip_non_native", skip_non_native);
|
||||
exe_options.addOption(bool, "have_llvm", enable_llvm);
|
||||
exe_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
|
||||
exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
|
||||
exe_options.addOption(bool, "llvm_has_ve", llvm_has_ve);
|
||||
exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
|
||||
|
||||
if (enable_llvm) {
|
||||
const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option);
|
||||
@ -261,6 +285,10 @@ pub fn build(b: *Builder) !void {
|
||||
test_stage2_options.addOption(bool, "is_stage1", is_stage1);
|
||||
test_stage2_options.addOption(bool, "omit_stage2", omit_stage2);
|
||||
test_stage2_options.addOption(bool, "have_llvm", enable_llvm);
|
||||
test_stage2_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
|
||||
test_stage2_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
|
||||
test_stage2_options.addOption(bool, "llvm_has_ve", llvm_has_ve);
|
||||
test_stage2_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
|
||||
test_stage2_options.addOption(bool, "enable_qemu", is_qemu_enabled);
|
||||
test_stage2_options.addOption(bool, "enable_wine", is_wine_enabled);
|
||||
test_stage2_options.addOption(bool, "enable_wasmtime", is_wasmtime_enabled);
|
||||
|
@ -7,6 +7,7 @@ const link = @import("../link.zig");
|
||||
const log = std.log.scoped(.codegen);
|
||||
const math = std.math;
|
||||
|
||||
const build_options = @import("build_options");
|
||||
const Module = @import("../Module.zig");
|
||||
const TypedValue = @import("../TypedValue.zig");
|
||||
const Zir = @import("../Zir.zig");
|
||||
@ -1969,7 +1970,7 @@ fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
|
||||
llvm.LLVMInitializeAMDGPUAsmPrinter();
|
||||
llvm.LLVMInitializeAMDGPUAsmParser();
|
||||
},
|
||||
.arm, .armeb => {
|
||||
.thumb, .thumbeb, .arm, .armeb => {
|
||||
llvm.LLVMInitializeARMTarget();
|
||||
llvm.LLVMInitializeARMTargetInfo();
|
||||
llvm.LLVMInitializeARMTargetMC();
|
||||
@ -2072,24 +2073,65 @@ fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void {
|
||||
llvm.LLVMInitializeXCoreTargetInfo();
|
||||
llvm.LLVMInitializeXCoreTargetMC();
|
||||
llvm.LLVMInitializeXCoreAsmPrinter();
|
||||
// There is no LLVMInitializeXCoreAsmParser function available.
|
||||
// There is no LLVMInitializeXCoreAsmParser function.
|
||||
},
|
||||
.arc => {},
|
||||
.csky => {},
|
||||
.r600 => {},
|
||||
.tce, .tcele => {},
|
||||
.thumb, .thumbeb => {},
|
||||
.le32, .le64 => {},
|
||||
.amdil, .amdil64 => {},
|
||||
.hsail, .hsail64 => {},
|
||||
.spir, .spir64 => {},
|
||||
.kalimba => {},
|
||||
.shave => {},
|
||||
.renderscript32 => {},
|
||||
.renderscript64 => {},
|
||||
.ve => {},
|
||||
.spu_2 => {},
|
||||
.spirv32 => {},
|
||||
.spirv64 => {},
|
||||
.m68k => {
|
||||
if (build_options.llvm_has_m68k) {
|
||||
llvm.LLVMInitializeM68kTarget();
|
||||
llvm.LLVMInitializeM68kTargetInfo();
|
||||
llvm.LLVMInitializeM68kTargetMC();
|
||||
llvm.LLVMInitializeM68kAsmPrinter();
|
||||
llvm.LLVMInitializeM68kAsmParser();
|
||||
}
|
||||
},
|
||||
.csky => {
|
||||
if (build_options.llvm_has_csky) {
|
||||
llvm.LLVMInitializeCSKYTarget();
|
||||
llvm.LLVMInitializeCSKYTargetInfo();
|
||||
llvm.LLVMInitializeCSKYTargetMC();
|
||||
// There is no LLVMInitializeCSKYAsmPrinter function.
|
||||
llvm.LLVMInitializeCSKYAsmParser();
|
||||
}
|
||||
},
|
||||
.ve => {
|
||||
if (build_options.llvm_has_ve) {
|
||||
llvm.LLVMInitializeVETarget();
|
||||
llvm.LLVMInitializeVETargetInfo();
|
||||
llvm.LLVMInitializeVETargetMC();
|
||||
llvm.LLVMInitializeVEAsmPrinter();
|
||||
llvm.LLVMInitializeVEAsmParser();
|
||||
}
|
||||
},
|
||||
.arc => {
|
||||
if (build_options.llvm_has_arc) {
|
||||
llvm.LLVMInitializeARCTarget();
|
||||
llvm.LLVMInitializeARCTargetInfo();
|
||||
llvm.LLVMInitializeARCTargetMC();
|
||||
llvm.LLVMInitializeARCAsmPrinter();
|
||||
// There is no LLVMInitializeARCAsmParser function.
|
||||
}
|
||||
},
|
||||
|
||||
// LLVM backends that have no initialization functions.
|
||||
.tce,
|
||||
.tcele,
|
||||
.r600,
|
||||
.le32,
|
||||
.le64,
|
||||
.amdil,
|
||||
.amdil64,
|
||||
.hsail,
|
||||
.hsail64,
|
||||
.shave,
|
||||
.spir,
|
||||
.spir64,
|
||||
.kalimba,
|
||||
.renderscript32,
|
||||
.renderscript64,
|
||||
=> {},
|
||||
|
||||
.spu_2 => unreachable, // LLVM does not support this backend
|
||||
.spirv32 => unreachable, // LLVM does not support this backend
|
||||
.spirv64 => unreachable, // LLVM does not support this backend
|
||||
}
|
||||
}
|
||||
|
@ -614,6 +614,10 @@ pub extern fn LLVMInitializeSystemZTargetInfo() void;
|
||||
pub extern fn LLVMInitializeWebAssemblyTargetInfo() void;
|
||||
pub extern fn LLVMInitializeX86TargetInfo() void;
|
||||
pub extern fn LLVMInitializeXCoreTargetInfo() void;
|
||||
pub extern fn LLVMInitializeM68kTargetInfo() void;
|
||||
pub extern fn LLVMInitializeCSKYTargetInfo() void;
|
||||
pub extern fn LLVMInitializeVETargetInfo() void;
|
||||
pub extern fn LLVMInitializeARCTargetInfo() void;
|
||||
|
||||
pub extern fn LLVMInitializeAArch64Target() void;
|
||||
pub extern fn LLVMInitializeAMDGPUTarget() void;
|
||||
@ -632,6 +636,10 @@ pub extern fn LLVMInitializeSystemZTarget() void;
|
||||
pub extern fn LLVMInitializeWebAssemblyTarget() void;
|
||||
pub extern fn LLVMInitializeX86Target() void;
|
||||
pub extern fn LLVMInitializeXCoreTarget() void;
|
||||
pub extern fn LLVMInitializeM68kTarget() void;
|
||||
pub extern fn LLVMInitializeVETarget() void;
|
||||
pub extern fn LLVMInitializeCSKYTarget() void;
|
||||
pub extern fn LLVMInitializeARCTarget() void;
|
||||
|
||||
pub extern fn LLVMInitializeAArch64TargetMC() void;
|
||||
pub extern fn LLVMInitializeAMDGPUTargetMC() void;
|
||||
@ -650,6 +658,10 @@ pub extern fn LLVMInitializeSystemZTargetMC() void;
|
||||
pub extern fn LLVMInitializeWebAssemblyTargetMC() void;
|
||||
pub extern fn LLVMInitializeX86TargetMC() void;
|
||||
pub extern fn LLVMInitializeXCoreTargetMC() void;
|
||||
pub extern fn LLVMInitializeM68kTargetMC() void;
|
||||
pub extern fn LLVMInitializeCSKYTargetMC() void;
|
||||
pub extern fn LLVMInitializeVETargetMC() void;
|
||||
pub extern fn LLVMInitializeARCTargetMC() void;
|
||||
|
||||
pub extern fn LLVMInitializeAArch64AsmPrinter() void;
|
||||
pub extern fn LLVMInitializeAMDGPUAsmPrinter() void;
|
||||
@ -668,6 +680,9 @@ pub extern fn LLVMInitializeSystemZAsmPrinter() void;
|
||||
pub extern fn LLVMInitializeWebAssemblyAsmPrinter() void;
|
||||
pub extern fn LLVMInitializeX86AsmPrinter() void;
|
||||
pub extern fn LLVMInitializeXCoreAsmPrinter() void;
|
||||
pub extern fn LLVMInitializeM68kAsmPrinter() void;
|
||||
pub extern fn LLVMInitializeVEAsmPrinter() void;
|
||||
pub extern fn LLVMInitializeARCAsmPrinter() void;
|
||||
|
||||
pub extern fn LLVMInitializeAArch64AsmParser() void;
|
||||
pub extern fn LLVMInitializeAMDGPUAsmParser() void;
|
||||
@ -684,6 +699,9 @@ pub extern fn LLVMInitializeSparcAsmParser() void;
|
||||
pub extern fn LLVMInitializeSystemZAsmParser() void;
|
||||
pub extern fn LLVMInitializeWebAssemblyAsmParser() void;
|
||||
pub extern fn LLVMInitializeX86AsmParser() void;
|
||||
pub extern fn LLVMInitializeM68kAsmParser() void;
|
||||
pub extern fn LLVMInitializeCSKYAsmParser() void;
|
||||
pub extern fn LLVMInitializeVEAsmParser() void;
|
||||
|
||||
extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
|
||||
extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
|
||||
|
@ -1,4 +1,8 @@
|
||||
pub const have_llvm = true;
|
||||
pub const llvm_has_m68k = false;
|
||||
pub const llvm_has_csky = false;
|
||||
pub const llvm_has_ve = false;
|
||||
pub const llvm_has_arc = false;
|
||||
pub const version: [:0]const u8 = "@ZIG_VERSION@";
|
||||
pub const semver = @import("std").SemanticVersion.parse(version) catch unreachable;
|
||||
pub const enable_logging: bool = @ZIG_ENABLE_LOGGING_BOOL@;
|
||||
|
Loading…
Reference in New Issue
Block a user