2017-04-19 18:00:12 +00:00
|
|
|
const std = @import("std");
|
2021-10-05 06:47:27 +00:00
|
|
|
const builtin = @import("builtin");
|
2023-03-07 07:40:55 +00:00
|
|
|
const assert = std.debug.assert;
|
2017-04-19 18:00:12 +00:00
|
|
|
const mem = std.mem;
|
2023-01-31 04:39:43 +00:00
|
|
|
const OptimizeMode = std.builtin.OptimizeMode;
|
2023-01-31 07:19:51 +00:00
|
|
|
const Step = std.Build.Step;
|
2017-04-19 18:00:12 +00:00
|
|
|
|
2020-01-03 03:45:48 +00:00
|
|
|
// Cases
|
2017-04-19 20:59:20 +00:00
|
|
|
const compare_output = @import("compare_output.zig");
|
2019-09-03 14:08:39 +00:00
|
|
|
const stack_traces = @import("stack_traces.zig");
|
2017-04-19 20:59:20 +00:00
|
|
|
const assemble_and_link = @import("assemble_and_link.zig");
|
2017-11-24 19:56:05 +00:00
|
|
|
const translate_c = @import("translate_c.zig");
|
2020-01-03 03:45:48 +00:00
|
|
|
const run_translated_c = @import("run_translated_c.zig");
|
2017-04-19 18:00:12 +00:00
|
|
|
|
2020-01-03 03:45:48 +00:00
|
|
|
// Implementations
|
2024-02-25 13:04:06 +00:00
|
|
|
pub const TranslateCContext = @import("src/TranslateC.zig");
|
|
|
|
pub const RunTranslatedCContext = @import("src/RunTranslatedC.zig");
|
2023-03-07 02:19:48 +00:00
|
|
|
pub const CompareOutputContext = @import("src/CompareOutput.zig");
|
2023-03-07 02:10:37 +00:00
|
|
|
pub const StackTracesContext = @import("src/StackTrace.zig");
|
2024-08-06 15:22:37 +00:00
|
|
|
pub const DebuggerContext = @import("src/Debugger.zig");
|
2020-01-03 03:45:48 +00:00
|
|
|
|
2019-09-22 03:55:56 +00:00
|
|
|
const TestTarget = struct {
|
2023-12-04 19:35:04 +00:00
|
|
|
target: std.Target.Query = .{},
|
2023-01-31 04:39:43 +00:00
|
|
|
optimize_mode: std.builtin.OptimizeMode = .Debug,
|
2023-04-13 23:44:45 +00:00
|
|
|
link_libc: ?bool = null,
|
|
|
|
single_threaded: ?bool = null,
|
|
|
|
use_llvm: ?bool = null,
|
|
|
|
use_lld: ?bool = null,
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
pic: ?bool = null,
|
2023-11-30 19:27:18 +00:00
|
|
|
strip: ?bool = null,
|
2024-10-05 00:25:13 +00:00
|
|
|
skip_modules: []const []const u8 = &.{},
|
2024-08-13 22:14:02 +00:00
|
|
|
|
|
|
|
// This is intended for targets that are known to be slow to compile. These are acceptable to
|
|
|
|
// run in CI, but should not be run on developer machines by default. As an example, at the time
|
|
|
|
// of writing, this includes LLVM's MIPS backend which takes upwards of 20 minutes longer to
|
|
|
|
// compile tests than other backends.
|
|
|
|
slow_backend: bool = false,
|
2019-09-22 03:55:56 +00:00
|
|
|
};
|
|
|
|
|
2020-01-22 22:13:31 +00:00
|
|
|
const test_targets = blk: {
|
|
|
|
// getBaselineCpuFeatures calls populateDependencies which has a O(N ^ 2) algorithm
|
|
|
|
// (where N is roughly 160, which technically makes it O(1), but it adds up to a
|
|
|
|
// lot of branches)
|
|
|
|
@setEvalBranchQuota(50000);
|
|
|
|
break :blk [_]TestTarget{
|
2022-04-22 03:28:36 +00:00
|
|
|
.{},
|
|
|
|
.{
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-01-22 22:13:31 +00:00
|
|
|
.single_threaded = true,
|
|
|
|
},
|
2023-04-13 23:44:45 +00:00
|
|
|
.{
|
|
|
|
.optimize_mode = .ReleaseFast,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.link_libc = true,
|
|
|
|
.optimize_mode = .ReleaseFast,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.optimize_mode = .ReleaseFast,
|
|
|
|
.single_threaded = true,
|
|
|
|
},
|
|
|
|
|
|
|
|
.{
|
|
|
|
.optimize_mode = .ReleaseSafe,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.link_libc = true,
|
|
|
|
.optimize_mode = .ReleaseSafe,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.optimize_mode = .ReleaseSafe,
|
|
|
|
.single_threaded = true,
|
|
|
|
},
|
|
|
|
|
|
|
|
.{
|
|
|
|
.optimize_mode = .ReleaseSmall,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.link_libc = true,
|
|
|
|
.optimize_mode = .ReleaseSmall,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.optimize_mode = .ReleaseSmall,
|
|
|
|
.single_threaded = true,
|
|
|
|
},
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2022-11-01 02:30:34 +00:00
|
|
|
.target = .{
|
|
|
|
.ofmt = .c,
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.link_libc = true,
|
|
|
|
},
|
2023-02-20 09:37:22 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
2023-04-13 23:44:45 +00:00
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
2023-02-20 09:37:22 +00:00
|
|
|
},
|
2023-10-26 09:30:41 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
.pic = true,
|
2023-10-26 09:30:41 +00:00
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
2023-11-30 19:27:18 +00:00
|
|
|
.strip = true,
|
2023-10-26 09:30:41 +00:00
|
|
|
},
|
2023-04-13 08:05:39 +00:00
|
|
|
// Doesn't support new liveness
|
|
|
|
//.{
|
|
|
|
// .target = .{
|
|
|
|
// .cpu_arch = .aarch64,
|
|
|
|
// .os_tag = .linux,
|
|
|
|
// },
|
|
|
|
// .use_llvm = false,
|
|
|
|
// .use_lld = false,
|
|
|
|
//},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .wasm32,
|
|
|
|
.os_tag = .wasi,
|
|
|
|
},
|
2023-04-13 23:44:45 +00:00
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
2022-04-22 03:28:36 +00:00
|
|
|
},
|
2022-11-22 05:56:05 +00:00
|
|
|
// https://github.com/ziglang/zig/issues/13623
|
|
|
|
//.{
|
|
|
|
// .target = .{
|
|
|
|
// .cpu_arch = .arm,
|
|
|
|
// .os_tag = .linux,
|
|
|
|
// },
|
2023-04-13 23:44:45 +00:00
|
|
|
// .use_llvm = false,
|
|
|
|
// .use_lld = false,
|
2022-11-22 05:56:05 +00:00
|
|
|
//},
|
|
|
|
// https://github.com/ziglang/zig/issues/13623
|
|
|
|
//.{
|
2023-12-04 19:35:04 +00:00
|
|
|
// .target = std.Target.Query.parse(.{
|
2022-11-22 05:56:05 +00:00
|
|
|
// .arch_os_abi = "arm-linux-none",
|
|
|
|
// .cpu_features = "generic+v8a",
|
|
|
|
// }) catch unreachable,
|
2023-04-13 23:44:45 +00:00
|
|
|
// .use_llvm = false,
|
|
|
|
// .use_lld = false,
|
2022-11-22 05:56:05 +00:00
|
|
|
//},
|
2023-04-13 08:05:39 +00:00
|
|
|
// Doesn't support new liveness
|
|
|
|
//.{
|
|
|
|
// .target = .{
|
|
|
|
// .cpu_arch = .aarch64,
|
|
|
|
// .os_tag = .macos,
|
|
|
|
// .abi = .none,
|
|
|
|
// },
|
|
|
|
// .use_llvm = false,
|
|
|
|
// .use_lld = false,
|
|
|
|
//},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .macos,
|
2022-05-15 15:56:51 +00:00
|
|
|
.abi = .none,
|
2022-04-22 03:28:36 +00:00
|
|
|
},
|
2023-04-13 23:44:45 +00:00
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
2022-04-22 03:28:36 +00:00
|
|
|
},
|
2022-09-06 15:53:21 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
2023-04-13 23:44:45 +00:00
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
2022-09-06 15:53:21 +00:00
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
|
|
|
|
.{
|
Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.
Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.
The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-05 15:23:49 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .wasm32,
|
|
|
|
.os_tag = .wasi,
|
|
|
|
},
|
|
|
|
.link_libc = false,
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2021-07-26 23:59:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .wasm32,
|
|
|
|
.os_tag = .wasi,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.
Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.
The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-05 15:23:49 +00:00
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2023-09-28 17:28:06 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
.use_lld = false,
|
|
|
|
},
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
2022-10-07 17:54:44 +00:00
|
|
|
.cpu_arch = .x86,
|
2020-02-26 06:18:23 +00:00
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
2019-11-30 15:13:33 +00:00
|
|
|
},
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
2022-10-07 17:54:44 +00:00
|
|
|
.cpu_arch = .x86,
|
2020-02-26 06:18:23 +00:00
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
2019-11-30 15:13:33 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-11-30 15:13:33 +00:00
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2021-06-06 09:12:41 +00:00
|
|
|
.target = .{
|
2022-10-07 17:54:44 +00:00
|
|
|
.cpu_arch = .x86,
|
2021-06-06 09:12:41 +00:00
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
2019-11-30 15:13:33 +00:00
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .aarch64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .aarch64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .aarch64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2021-09-07 16:44:21 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .aarch64,
|
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2024-08-28 19:42:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabi,
|
|
|
|
},
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.{
|
2024-08-28 19:42:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabihf,
|
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
},
|
|
|
|
.{
|
2024-08-28 19:42:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabi,
|
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.link_libc = true,
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2024-08-28 19:42:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabihf,
|
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-09-25 19:57:13 +00:00
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.{
|
2024-08-28 19:42:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnueabi,
|
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.link_libc = true,
|
|
|
|
},
|
2024-08-12 05:20:07 +00:00
|
|
|
.{
|
2024-08-28 19:42:34 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnueabihf,
|
|
|
|
},
|
2024-08-12 05:20:07 +00:00
|
|
|
.link_libc = true,
|
|
|
|
},
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2024-10-05 00:25:59 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .thumb,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabi,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .thumb,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabihf,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .thumb,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabi,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
.skip_modules = &.{"std"},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .thumb,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabihf,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
.skip_modules = &.{"std"},
|
|
|
|
},
|
|
|
|
// Calls are normally lowered to branch instructions that only support +/- 16 MB range when
|
|
|
|
// targeting Thumb. This is not sufficient for the std test binary linked statically with
|
|
|
|
// musl, so use long calls to avoid out-of-range relocations.
|
|
|
|
.{
|
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "thumb-linux-musleabi",
|
|
|
|
.cpu_features = "baseline+long_calls",
|
|
|
|
}) catch @panic("OOM"),
|
|
|
|
.link_libc = true,
|
|
|
|
.pic = false, // Long calls don't work with PIC.
|
|
|
|
.skip_modules = &.{
|
|
|
|
"behavior",
|
|
|
|
"c-import",
|
|
|
|
"compiler-rt",
|
|
|
|
"universal-libc",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "thumb-linux-musleabihf",
|
|
|
|
.cpu_features = "baseline+long_calls",
|
|
|
|
}) catch @panic("OOM"),
|
|
|
|
.link_libc = true,
|
|
|
|
.pic = false, // Long calls don't work with PIC.
|
|
|
|
.skip_modules = &.{
|
|
|
|
"behavior",
|
|
|
|
"c-import",
|
|
|
|
"compiler-rt",
|
|
|
|
"universal-libc",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2024-08-12 05:27:35 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
2024-08-28 19:31:40 +00:00
|
|
|
.abi = .eabi,
|
|
|
|
},
|
|
|
|
.slow_backend = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabihf,
|
|
|
|
},
|
|
|
|
.slow_backend = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabi,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.link_libc = true,
|
2024-08-13 22:14:02 +00:00
|
|
|
.slow_backend = true,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
2024-08-24 22:53:24 +00:00
|
|
|
.abi = .musleabihf,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
|
|
|
.link_libc = true,
|
2024-08-13 22:14:02 +00:00
|
|
|
.slow_backend = true,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnueabi,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
.slow_backend = true,
|
|
|
|
},
|
2024-08-13 19:51:56 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnueabihf,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
2024-08-13 22:14:02 +00:00
|
|
|
.slow_backend = true,
|
2024-08-13 19:51:56 +00:00
|
|
|
},
|
2020-04-21 16:42:21 +00:00
|
|
|
|
2024-08-12 05:27:35 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mipsel,
|
|
|
|
.os_tag = .linux,
|
2024-08-28 19:31:40 +00:00
|
|
|
.abi = .eabi,
|
|
|
|
},
|
|
|
|
.slow_backend = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mipsel,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabihf,
|
|
|
|
},
|
|
|
|
.slow_backend = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mipsel,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabi,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.link_libc = true,
|
2024-08-13 22:14:02 +00:00
|
|
|
.slow_backend = true,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mipsel,
|
|
|
|
.os_tag = .linux,
|
2024-08-24 22:53:24 +00:00
|
|
|
.abi = .musleabihf,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
|
|
|
.link_libc = true,
|
2024-08-13 22:14:02 +00:00
|
|
|
.slow_backend = true,
|
2024-08-12 05:27:35 +00:00
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mipsel,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnueabi,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
.slow_backend = true,
|
|
|
|
},
|
2024-08-13 19:51:56 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mipsel,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnueabihf,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
2024-08-13 22:14:02 +00:00
|
|
|
.slow_backend = true,
|
2024-08-13 19:51:56 +00:00
|
|
|
},
|
2019-09-21 21:00:36 +00:00
|
|
|
|
2024-08-16 09:24:48 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips64,
|
|
|
|
.os_tag = .linux,
|
2024-10-16 04:30:16 +00:00
|
|
|
.abi = .muslabi64,
|
2024-08-16 09:24:48 +00:00
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnuabi64,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips64el,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips64el,
|
|
|
|
.os_tag = .linux,
|
2024-10-16 04:30:16 +00:00
|
|
|
.abi = .muslabi64,
|
2024-08-16 09:24:48 +00:00
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips64el,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnuabi64,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2021-04-20 20:08:19 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc,
|
|
|
|
.os_tag = .linux,
|
2024-08-28 19:31:40 +00:00
|
|
|
.abi = .eabi,
|
2021-04-20 20:08:19 +00:00
|
|
|
},
|
|
|
|
},
|
2024-08-28 19:31:40 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .eabihf,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabi,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2021-04-20 20:08:19 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc,
|
|
|
|
.os_tag = .linux,
|
2024-08-24 22:54:06 +00:00
|
|
|
.abi = .musleabihf,
|
2021-04-20 20:08:19 +00:00
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
2021-12-16 02:25:26 +00:00
|
|
|
// https://github.com/ziglang/zig/issues/2256
|
2022-04-22 03:28:36 +00:00
|
|
|
//.{
|
2021-12-16 02:25:26 +00:00
|
|
|
// .target = .{
|
|
|
|
// .cpu_arch = .powerpc,
|
|
|
|
// .os_tag = .linux,
|
|
|
|
// .abi = .gnueabihf,
|
|
|
|
// },
|
|
|
|
// .link_libc = true,
|
|
|
|
//},
|
2021-04-20 20:08:19 +00:00
|
|
|
|
2024-09-04 23:15:04 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
// Requires ELFv1 linker support.
|
|
|
|
// .{
|
|
|
|
// .target = .{
|
|
|
|
// .cpu_arch = .powerpc64,
|
|
|
|
// .os_tag = .linux,
|
|
|
|
// .abi = .gnu,
|
|
|
|
// },
|
|
|
|
// .link_libc = true,
|
|
|
|
// },
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-04-02 23:48:48 +00:00
|
|
|
.target = .{
|
2022-10-11 18:11:46 +00:00
|
|
|
.cpu_arch = .powerpc64le,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc64le,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc64le,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
2024-10-06 09:12:54 +00:00
|
|
|
.{
|
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "riscv32-linux-none",
|
|
|
|
.cpu_features = "baseline-d-f",
|
|
|
|
}) catch unreachable,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "riscv32-linux-musl",
|
|
|
|
.cpu_features = "baseline-d-f",
|
|
|
|
}) catch unreachable,
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
2024-09-20 11:02:55 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv32,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv32,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv32,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
2024-10-06 09:12:54 +00:00
|
|
|
.{
|
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "riscv64-linux-none",
|
|
|
|
.cpu_features = "baseline-d-f",
|
|
|
|
}) catch unreachable,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "riscv64-linux-musl",
|
|
|
|
.cpu_features = "baseline-d-f",
|
|
|
|
}) catch unreachable,
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
2024-08-30 17:47:02 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
2020-02-17 05:06:19 +00:00
|
|
|
|
2024-04-14 06:11:32 +00:00
|
|
|
.{
|
2024-08-30 17:47:02 +00:00
|
|
|
.target = std.Target.Query.parse(.{
|
|
|
|
.arch_os_abi = "riscv64-linux-musl",
|
|
|
|
.cpu_features = "baseline+v+zbb",
|
2024-10-06 09:12:54 +00:00
|
|
|
}) catch unreachable,
|
2024-04-14 06:11:32 +00:00
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
|
|
|
},
|
|
|
|
|
2024-10-01 11:12:11 +00:00
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .s390x,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .s390x,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .s390x,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
.link_libc = true,
|
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
2020-10-12 08:59:43 +00:00
|
|
|
.os_tag = .macos,
|
2022-05-15 15:56:51 +00:00
|
|
|
.abi = .none,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
2021-12-01 23:11:29 +00:00
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2021-12-01 23:11:29 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .aarch64,
|
|
|
|
.os_tag = .macos,
|
2022-05-15 15:56:51 +00:00
|
|
|
.abi = .none,
|
2021-12-01 23:11:29 +00:00
|
|
|
},
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
2022-10-07 17:54:44 +00:00
|
|
|
.cpu_arch = .x86,
|
2020-02-26 06:18:23 +00:00
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .msvc,
|
2019-10-11 17:13:59 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .msvc,
|
2019-09-22 03:55:56 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
2022-10-07 17:54:44 +00:00
|
|
|
.cpu_arch = .x86,
|
2020-02-26 06:18:23 +00:00
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .gnu,
|
2019-10-09 20:49:33 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-10-09 20:49:33 +00:00
|
|
|
},
|
|
|
|
|
2022-04-22 03:28:36 +00:00
|
|
|
.{
|
2020-02-26 06:18:23 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .gnu,
|
2019-09-22 23:11:41 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
.link_libc = true,
|
2019-09-22 23:11:41 +00:00
|
|
|
},
|
2020-01-22 22:13:31 +00:00
|
|
|
};
|
2017-08-30 18:55:26 +00:00
|
|
|
};
|
|
|
|
|
2023-10-26 09:30:41 +00:00
|
|
|
const CAbiTarget = struct {
|
2023-12-04 19:35:04 +00:00
|
|
|
target: std.Target.Query = .{},
|
2023-10-26 09:30:41 +00:00
|
|
|
use_llvm: ?bool = null,
|
|
|
|
use_lld: ?bool = null,
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
pic: ?bool = null,
|
2023-11-30 19:27:18 +00:00
|
|
|
strip: ?bool = null,
|
2023-10-26 09:30:41 +00:00
|
|
|
c_defines: []const []const u8 = &.{},
|
|
|
|
};
|
|
|
|
|
|
|
|
const c_abi_targets = [_]CAbiTarget{
|
2023-03-07 02:10:37 +00:00
|
|
|
.{},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
|
|
|
.c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v2 },
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
2023-11-30 19:27:18 +00:00
|
|
|
.strip = true,
|
2023-10-26 09:30:41 +00:00
|
|
|
.c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.cpu_model = .{ .explicit = &std.Target.x86.cpu.x86_64_v3 },
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
.use_llvm = false,
|
|
|
|
.use_lld = false,
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
.pic = true,
|
2023-10-26 09:30:41 +00:00
|
|
|
.c_defines = &.{"ZIG_BACKEND_STAGE2_X86_64"},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .aarch64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .arm,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musleabihf,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .mips,
|
|
|
|
.os_tag = .linux,
|
2024-08-24 22:53:24 +00:00
|
|
|
.abi = .musleabihf,
|
2023-10-26 09:30:41 +00:00
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .riscv64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .wasm32,
|
|
|
|
.os_tag = .wasi,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
.{
|
2023-10-26 09:30:41 +00:00
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc,
|
|
|
|
.os_tag = .linux,
|
2024-08-24 22:54:06 +00:00
|
|
|
.abi = .musleabihf,
|
2023-10-26 09:30:41 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .powerpc64le,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .musl,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86,
|
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.{
|
|
|
|
.target = .{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .windows,
|
|
|
|
.abi = .gnu,
|
|
|
|
},
|
2023-03-07 02:10:37 +00:00
|
|
|
},
|
|
|
|
};
|
2017-10-31 08:47:55 +00:00
|
|
|
|
2023-03-07 02:10:37 +00:00
|
|
|
pub fn addCompareOutputTests(
|
|
|
|
b: *std.Build,
|
2024-02-25 13:04:06 +00:00
|
|
|
test_filters: []const []const u8,
|
2023-03-07 02:10:37 +00:00
|
|
|
optimize_modes: []const OptimizeMode,
|
|
|
|
) *Step {
|
|
|
|
const cases = b.allocator.create(CompareOutputContext) catch @panic("OOM");
|
2019-02-03 21:13:28 +00:00
|
|
|
cases.* = CompareOutputContext{
|
2017-04-19 18:00:12 +00:00
|
|
|
.b = b,
|
|
|
|
.step = b.step("test-compare-output", "Run the compare output tests"),
|
|
|
|
.test_index = 0,
|
2024-02-25 13:04:06 +00:00
|
|
|
.test_filters = test_filters,
|
2023-01-31 04:39:43 +00:00
|
|
|
.optimize_modes = optimize_modes,
|
2019-02-03 21:13:28 +00:00
|
|
|
};
|
2017-04-19 18:00:12 +00:00
|
|
|
|
|
|
|
compare_output.addCases(cases);
|
|
|
|
|
|
|
|
return cases.step;
|
|
|
|
}
|
|
|
|
|
2023-03-07 02:10:37 +00:00
|
|
|
pub fn addStackTraceTests(
|
|
|
|
b: *std.Build,
|
2024-02-25 13:04:06 +00:00
|
|
|
test_filters: []const []const u8,
|
2023-03-07 02:10:37 +00:00
|
|
|
optimize_modes: []const OptimizeMode,
|
|
|
|
) *Step {
|
|
|
|
const check_exe = b.addExecutable(.{
|
|
|
|
.name = "check-stack-trace",
|
2024-04-11 21:02:47 +00:00
|
|
|
.root_source_file = b.path("test/src/check-stack-trace.zig"),
|
2024-06-13 12:00:22 +00:00
|
|
|
.target = b.graph.host,
|
2023-03-07 02:10:37 +00:00
|
|
|
.optimize = .Debug,
|
|
|
|
});
|
|
|
|
|
|
|
|
const cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
|
|
|
|
cases.* = .{
|
2019-05-28 00:07:05 +00:00
|
|
|
.b = b,
|
2019-09-03 14:08:39 +00:00
|
|
|
.step = b.step("test-stack-traces", "Run the stack trace tests"),
|
2019-05-28 00:07:05 +00:00
|
|
|
.test_index = 0,
|
2024-02-25 13:04:06 +00:00
|
|
|
.test_filters = test_filters,
|
2023-01-31 04:39:43 +00:00
|
|
|
.optimize_modes = optimize_modes,
|
2023-03-07 02:10:37 +00:00
|
|
|
.check_exe = check_exe,
|
2019-05-28 00:07:05 +00:00
|
|
|
};
|
|
|
|
|
2019-09-03 14:08:39 +00:00
|
|
|
stack_traces.addCases(cases);
|
2019-05-28 00:07:05 +00:00
|
|
|
|
|
|
|
return cases.step;
|
|
|
|
}
|
|
|
|
|
2024-02-17 16:47:13 +00:00
|
|
|
fn compilerHasPackageManager(b: *std.Build) bool {
|
|
|
|
// We can only use dependencies if the compiler was built with support for package management.
|
|
|
|
// (zig2 doesn't support it, but we still need to construct a build graph to build stage3.)
|
|
|
|
return b.available_deps.len != 0;
|
|
|
|
}
|
|
|
|
|
2021-08-02 08:04:54 +00:00
|
|
|
pub fn addStandaloneTests(
|
2023-01-31 07:19:51 +00:00
|
|
|
b: *std.Build,
|
2023-01-31 04:39:43 +00:00
|
|
|
optimize_modes: []const OptimizeMode,
|
2021-08-02 08:04:54 +00:00
|
|
|
enable_macos_sdk: bool,
|
2023-08-18 09:57:12 +00:00
|
|
|
enable_ios_sdk: bool,
|
2022-11-26 19:23:32 +00:00
|
|
|
enable_symlinks_windows: bool,
|
2023-01-31 07:19:51 +00:00
|
|
|
) *Step {
|
2023-03-08 05:40:53 +00:00
|
|
|
const step = b.step("test-standalone", "Run the standalone tests");
|
2024-02-17 16:47:13 +00:00
|
|
|
if (compilerHasPackageManager(b)) {
|
2024-01-16 20:29:54 +00:00
|
|
|
const test_cases_dep_name = "standalone_test_cases";
|
|
|
|
const test_cases_dep = b.dependency(test_cases_dep_name, .{
|
2024-02-17 16:23:08 +00:00
|
|
|
.enable_ios_sdk = enable_ios_sdk,
|
|
|
|
.enable_macos_sdk = enable_macos_sdk,
|
|
|
|
.enable_symlinks_windows = enable_symlinks_windows,
|
|
|
|
.simple_skip_debug = mem.indexOfScalar(OptimizeMode, optimize_modes, .Debug) == null,
|
|
|
|
.simple_skip_release_safe = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSafe) == null,
|
|
|
|
.simple_skip_release_fast = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseFast) == null,
|
|
|
|
.simple_skip_release_small = mem.indexOfScalar(OptimizeMode, optimize_modes, .ReleaseSmall) == null,
|
2024-01-16 20:29:54 +00:00
|
|
|
});
|
|
|
|
const test_cases_dep_step = test_cases_dep.builder.default_step;
|
|
|
|
test_cases_dep_step.name = b.dupe(test_cases_dep_name);
|
|
|
|
step.dependOn(test_cases_dep.builder.default_step);
|
|
|
|
}
|
2023-03-08 05:40:53 +00:00
|
|
|
return step;
|
2017-04-19 18:00:12 +00:00
|
|
|
}
|
|
|
|
|
2022-05-28 09:44:53 +00:00
|
|
|
pub fn addLinkTests(
|
2023-01-31 07:19:51 +00:00
|
|
|
b: *std.Build,
|
2022-05-28 09:44:53 +00:00
|
|
|
enable_macos_sdk: bool,
|
2023-08-18 09:57:12 +00:00
|
|
|
enable_ios_sdk: bool,
|
2022-11-26 19:23:32 +00:00
|
|
|
enable_symlinks_windows: bool,
|
2023-01-31 07:19:51 +00:00
|
|
|
) *Step {
|
2023-03-07 07:40:55 +00:00
|
|
|
const step = b.step("test-link", "Run the linker tests");
|
2024-02-17 16:47:13 +00:00
|
|
|
if (compilerHasPackageManager(b)) {
|
|
|
|
const test_cases_dep_name = "link_test_cases";
|
|
|
|
const test_cases_dep = b.dependency(test_cases_dep_name, .{
|
|
|
|
.enable_ios_sdk = enable_ios_sdk,
|
|
|
|
.enable_macos_sdk = enable_macos_sdk,
|
|
|
|
.enable_symlinks_windows = enable_symlinks_windows,
|
|
|
|
});
|
|
|
|
const test_cases_dep_step = test_cases_dep.builder.default_step;
|
|
|
|
test_cases_dep_step.name = b.dupe(test_cases_dep_name);
|
|
|
|
step.dependOn(test_cases_dep.builder.default_step);
|
2023-03-07 07:40:55 +00:00
|
|
|
}
|
|
|
|
return step;
|
2022-05-28 09:44:53 +00:00
|
|
|
}
|
|
|
|
|
2023-03-08 07:16:16 +00:00
|
|
|
pub fn addCliTests(b: *std.Build) *Step {
|
2018-09-17 21:08:56 +00:00
|
|
|
const step = b.step("test-cli", "Test the command line interface");
|
2023-03-14 21:44:38 +00:00
|
|
|
const s = std.fs.path.sep_str;
|
2018-09-17 21:08:56 +00:00
|
|
|
|
2023-03-07 05:44:36 +00:00
|
|
|
{
|
2023-11-21 06:01:45 +00:00
|
|
|
// Test `zig init`.
|
2023-03-07 05:44:36 +00:00
|
|
|
const tmp_path = b.makeTempPath();
|
2024-02-01 22:44:44 +00:00
|
|
|
const init_exe = b.addSystemCommand(&.{ b.graph.zig_exe, "init" });
|
2023-10-10 22:39:44 +00:00
|
|
|
init_exe.setCwd(.{ .cwd_relative = tmp_path });
|
2023-11-21 06:01:45 +00:00
|
|
|
init_exe.setName("zig init");
|
2023-03-07 05:44:36 +00:00
|
|
|
init_exe.expectStdOutEqual("");
|
2023-11-21 06:01:45 +00:00
|
|
|
init_exe.expectStdErrEqual("info: created build.zig\n" ++
|
2023-11-21 06:30:51 +00:00
|
|
|
"info: created build.zig.zon\n" ++
|
2023-11-21 06:01:45 +00:00
|
|
|
"info: created src" ++ s ++ "main.zig\n" ++
|
|
|
|
"info: created src" ++ s ++ "root.zig\n" ++
|
|
|
|
"info: see `zig build --help` for a menu of options\n");
|
2023-03-07 05:44:36 +00:00
|
|
|
|
|
|
|
// Test missing output path.
|
|
|
|
const bad_out_arg = "-femit-bin=does" ++ s ++ "not" ++ s ++ "exist" ++ s ++ "foo.exe";
|
|
|
|
const ok_src_arg = "src" ++ s ++ "main.zig";
|
|
|
|
const expected = "error: unable to open output directory 'does" ++ s ++ "not" ++ s ++ "exist': FileNotFound\n";
|
2024-02-01 22:44:44 +00:00
|
|
|
const run_bad = b.addSystemCommand(&.{ b.graph.zig_exe, "build-exe", ok_src_arg, bad_out_arg });
|
2023-03-07 05:44:36 +00:00
|
|
|
run_bad.setName("zig build-exe error message for bad -femit-bin arg");
|
|
|
|
run_bad.expectExitCode(1);
|
|
|
|
run_bad.expectStdErrEqual(expected);
|
|
|
|
run_bad.expectStdOutEqual("");
|
|
|
|
run_bad.step.dependOn(&init_exe.step);
|
|
|
|
|
2024-02-01 22:44:44 +00:00
|
|
|
const run_test = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "test" });
|
2023-10-10 22:39:44 +00:00
|
|
|
run_test.setCwd(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
run_test.setName("zig build test");
|
|
|
|
run_test.expectStdOutEqual("");
|
|
|
|
run_test.step.dependOn(&init_exe.step);
|
|
|
|
|
2024-02-01 22:44:44 +00:00
|
|
|
const run_run = b.addSystemCommand(&.{ b.graph.zig_exe, "build", "run" });
|
2023-10-10 22:39:44 +00:00
|
|
|
run_run.setCwd(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
run_run.setName("zig build run");
|
|
|
|
run_run.expectStdOutEqual("Run `zig build test` to run the tests.\n");
|
|
|
|
run_run.expectStdErrEqual("All your codebase are belong to us.\n");
|
|
|
|
run_run.step.dependOn(&init_exe.step);
|
|
|
|
|
2024-07-10 04:08:20 +00:00
|
|
|
const cleanup = b.addRemoveDirTree(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
cleanup.step.dependOn(&run_test.step);
|
|
|
|
cleanup.step.dependOn(&run_run.step);
|
|
|
|
cleanup.step.dependOn(&run_bad.step);
|
|
|
|
|
|
|
|
step.dependOn(&cleanup.step);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test Godbolt API
|
|
|
|
if (builtin.os.tag == .linux and builtin.cpu.arch == .x86_64) {
|
|
|
|
const tmp_path = b.makeTempPath();
|
|
|
|
|
2024-07-02 12:15:29 +00:00
|
|
|
const example_zig = b.addWriteFiles().add("example.zig",
|
2023-03-07 05:44:36 +00:00
|
|
|
\\// Type your code here, or load an example.
|
|
|
|
\\export fn square(num: i32) i32 {
|
|
|
|
\\ return num * num;
|
|
|
|
\\}
|
|
|
|
\\extern fn zig_panic() noreturn;
|
|
|
|
\\pub fn panic(msg: []const u8, error_return_trace: ?*@import("std").builtin.StackTrace, _: ?usize) noreturn {
|
|
|
|
\\ _ = msg;
|
|
|
|
\\ _ = error_return_trace;
|
|
|
|
\\ zig_panic();
|
|
|
|
\\}
|
|
|
|
);
|
|
|
|
|
|
|
|
// This is intended to be the exact CLI usage used by godbolt.org.
|
|
|
|
const run = b.addSystemCommand(&.{
|
2024-02-01 22:44:44 +00:00
|
|
|
b.graph.zig_exe, "build-obj",
|
2023-03-07 05:44:36 +00:00
|
|
|
"--cache-dir", tmp_path,
|
|
|
|
"--name", "example",
|
|
|
|
"-fno-emit-bin", "-fno-emit-h",
|
|
|
|
"-fstrip", "-OReleaseFast",
|
|
|
|
});
|
2024-07-02 12:15:29 +00:00
|
|
|
run.addFileArg(example_zig);
|
2023-03-07 05:44:36 +00:00
|
|
|
const example_s = run.addPrefixedOutputFileArg("-femit-asm=", "example.s");
|
|
|
|
|
|
|
|
const checkfile = b.addCheckFile(example_s, .{
|
|
|
|
.expected_matches = &.{
|
|
|
|
"square:",
|
|
|
|
"mov\teax, edi",
|
|
|
|
"imul\teax, edi",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
checkfile.setName("check godbolt.org CLI usage generating valid asm");
|
|
|
|
|
2024-07-10 04:08:20 +00:00
|
|
|
const cleanup = b.addRemoveDirTree(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
cleanup.step.dependOn(&checkfile.step);
|
|
|
|
|
|
|
|
step.dependOn(&cleanup.step);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
// Test `zig fmt`.
|
|
|
|
// This test must use a temporary directory rather than a cache
|
|
|
|
// directory because this test will be mutating the files. The cache
|
|
|
|
// system relies on cache directories being mutated only by their
|
|
|
|
// owners.
|
|
|
|
const tmp_path = b.makeTempPath();
|
|
|
|
const unformatted_code = " // no reason for indent";
|
|
|
|
|
2023-03-07 07:40:55 +00:00
|
|
|
var dir = std.fs.cwd().openDir(tmp_path, .{}) catch @panic("unhandled");
|
2023-03-07 05:44:36 +00:00
|
|
|
defer dir.close();
|
2024-05-03 03:54:48 +00:00
|
|
|
dir.writeFile(.{ .sub_path = "fmt1.zig", .data = unformatted_code }) catch @panic("unhandled");
|
|
|
|
dir.writeFile(.{ .sub_path = "fmt2.zig", .data = unformatted_code }) catch @panic("unhandled");
|
2023-06-25 02:50:28 +00:00
|
|
|
dir.makeDir("subdir") catch @panic("unhandled");
|
|
|
|
var subdir = dir.openDir("subdir", .{}) catch @panic("unhandled");
|
|
|
|
defer subdir.close();
|
2024-05-03 03:54:48 +00:00
|
|
|
subdir.writeFile(.{ .sub_path = "fmt3.zig", .data = unformatted_code }) catch @panic("unhandled");
|
2023-03-07 05:44:36 +00:00
|
|
|
|
|
|
|
// Test zig fmt affecting only the appropriate files.
|
2024-02-01 22:44:44 +00:00
|
|
|
const run1 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "fmt1.zig" });
|
2023-03-07 05:44:36 +00:00
|
|
|
run1.setName("run zig fmt one file");
|
2023-10-10 22:39:44 +00:00
|
|
|
run1.setCwd(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
run1.has_side_effects = true;
|
|
|
|
// stdout should be file path + \n
|
|
|
|
run1.expectStdOutEqual("fmt1.zig\n");
|
|
|
|
|
2023-06-25 02:50:28 +00:00
|
|
|
// Test excluding files and directories from a run
|
2024-02-01 22:44:44 +00:00
|
|
|
const run2 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "--exclude", "fmt2.zig", "--exclude", "subdir", "." });
|
2023-06-25 02:50:28 +00:00
|
|
|
run2.setName("run zig fmt on directory with exclusions");
|
2023-10-10 22:39:44 +00:00
|
|
|
run2.setCwd(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
run2.has_side_effects = true;
|
2023-06-25 02:50:28 +00:00
|
|
|
run2.expectStdOutEqual("");
|
2023-03-07 05:44:36 +00:00
|
|
|
run2.step.dependOn(&run1.step);
|
|
|
|
|
2023-06-25 02:50:28 +00:00
|
|
|
// Test excluding non-existent file
|
2024-02-01 22:44:44 +00:00
|
|
|
const run3 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "--exclude", "fmt2.zig", "--exclude", "nonexistent.zig", "." });
|
2023-06-25 02:50:28 +00:00
|
|
|
run3.setName("run zig fmt on directory with non-existent exclusion");
|
2023-10-10 22:39:44 +00:00
|
|
|
run3.setCwd(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
run3.has_side_effects = true;
|
2023-06-25 02:50:28 +00:00
|
|
|
run3.expectStdOutEqual("." ++ s ++ "subdir" ++ s ++ "fmt3.zig\n");
|
2023-03-07 05:44:36 +00:00
|
|
|
run3.step.dependOn(&run2.step);
|
|
|
|
|
2023-06-25 02:50:28 +00:00
|
|
|
// running it on the dir, only the new file should be changed
|
2024-02-01 22:44:44 +00:00
|
|
|
const run4 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "." });
|
2023-06-25 02:50:28 +00:00
|
|
|
run4.setName("run zig fmt the directory");
|
2023-10-10 22:39:44 +00:00
|
|
|
run4.setCwd(.{ .cwd_relative = tmp_path });
|
2023-03-07 05:44:36 +00:00
|
|
|
run4.has_side_effects = true;
|
2023-06-25 02:50:28 +00:00
|
|
|
run4.expectStdOutEqual("." ++ s ++ "fmt2.zig\n");
|
|
|
|
run4.step.dependOn(&run3.step);
|
|
|
|
|
|
|
|
// both files have been formatted, nothing should change now
|
2024-02-01 22:44:44 +00:00
|
|
|
const run5 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "." });
|
2023-06-25 02:50:28 +00:00
|
|
|
run5.setName("run zig fmt with nothing to do");
|
2023-10-10 22:39:44 +00:00
|
|
|
run5.setCwd(.{ .cwd_relative = tmp_path });
|
2023-06-25 02:50:28 +00:00
|
|
|
run5.has_side_effects = true;
|
|
|
|
run5.expectStdOutEqual("");
|
|
|
|
run5.step.dependOn(&run4.step);
|
|
|
|
|
|
|
|
const unformatted_code_utf16 = "\xff\xfe \x00 \x00 \x00 \x00/\x00/\x00 \x00n\x00o\x00 \x00r\x00e\x00a\x00s\x00o\x00n\x00";
|
|
|
|
const fmt6_path = std.fs.path.join(b.allocator, &.{ tmp_path, "fmt6.zig" }) catch @panic("OOM");
|
2024-07-10 04:47:26 +00:00
|
|
|
const write6 = b.addUpdateSourceFiles();
|
2023-06-25 02:50:28 +00:00
|
|
|
write6.addBytesToSource(unformatted_code_utf16, fmt6_path);
|
|
|
|
write6.step.dependOn(&run5.step);
|
|
|
|
|
|
|
|
// Test `zig fmt` handling UTF-16 decoding.
|
2024-02-01 22:44:44 +00:00
|
|
|
const run6 = b.addSystemCommand(&.{ b.graph.zig_exe, "fmt", "." });
|
2023-06-25 02:50:28 +00:00
|
|
|
run6.setName("run zig fmt convert UTF-16 to UTF-8");
|
2023-10-10 22:39:44 +00:00
|
|
|
run6.setCwd(.{ .cwd_relative = tmp_path });
|
2023-06-25 02:50:28 +00:00
|
|
|
run6.has_side_effects = true;
|
|
|
|
run6.expectStdOutEqual("." ++ s ++ "fmt6.zig\n");
|
|
|
|
run6.step.dependOn(&write6.step);
|
2023-03-07 05:44:36 +00:00
|
|
|
|
|
|
|
// TODO change this to an exact match
|
2024-04-11 21:02:47 +00:00
|
|
|
const check6 = b.addCheckFile(.{ .cwd_relative = fmt6_path }, .{
|
2023-03-07 05:44:36 +00:00
|
|
|
.expected_matches = &.{
|
|
|
|
"// no reason",
|
|
|
|
},
|
|
|
|
});
|
2023-06-25 02:50:28 +00:00
|
|
|
check6.step.dependOn(&run6.step);
|
2023-03-07 05:44:36 +00:00
|
|
|
|
2024-07-10 04:08:20 +00:00
|
|
|
const cleanup = b.addRemoveDirTree(.{ .cwd_relative = tmp_path });
|
2023-06-25 02:50:28 +00:00
|
|
|
cleanup.step.dependOn(&check6.step);
|
2023-03-07 05:44:36 +00:00
|
|
|
|
|
|
|
step.dependOn(&cleanup.step);
|
|
|
|
}
|
2018-09-17 21:08:56 +00:00
|
|
|
|
2023-03-08 07:16:16 +00:00
|
|
|
{
|
|
|
|
// TODO this should move to become a CLI test rather than standalone
|
|
|
|
// cases.addBuildFile("test/standalone/options/build.zig", .{
|
|
|
|
// .extra_argv = &.{
|
|
|
|
// "-Dbool_true",
|
|
|
|
// "-Dbool_false=false",
|
|
|
|
// "-Dint=1234",
|
|
|
|
// "-De=two",
|
|
|
|
// "-Dstring=hello",
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
}
|
|
|
|
|
2018-09-17 21:08:56 +00:00
|
|
|
return step;
|
|
|
|
}
|
|
|
|
|
2024-02-25 13:04:06 +00:00
|
|
|
pub fn addAssembleAndLinkTests(b: *std.Build, test_filters: []const []const u8, optimize_modes: []const OptimizeMode) *Step {
|
2023-03-07 02:10:37 +00:00
|
|
|
const cases = b.allocator.create(CompareOutputContext) catch @panic("OOM");
|
2019-02-03 21:13:28 +00:00
|
|
|
cases.* = CompareOutputContext{
|
2017-04-19 18:00:12 +00:00
|
|
|
.b = b,
|
|
|
|
.step = b.step("test-asm-link", "Run the assemble and link tests"),
|
|
|
|
.test_index = 0,
|
2024-02-25 13:04:06 +00:00
|
|
|
.test_filters = test_filters,
|
2023-01-31 04:39:43 +00:00
|
|
|
.optimize_modes = optimize_modes,
|
2019-02-03 21:13:28 +00:00
|
|
|
};
|
2017-04-19 18:00:12 +00:00
|
|
|
|
|
|
|
assemble_and_link.addCases(cases);
|
|
|
|
|
|
|
|
return cases.step;
|
|
|
|
}
|
|
|
|
|
2024-03-05 01:26:41 +00:00
|
|
|
pub fn addTranslateCTests(b: *std.Build, parent_step: *std.Build.Step, test_filters: []const []const u8) void {
|
2023-03-07 02:10:37 +00:00
|
|
|
const cases = b.allocator.create(TranslateCContext) catch @panic("OOM");
|
2019-02-03 21:13:28 +00:00
|
|
|
cases.* = TranslateCContext{
|
2017-04-19 20:59:20 +00:00
|
|
|
.b = b,
|
2024-03-05 01:26:41 +00:00
|
|
|
.step = parent_step,
|
2017-04-19 20:59:20 +00:00
|
|
|
.test_index = 0,
|
2024-02-25 13:04:06 +00:00
|
|
|
.test_filters = test_filters,
|
2019-02-03 21:13:28 +00:00
|
|
|
};
|
2017-04-19 20:59:20 +00:00
|
|
|
|
2017-11-24 19:56:05 +00:00
|
|
|
translate_c.addCases(cases);
|
2017-04-19 20:59:20 +00:00
|
|
|
|
2024-03-05 01:26:41 +00:00
|
|
|
return;
|
2017-04-19 20:59:20 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 20:46:05 +00:00
|
|
|
pub fn addRunTranslatedCTests(
|
2023-01-31 07:19:51 +00:00
|
|
|
b: *std.Build,
|
2024-03-05 01:26:41 +00:00
|
|
|
parent_step: *std.Build.Step,
|
2024-02-25 13:04:06 +00:00
|
|
|
test_filters: []const []const u8,
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
target: std.Build.ResolvedTarget,
|
2024-03-05 01:26:41 +00:00
|
|
|
) void {
|
2023-03-07 02:10:37 +00:00
|
|
|
const cases = b.allocator.create(RunTranslatedCContext) catch @panic("OOM");
|
2020-01-03 03:45:48 +00:00
|
|
|
cases.* = .{
|
|
|
|
.b = b,
|
2024-03-05 01:26:41 +00:00
|
|
|
.step = parent_step,
|
2020-01-03 03:45:48 +00:00
|
|
|
.test_index = 0,
|
2024-02-25 13:04:06 +00:00
|
|
|
.test_filters = test_filters,
|
2020-12-08 20:46:05 +00:00
|
|
|
.target = target,
|
2020-01-03 03:45:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
run_translated_c.addCases(cases);
|
|
|
|
|
2024-03-05 01:26:41 +00:00
|
|
|
return;
|
2020-01-03 03:45:48 +00:00
|
|
|
}
|
|
|
|
|
2023-03-06 07:27:46 +00:00
|
|
|
const ModuleTestOptions = struct {
|
2024-02-25 13:04:06 +00:00
|
|
|
test_filters: []const []const u8,
|
2024-08-13 21:59:50 +00:00
|
|
|
test_target_filters: []const []const u8,
|
2024-08-13 22:14:02 +00:00
|
|
|
test_slow_targets: bool,
|
2019-05-15 01:21:59 +00:00
|
|
|
root_src: []const u8,
|
|
|
|
name: []const u8,
|
|
|
|
desc: []const u8,
|
2023-01-31 04:39:43 +00:00
|
|
|
optimize_modes: []const OptimizeMode,
|
2024-02-20 09:15:10 +00:00
|
|
|
include_paths: []const []const u8,
|
2019-09-22 03:55:56 +00:00
|
|
|
skip_single_threaded: bool,
|
2019-05-15 01:21:59 +00:00
|
|
|
skip_non_native: bool,
|
2019-09-22 03:55:56 +00:00
|
|
|
skip_libc: bool,
|
2023-03-06 07:27:46 +00:00
|
|
|
max_rss: usize = 0,
|
2024-06-02 07:10:35 +00:00
|
|
|
no_builtin: bool = false,
|
2023-03-06 07:27:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
|
|
|
|
const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
|
2019-09-09 21:57:32 +00:00
|
|
|
|
2024-10-05 00:25:13 +00:00
|
|
|
for_targets: for (test_targets) |test_target| {
|
|
|
|
if (test_target.skip_modules.len > 0) {
|
|
|
|
for (test_target.skip_modules) |skip_mod| {
|
|
|
|
if (std.mem.eql(u8, options.name, skip_mod)) continue :for_targets;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-13 22:14:02 +00:00
|
|
|
if (!options.test_slow_targets and test_target.slow_backend) continue;
|
|
|
|
|
2024-07-30 06:06:39 +00:00
|
|
|
if (options.skip_non_native and !test_target.target.isNative())
|
2019-09-22 03:55:56 +00:00
|
|
|
continue;
|
2019-09-09 21:57:32 +00:00
|
|
|
|
2023-12-05 03:30:32 +00:00
|
|
|
const resolved_target = b.resolveTargetQuery(test_target.target);
|
2023-12-05 23:09:07 +00:00
|
|
|
const target = resolved_target.result;
|
2024-08-13 21:59:50 +00:00
|
|
|
const triple_txt = target.zigTriple(b.allocator) catch @panic("OOM");
|
|
|
|
|
|
|
|
if (options.test_target_filters.len > 0) {
|
|
|
|
for (options.test_target_filters) |filter| {
|
|
|
|
if (std.mem.indexOf(u8, triple_txt, filter) != null) break;
|
|
|
|
} else continue;
|
|
|
|
}
|
2023-12-05 03:30:32 +00:00
|
|
|
|
2023-04-13 23:44:45 +00:00
|
|
|
if (options.skip_libc and test_target.link_libc == true)
|
2019-09-22 03:55:56 +00:00
|
|
|
continue;
|
|
|
|
|
2023-04-13 23:44:45 +00:00
|
|
|
if (options.skip_single_threaded and test_target.single_threaded == true)
|
2019-05-15 01:21:59 +00:00
|
|
|
continue;
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2023-04-13 23:44:45 +00:00
|
|
|
// TODO get compiler-rt tests passing for self-hosted backends.
|
2023-12-05 03:30:32 +00:00
|
|
|
if ((target.cpu.arch != .x86_64 or target.ofmt != .elf) and
|
2023-10-22 19:46:33 +00:00
|
|
|
test_target.use_llvm == false and mem.eql(u8, options.name, "compiler-rt"))
|
2019-09-22 03:55:56 +00:00
|
|
|
continue;
|
|
|
|
|
2023-04-14 20:06:22 +00:00
|
|
|
// TODO get compiler-rt tests passing for wasm32-wasi
|
|
|
|
// currently causes "LLVM ERROR: Unable to expand fixed point multiplication."
|
2023-12-05 03:30:32 +00:00
|
|
|
if (target.cpu.arch == .wasm32 and target.os.tag == .wasi and
|
2023-04-14 20:06:22 +00:00
|
|
|
mem.eql(u8, options.name, "compiler-rt"))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-10-18 02:15:46 +00:00
|
|
|
// TODO get universal-libc tests passing for other self-hosted backends.
|
2023-12-05 03:30:32 +00:00
|
|
|
if (target.cpu.arch != .x86_64 and
|
2023-10-18 02:15:46 +00:00
|
|
|
test_target.use_llvm == false and mem.eql(u8, options.name, "universal-libc"))
|
2019-09-22 18:40:54 +00:00
|
|
|
continue;
|
|
|
|
|
2023-10-22 19:46:33 +00:00
|
|
|
// TODO get std lib tests passing for other self-hosted backends.
|
2023-12-05 03:30:32 +00:00
|
|
|
if ((target.cpu.arch != .x86_64 or target.os.tag != .linux) and
|
2023-10-22 19:46:33 +00:00
|
|
|
test_target.use_llvm == false and mem.eql(u8, options.name, "std"))
|
2023-04-13 23:44:45 +00:00
|
|
|
continue;
|
2022-04-22 03:28:36 +00:00
|
|
|
|
2024-04-14 06:11:32 +00:00
|
|
|
if (target.cpu.arch != .x86_64 and
|
|
|
|
test_target.use_llvm == false and mem.eql(u8, options.name, "c-import"))
|
|
|
|
continue;
|
|
|
|
|
2023-03-06 07:27:46 +00:00
|
|
|
const want_this_mode = for (options.optimize_modes) |m| {
|
2023-01-31 04:39:43 +00:00
|
|
|
if (m == test_target.optimize_mode) break true;
|
2019-09-22 03:55:56 +00:00
|
|
|
} else false;
|
|
|
|
if (!want_this_mode) continue;
|
|
|
|
|
2023-04-13 23:44:45 +00:00
|
|
|
const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
|
2023-12-05 03:30:32 +00:00
|
|
|
const model_txt = target.cpu.model.name;
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2023-03-06 07:27:46 +00:00
|
|
|
// wasm32-wasi builds need more RAM, idk why
|
2023-12-05 03:30:32 +00:00
|
|
|
const max_rss = if (target.os.tag == .wasi)
|
2023-03-06 07:27:46 +00:00
|
|
|
options.max_rss * 2
|
|
|
|
else
|
|
|
|
options.max_rss;
|
|
|
|
|
2023-01-31 04:39:43 +00:00
|
|
|
const these_tests = b.addTest(.{
|
2024-04-11 21:02:47 +00:00
|
|
|
.root_source_file = b.path(options.root_src),
|
2023-01-31 04:39:43 +00:00
|
|
|
.optimize = test_target.optimize_mode,
|
2023-12-05 03:30:32 +00:00
|
|
|
.target = resolved_target,
|
2023-03-06 07:27:46 +00:00
|
|
|
.max_rss = max_rss,
|
2024-02-25 13:04:06 +00:00
|
|
|
.filters = options.test_filters,
|
2023-04-13 23:44:45 +00:00
|
|
|
.link_libc = test_target.link_libc,
|
|
|
|
.single_threaded = test_target.single_threaded,
|
|
|
|
.use_llvm = test_target.use_llvm,
|
|
|
|
.use_lld = test_target.use_lld,
|
2024-04-11 21:02:47 +00:00
|
|
|
.zig_lib_dir = b.path("lib"),
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
.pic = test_target.pic,
|
|
|
|
.strip = test_target.strip,
|
2023-01-31 04:39:43 +00:00
|
|
|
});
|
2024-06-02 07:10:35 +00:00
|
|
|
if (options.no_builtin) these_tests.no_builtin = true;
|
2023-04-13 23:44:45 +00:00
|
|
|
const single_threaded_suffix = if (test_target.single_threaded == true) "-single" else "";
|
|
|
|
const backend_suffix = if (test_target.use_llvm == true)
|
|
|
|
"-llvm"
|
2023-12-05 03:30:32 +00:00
|
|
|
else if (target.ofmt == std.Target.ObjectFormat.c)
|
2023-04-13 23:44:45 +00:00
|
|
|
"-cbe"
|
|
|
|
else if (test_target.use_llvm == false)
|
|
|
|
"-selfhosted"
|
|
|
|
else
|
|
|
|
"";
|
2023-09-28 17:28:06 +00:00
|
|
|
const use_lld = if (test_target.use_lld == false) "-no-lld" else "";
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
const use_pic = if (test_target.pic == true) "-pic" else "";
|
2023-04-13 23:44:45 +00:00
|
|
|
|
2024-04-11 21:02:47 +00:00
|
|
|
for (options.include_paths) |include_path| these_tests.addIncludePath(b.path(include_path));
|
2019-09-22 03:55:56 +00:00
|
|
|
|
2023-10-28 19:10:56 +00:00
|
|
|
const qualified_name = b.fmt("{s}-{s}-{s}-{s}{s}{s}{s}{s}{s}", .{
|
2023-03-12 07:39:21 +00:00
|
|
|
options.name,
|
2023-04-13 23:44:45 +00:00
|
|
|
triple_txt,
|
2023-10-26 09:30:41 +00:00
|
|
|
model_txt,
|
2023-03-12 07:39:21 +00:00
|
|
|
@tagName(test_target.optimize_mode),
|
2023-04-13 23:44:45 +00:00
|
|
|
libc_suffix,
|
|
|
|
single_threaded_suffix,
|
|
|
|
backend_suffix,
|
2023-09-28 17:28:06 +00:00
|
|
|
use_lld,
|
2023-10-28 19:10:56 +00:00
|
|
|
use_pic,
|
2023-04-14 00:22:53 +00:00
|
|
|
});
|
|
|
|
|
2023-12-05 03:30:32 +00:00
|
|
|
if (target.ofmt == std.Target.ObjectFormat.c) {
|
|
|
|
var altered_query = test_target.target;
|
|
|
|
altered_query.ofmt = null;
|
2023-04-14 00:22:53 +00:00
|
|
|
|
|
|
|
const compile_c = b.addExecutable(.{
|
|
|
|
.name = qualified_name,
|
|
|
|
.link_libc = test_target.link_libc,
|
2023-12-05 03:30:32 +00:00
|
|
|
.target = b.resolveTargetQuery(altered_query),
|
2024-04-11 21:02:47 +00:00
|
|
|
.zig_lib_dir = b.path("lib"),
|
2023-04-14 00:22:53 +00:00
|
|
|
});
|
2023-07-19 08:49:34 +00:00
|
|
|
compile_c.addCSourceFile(.{
|
|
|
|
.file = these_tests.getEmittedBin(),
|
|
|
|
.flags = &.{
|
2024-03-29 00:41:58 +00:00
|
|
|
// Tracking issue for making the C backend generate C89 compatible code:
|
|
|
|
// https://github.com/ziglang/zig/issues/19468
|
2023-04-14 00:22:53 +00:00
|
|
|
"-std=c99",
|
|
|
|
"-Werror",
|
2024-03-29 00:41:58 +00:00
|
|
|
|
2024-04-12 03:40:15 +00:00
|
|
|
"-Wall",
|
|
|
|
"-Wembedded-directive",
|
|
|
|
"-Wempty-translation-unit",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wgnu",
|
|
|
|
"-Winvalid-utf8",
|
|
|
|
"-Wkeyword-macro",
|
|
|
|
"-Woverlength-strings",
|
|
|
|
|
2024-03-29 00:41:58 +00:00
|
|
|
// Tracking issue for making the C backend generate code
|
|
|
|
// that does not trigger warnings:
|
|
|
|
// https://github.com/ziglang/zig/issues/19467
|
|
|
|
|
|
|
|
// spotted everywhere
|
2023-04-20 14:30:27 +00:00
|
|
|
"-Wno-builtin-requires-header",
|
2024-03-29 00:41:58 +00:00
|
|
|
|
|
|
|
// spotted on linux
|
2024-04-12 03:40:15 +00:00
|
|
|
"-Wno-braced-scalar-init",
|
|
|
|
"-Wno-excess-initializers",
|
|
|
|
"-Wno-incompatible-pointer-types-discards-qualifiers",
|
|
|
|
"-Wno-unused",
|
|
|
|
"-Wno-unused-parameter",
|
2024-03-29 00:41:58 +00:00
|
|
|
|
|
|
|
// spotted on darwin
|
2024-04-12 03:40:15 +00:00
|
|
|
"-Wno-incompatible-pointer-types",
|
2023-04-14 00:22:53 +00:00
|
|
|
},
|
|
|
|
});
|
2024-04-11 21:02:47 +00:00
|
|
|
compile_c.addIncludePath(b.path("lib")); // for zig.h
|
2023-12-05 03:30:32 +00:00
|
|
|
if (target.os.tag == .windows) {
|
2023-04-24 18:58:17 +00:00
|
|
|
if (true) {
|
|
|
|
// Unfortunately this requires about 8G of RAM for clang to compile
|
|
|
|
// and our Windows CI runners do not have this much.
|
|
|
|
step.dependOn(&these_tests.step);
|
|
|
|
continue;
|
|
|
|
}
|
2023-04-20 18:42:11 +00:00
|
|
|
if (test_target.link_libc == false) {
|
|
|
|
compile_c.subsystem = .Console;
|
|
|
|
compile_c.linkSystemLibrary("kernel32");
|
|
|
|
compile_c.linkSystemLibrary("ntdll");
|
|
|
|
}
|
2023-04-19 06:38:41 +00:00
|
|
|
if (mem.eql(u8, options.name, "std")) {
|
2023-04-20 18:42:11 +00:00
|
|
|
if (test_target.link_libc == false) {
|
|
|
|
compile_c.linkSystemLibrary("shell32");
|
|
|
|
compile_c.linkSystemLibrary("advapi32");
|
|
|
|
}
|
2023-04-19 06:38:41 +00:00
|
|
|
compile_c.linkSystemLibrary("crypt32");
|
|
|
|
compile_c.linkSystemLibrary("ws2_32");
|
|
|
|
compile_c.linkSystemLibrary("ole32");
|
|
|
|
}
|
2023-04-14 00:22:53 +00:00
|
|
|
}
|
2023-03-12 07:39:21 +00:00
|
|
|
|
2023-04-14 00:22:53 +00:00
|
|
|
const run = b.addRunArtifact(compile_c);
|
|
|
|
run.skip_foreign_checks = true;
|
|
|
|
run.enableTestRunnerMode();
|
|
|
|
run.setName(b.fmt("run test {s}", .{qualified_name}));
|
|
|
|
|
|
|
|
step.dependOn(&run.step);
|
|
|
|
} else {
|
|
|
|
const run = b.addRunArtifact(these_tests);
|
|
|
|
run.skip_foreign_checks = true;
|
|
|
|
run.setName(b.fmt("run test {s}", .{qualified_name}));
|
|
|
|
|
|
|
|
step.dependOn(&run.step);
|
|
|
|
}
|
2017-04-20 06:26:36 +00:00
|
|
|
}
|
|
|
|
return step;
|
|
|
|
}
|
|
|
|
|
2023-01-31 07:19:51 +00:00
|
|
|
pub fn addCAbiTests(b: *std.Build, skip_non_native: bool, skip_release: bool) *Step {
|
2022-10-21 20:01:49 +00:00
|
|
|
const step = b.step("test-c-abi", "Run the C ABI tests");
|
|
|
|
|
2023-07-28 16:48:01 +00:00
|
|
|
const optimize_modes: [3]OptimizeMode = .{ .Debug, .ReleaseSafe, .ReleaseFast };
|
2023-01-11 15:25:02 +00:00
|
|
|
|
2023-03-07 05:57:53 +00:00
|
|
|
for (optimize_modes) |optimize_mode| {
|
|
|
|
if (optimize_mode != .Debug and skip_release) continue;
|
|
|
|
|
|
|
|
for (c_abi_targets) |c_abi_target| {
|
2023-10-26 09:30:41 +00:00
|
|
|
if (skip_non_native and !c_abi_target.target.isNative()) continue;
|
2023-03-07 05:57:53 +00:00
|
|
|
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
const resolved_target = b.resolveTargetQuery(c_abi_target.target);
|
2023-12-05 23:09:07 +00:00
|
|
|
const target = resolved_target.result;
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
|
|
|
|
if (target.os.tag == .windows and target.cpu.arch == .aarch64) {
|
2023-03-15 17:47:36 +00:00
|
|
|
// https://github.com/ziglang/zig/issues/14908
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-03-07 05:57:53 +00:00
|
|
|
const test_step = b.addTest(.{
|
2023-10-28 19:10:56 +00:00
|
|
|
.name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}{s}", .{
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
target.zigTriple(b.allocator) catch @panic("OOM"),
|
|
|
|
target.cpu.model.name,
|
2023-10-26 09:30:41 +00:00
|
|
|
@tagName(optimize_mode),
|
|
|
|
if (c_abi_target.use_llvm == true)
|
|
|
|
"-llvm"
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
else if (target.ofmt == .c)
|
2023-10-26 09:30:41 +00:00
|
|
|
"-cbe"
|
|
|
|
else if (c_abi_target.use_llvm == false)
|
|
|
|
"-selfhosted"
|
|
|
|
else
|
|
|
|
"",
|
|
|
|
if (c_abi_target.use_lld == false) "-no-lld" else "",
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
if (c_abi_target.pic == true) "-pic" else "",
|
2023-10-26 09:30:41 +00:00
|
|
|
}),
|
2024-04-11 21:02:47 +00:00
|
|
|
.root_source_file = b.path("test/c_abi/main.zig"),
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
.target = resolved_target,
|
2023-03-07 05:57:53 +00:00
|
|
|
.optimize = optimize_mode,
|
2023-10-26 09:30:41 +00:00
|
|
|
.link_libc = true,
|
|
|
|
.use_llvm = c_abi_target.use_llvm,
|
|
|
|
.use_lld = c_abi_target.use_lld,
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
.pic = c_abi_target.pic,
|
|
|
|
.strip = c_abi_target.strip,
|
2023-03-07 05:57:53 +00:00
|
|
|
});
|
2023-07-19 08:49:34 +00:00
|
|
|
test_step.addCSourceFile(.{
|
2024-04-11 21:02:47 +00:00
|
|
|
.file = b.path("test/c_abi/cfuncs.c"),
|
2023-07-19 08:49:34 +00:00
|
|
|
.flags = &.{"-std=c99"},
|
|
|
|
});
|
2023-10-26 09:30:41 +00:00
|
|
|
for (c_abi_target.c_defines) |define| test_step.defineCMacro(define, null);
|
2023-03-14 06:41:41 +00:00
|
|
|
|
2023-07-26 04:09:17 +00:00
|
|
|
// This test is intentionally trying to check if the external ABI is
|
|
|
|
// done properly. LTO would be a hindrance to this.
|
|
|
|
test_step.want_lto = false;
|
2023-01-19 05:37:20 +00:00
|
|
|
|
2023-04-11 00:05:09 +00:00
|
|
|
const run = b.addRunArtifact(test_step);
|
2023-03-12 07:39:21 +00:00
|
|
|
run.skip_foreign_checks = true;
|
|
|
|
step.dependOn(&run.step);
|
2023-03-07 05:57:53 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-21 20:01:49 +00:00
|
|
|
return step;
|
|
|
|
}
|
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-10 01:22:51 +00:00
|
|
|
|
|
|
|
pub fn addCases(
|
|
|
|
b: *std.Build,
|
|
|
|
parent_step: *Step,
|
2024-02-25 13:04:06 +00:00
|
|
|
test_filters: []const []const u8,
|
2024-03-05 01:26:41 +00:00
|
|
|
target: std.Build.ResolvedTarget,
|
|
|
|
translate_c_options: @import("src/Cases.zig").TranslateCOptions,
|
2023-07-31 13:43:29 +00:00
|
|
|
build_options: @import("cases.zig").BuildOptions,
|
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-10 01:22:51 +00:00
|
|
|
) !void {
|
|
|
|
const arena = b.allocator;
|
|
|
|
const gpa = b.allocator;
|
|
|
|
|
|
|
|
var cases = @import("src/Cases.zig").init(gpa, arena);
|
|
|
|
|
2023-11-22 20:12:22 +00:00
|
|
|
var dir = try b.build_root.handle.openDir("test/cases", .{ .iterate = true });
|
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-10 01:22:51 +00:00
|
|
|
defer dir.close();
|
|
|
|
|
zig build system: change target, compilation, and module APIs
Introduce the concept of "target query" and "resolved target". A target
query is what the user specifies, with some things left to default. A
resolved target has the default things discovered and populated.
In the future, std.zig.CrossTarget will be rename to std.Target.Query.
Introduces `std.Build.resolveTargetQuery` to get from one to the other.
The concept of `main_mod_path` is gone, no longer supported. You have to
put the root source file at the module root now.
* remove deprecated API
* update build.zig for the breaking API changes in this branch
* move std.Build.Step.Compile.BuildId to std.zig.BuildId
* add more options to std.Build.ExecutableOptions, std.Build.ObjectOptions,
std.Build.SharedLibraryOptions, std.Build.StaticLibraryOptions, and
std.Build.TestOptions.
* remove `std.Build.constructCMacro`. There is no use for this API.
* deprecate `std.Build.Step.Compile.defineCMacro`. Instead,
`std.Build.Module.addCMacro` is provided.
- remove `std.Build.Step.Compile.defineCMacroRaw`.
* deprecate `std.Build.Step.Compile.linkFrameworkNeeded`
- use `std.Build.Module.linkFramework`
* deprecate `std.Build.Step.Compile.linkFrameworkWeak`
- use `std.Build.Module.linkFramework`
* move more logic into `std.Build.Module`
* allow `target` and `optimize` to be `null` when creating a Module.
Along with other fields, those unspecified options will be inherited
from parent `Module` when inserted into an import table.
* the `target` field of `addExecutable` is now required. pass `b.host`
to get the host target.
2023-12-03 04:51:34 +00:00
|
|
|
cases.addFromDir(dir, b);
|
|
|
|
try @import("cases.zig").addCases(&cases, build_options, b);
|
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-10 01:22:51 +00:00
|
|
|
|
2024-03-05 01:26:41 +00:00
|
|
|
cases.lowerToTranslateCSteps(b, parent_step, test_filters, target, translate_c_options);
|
|
|
|
|
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-10 01:22:51 +00:00
|
|
|
cases.lowerToBuildSteps(
|
|
|
|
b,
|
|
|
|
parent_step,
|
2024-02-25 13:04:06 +00:00
|
|
|
test_filters,
|
re-enable test-cases and get them all passing
Instead of using `zig test` to build a special version of the compiler
that runs all the test-cases, the zig build system is now used as much
as possible - all with the basic steps found in the standard library.
For incremental compilation tests (the ones that look like foo.0.zig,
foo.1.zig, foo.2.zig, etc.), a special version of the compiler is
compiled into a utility executable called "check-case" which checks
exactly one sequence of incremental updates in an independent
subprocess. Previously, all incremental and non-incremental test cases
were done in the same test runner process.
The compile error checking code is now simpler, but also a bit
rudimentary, and so it additionally makes sure that the actual compile
errors do not include *extra* messages, and it makes sure that the
actual compile errors output in the same order as expected. It is also
based on the "ends-with" property of each line rather than the previous
logic, which frankly I didn't want to touch with a ten-meter pole. The
compile error test cases have been updated to pass in light of these
differences.
Previously, 'error' mode with 0 compile errors was used to shoehorn in a
different kind of test-case - one that only checks if a piece of code
compiles without errors. Now there is a 'compile' mode of test-cases,
and 'error' must be only used when there are greater than 0 errors.
link test cases are updated to omit the target object format argument
when calling checkObject since that is no longer needed.
The test/stage2 directory is removed; the 2 files within are moved to be
directly in the test/ directory.
2023-03-10 01:22:51 +00:00
|
|
|
);
|
|
|
|
}
|
2024-08-06 15:22:37 +00:00
|
|
|
|
|
|
|
pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step {
|
|
|
|
const step = b.step("test-debugger", "Run the debugger tests");
|
|
|
|
if (options.gdb == null and options.lldb == null) {
|
|
|
|
step.dependOn(&b.addFail("test-debugger requires -Dgdb and/or -Dlldb").step);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
var context: DebuggerContext = .{
|
|
|
|
.b = b,
|
|
|
|
.options = options,
|
|
|
|
.root_step = step,
|
|
|
|
};
|
|
|
|
context.addTestsForTarget(.{
|
|
|
|
.resolved = b.resolveTargetQuery(.{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
}),
|
|
|
|
.pic = false,
|
|
|
|
.test_name_suffix = "x86_64-linux",
|
|
|
|
});
|
|
|
|
context.addTestsForTarget(.{
|
|
|
|
.resolved = b.resolveTargetQuery(.{
|
|
|
|
.cpu_arch = .x86_64,
|
|
|
|
.os_tag = .linux,
|
|
|
|
.abi = .none,
|
|
|
|
}),
|
|
|
|
.pic = true,
|
|
|
|
.test_name_suffix = "x86_64-linux-pic",
|
|
|
|
});
|
|
|
|
return step;
|
|
|
|
}
|
2024-08-20 17:09:23 +00:00
|
|
|
|
|
|
|
pub fn addIncrementalTests(b: *std.Build, test_step: *Step) !void {
|
|
|
|
const incr_check = b.addExecutable(.{
|
|
|
|
.name = "incr-check",
|
|
|
|
.root_source_file = b.path("tools/incr-check.zig"),
|
|
|
|
.target = b.graph.host,
|
|
|
|
.optimize = .Debug,
|
|
|
|
});
|
|
|
|
|
|
|
|
var dir = try b.build_root.handle.openDir("test/incremental", .{ .iterate = true });
|
|
|
|
defer dir.close();
|
|
|
|
|
|
|
|
var it = try dir.walk(b.graph.arena);
|
|
|
|
while (try it.next()) |entry| {
|
|
|
|
if (entry.kind != .file) continue;
|
|
|
|
|
|
|
|
const run = b.addRunArtifact(incr_check);
|
|
|
|
run.setName(b.fmt("incr-check '{s}'", .{entry.basename}));
|
|
|
|
|
|
|
|
run.addArg(b.graph.zig_exe);
|
|
|
|
run.addFileArg(b.path("test/incremental/").path(b, entry.path));
|
|
|
|
run.addArgs(&.{ "--zig-lib-dir", b.fmt("{}", .{b.graph.zig_lib_directory}) });
|
|
|
|
|
|
|
|
run.addCheck(.{ .expect_term = .{ .Exited = 0 } });
|
|
|
|
|
|
|
|
test_step.dependOn(&run.step);
|
|
|
|
}
|
|
|
|
}
|