mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-05-21 08:32:02 +03:00
zig build: promote qemu, wine, wasmtime, darling, and rosetta
from zig-specific options to generally recognized zig build options that any project can take advantage of. See the updated usage text for more details.
This commit is contained in:
+22
-27
@@ -70,6 +70,22 @@ pub const Builder = struct {
|
||||
args: ?[][]const u8 = null,
|
||||
debug_log_scopes: []const []const u8 = &.{},
|
||||
|
||||
/// Experimental. Use system Darling installation to run cross compiled macOS build artifacts.
|
||||
enable_darling: bool = false,
|
||||
/// Use system QEMU installation to run cross compiled foreign architecture build artifacts.
|
||||
enable_qemu: bool = false,
|
||||
/// Darwin. Use Rosetta to run x86_64 macOS build artifacts on arm64 macOS.
|
||||
enable_rosetta: bool = false,
|
||||
/// Use system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
|
||||
enable_wasmtime: bool = false,
|
||||
/// Use system Wine installation to run cross compiled Windows build artifacts.
|
||||
enable_wine: bool = false,
|
||||
/// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
|
||||
/// this will be the directory $glibc-build-dir/install/glibcs
|
||||
/// Given the example of the aarch64 target, this is the directory
|
||||
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
|
||||
glibc_runtimes_dir: ?[]const u8 = null,
|
||||
|
||||
const PkgConfigError = error{
|
||||
PkgConfigCrashed,
|
||||
PkgConfigFailed,
|
||||
@@ -1504,27 +1520,6 @@ pub const LibExeObjStep = struct {
|
||||
/// Permit read-only relocations in read-only segments. Disallowed by default.
|
||||
link_z_notext: bool = false,
|
||||
|
||||
/// Uses system Wine installation to run cross compiled Windows build artifacts.
|
||||
enable_wine: bool = false,
|
||||
|
||||
/// Uses system QEMU installation to run cross compiled foreign architecture build artifacts.
|
||||
enable_qemu: bool = false,
|
||||
|
||||
/// Uses system Wasmtime installation to run cross compiled wasm/wasi build artifacts.
|
||||
enable_wasmtime: bool = false,
|
||||
|
||||
/// Experimental. Uses system Darling installation to run cross compiled macOS build artifacts.
|
||||
enable_darling: bool = false,
|
||||
|
||||
/// Darwin. Uses Rosetta to run x86_64 macOS build artifacts on arm64 macOS.
|
||||
enable_rosetta: bool = false,
|
||||
|
||||
/// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc,
|
||||
/// this will be the directory $glibc-build-dir/install/glibcs
|
||||
/// Given the example of the aarch64 target, this is the directory
|
||||
/// that contains the path `aarch64-linux-gnu/lib/ld-linux-aarch64.so.1`.
|
||||
glibc_multi_install_dir: ?[]const u8 = null,
|
||||
|
||||
/// Position Independent Code
|
||||
force_pic: ?bool = null,
|
||||
|
||||
@@ -2533,13 +2528,13 @@ pub const LibExeObjStep = struct {
|
||||
}
|
||||
} else switch (self.target.getExternalExecutor()) {
|
||||
.native, .unavailable => {},
|
||||
.rosetta => if (self.enable_rosetta) {
|
||||
.rosetta => if (builder.enable_rosetta) {
|
||||
try zig_args.append("--test-cmd-bin");
|
||||
},
|
||||
.qemu => |bin_name| if (self.enable_qemu) qemu: {
|
||||
.qemu => |bin_name| if (builder.enable_qemu) qemu: {
|
||||
const need_cross_glibc = self.target.isGnuLibC() and self.is_linking_libc;
|
||||
const glibc_dir_arg = if (need_cross_glibc)
|
||||
self.glibc_multi_install_dir orelse break :qemu
|
||||
builder.glibc_runtimes_dir orelse break :qemu
|
||||
else
|
||||
null;
|
||||
try zig_args.append("--test-cmd");
|
||||
@@ -2567,19 +2562,19 @@ pub const LibExeObjStep = struct {
|
||||
}
|
||||
try zig_args.append("--test-cmd-bin");
|
||||
},
|
||||
.wine => |bin_name| if (self.enable_wine) {
|
||||
.wine => |bin_name| if (builder.enable_wine) {
|
||||
try zig_args.append("--test-cmd");
|
||||
try zig_args.append(bin_name);
|
||||
try zig_args.append("--test-cmd-bin");
|
||||
},
|
||||
.wasmtime => |bin_name| if (self.enable_wasmtime) {
|
||||
.wasmtime => |bin_name| if (builder.enable_wasmtime) {
|
||||
try zig_args.append("--test-cmd");
|
||||
try zig_args.append(bin_name);
|
||||
try zig_args.append("--test-cmd");
|
||||
try zig_args.append("--dir=.");
|
||||
try zig_args.append("--test-cmd-bin");
|
||||
},
|
||||
.darling => |bin_name| if (self.enable_darling) {
|
||||
.darling => |bin_name| if (builder.enable_darling) {
|
||||
try zig_args.append("--test-cmd");
|
||||
try zig_args.append(bin_name);
|
||||
try zig_args.append("--test-cmd-bin");
|
||||
|
||||
@@ -142,6 +142,11 @@ pub fn main() !void {
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
try debug_log_scopes.append(next_arg);
|
||||
} else if (mem.eql(u8, arg, "--glibc-runtimes")) {
|
||||
builder.glibc_runtimes_dir = nextArg(args, &arg_idx) orelse {
|
||||
std.debug.print("Expected argument after --glibc-runtimes\n\n", .{});
|
||||
return usageAndErr(builder, false, stderr_stream);
|
||||
};
|
||||
} else if (mem.eql(u8, arg, "--verbose-tokenize")) {
|
||||
builder.verbose_tokenize = true;
|
||||
} else if (mem.eql(u8, arg, "--verbose-ast")) {
|
||||
@@ -160,6 +165,26 @@ pub fn main() !void {
|
||||
builder.verbose_llvm_cpu_features = true;
|
||||
} else if (mem.eql(u8, arg, "--prominent-compile-errors")) {
|
||||
builder.prominent_compile_errors = true;
|
||||
} else if (mem.eql(u8, arg, "-fwine")) {
|
||||
builder.enable_wine = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-wine")) {
|
||||
builder.enable_wine = false;
|
||||
} else if (mem.eql(u8, arg, "-fqemu")) {
|
||||
builder.enable_qemu = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-qemu")) {
|
||||
builder.enable_qemu = false;
|
||||
} else if (mem.eql(u8, arg, "-fwasmtime")) {
|
||||
builder.enable_wasmtime = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-wasmtime")) {
|
||||
builder.enable_wasmtime = false;
|
||||
} else if (mem.eql(u8, arg, "-frosetta")) {
|
||||
builder.enable_rosetta = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-rosetta")) {
|
||||
builder.enable_rosetta = false;
|
||||
} else if (mem.eql(u8, arg, "-fdarling")) {
|
||||
builder.enable_darling = true;
|
||||
} else if (mem.eql(u8, arg, "-fno-darling")) {
|
||||
builder.enable_darling = false;
|
||||
} else if (mem.eql(u8, arg, "--")) {
|
||||
builder.args = argsRest(args, arg_idx);
|
||||
break;
|
||||
@@ -233,6 +258,22 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
|
||||
\\ --search-prefix [path] Add a path to look for binaries, libraries, headers
|
||||
\\ --libc [file] Provide a file which specifies libc paths
|
||||
\\
|
||||
\\ -fdarling, -fno-darling Integration with system-installed Darling to
|
||||
\\ execute macOS programs on Linux hosts
|
||||
\\ (default: no)
|
||||
\\ -fqemu, -fno-qemu Integration with system-installed QEMU to execute
|
||||
\\ foreign-architecture programs on Linux hosts
|
||||
\\ (default: no)
|
||||
\\ --glibc-runtimes [path] Enhances QEMU integration by providing glibc built
|
||||
\\ for multiple foreign architectures, allowing
|
||||
\\ execution of non-native programs that link with glibc.
|
||||
\\ -frosetta, -fno-rosetta Rely on Rosetta to execute x86_64 programs on
|
||||
\\ ARM64 macOS hosts. (default: no)
|
||||
\\ -fwasmtime, -fno-wasmtime Integration with system-installed wasmtime to
|
||||
\\ execute WASI binaries. (default: no)
|
||||
\\ -fwine, -fno-wine Integration with system-installed Wine to execute
|
||||
\\ Windows programs on Linux hosts. (default: no)
|
||||
\\
|
||||
\\ -h, --help Print this help and exit
|
||||
\\ --verbose Print commands before executing them
|
||||
\\ --color [auto|off|on] Enable or disable colored error messages
|
||||
|
||||
Reference in New Issue
Block a user