| author | |
| committer | |
| log | 77516af118f219f9d73494c8a1d5df3e23672680 |
| tree | b9e6a0ef5556fca556a22ec2dc29610c4ad68041 |
| parent | 7efca2e6f51458de8e70a6f5cbbc292026321681 |
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.4 files changed, 111 insertions(+), 19 deletions(-)
build.zig+28| ... | @@ -64,6 +64,26 @@ pub fn build(b: *Builder) !void { | ... | @@ -64,6 +64,26 @@ pub fn build(b: *Builder) !void { |
| 64 | const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false; | 64 | const omit_stage2 = b.option(bool, "omit-stage2", "Do not include stage2 behind a feature flag inside stage1") orelse false; |
| 65 | const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; | 65 | const static_llvm = b.option(bool, "static-llvm", "Disable integration with system-installed LLVM, Clang, LLD, and libc++") orelse false; |
| 66 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm); | 66 | const enable_llvm = b.option(bool, "enable-llvm", "Build self-hosted compiler with LLVM backend enabled") orelse (is_stage1 or static_llvm); |
| 67 | const llvm_has_m68k = b.option( | ||
| 68 | bool, | ||
| 69 | "llvm-has-m68k", | ||
| 70 | "Whether LLVM has the experimental target m68k enabled", | ||
| 71 | ) orelse false; | ||
| 72 | const llvm_has_csky = b.option( | ||
| 73 | bool, | ||
| 74 | "llvm-has-csky", | ||
| 75 | "Whether LLVM has the experimental target csky enabled", | ||
| 76 | ) orelse false; | ||
| 77 | const llvm_has_ve = b.option( | ||
| 78 | bool, | ||
| 79 | "llvm-has-ve", | ||
| 80 | "Whether LLVM has the experimental target ve enabled", | ||
| 81 | ) orelse false; | ||
| 82 | const llvm_has_arc = b.option( | ||
| 83 | bool, | ||
| 84 | "llvm-has-arc", | ||
| 85 | "Whether LLVM has the experimental target arc enabled", | ||
| 86 | ) orelse false; | ||
| 67 | const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse false; | 87 | const enable_macos_sdk = b.option(bool, "enable-macos-sdk", "Run tests requiring presence of macOS SDK and frameworks") orelse false; |
| 68 | const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); | 88 | const config_h_path_option = b.option([]const u8, "config_h", "Path to the generated config.h"); |
| 69 | 89 | ||
| ... | @@ -115,6 +135,10 @@ pub fn build(b: *Builder) !void { | ... | @@ -115,6 +135,10 @@ pub fn build(b: *Builder) !void { |
| 115 | exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames); | 135 | exe_options.addOption(u32, "mem_leak_frames", mem_leak_frames); |
| 116 | exe_options.addOption(bool, "skip_non_native", skip_non_native); | 136 | exe_options.addOption(bool, "skip_non_native", skip_non_native); |
| 117 | exe_options.addOption(bool, "have_llvm", enable_llvm); | 137 | exe_options.addOption(bool, "have_llvm", enable_llvm); |
| 138 | exe_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); | ||
| 139 | exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky); | ||
| 140 | exe_options.addOption(bool, "llvm_has_ve", llvm_has_ve); | ||
| 141 | exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc); | ||
| 118 | 142 | ||
| 119 | if (enable_llvm) { | 143 | if (enable_llvm) { |
| 120 | const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); | 144 | const cmake_cfg = if (static_llvm) null else findAndParseConfigH(b, config_h_path_option); |
| ... | @@ -261,6 +285,10 @@ pub fn build(b: *Builder) !void { | ... | @@ -261,6 +285,10 @@ pub fn build(b: *Builder) !void { |
| 261 | test_stage2_options.addOption(bool, "is_stage1", is_stage1); | 285 | test_stage2_options.addOption(bool, "is_stage1", is_stage1); |
| 262 | test_stage2_options.addOption(bool, "omit_stage2", omit_stage2); | 286 | test_stage2_options.addOption(bool, "omit_stage2", omit_stage2); |
| 263 | test_stage2_options.addOption(bool, "have_llvm", enable_llvm); | 287 | test_stage2_options.addOption(bool, "have_llvm", enable_llvm); |
| 288 | test_stage2_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k); | ||
| 289 | test_stage2_options.addOption(bool, "llvm_has_csky", llvm_has_csky); | ||
| 290 | test_stage2_options.addOption(bool, "llvm_has_ve", llvm_has_ve); | ||
| 291 | test_stage2_options.addOption(bool, "llvm_has_arc", llvm_has_arc); | ||
| 264 | test_stage2_options.addOption(bool, "enable_qemu", is_qemu_enabled); | 292 | test_stage2_options.addOption(bool, "enable_qemu", is_qemu_enabled); |
| 265 | test_stage2_options.addOption(bool, "enable_wine", is_wine_enabled); | 293 | test_stage2_options.addOption(bool, "enable_wine", is_wine_enabled); |
| 266 | test_stage2_options.addOption(bool, "enable_wasmtime", is_wasmtime_enabled); | 294 | test_stage2_options.addOption(bool, "enable_wasmtime", is_wasmtime_enabled); |
src/codegen/llvm.zig+61-19| ... | @@ -7,6 +7,7 @@ const link = @import("../link.zig"); | ... | @@ -7,6 +7,7 @@ const link = @import("../link.zig"); |
| 7 | const log = std.log.scoped(.codegen); | 7 | const log = std.log.scoped(.codegen); |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | 9 | ||
| 10 | const build_options = @import("build_options"); | ||
| 10 | const Module = @import("../Module.zig"); | 11 | const Module = @import("../Module.zig"); |
| 11 | const TypedValue = @import("../TypedValue.zig"); | 12 | const TypedValue = @import("../TypedValue.zig"); |
| 12 | const Zir = @import("../Zir.zig"); | 13 | const Zir = @import("../Zir.zig"); |
| ... | @@ -1969,7 +1970,7 @@ fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { | ... | @@ -1969,7 +1970,7 @@ fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { |
| 1969 | llvm.LLVMInitializeAMDGPUAsmPrinter(); | 1970 | llvm.LLVMInitializeAMDGPUAsmPrinter(); |
| 1970 | llvm.LLVMInitializeAMDGPUAsmParser(); | 1971 | llvm.LLVMInitializeAMDGPUAsmParser(); |
| 1971 | }, | 1972 | }, |
| 1972 | .arm, .armeb => { | 1973 | .thumb, .thumbeb, .arm, .armeb => { |
| 1973 | llvm.LLVMInitializeARMTarget(); | 1974 | llvm.LLVMInitializeARMTarget(); |
| 1974 | llvm.LLVMInitializeARMTargetInfo(); | 1975 | llvm.LLVMInitializeARMTargetInfo(); |
| 1975 | llvm.LLVMInitializeARMTargetMC(); | 1976 | llvm.LLVMInitializeARMTargetMC(); |
| ... | @@ -2072,24 +2073,65 @@ fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { | ... | @@ -2072,24 +2073,65 @@ fn initializeLLVMTarget(arch: std.Target.Cpu.Arch) void { |
| 2072 | llvm.LLVMInitializeXCoreTargetInfo(); | 2073 | llvm.LLVMInitializeXCoreTargetInfo(); |
| 2073 | llvm.LLVMInitializeXCoreTargetMC(); | 2074 | llvm.LLVMInitializeXCoreTargetMC(); |
| 2074 | llvm.LLVMInitializeXCoreAsmPrinter(); | 2075 | llvm.LLVMInitializeXCoreAsmPrinter(); |
| 2075 | // There is no LLVMInitializeXCoreAsmParser function available. | 2076 | // There is no LLVMInitializeXCoreAsmParser function. |
| 2076 | }, | 2077 | }, |
| 2077 | .arc => {}, | 2078 | .m68k => { |
| 2078 | .csky => {}, | 2079 | if (build_options.llvm_has_m68k) { |
| 2079 | .r600 => {}, | 2080 | llvm.LLVMInitializeM68kTarget(); |
| 2080 | .tce, .tcele => {}, | 2081 | llvm.LLVMInitializeM68kTargetInfo(); |
| 2081 | .thumb, .thumbeb => {}, | 2082 | llvm.LLVMInitializeM68kTargetMC(); |
| 2082 | .le32, .le64 => {}, | 2083 | llvm.LLVMInitializeM68kAsmPrinter(); |
| 2083 | .amdil, .amdil64 => {}, | 2084 | llvm.LLVMInitializeM68kAsmParser(); |
| 2084 | .hsail, .hsail64 => {}, | 2085 | } |
| 2085 | .spir, .spir64 => {}, | 2086 | }, |
| 2086 | .kalimba => {}, | 2087 | .csky => { |
| 2087 | .shave => {}, | 2088 | if (build_options.llvm_has_csky) { |
| 2088 | .renderscript32 => {}, | 2089 | llvm.LLVMInitializeCSKYTarget(); |
| 2089 | .renderscript64 => {}, | 2090 | llvm.LLVMInitializeCSKYTargetInfo(); |
| 2090 | .ve => {}, | 2091 | llvm.LLVMInitializeCSKYTargetMC(); |
| 2091 | .spu_2 => {}, | 2092 | // There is no LLVMInitializeCSKYAsmPrinter function. |
| 2092 | .spirv32 => {}, | 2093 | llvm.LLVMInitializeCSKYAsmParser(); |
| 2093 | .spirv64 => {}, | 2094 | } |
| 2095 | }, | ||
| 2096 | .ve => { | ||
| 2097 | if (build_options.llvm_has_ve) { | ||
| 2098 | llvm.LLVMInitializeVETarget(); | ||
| 2099 | llvm.LLVMInitializeVETargetInfo(); | ||
| 2100 | llvm.LLVMInitializeVETargetMC(); | ||
| 2101 | llvm.LLVMInitializeVEAsmPrinter(); | ||
| 2102 | llvm.LLVMInitializeVEAsmParser(); | ||
| 2103 | } | ||
| 2104 | }, | ||
| 2105 | .arc => { | ||
| 2106 | if (build_options.llvm_has_arc) { | ||
| 2107 | llvm.LLVMInitializeARCTarget(); | ||
| 2108 | llvm.LLVMInitializeARCTargetInfo(); | ||
| 2109 | llvm.LLVMInitializeARCTargetMC(); | ||
| 2110 | llvm.LLVMInitializeARCAsmPrinter(); | ||
| 2111 | // There is no LLVMInitializeARCAsmParser function. | ||
| 2112 | } | ||
| 2113 | }, | ||
| 2114 | |||
| 2115 | // LLVM backends that have no initialization functions. | ||
| 2116 | .tce, | ||
| 2117 | .tcele, | ||
| 2118 | .r600, | ||
| 2119 | .le32, | ||
| 2120 | .le64, | ||
| 2121 | .amdil, | ||
| 2122 | .amdil64, | ||
| 2123 | .hsail, | ||
| 2124 | .hsail64, | ||
| 2125 | .shave, | ||
| 2126 | .spir, | ||
| 2127 | .spir64, | ||
| 2128 | .kalimba, | ||
| 2129 | .renderscript32, | ||
| 2130 | .renderscript64, | ||
| 2131 | => {}, | ||
| 2132 | |||
| 2133 | .spu_2 => unreachable, // LLVM does not support this backend | ||
| 2134 | .spirv32 => unreachable, // LLVM does not support this backend | ||
| 2135 | .spirv64 => unreachable, // LLVM does not support this backend | ||
| 2094 | } | 2136 | } |
| 2095 | } | 2137 | } |
src/codegen/llvm/bindings.zig+18| ... | @@ -614,6 +614,10 @@ pub extern fn LLVMInitializeSystemZTargetInfo() void; | ... | @@ -614,6 +614,10 @@ pub extern fn LLVMInitializeSystemZTargetInfo() void; |
| 614 | pub extern fn LLVMInitializeWebAssemblyTargetInfo() void; | 614 | pub extern fn LLVMInitializeWebAssemblyTargetInfo() void; |
| 615 | pub extern fn LLVMInitializeX86TargetInfo() void; | 615 | pub extern fn LLVMInitializeX86TargetInfo() void; |
| 616 | pub extern fn LLVMInitializeXCoreTargetInfo() void; | 616 | pub extern fn LLVMInitializeXCoreTargetInfo() void; |
| 617 | pub extern fn LLVMInitializeM68kTargetInfo() void; | ||
| 618 | pub extern fn LLVMInitializeCSKYTargetInfo() void; | ||
| 619 | pub extern fn LLVMInitializeVETargetInfo() void; | ||
| 620 | pub extern fn LLVMInitializeARCTargetInfo() void; | ||
| 617 | 621 | ||
| 618 | pub extern fn LLVMInitializeAArch64Target() void; | 622 | pub extern fn LLVMInitializeAArch64Target() void; |
| 619 | pub extern fn LLVMInitializeAMDGPUTarget() void; | 623 | pub extern fn LLVMInitializeAMDGPUTarget() void; |
| ... | @@ -632,6 +636,10 @@ pub extern fn LLVMInitializeSystemZTarget() void; | ... | @@ -632,6 +636,10 @@ pub extern fn LLVMInitializeSystemZTarget() void; |
| 632 | pub extern fn LLVMInitializeWebAssemblyTarget() void; | 636 | pub extern fn LLVMInitializeWebAssemblyTarget() void; |
| 633 | pub extern fn LLVMInitializeX86Target() void; | 637 | pub extern fn LLVMInitializeX86Target() void; |
| 634 | pub extern fn LLVMInitializeXCoreTarget() void; | 638 | pub extern fn LLVMInitializeXCoreTarget() void; |
| 639 | pub extern fn LLVMInitializeM68kTarget() void; | ||
| 640 | pub extern fn LLVMInitializeVETarget() void; | ||
| 641 | pub extern fn LLVMInitializeCSKYTarget() void; | ||
| 642 | pub extern fn LLVMInitializeARCTarget() void; | ||
| 635 | 643 | ||
| 636 | pub extern fn LLVMInitializeAArch64TargetMC() void; | 644 | pub extern fn LLVMInitializeAArch64TargetMC() void; |
| 637 | pub extern fn LLVMInitializeAMDGPUTargetMC() void; | 645 | pub extern fn LLVMInitializeAMDGPUTargetMC() void; |
| ... | @@ -650,6 +658,10 @@ pub extern fn LLVMInitializeSystemZTargetMC() void; | ... | @@ -650,6 +658,10 @@ pub extern fn LLVMInitializeSystemZTargetMC() void; |
| 650 | pub extern fn LLVMInitializeWebAssemblyTargetMC() void; | 658 | pub extern fn LLVMInitializeWebAssemblyTargetMC() void; |
| 651 | pub extern fn LLVMInitializeX86TargetMC() void; | 659 | pub extern fn LLVMInitializeX86TargetMC() void; |
| 652 | pub extern fn LLVMInitializeXCoreTargetMC() void; | 660 | pub extern fn LLVMInitializeXCoreTargetMC() void; |
| 661 | pub extern fn LLVMInitializeM68kTargetMC() void; | ||
| 662 | pub extern fn LLVMInitializeCSKYTargetMC() void; | ||
| 663 | pub extern fn LLVMInitializeVETargetMC() void; | ||
| 664 | pub extern fn LLVMInitializeARCTargetMC() void; | ||
| 653 | 665 | ||
| 654 | pub extern fn LLVMInitializeAArch64AsmPrinter() void; | 666 | pub extern fn LLVMInitializeAArch64AsmPrinter() void; |
| 655 | pub extern fn LLVMInitializeAMDGPUAsmPrinter() void; | 667 | pub extern fn LLVMInitializeAMDGPUAsmPrinter() void; |
| ... | @@ -668,6 +680,9 @@ pub extern fn LLVMInitializeSystemZAsmPrinter() void; | ... | @@ -668,6 +680,9 @@ pub extern fn LLVMInitializeSystemZAsmPrinter() void; |
| 668 | pub extern fn LLVMInitializeWebAssemblyAsmPrinter() void; | 680 | pub extern fn LLVMInitializeWebAssemblyAsmPrinter() void; |
| 669 | pub extern fn LLVMInitializeX86AsmPrinter() void; | 681 | pub extern fn LLVMInitializeX86AsmPrinter() void; |
| 670 | pub extern fn LLVMInitializeXCoreAsmPrinter() void; | 682 | pub extern fn LLVMInitializeXCoreAsmPrinter() void; |
| 683 | pub extern fn LLVMInitializeM68kAsmPrinter() void; | ||
| 684 | pub extern fn LLVMInitializeVEAsmPrinter() void; | ||
| 685 | pub extern fn LLVMInitializeARCAsmPrinter() void; | ||
| 671 | 686 | ||
| 672 | pub extern fn LLVMInitializeAArch64AsmParser() void; | 687 | pub extern fn LLVMInitializeAArch64AsmParser() void; |
| 673 | pub extern fn LLVMInitializeAMDGPUAsmParser() void; | 688 | pub extern fn LLVMInitializeAMDGPUAsmParser() void; |
| ... | @@ -684,6 +699,9 @@ pub extern fn LLVMInitializeSparcAsmParser() void; | ... | @@ -684,6 +699,9 @@ pub extern fn LLVMInitializeSparcAsmParser() void; |
| 684 | pub extern fn LLVMInitializeSystemZAsmParser() void; | 699 | pub extern fn LLVMInitializeSystemZAsmParser() void; |
| 685 | pub extern fn LLVMInitializeWebAssemblyAsmParser() void; | 700 | pub extern fn LLVMInitializeWebAssemblyAsmParser() void; |
| 686 | pub extern fn LLVMInitializeX86AsmParser() void; | 701 | pub extern fn LLVMInitializeX86AsmParser() void; |
| 702 | pub extern fn LLVMInitializeM68kAsmParser() void; | ||
| 703 | pub extern fn LLVMInitializeCSKYAsmParser() void; | ||
| 704 | pub extern fn LLVMInitializeVEAsmParser() void; | ||
| 687 | 705 | ||
| 688 | extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | 706 | extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; |
| 689 | extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | 707 | extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; |
src/config.zig.in+4| ... | @@ -1,4 +1,8 @@ | ... | @@ -1,4 +1,8 @@ |
| 1 | pub const have_llvm = true; | 1 | pub const have_llvm = true; |
| 2 | pub const llvm_has_m68k = false; | ||
| 3 | pub const llvm_has_csky = false; | ||
| 4 | pub const llvm_has_ve = false; | ||
| 5 | pub const llvm_has_arc = false; | ||
| 2 | pub const version: [:0]const u8 = "@ZIG_VERSION@"; | 6 | pub const version: [:0]const u8 = "@ZIG_VERSION@"; |
| 3 | pub const semver = @import("std").SemanticVersion.parse(version) catch unreachable; | 7 | pub const semver = @import("std").SemanticVersion.parse(version) catch unreachable; |
| 4 | pub const enable_logging: bool = @ZIG_ENABLE_LOGGING_BOOL@; | 8 | pub const enable_logging: bool = @ZIG_ENABLE_LOGGING_BOOL@; |