remove "enable_llvm" switch
This commit is contained in:
parent
621ce78874
commit
3a232da71e
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -61,7 +61,6 @@ jobs:
|
||||
matrix:
|
||||
os: [ ubuntu-24.04 ]
|
||||
BIRTH_ZIG_BUILD_TYPE: ${{ fromJSON(needs.generate-config.outputs.BIRTH_ZIG_BUILD_TYPES) }}
|
||||
ENABLE_LLVM: [ true, false ]
|
||||
SYSTEM_LLVM: [ true, false ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
@ -78,6 +77,6 @@ jobs:
|
||||
run: sudo apt-get update && sudo apt-get install -y llvm-dev liblld-dev
|
||||
- name: Build and test
|
||||
run: |
|
||||
zig build test --summary all -Denable_llvm=${{matrix.ENABLE_LLVM}} -Doptimize=${{matrix.BIRTH_ZIG_BUILD_TYPE}} -Dsystem_llvm=${{matrix.SYSTEM_LLVM}}
|
||||
zig build install -Denable_llvm=${{matrix.ENABLE_LLVM}} -Doptimize=${{matrix.BIRTH_ZIG_BUILD_TYPE}} -Dsystem_llvm=${{matrix.SYSTEM_LLVM}}
|
||||
zig build test --summary all -Doptimize=${{matrix.BIRTH_ZIG_BUILD_TYPE}} -Dsystem_llvm=${{matrix.SYSTEM_LLVM}}
|
||||
zig build install -Doptimize=${{matrix.BIRTH_ZIG_BUILD_TYPE}} -Dsystem_llvm=${{matrix.SYSTEM_LLVM}}
|
||||
ldd zig-out/bin/bloat-buster
|
||||
|
11
build.zig
11
build.zig
@ -65,7 +65,6 @@ const LLVM = struct {
|
||||
module: *std.Build.Module,
|
||||
|
||||
fn setup(b: *std.Build, path: []const u8) !LLVM {
|
||||
if (enable_llvm) {
|
||||
var llvm_libs = std.ArrayList([]const u8).init(b.allocator);
|
||||
var flags = std.ArrayList([]const u8).init(b.allocator);
|
||||
const llvm_config_path = if (b.option([]const u8, "llvm_prefix", "LLVM prefix")) |llvm_prefix| blk: {
|
||||
@ -258,9 +257,6 @@ const LLVM = struct {
|
||||
return LLVM{
|
||||
.module = llvm,
|
||||
};
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
fn link(llvm: LLVM, compile: *std.Build.Step.Compile) void {
|
||||
@ -283,7 +279,6 @@ fn debug_binary(b: *std.Build, exe: *std.Build.Step.Compile) *std.Build.Step.Run
|
||||
return run_step;
|
||||
}
|
||||
|
||||
var enable_llvm: bool = undefined;
|
||||
var system_llvm: bool = undefined;
|
||||
var target: std.Build.ResolvedTarget = undefined;
|
||||
var optimize: std.builtin.OptimizeMode = undefined;
|
||||
@ -293,12 +288,10 @@ pub fn build(b: *std.Build) !void {
|
||||
env = try std.process.getEnvMap(b.allocator);
|
||||
target = b.standardTargetOptions(.{});
|
||||
optimize = b.standardOptimizeOption(.{});
|
||||
enable_llvm = b.option(bool, "enable_llvm", "Enable LLVM") orelse false;
|
||||
system_llvm = b.option(bool, "system_llvm", "Link against system LLVM libraries") orelse true;
|
||||
const path = env.get("PATH") orelse unreachable;
|
||||
|
||||
const configuration = b.addOptions();
|
||||
configuration.addOption(bool, "enable_llvm", enable_llvm);
|
||||
|
||||
const exe_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
@ -315,9 +308,7 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
exe.linkLibC();
|
||||
|
||||
if (enable_llvm) {
|
||||
llvm.link(exe);
|
||||
}
|
||||
|
||||
b.installArtifact(exe);
|
||||
|
||||
@ -338,9 +329,7 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
exe_unit_tests.linkLibC();
|
||||
|
||||
if (enable_llvm) {
|
||||
llvm.link(exe);
|
||||
}
|
||||
|
||||
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
|
||||
|
||||
|
26
src/LLVM.zig
26
src/LLVM.zig
@ -760,9 +760,16 @@ const LldArgvBuilder = struct {
|
||||
};
|
||||
|
||||
test "experiment" {
|
||||
if (!configuration.enable_llvm) {
|
||||
return error.SkipZigTest;
|
||||
}
|
||||
const std = @import("std");
|
||||
var tmp_dir = std.testing.tmpDir(.{});
|
||||
defer tmp_dir.cleanup();
|
||||
const allocator = std.testing.allocator;
|
||||
|
||||
const object_file_path = try std.mem.joinZ(allocator, "/", &.{ ".zig-cache", "tmp", &tmp_dir.sub_path, "foo.o" });
|
||||
// Zig stuf... sigh
|
||||
defer allocator.free(object_file_path);
|
||||
const executable_file_path = try std.mem.joinZ(allocator, "/", &.{ ".zig-cache", "tmp", &tmp_dir.sub_path, "foo" });
|
||||
defer allocator.free(executable_file_path);
|
||||
|
||||
lib.GlobalState.initialize();
|
||||
initialize_all();
|
||||
@ -814,9 +821,8 @@ test "experiment" {
|
||||
module.set_target(target_machine);
|
||||
|
||||
module.run_optimization_pipeline(target_machine, OptimizationPipelineOptions.default(.{ .optimization_level = .O3, .debug_info = 1 }));
|
||||
const object_path = "foo.o";
|
||||
const result = module.run_code_generation_pipeline(target_machine, CodeGenerationPipelineOptions{
|
||||
.output_file_path = String.from_slice(object_path),
|
||||
.output_file_path = String.from_slice(object_file_path),
|
||||
.output_dwarf_file_path = .{},
|
||||
.flags = .{
|
||||
.code_generation_file_type = .object_file,
|
||||
@ -826,7 +832,11 @@ test "experiment" {
|
||||
});
|
||||
switch (result) {
|
||||
.success => {},
|
||||
.failed_to_create_file => return error.failed_to_create_file,
|
||||
.failed_to_create_file => {
|
||||
lib.print_string_stderr(object_file_path);
|
||||
lib.print_string_stderr("\n");
|
||||
return error.failed_to_create_file;
|
||||
},
|
||||
.failed_to_add_emit_passes => return error.failed_to_add_emit_passes,
|
||||
}
|
||||
|
||||
@ -834,8 +844,8 @@ test "experiment" {
|
||||
arg_builder.add("ld.lld");
|
||||
arg_builder.add("--error-limit=0");
|
||||
arg_builder.add("-o");
|
||||
arg_builder.add("foo");
|
||||
const objects: []const [*:0]const u8 = &.{object_path};
|
||||
arg_builder.add(executable_file_path);
|
||||
const objects: []const [*:0]const u8 = &.{object_file_path};
|
||||
for (objects) |object| {
|
||||
arg_builder.add(object);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user