Compare commits
63 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0ba8b728f | ||
|
|
404a057f77 | ||
|
|
7a29161e8e | ||
|
|
236fb915cc | ||
|
|
e9388fde64 | ||
|
|
46a28175b3 | ||
|
|
59dd7a0fbd | ||
|
|
0aeeff0d94 | ||
|
|
ce9d2eda73 | ||
|
|
d6eac43a5b | ||
|
|
0039cb7ef2 | ||
|
|
88146ea704 | ||
|
|
6e469bc44d | ||
|
|
2d4b264527 | ||
|
|
95845ba2ac | ||
|
|
4a09703f62 | ||
|
|
82908b525d | ||
|
|
aba1dbc954 | ||
|
|
6ce3c2423e | ||
|
|
52150b701c | ||
|
|
869880adac | ||
|
|
511aa28983 | ||
|
|
e57c9c0931 | ||
|
|
d37182383d | ||
|
|
1216050520 | ||
|
|
8832314acf | ||
|
|
4616fb0937 | ||
|
|
fa4a626fac | ||
|
|
33c3bf0631 | ||
|
|
2563d32425 | ||
|
|
33809a0c53 | ||
|
|
2648e3651e | ||
|
|
d09afc08da | ||
|
|
ddde99bdfa | ||
|
|
f2110b0c0d | ||
|
|
7ce03acb9d | ||
|
|
c3aa32e984 | ||
|
|
efe06c5f31 | ||
|
|
7b908cb024 | ||
|
|
16d3f7b2fa | ||
|
|
fa5011aa31 | ||
|
|
595a7f8b08 | ||
|
|
6c482b8033 | ||
|
|
ad63be7eb9 | ||
|
|
704f8f4013 | ||
|
|
ef9fb428b7 | ||
|
|
600b652825 | ||
|
|
e36bf2baff | ||
|
|
4babedf1be | ||
|
|
0dc64d9064 | ||
|
|
5d29b9fad6 | ||
|
|
6de152ec7c | ||
|
|
cc25f75478 | ||
|
|
eb28c8aa35 | ||
|
|
f6773232ac | ||
|
|
9deea9b1d8 | ||
|
|
8e0a802ea1 | ||
|
|
eb5d67b146 | ||
|
|
082e5091af | ||
|
|
3b1f9b476c | ||
|
|
2478b5bb0e | ||
|
|
7974576967 | ||
|
|
011a78325e |
11
.github/CODEOWNERS
vendored
Normal file
11
.github/CODEOWNERS
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# std.json
|
||||
/lib/std/json* @thejoshwolfe
|
||||
|
||||
# std.Thread
|
||||
/lib/std/Thread* @kprotty
|
||||
|
||||
# resinator
|
||||
/lib/compiler/resinator/* @squeek502
|
||||
|
||||
# SPIR-V selfhosted backend
|
||||
/src/codegen/spirv* @Snektron
|
||||
18
.github/workflows/ci.yaml
vendored
18
.github/workflows/ci.yaml
vendored
@@ -4,14 +4,11 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- llvm19
|
||||
- 0.12.x
|
||||
concurrency:
|
||||
# Cancels pending runs when a PR gets updated.
|
||||
group: ${{ github.head_ref || github.run_id }}-${{ github.actor }}
|
||||
cancel-in-progress: true
|
||||
permissions:
|
||||
# Sets permission policy for `GITHUB_TOKEN`
|
||||
contents: read
|
||||
jobs:
|
||||
x86_64-linux-debug:
|
||||
timeout-minutes: 420
|
||||
@@ -46,7 +43,7 @@ jobs:
|
||||
- name: Build and Test
|
||||
run: sh ci/aarch64-linux-release.sh
|
||||
x86_64-macos-release:
|
||||
runs-on: "macos-13"
|
||||
runs-on: "macos-11"
|
||||
env:
|
||||
ARCH: "x86_64"
|
||||
steps:
|
||||
@@ -73,7 +70,6 @@ jobs:
|
||||
- name: Build and Test
|
||||
run: ci/aarch64-macos-release.sh
|
||||
x86_64-windows-debug:
|
||||
timeout-minutes: 420
|
||||
runs-on: [self-hosted, Windows, x86_64]
|
||||
env:
|
||||
ARCH: "x86_64"
|
||||
@@ -83,7 +79,6 @@ jobs:
|
||||
- name: Build and Test
|
||||
run: ci/x86_64-windows-debug.ps1
|
||||
x86_64-windows-release:
|
||||
timeout-minutes: 420
|
||||
runs-on: [self-hosted, Windows, x86_64]
|
||||
env:
|
||||
ARCH: "x86_64"
|
||||
@@ -92,3 +87,12 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
- name: Build and Test
|
||||
run: ci/x86_64-windows-release.ps1
|
||||
aarch64-windows:
|
||||
runs-on: [self-hosted, Windows, aarch64]
|
||||
env:
|
||||
ARCH: "aarch64"
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Build and Test
|
||||
run: ci/aarch64-windows.ps1
|
||||
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -9,14 +9,10 @@
|
||||
# Cheers!
|
||||
# -andrewrk
|
||||
|
||||
.zig-cache/
|
||||
zig-cache/
|
||||
zig-out/
|
||||
/release/
|
||||
/debug/
|
||||
/build/
|
||||
/build-*/
|
||||
/docgen_tmp/
|
||||
|
||||
# Although this was renamed to .zig-cache, let's leave it here for a few
|
||||
# releases to make it less annoying to work with multiple branches.
|
||||
zig-cache/
|
||||
|
||||
19
.mailmap
19
.mailmap
@@ -9,8 +9,6 @@ David Rubin <daviru007@icloud.com> <87927264+Rexicon226@users.noreply.github.com
|
||||
Dominic <4678790+dweiller@users.noreply.github.com>
|
||||
Dominic <4678790+dweiller@users.noreply.github.com> <4678790+dweiller@users.noreplay.github.com>
|
||||
Eric Eastwood <madlittlemods@gmail.com> <contact@ericeastwood.com>
|
||||
Eric Joldasov <bratishkaerik@landless-city.net>
|
||||
Eric Joldasov <bratishkaerik@landless-city.net> <bratishkaerik@landless-city.net>
|
||||
Felix "xq" Queißner <xq@random-projects.net>
|
||||
Felix "xq" Queißner <xq@random-projects.net> <felix@ib-queissner.de>
|
||||
Felix "xq" Queißner <xq@random-projects.net> <git@masterq32.de>
|
||||
@@ -19,16 +17,12 @@ Felix "xq" Queißner <xq@random-projects.net> <git@random-projects.net>
|
||||
Frank Denis <124872+jedisct1@users.noreply.github.com> <github@pureftpd.org>
|
||||
Garrett Beck <garrettlennoxbeck@gmail.com> <138411610+garrettlennoxbeck@users.noreply.github.com>
|
||||
Gaëtan S <blaxoujunior@gmail.com>
|
||||
GalaxyShard <dominic.adragna@byteroach.com>
|
||||
GalaxyShard <dominic.adragna@byteroach.com> <76917584+GalaxyShard@users.noreply.github.com>
|
||||
HydroH <iodizon@163.com> <ixlesis@gmail.com>
|
||||
Igor Anić <igor.anic@gmail.com>
|
||||
IntegratedQuantum <jahe788@gmail.com> <43880493+IntegratedQuantum@users.noreply.github.com>
|
||||
Isaac Freund <mail@isaacfreund.com> <ifreund@ifreund.xyz>
|
||||
Isaac Freund <mail@isaacfreund.com> <isaac.freund@coil.com>
|
||||
Jacob Young <amazingjacob@gmail.com>
|
||||
Jacob Young <amazingjacob@gmail.com> <jacobly0@users.noreply.github.com>
|
||||
Jacob Young <amazingjacob@gmail.com> <15544577+jacobly0@users.noreply.github.com>
|
||||
Jacob Young <jacobly0@users.noreply.github.com>
|
||||
Jan Philipp Hafer <jan.hafer@rwth-aachen.de> <anon_1plus1equals3@mailbox.org>
|
||||
Jeremy Volkman <jeremy@jvolkman.com> <jeremy@cedarai.com>
|
||||
Jimmi Holst Christensen <jhc@dismail.de> <jhc@dismail.de>
|
||||
@@ -41,15 +35,10 @@ Jonathan Marler <johnnymarler@gmail.com> <jonathan.j.marler@hp.com>
|
||||
Krzysztof Wolicki <der.teufel.mail@gmail.com>
|
||||
Krzysztof Wolicki <der.teufel.mail@gmail.com> <46651553+der-teufel-programming@users.noreply.github.com>
|
||||
LemonBoy <thatlemon@gmail.com> <LemonBoy@users.noreply.github.com>
|
||||
Lucas Santos <lucascarvalhosantos91@gmail.com>
|
||||
Lucas Santos <lucascarvalhosantos91@gmail.com> <117400842+LucasSantos91@users.noreply.github.com>
|
||||
Luuk de Gram <luuk@degram.dev> <Luukdegram@users.noreply.github.com>
|
||||
Marc Tiehuis <marc@tiehu.is> <marctiehuis@gmail.com>
|
||||
Mason Remaley <mason@anthropicstudios.com>
|
||||
Mason Remaley <mason@anthropicstudios.com> <MasonRemaley@users.noreply.github.com>
|
||||
Matthew Lugg <mlugg@mlugg.co.uk>
|
||||
Meghan Denny <hello@nektro.net>
|
||||
Meghan Denny <hello@nektro.net> <meghan@bun.sh>
|
||||
Michael Bartnett <michael.bartnett@gmail.com> <michaelbartnett@users.noreply.github.com>
|
||||
Motiejus Jakštys <motiejus@jakstys.lt> <motiejus@uber.com>
|
||||
Niles Salter <Validark@pm.me>
|
||||
@@ -69,15 +58,9 @@ Travis Staloch <twostepted@gmail.com>
|
||||
Travis Staloch <twostepted@gmail.com> <1562827+travisstaloch@users.noreply.github.com>
|
||||
Veikka Tuominen <git@vexu.eu>
|
||||
Veikka Tuominen <git@vexu.eu> <15308111+Vexu@users.noreply.github.com>
|
||||
Will Lillis <will.lillis24@gmail.com>
|
||||
Will Lillis <will.lillis24@gmail.com> <wlillis@umass.edu>
|
||||
Wooster <r00ster91@proton.me>
|
||||
Wooster <r00ster91@proton.me> <wooster0@proton.me>
|
||||
antlilja <liljaanton2001@gmail.com> <12533691+antlilja@users.noreply.github.com>
|
||||
february cozzocrea <february.cozzocrea@gmail.com> <91439207+f-cozzocrea@users.noreply.github.com>
|
||||
garrisonhh <garrisonhh@pm.me> <71951273+garrisonhh@users.noreply.github.com>
|
||||
kj4tmp <kj4tmp@gmail.com>
|
||||
kj4tmp <kj4tmp@gmail.com> <56497124+kj4tmp@users.noreply.github.com>
|
||||
saurabh <saurabhm@proton.me>
|
||||
saurabh <tech@saurabh.mozmail.com> <saurabhm@proton.me>
|
||||
xEgoist <egoist@egoistic.dev> <101279047+xEgoist@users.noreply.github.com>
|
||||
|
||||
1279
CMakeLists.txt
1279
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
30
README.md
30
README.md
@@ -13,9 +13,11 @@ Documentation** corresponding to the version of Zig that you are using by
|
||||
following the appropriate link on the
|
||||
[download page](https://ziglang.org/download).
|
||||
|
||||
Otherwise, you're looking at a release of Zig, so you can find the language
|
||||
reference at `doc/langref.html`, and the standard library documentation by
|
||||
running `zig std`, which will open a browser tab.
|
||||
Otherwise, you're looking at a release of Zig, and you can find documentation
|
||||
here:
|
||||
|
||||
* doc/langref.html
|
||||
* doc/std/index.html
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -45,9 +47,9 @@ mechanism supports that use case too (i.e. `/usr/bin/zig` and `/usr/lib/zig/`).
|
||||
|
||||
Ensure you have the required dependencies:
|
||||
|
||||
* CMake >= 3.15
|
||||
* CMake >= 3.5
|
||||
* System C/C++ Toolchain
|
||||
* LLVM, Clang, LLD development libraries == 19.x
|
||||
* LLVM, Clang, LLD development libraries == 17.x
|
||||
|
||||
Then it is the standard CMake build process:
|
||||
|
||||
@@ -76,25 +78,21 @@ This produces a `zig2` executable in the current working directory. This is a
|
||||
[without LLVM extensions](https://github.com/ziglang/zig/issues/16270), and is
|
||||
therefore lacking these features:
|
||||
- Release mode optimizations
|
||||
- [aarch64 machine code backend](https://github.com/ziglang/zig/issues/21172)
|
||||
- [@cImport](https://github.com/ziglang/zig/issues/20630)
|
||||
- [zig translate-c](https://github.com/ziglang/zig/issues/20875)
|
||||
- [Ability to compile assembly files](https://github.com/ziglang/zig/issues/21169)
|
||||
- aarch64 machine code backend
|
||||
- `@cImport` / `zig translate-c`
|
||||
- Ability to compile C files
|
||||
- Ability to compile assembly files
|
||||
- [Some ELF linking features](https://github.com/ziglang/zig/issues/17749)
|
||||
- [Most COFF/PE linking features](https://github.com/ziglang/zig/issues/17751)
|
||||
- [Some WebAssembly linking features](https://github.com/ziglang/zig/issues/17750)
|
||||
- [Ability to create import libs from def files](https://github.com/ziglang/zig/issues/17807)
|
||||
- [Automatic importlib file generation for Windows DLLs](https://github.com/ziglang/zig/issues/17753)
|
||||
- [Ability to create static archives from object files](https://github.com/ziglang/zig/issues/9828)
|
||||
- Ability to compile C, C++, Objective-C, and Objective-C++ files
|
||||
- Ability to compile C++, Objective-C, and Objective-C++ files
|
||||
|
||||
However, a compiler built this way does provide a C backend, which may be
|
||||
useful for creating system packages of Zig projects using the system C
|
||||
toolchain. **In this case, LLVM is not needed!**
|
||||
|
||||
Furthermore, a compiler built this way provides an LLVM backend that produces
|
||||
bitcode files, which may be compiled into object files via a system Clang
|
||||
package. This can be used to produce system packages of Zig applications
|
||||
without the Zig package dependency on LLVM.
|
||||
toolchain. In such case, LLVM is not needed!
|
||||
|
||||
## Contributing
|
||||
|
||||
|
||||
18
bootstrap.c
18
bootstrap.c
@@ -123,7 +123,7 @@ int main(int argc, char **argv) {
|
||||
if (f == NULL)
|
||||
panic("unable to open config.zig for writing");
|
||||
|
||||
const char *zig_version = "0.14.0-dev.bootstrap";
|
||||
const char *zig_version = "0.12.0-dev.bootstrap";
|
||||
|
||||
int written = fprintf(f,
|
||||
"pub const have_llvm = false;\n"
|
||||
@@ -139,9 +139,9 @@ int main(int argc, char **argv) {
|
||||
"pub const enable_tracy = false;\n"
|
||||
"pub const value_tracing = false;\n"
|
||||
"pub const skip_non_native = false;\n"
|
||||
"pub const debug_gpa = false;\n"
|
||||
"pub const dev = .core;\n"
|
||||
"pub const value_interpret_mode = .direct;\n"
|
||||
"pub const force_gpa = false;\n"
|
||||
"pub const only_c = false;\n"
|
||||
"pub const only_core_functionality = true;\n"
|
||||
, zig_version);
|
||||
if (written < 100)
|
||||
panic("unable to write to config.zig file");
|
||||
@@ -157,9 +157,9 @@ int main(int argc, char **argv) {
|
||||
"-target", host_triple,
|
||||
"--dep", "build_options",
|
||||
"--dep", "aro",
|
||||
"-Mroot=src/main.zig",
|
||||
"-Mbuild_options=config.zig",
|
||||
"-Maro=lib/compiler/aro/aro.zig",
|
||||
"--mod", "root", "src/main.zig",
|
||||
"--mod", "build_options", "config.zig",
|
||||
"--mod", "aro", "lib/compiler/aro/aro.zig",
|
||||
NULL,
|
||||
};
|
||||
print_and_run(child_argv);
|
||||
@@ -171,7 +171,9 @@ int main(int argc, char **argv) {
|
||||
"-ofmt=c", "-OReleaseSmall",
|
||||
"--name", "compiler_rt", "-femit-bin=compiler_rt.c",
|
||||
"-target", host_triple,
|
||||
"-Mroot=lib/compiler_rt.zig",
|
||||
"--dep", "build_options",
|
||||
"--mod", "root", "lib/compiler_rt.zig",
|
||||
"--mod", "build_options", "config.zig",
|
||||
NULL,
|
||||
};
|
||||
print_and_run(child_argv);
|
||||
|
||||
550
build.zig
550
build.zig
@@ -8,19 +8,18 @@ const io = std.io;
|
||||
const fs = std.fs;
|
||||
const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
|
||||
const assert = std.debug.assert;
|
||||
const DevEnv = @import("src/dev.zig").Env;
|
||||
const ValueInterpretMode = enum { direct, by_name };
|
||||
|
||||
const zig_version: std.SemanticVersion = .{ .major = 0, .minor = 15, .patch = 0 };
|
||||
const stack_size = 46 * 1024 * 1024;
|
||||
const zig_version = std.SemanticVersion{ .major = 0, .minor = 12, .patch = 1 };
|
||||
const stack_size = 32 * 1024 * 1024;
|
||||
|
||||
pub fn build(b: *std.Build) !void {
|
||||
const only_c = b.option(bool, "only-c", "Translate the Zig compiler to C code, with only the C backend enabled") orelse false;
|
||||
const target = b.standardTargetOptions(.{
|
||||
.default_target = .{
|
||||
.ofmt = if (only_c) .c else null,
|
||||
},
|
||||
});
|
||||
const target = t: {
|
||||
var default_target: std.zig.CrossTarget = .{};
|
||||
default_target.ofmt = b.option(std.Target.ObjectFormat, "ofmt", "Object format to target") orelse if (only_c) .c else null;
|
||||
break :t b.standardTargetOptions(.{ .default_target = default_target });
|
||||
};
|
||||
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
|
||||
const flat = b.option(bool, "flat", "Put files into the installation prefix in a manner suited for upstream distribution rather than a posix file system hierarchy standard") orelse false;
|
||||
@@ -32,37 +31,40 @@ pub fn build(b: *std.Build) !void {
|
||||
const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
|
||||
const std_docs = b.option(bool, "std-docs", "include standard library autodocs") orelse false;
|
||||
const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
|
||||
const enable_superhtml = b.option(bool, "enable-superhtml", "Check langref output HTML validity") orelse false;
|
||||
|
||||
const langref_file = generateLangRef(b);
|
||||
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
|
||||
const check_langref = superHtmlCheck(b, langref_file);
|
||||
if (enable_superhtml) install_langref.step.dependOn(check_langref);
|
||||
const docgen_exe = b.addExecutable(.{
|
||||
.name = "docgen",
|
||||
.root_source_file = b.path("tools/docgen.zig"),
|
||||
.target = b.host,
|
||||
.optimize = .Debug,
|
||||
.single_threaded = single_threaded,
|
||||
});
|
||||
|
||||
const check_autodocs = superHtmlCheck(b, b.path("lib/docs/index.html"));
|
||||
if (enable_superhtml) {
|
||||
test_step.dependOn(check_langref);
|
||||
test_step.dependOn(check_autodocs);
|
||||
const docgen_cmd = b.addRunArtifact(docgen_exe);
|
||||
docgen_cmd.addArgs(&.{ "--zig", b.graph.zig_exe });
|
||||
if (b.zig_lib_dir) |p| {
|
||||
docgen_cmd.addArg("--zig-lib-dir");
|
||||
docgen_cmd.addDirectoryArg(p);
|
||||
}
|
||||
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
|
||||
const langref_file = docgen_cmd.addOutputFileArg("langref.html");
|
||||
const install_langref = b.addInstallFileWithDir(langref_file, .prefix, "doc/langref.html");
|
||||
if (!skip_install_langref) {
|
||||
b.getInstallStep().dependOn(&install_langref.step);
|
||||
}
|
||||
|
||||
const autodoc_test = b.addObject(.{
|
||||
.name = "std",
|
||||
.root_source_file = b.path("lib/std/std.zig"),
|
||||
.target = target,
|
||||
.zig_lib_dir = b.path("lib"),
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("lib/std/std.zig"),
|
||||
.target = target,
|
||||
.optimize = .Debug,
|
||||
}),
|
||||
.optimize = .Debug,
|
||||
});
|
||||
const install_std_docs = b.addInstallDirectory(.{
|
||||
.source_dir = autodoc_test.getEmittedDocs(),
|
||||
.install_dir = .prefix,
|
||||
.install_subdir = "doc/std",
|
||||
});
|
||||
//if (enable_tidy) install_std_docs.step.dependOn(check_autodocs);
|
||||
if (std_docs) {
|
||||
b.getInstallStep().dependOn(&install_std_docs.step);
|
||||
}
|
||||
@@ -82,6 +84,15 @@ pub fn build(b: *std.Build) !void {
|
||||
docs_step.dependOn(langref_step);
|
||||
docs_step.dependOn(std_docs_step);
|
||||
|
||||
const check_case_exe = b.addExecutable(.{
|
||||
.name = "check-case",
|
||||
.root_source_file = b.path("test/src/Cases.zig"),
|
||||
.target = b.host,
|
||||
.optimize = optimize,
|
||||
.single_threaded = single_threaded,
|
||||
});
|
||||
check_case_exe.stack_size = stack_size;
|
||||
|
||||
const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
|
||||
const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse false;
|
||||
const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
|
||||
@@ -170,14 +181,11 @@ pub fn build(b: *std.Build) !void {
|
||||
const tracy = b.option([]const u8, "tracy", "Enable Tracy integration. Supply path to Tracy source");
|
||||
const tracy_callstack = b.option(bool, "tracy-callstack", "Include callstack information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);
|
||||
const tracy_allocation = b.option(bool, "tracy-allocation", "Include allocation information with Tracy data. Does nothing if -Dtracy is not provided") orelse (tracy != null);
|
||||
const tracy_callstack_depth: u32 = b.option(u32, "tracy-callstack-depth", "Declare callstack depth for Tracy data. Does nothing if -Dtracy_callstack is not provided") orelse 10;
|
||||
const debug_gpa = b.option(bool, "debug-allocator", "Force the compiler to use DebugAllocator") orelse false;
|
||||
const force_gpa = b.option(bool, "force-gpa", "Force the compiler to use GeneralPurposeAllocator") orelse false;
|
||||
const link_libc = b.option(bool, "force-link-libc", "Force self-hosted compiler to link libc") orelse (enable_llvm or only_c);
|
||||
const sanitize_thread = b.option(bool, "sanitize-thread", "Enable thread-sanitization") orelse false;
|
||||
const strip = b.option(bool, "strip", "Omit debug information");
|
||||
const valgrind = b.option(bool, "valgrind", "Enable valgrind integration");
|
||||
const pie = b.option(bool, "pie", "Produce a Position Independent Executable");
|
||||
const value_interpret_mode = b.option(ValueInterpretMode, "value-interpret-mode", "How the compiler translates between 'std.builtin' types and its internal datastructures") orelse .direct;
|
||||
const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false;
|
||||
|
||||
const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: {
|
||||
@@ -190,7 +198,6 @@ pub fn build(b: *std.Build) !void {
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
.strip = strip,
|
||||
.valgrind = valgrind,
|
||||
.sanitize_thread = sanitize_thread,
|
||||
.single_threaded = single_threaded,
|
||||
});
|
||||
@@ -217,6 +224,7 @@ pub fn build(b: *std.Build) !void {
|
||||
if (target.result.os.tag == .windows and target.result.abi == .gnu) {
|
||||
// LTO is currently broken on mingw, this can be removed when it's fixed.
|
||||
exe.want_lto = false;
|
||||
check_case_exe.want_lto = false;
|
||||
}
|
||||
|
||||
const use_llvm = b.option(bool, "use-llvm", "Use the llvm backend");
|
||||
@@ -233,12 +241,13 @@ pub fn build(b: *std.Build) !void {
|
||||
exe_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
|
||||
exe_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
|
||||
exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
|
||||
exe_options.addOption(bool, "debug_gpa", debug_gpa);
|
||||
exe_options.addOption(DevEnv, "dev", b.option(DevEnv, "dev", "Build a compiler with a reduced feature set for development of specific features") orelse if (only_c) .bootstrap else .full);
|
||||
exe_options.addOption(ValueInterpretMode, "value_interpret_mode", value_interpret_mode);
|
||||
exe_options.addOption(bool, "force_gpa", force_gpa);
|
||||
exe_options.addOption(bool, "only_c", only_c);
|
||||
exe_options.addOption(bool, "only_core_functionality", only_c);
|
||||
|
||||
if (link_libc) {
|
||||
exe.root_module.link_libc = true;
|
||||
exe.linkLibC();
|
||||
check_case_exe.linkLibC();
|
||||
}
|
||||
|
||||
const is_debug = optimize == .Debug;
|
||||
@@ -257,10 +266,13 @@ pub fn build(b: *std.Build) !void {
|
||||
var code: u8 = undefined;
|
||||
const git_describe_untrimmed = b.runAllowFail(&[_][]const u8{
|
||||
"git",
|
||||
"-C", b.build_root.path orelse ".", // affects the --git-dir argument
|
||||
"--git-dir", ".git", // affected by the -C argument
|
||||
"describe", "--match", "*.*.*", //
|
||||
"--tags", "--abbrev=9",
|
||||
"-C",
|
||||
b.build_root.path orelse ".",
|
||||
"describe",
|
||||
"--match",
|
||||
"*.*.*",
|
||||
"--tags",
|
||||
"--abbrev=9",
|
||||
}, &code, .Ignore) catch {
|
||||
break :v version_string;
|
||||
};
|
||||
@@ -329,17 +341,18 @@ pub fn build(b: *std.Build) !void {
|
||||
}
|
||||
|
||||
try addCmakeCfgOptionsToExe(b, cfg, exe, use_zig_libcxx);
|
||||
try addCmakeCfgOptionsToExe(b, cfg, check_case_exe, use_zig_libcxx);
|
||||
} else {
|
||||
// Here we are -Denable-llvm but no cmake integration.
|
||||
try addStaticLlvmOptionsToModule(exe.root_module);
|
||||
try addStaticLlvmOptionsToExe(exe);
|
||||
try addStaticLlvmOptionsToExe(check_case_exe);
|
||||
}
|
||||
if (target.result.os.tag == .windows) {
|
||||
// LLVM depends on networking as of version 18.
|
||||
exe.root_module.linkSystemLibrary("ws2_32", .{});
|
||||
|
||||
exe.root_module.linkSystemLibrary("version", .{});
|
||||
exe.root_module.linkSystemLibrary("uuid", .{});
|
||||
exe.root_module.linkSystemLibrary("ole32", .{});
|
||||
inline for (.{ exe, check_case_exe }) |artifact| {
|
||||
artifact.linkSystemLibrary("version");
|
||||
artifact.linkSystemLibrary("uuid");
|
||||
artifact.linkSystemLibrary("ole32");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +365,6 @@ pub fn build(b: *std.Build) !void {
|
||||
exe_options.addOption(bool, "enable_tracy", tracy != null);
|
||||
exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
|
||||
exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
|
||||
exe_options.addOption(u32, "tracy_callstack_depth", tracy_callstack_depth);
|
||||
exe_options.addOption(bool, "value_tracing", value_tracing);
|
||||
if (tracy) |tracy_path| {
|
||||
const client_cpp = b.pathJoin(
|
||||
@@ -365,22 +377,48 @@ pub fn build(b: *std.Build) !void {
|
||||
else
|
||||
&[_][]const u8{ "-DTRACY_ENABLE=1", "-fno-sanitize=undefined" };
|
||||
|
||||
exe.root_module.addIncludePath(.{ .cwd_relative = tracy_path });
|
||||
exe.root_module.addCSourceFile(.{ .file = .{ .cwd_relative = client_cpp }, .flags = tracy_c_flags });
|
||||
exe.addIncludePath(.{ .cwd_relative = tracy_path });
|
||||
exe.addCSourceFile(.{ .file = .{ .cwd_relative = client_cpp }, .flags = tracy_c_flags });
|
||||
if (!enable_llvm) {
|
||||
exe.root_module.linkSystemLibrary("c++", .{ .use_pkg_config = .no });
|
||||
}
|
||||
exe.root_module.link_libc = true;
|
||||
exe.linkLibC();
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
exe.root_module.linkSystemLibrary("dbghelp", .{});
|
||||
exe.root_module.linkSystemLibrary("ws2_32", .{});
|
||||
exe.linkSystemLibrary("dbghelp");
|
||||
exe.linkSystemLibrary("ws2_32");
|
||||
}
|
||||
}
|
||||
|
||||
const test_filters = b.option([]const []const u8, "test-filter", "Skip tests that do not match any filter") orelse &[0][]const u8{};
|
||||
const test_target_filters = b.option([]const []const u8, "test-target-filter", "Skip tests whose target triple do not match any filter") orelse &[0][]const u8{};
|
||||
const test_slow_targets = b.option(bool, "test-slow-targets", "Enable running module tests for targets that have a slow compiler backend") orelse false;
|
||||
|
||||
const test_cases_options = b.addOptions();
|
||||
check_case_exe.root_module.addOptions("build_options", test_cases_options);
|
||||
|
||||
test_cases_options.addOption(bool, "enable_tracy", false);
|
||||
test_cases_options.addOption(bool, "enable_debug_extensions", enable_debug_extensions);
|
||||
test_cases_options.addOption(bool, "enable_logging", enable_logging);
|
||||
test_cases_options.addOption(bool, "enable_link_snapshots", enable_link_snapshots);
|
||||
test_cases_options.addOption(bool, "skip_non_native", skip_non_native);
|
||||
test_cases_options.addOption(bool, "have_llvm", enable_llvm);
|
||||
test_cases_options.addOption(bool, "llvm_has_m68k", llvm_has_m68k);
|
||||
test_cases_options.addOption(bool, "llvm_has_csky", llvm_has_csky);
|
||||
test_cases_options.addOption(bool, "llvm_has_arc", llvm_has_arc);
|
||||
test_cases_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
|
||||
test_cases_options.addOption(bool, "force_gpa", force_gpa);
|
||||
test_cases_options.addOption(bool, "only_c", only_c);
|
||||
test_cases_options.addOption(bool, "only_core_functionality", true);
|
||||
test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu);
|
||||
test_cases_options.addOption(bool, "enable_wine", b.enable_wine);
|
||||
test_cases_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime);
|
||||
test_cases_options.addOption(bool, "enable_rosetta", b.enable_rosetta);
|
||||
test_cases_options.addOption(bool, "enable_darling", b.enable_darling);
|
||||
test_cases_options.addOption(u32, "mem_leak_frames", mem_leak_frames * 2);
|
||||
test_cases_options.addOption(bool, "value_tracing", value_tracing);
|
||||
test_cases_options.addOption(?[]const u8, "glibc_runtimes_dir", b.glibc_runtimes_dir);
|
||||
test_cases_options.addOption([:0]const u8, "version", version);
|
||||
test_cases_options.addOption(std.SemanticVersion, "semver", semver);
|
||||
test_cases_options.addOption([]const []const u8, "test_filters", test_filters);
|
||||
|
||||
var chosen_opt_modes_buf: [4]builtin.OptimizeMode = undefined;
|
||||
var chosen_mode_index: usize = 0;
|
||||
@@ -402,24 +440,21 @@ pub fn build(b: *std.Build) !void {
|
||||
}
|
||||
const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
|
||||
|
||||
const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" };
|
||||
const fmt_exclude_paths = &.{ "test/cases", "test/behavior/zon" };
|
||||
const fmt_include_paths = &.{ "doc", "lib", "src", "test", "tools", "build.zig" };
|
||||
const fmt_exclude_paths = &.{"test/cases"};
|
||||
const do_fmt = b.addFmt(.{
|
||||
.paths = fmt_include_paths,
|
||||
.exclude_paths = fmt_exclude_paths,
|
||||
});
|
||||
b.step("fmt", "Modify source files in place to have conforming formatting").dependOn(&do_fmt.step);
|
||||
|
||||
const check_fmt = b.step("test-fmt", "Check source files having conforming formatting");
|
||||
check_fmt.dependOn(&b.addFmt(.{
|
||||
b.step("test-fmt", "Check source files having conforming formatting").dependOn(&b.addFmt(.{
|
||||
.paths = fmt_include_paths,
|
||||
.exclude_paths = fmt_exclude_paths,
|
||||
.check = true,
|
||||
}).step);
|
||||
test_step.dependOn(check_fmt);
|
||||
|
||||
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
|
||||
try tests.addCases(b, test_cases_step, test_filters, test_target_filters, target, .{
|
||||
try tests.addCases(b, test_cases_step, test_filters, check_case_exe, target, .{
|
||||
.skip_translate_c = skip_translate_c,
|
||||
.skip_run_translated_c = skip_run_translated_c,
|
||||
}, .{
|
||||
@@ -431,13 +466,8 @@ pub fn build(b: *std.Build) !void {
|
||||
});
|
||||
test_step.dependOn(test_cases_step);
|
||||
|
||||
const test_modules_step = b.step("test-modules", "Run the per-target module tests");
|
||||
test_step.dependOn(test_modules_step);
|
||||
|
||||
test_modules_step.dependOn(tests.addModuleTests(b, .{
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.test_slow_targets = test_slow_targets,
|
||||
.root_src = "test/behavior.zig",
|
||||
.name = "behavior",
|
||||
.desc = "Run the behavior tests",
|
||||
@@ -446,14 +476,11 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_libc = skip_libc,
|
||||
.use_llvm = use_llvm,
|
||||
.max_rss = 2 * 1024 * 1024 * 1024,
|
||||
.max_rss = 1 * 1024 * 1024 * 1024,
|
||||
}));
|
||||
|
||||
test_modules_step.dependOn(tests.addModuleTests(b, .{
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.test_slow_targets = test_slow_targets,
|
||||
.root_src = "test/c_import.zig",
|
||||
.name = "c-import",
|
||||
.desc = "Run the @cImport tests",
|
||||
@@ -462,13 +489,10 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_libc = skip_libc,
|
||||
.use_llvm = use_llvm,
|
||||
}));
|
||||
|
||||
test_modules_step.dependOn(tests.addModuleTests(b, .{
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.test_slow_targets = test_slow_targets,
|
||||
.root_src = "lib/compiler_rt.zig",
|
||||
.name = "compiler-rt",
|
||||
.desc = "Run the compiler_rt tests",
|
||||
@@ -477,14 +501,10 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_libc = true,
|
||||
.use_llvm = use_llvm,
|
||||
.no_builtin = true,
|
||||
}));
|
||||
|
||||
test_modules_step.dependOn(tests.addModuleTests(b, .{
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.test_slow_targets = test_slow_targets,
|
||||
.root_src = "lib/c.zig",
|
||||
.name = "universal-libc",
|
||||
.desc = "Run the universal libc tests",
|
||||
@@ -493,46 +513,8 @@ pub fn build(b: *std.Build) !void {
|
||||
.skip_single_threaded = true,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_libc = true,
|
||||
.use_llvm = use_llvm,
|
||||
.no_builtin = true,
|
||||
}));
|
||||
|
||||
test_modules_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.test_slow_targets = test_slow_targets,
|
||||
.root_src = "lib/std/std.zig",
|
||||
.name = "std",
|
||||
.desc = "Run the standard library tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{},
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_libc = skip_libc,
|
||||
.use_llvm = use_llvm,
|
||||
// I observed a value of 5136793600 on the M2 CI.
|
||||
.max_rss = 5368709120,
|
||||
}));
|
||||
|
||||
const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests");
|
||||
test_step.dependOn(unit_tests_step);
|
||||
|
||||
const unit_tests = b.addTest(.{
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.optimize = optimize,
|
||||
.target = target,
|
||||
.link_libc = link_libc,
|
||||
.single_threaded = single_threaded,
|
||||
}),
|
||||
.filters = test_filters,
|
||||
.use_llvm = use_llvm,
|
||||
.use_lld = use_llvm,
|
||||
.zig_lib_dir = b.path("lib"),
|
||||
});
|
||||
unit_tests.root_module.addOptions("build_options", exe_options);
|
||||
unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step);
|
||||
|
||||
test_step.dependOn(tests.addCompareOutputTests(b, test_filters, optimization_modes));
|
||||
test_step.dependOn(tests.addStandaloneTests(
|
||||
b,
|
||||
@@ -541,63 +523,61 @@ pub fn build(b: *std.Build) !void {
|
||||
enable_ios_sdk,
|
||||
enable_symlinks_windows,
|
||||
));
|
||||
test_step.dependOn(tests.addCAbiTests(b, .{
|
||||
.test_target_filters = test_target_filters,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_release = skip_release,
|
||||
}));
|
||||
test_step.dependOn(tests.addCAbiTests(b, skip_non_native, skip_release));
|
||||
test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
|
||||
test_step.dependOn(tests.addStackTraceTests(b, test_filters, optimization_modes));
|
||||
test_step.dependOn(tests.addCliTests(b));
|
||||
test_step.dependOn(tests.addAssembleAndLinkTests(b, test_filters, optimization_modes));
|
||||
if (tests.addDebuggerTests(b, .{
|
||||
test_step.dependOn(tests.addModuleTests(b, .{
|
||||
.test_filters = test_filters,
|
||||
.test_target_filters = test_target_filters,
|
||||
.gdb = b.option([]const u8, "gdb", "path to gdb binary"),
|
||||
.lldb = b.option([]const u8, "lldb", "path to lldb binary"),
|
||||
.root_src = "lib/std/std.zig",
|
||||
.name = "std",
|
||||
.desc = "Run the standard library tests",
|
||||
.optimize_modes = optimization_modes,
|
||||
.include_paths = &.{},
|
||||
.skip_single_threaded = skip_single_threaded,
|
||||
.skip_non_native = skip_non_native,
|
||||
.skip_libc = skip_libc,
|
||||
})) |test_debugger_step| test_step.dependOn(test_debugger_step);
|
||||
// I observed a value of 4572626944 on the M2 CI.
|
||||
.max_rss = 5029889638,
|
||||
}));
|
||||
|
||||
try addWasiUpdateStep(b, version);
|
||||
|
||||
b.step("fmt", "Modify source files in place to have conforming formatting")
|
||||
.dependOn(&do_fmt.step);
|
||||
|
||||
const update_mingw_step = b.step("update-mingw", "Update zig's bundled mingw");
|
||||
const opt_mingw_src_path = b.option([]const u8, "mingw-src", "path to mingw-w64 source directory");
|
||||
const update_mingw_exe = b.addExecutable(.{
|
||||
.name = "update_mingw",
|
||||
.target = b.host,
|
||||
.root_source_file = b.path("tools/update_mingw.zig"),
|
||||
});
|
||||
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
|
||||
update_mingw_run.addDirectoryArg(b.path("lib"));
|
||||
if (opt_mingw_src_path) |mingw_src_path| {
|
||||
const update_mingw_exe = b.addExecutable(.{
|
||||
.name = "update_mingw",
|
||||
.root_module = b.createModule(.{
|
||||
.target = b.graph.host,
|
||||
.root_source_file = b.path("tools/update_mingw.zig"),
|
||||
}),
|
||||
});
|
||||
const update_mingw_run = b.addRunArtifact(update_mingw_exe);
|
||||
update_mingw_run.addDirectoryArg(b.path("lib"));
|
||||
update_mingw_run.addDirectoryArg(.{ .cwd_relative = mingw_src_path });
|
||||
|
||||
update_mingw_step.dependOn(&update_mingw_run.step);
|
||||
} else {
|
||||
update_mingw_step.dependOn(&b.addFail("The -Dmingw-src=... option is required for this step").step);
|
||||
// Intentionally cause an error if this build step is requested.
|
||||
update_mingw_run.addArg("--missing-mingw-source-directory");
|
||||
}
|
||||
|
||||
const test_incremental_step = b.step("test-incremental", "Run the incremental compilation test cases");
|
||||
try tests.addIncrementalTests(b, test_incremental_step);
|
||||
test_step.dependOn(test_incremental_step);
|
||||
update_mingw_step.dependOn(&update_mingw_run.step);
|
||||
}
|
||||
|
||||
fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||
const semver = try std.SemanticVersion.parse(version);
|
||||
|
||||
var target_query: std.zig.CrossTarget = .{
|
||||
.cpu_arch = .wasm32,
|
||||
.os_tag = .wasi,
|
||||
};
|
||||
target_query.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory));
|
||||
|
||||
const exe = addCompilerStep(b, .{
|
||||
.optimize = .ReleaseSmall,
|
||||
.target = b.resolveTargetQuery(std.Target.Query.parse(.{
|
||||
.arch_os_abi = "wasm32-wasi",
|
||||
// * `extended_const` is not supported by the `wasm-opt` version in CI.
|
||||
// * `nontrapping_bulk_memory_len0` is supported by `wasm2c`.
|
||||
.cpu_features = "baseline-extended_const+nontrapping_bulk_memory_len0",
|
||||
}) catch unreachable),
|
||||
.target = b.resolveTargetQuery(target_query),
|
||||
});
|
||||
|
||||
const exe_options = b.addOptions();
|
||||
@@ -605,7 +585,8 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||
|
||||
exe_options.addOption(u32, "mem_leak_frames", 0);
|
||||
exe_options.addOption(bool, "have_llvm", false);
|
||||
exe_options.addOption(bool, "debug_gpa", false);
|
||||
exe_options.addOption(bool, "force_gpa", false);
|
||||
exe_options.addOption(bool, "only_c", true);
|
||||
exe_options.addOption([:0]const u8, "version", version);
|
||||
exe_options.addOption(std.SemanticVersion, "semver", semver);
|
||||
exe_options.addOption(bool, "enable_debug_extensions", false);
|
||||
@@ -614,40 +595,20 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||
exe_options.addOption(bool, "enable_tracy", false);
|
||||
exe_options.addOption(bool, "enable_tracy_callstack", false);
|
||||
exe_options.addOption(bool, "enable_tracy_allocation", false);
|
||||
exe_options.addOption(u32, "tracy_callstack_depth", 0);
|
||||
exe_options.addOption(bool, "value_tracing", false);
|
||||
exe_options.addOption(DevEnv, "dev", .bootstrap);
|
||||
|
||||
// zig1 chooses to interpret values by name. The tradeoff is as follows:
|
||||
//
|
||||
// * We lose a small amount of performance. This is essentially irrelevant for zig1.
|
||||
//
|
||||
// * We lose the ability to perform trivial renames on certain `std.builtin` types without
|
||||
// zig1.wasm updates. For instance, we cannot rename an enum from PascalCase fields to
|
||||
// snake_case fields without an update.
|
||||
//
|
||||
// * We gain the ability to add and remove fields to and from `std.builtin` types without
|
||||
// zig1.wasm updates. For instance, we can add a new tag to `CallingConvention` without
|
||||
// an update.
|
||||
//
|
||||
// Because field renames only happen when we apply a breaking change to the language (which
|
||||
// is becoming progressively rarer), but tags may be added to or removed from target-dependent
|
||||
// types over time in response to new targets coming into use, we gain more than we lose here.
|
||||
exe_options.addOption(ValueInterpretMode, "value_interpret_mode", .by_name);
|
||||
exe_options.addOption(bool, "only_core_functionality", true);
|
||||
|
||||
const run_opt = b.addSystemCommand(&.{
|
||||
"wasm-opt",
|
||||
"-Oz",
|
||||
"--enable-bulk-memory",
|
||||
"--enable-mutable-globals",
|
||||
"--enable-nontrapping-float-to-int",
|
||||
"--enable-sign-ext",
|
||||
});
|
||||
run_opt.addArtifactArg(exe);
|
||||
run_opt.addArg("-o");
|
||||
run_opt.addFileArg(b.path("stage1/zig1.wasm"));
|
||||
|
||||
const copy_zig_h = b.addUpdateSourceFiles();
|
||||
const copy_zig_h = b.addWriteFiles();
|
||||
copy_zig_h.addCopyFileToSource(b.path("lib/zig.h"), "stage1/zig.h");
|
||||
|
||||
const update_zig1_step = b.step("update-zig1", "Update stage1/zig1.wasm");
|
||||
@@ -659,59 +620,39 @@ const AddCompilerStepOptions = struct {
|
||||
optimize: std.builtin.OptimizeMode,
|
||||
target: std.Build.ResolvedTarget,
|
||||
strip: ?bool = null,
|
||||
valgrind: ?bool = null,
|
||||
sanitize_thread: ?bool = null,
|
||||
single_threaded: ?bool = null,
|
||||
};
|
||||
|
||||
fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile {
|
||||
const compiler_mod = b.createModule(.{
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zig",
|
||||
.root_source_file = b.path("src/main.zig"),
|
||||
.target = options.target,
|
||||
.optimize = options.optimize,
|
||||
.max_rss = 7_000_000_000,
|
||||
.strip = options.strip,
|
||||
.sanitize_thread = options.sanitize_thread,
|
||||
.single_threaded = options.single_threaded,
|
||||
.code_model = switch (options.target.result.cpu.arch) {
|
||||
// NB:
|
||||
// For loongarch, LLVM supports only small, medium and large
|
||||
// code model. If we don't explicitly specify the code model,
|
||||
// the default value `small' will be used.
|
||||
//
|
||||
// Since zig binary itself is relatively large, using a `small'
|
||||
// code model will cause
|
||||
//
|
||||
// relocation R_LARCH_B26 out of range
|
||||
//
|
||||
// error when linking a loongarch32/loongarch64 zig binary.
|
||||
//
|
||||
// Here we explicitly set code model to `medium' to avoid this
|
||||
// error.
|
||||
.loongarch32, .loongarch64 => .medium,
|
||||
else => .default,
|
||||
},
|
||||
.valgrind = options.valgrind,
|
||||
});
|
||||
|
||||
const aro_mod = b.createModule(.{
|
||||
.root_source_file = b.path("lib/compiler/aro/aro.zig"),
|
||||
});
|
||||
|
||||
const aro_translate_c_mod = b.createModule(.{
|
||||
.root_source_file = b.path("lib/compiler/aro_translate_c.zig"),
|
||||
});
|
||||
|
||||
aro_translate_c_mod.addImport("aro", aro_mod);
|
||||
compiler_mod.addImport("aro", aro_mod);
|
||||
compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "zig",
|
||||
.max_rss = 7_800_000_000,
|
||||
.root_module = compiler_mod,
|
||||
});
|
||||
exe.stack_size = stack_size;
|
||||
|
||||
const aro_module = b.createModule(.{
|
||||
.root_source_file = b.path("lib/compiler/aro/aro.zig"),
|
||||
});
|
||||
|
||||
const aro_translate_c_module = b.createModule(.{
|
||||
.root_source_file = b.path("lib/compiler/aro_translate_c.zig"),
|
||||
.imports = &.{
|
||||
.{
|
||||
.name = "aro",
|
||||
.module = aro_module,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
exe.root_module.addImport("aro", aro_module);
|
||||
exe.root_module.addImport("aro_translate_c", aro_translate_c_module);
|
||||
return exe;
|
||||
}
|
||||
|
||||
@@ -721,11 +662,10 @@ const exe_cflags = [_][]const u8{
|
||||
"-D__STDC_FORMAT_MACROS",
|
||||
"-D__STDC_LIMIT_MACROS",
|
||||
"-D_GNU_SOURCE",
|
||||
"-fvisibility-inlines-hidden",
|
||||
"-fno-exceptions",
|
||||
"-fno-rtti",
|
||||
"-fno-stack-protector",
|
||||
"-fvisibility-inlines-hidden",
|
||||
"-Wno-type-limits",
|
||||
"-Werror=type-limits",
|
||||
"-Wno-missing-braces",
|
||||
"-Wno-comment",
|
||||
};
|
||||
@@ -736,15 +676,11 @@ fn addCmakeCfgOptionsToExe(
|
||||
exe: *std.Build.Step.Compile,
|
||||
use_zig_libcxx: bool,
|
||||
) !void {
|
||||
const mod = exe.root_module;
|
||||
const target = mod.resolved_target.?.result;
|
||||
|
||||
if (target.os.tag.isDarwin()) {
|
||||
if (exe.rootModuleTarget().isDarwin()) {
|
||||
// useful for package maintainers
|
||||
exe.headerpad_max_install_names = true;
|
||||
}
|
||||
|
||||
mod.addObjectFile(.{ .cwd_relative = b.pathJoin(&.{
|
||||
exe.addObjectFile(.{ .cwd_relative = b.pathJoin(&[_][]const u8{
|
||||
cfg.cmake_binary_dir,
|
||||
"zigcpp",
|
||||
b.fmt("{s}{s}{s}", .{
|
||||
@@ -754,53 +690,58 @@ fn addCmakeCfgOptionsToExe(
|
||||
}),
|
||||
}) });
|
||||
assert(cfg.lld_include_dir.len != 0);
|
||||
mod.addIncludePath(.{ .cwd_relative = cfg.lld_include_dir });
|
||||
mod.addIncludePath(.{ .cwd_relative = cfg.llvm_include_dir });
|
||||
mod.addLibraryPath(.{ .cwd_relative = cfg.llvm_lib_dir });
|
||||
addCMakeLibraryList(mod, cfg.clang_libraries);
|
||||
addCMakeLibraryList(mod, cfg.lld_libraries);
|
||||
addCMakeLibraryList(mod, cfg.llvm_libraries);
|
||||
exe.addIncludePath(.{ .cwd_relative = cfg.lld_include_dir });
|
||||
exe.addIncludePath(.{ .cwd_relative = cfg.llvm_include_dir });
|
||||
exe.addLibraryPath(.{ .cwd_relative = cfg.llvm_lib_dir });
|
||||
addCMakeLibraryList(exe, cfg.clang_libraries);
|
||||
addCMakeLibraryList(exe, cfg.lld_libraries);
|
||||
addCMakeLibraryList(exe, cfg.llvm_libraries);
|
||||
|
||||
if (use_zig_libcxx) {
|
||||
mod.link_libcpp = true;
|
||||
exe.linkLibCpp();
|
||||
} else {
|
||||
// System -lc++ must be used because in this code path we are attempting to link
|
||||
// against system-provided LLVM, Clang, LLD.
|
||||
const need_cpp_includes = true;
|
||||
const static = cfg.llvm_linkage == .static;
|
||||
const lib_suffix = if (static) target.staticLibSuffix()[1..] else target.dynamicLibSuffix()[1..];
|
||||
switch (target.os.tag) {
|
||||
const lib_suffix = if (static) exe.rootModuleTarget().staticLibSuffix()[1..] else exe.rootModuleTarget().dynamicLibSuffix()[1..];
|
||||
switch (exe.rootModuleTarget().os.tag) {
|
||||
.linux => {
|
||||
// First we try to link against the detected libcxx name. If that doesn't work, we fall
|
||||
// back to -lc++ and cross our fingers.
|
||||
addCxxKnownPath(b, cfg, exe, b.fmt("lib{s}.{s}", .{ cfg.system_libcxx, lib_suffix }), "", need_cpp_includes) catch |err| switch (err) {
|
||||
error.RequiredLibraryNotFound => {
|
||||
mod.link_libcpp = true;
|
||||
exe.linkLibCpp();
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
mod.linkSystemLibrary("unwind", .{});
|
||||
exe.linkSystemLibrary("unwind");
|
||||
},
|
||||
.ios, .macos, .watchos, .tvos, .visionos => {
|
||||
mod.link_libcpp = true;
|
||||
.ios, .macos, .watchos, .tvos => {
|
||||
exe.linkLibCpp();
|
||||
},
|
||||
.windows => {
|
||||
if (target.abi != .msvc) mod.link_libcpp = true;
|
||||
if (exe.rootModuleTarget().abi != .msvc) exe.linkLibCpp();
|
||||
},
|
||||
.freebsd => {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
if (static) try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
if (static) {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
} else {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
}
|
||||
},
|
||||
.openbsd => {
|
||||
// - llvm requires libexecinfo which has conflicting symbols with libc++abi
|
||||
// - only an issue with .a linking
|
||||
// - workaround is to link c++abi dynamically
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{target.dynamicLibSuffix()[1..]}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{target.dynamicLibSuffix()[1..]}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
},
|
||||
.netbsd, .dragonfly => {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
if (static) try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
if (static) {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
} else {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
}
|
||||
},
|
||||
.solaris, .illumos => {
|
||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||
@@ -814,46 +755,46 @@ fn addCmakeCfgOptionsToExe(
|
||||
}
|
||||
|
||||
if (cfg.dia_guids_lib.len != 0) {
|
||||
mod.addObjectFile(.{ .cwd_relative = cfg.dia_guids_lib });
|
||||
exe.addObjectFile(.{ .cwd_relative = cfg.dia_guids_lib });
|
||||
}
|
||||
}
|
||||
|
||||
fn addStaticLlvmOptionsToModule(mod: *std.Build.Module) !void {
|
||||
fn addStaticLlvmOptionsToExe(exe: *std.Build.Step.Compile) !void {
|
||||
// Adds the Zig C++ sources which both stage1 and stage2 need.
|
||||
//
|
||||
// We need this because otherwise zig_clang_cc1_main.cpp ends up pulling
|
||||
// in a dependency on llvm::cfg::Update<llvm::BasicBlock*>::dump() which is
|
||||
// unavailable when LLVM is compiled in Release mode.
|
||||
const zig_cpp_cflags = exe_cflags ++ [_][]const u8{"-DNDEBUG=1"};
|
||||
mod.addCSourceFiles(.{
|
||||
exe.addCSourceFiles(.{
|
||||
.files = &zig_cpp_sources,
|
||||
.flags = &zig_cpp_cflags,
|
||||
});
|
||||
|
||||
for (clang_libs) |lib_name| {
|
||||
mod.linkSystemLibrary(lib_name, .{});
|
||||
exe.linkSystemLibrary(lib_name);
|
||||
}
|
||||
|
||||
for (lld_libs) |lib_name| {
|
||||
mod.linkSystemLibrary(lib_name, .{});
|
||||
exe.linkSystemLibrary(lib_name);
|
||||
}
|
||||
|
||||
for (llvm_libs) |lib_name| {
|
||||
mod.linkSystemLibrary(lib_name, .{});
|
||||
exe.linkSystemLibrary(lib_name);
|
||||
}
|
||||
|
||||
mod.linkSystemLibrary("z", .{});
|
||||
mod.linkSystemLibrary("zstd", .{});
|
||||
exe.linkSystemLibrary("z");
|
||||
exe.linkSystemLibrary("zstd");
|
||||
|
||||
if (mod.resolved_target.?.result.os.tag != .windows or mod.resolved_target.?.result.abi != .msvc) {
|
||||
if (exe.rootModuleTarget().os.tag != .windows or exe.rootModuleTarget().abi != .msvc) {
|
||||
// This means we rely on clang-or-zig-built LLVM, Clang, LLD libraries.
|
||||
mod.linkSystemLibrary("c++", .{});
|
||||
exe.linkSystemLibrary("c++");
|
||||
}
|
||||
|
||||
if (mod.resolved_target.?.result.os.tag == .windows) {
|
||||
mod.linkSystemLibrary("version", .{});
|
||||
mod.linkSystemLibrary("uuid", .{});
|
||||
mod.linkSystemLibrary("ole32", .{});
|
||||
if (exe.rootModuleTarget().os.tag == .windows) {
|
||||
exe.linkSystemLibrary("version");
|
||||
exe.linkSystemLibrary("uuid");
|
||||
exe.linkSystemLibrary("ole32");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,33 +827,29 @@ fn addCxxKnownPath(
|
||||
}
|
||||
return error.RequiredLibraryNotFound;
|
||||
}
|
||||
// By default, explicit library paths are not checked for being linker scripts,
|
||||
// but libc++ may very well be one, so force all inputs to be checked when passing
|
||||
// an explicit path to libc++.
|
||||
exe.allow_so_scripts = true;
|
||||
exe.root_module.addObjectFile(.{ .cwd_relative = path_unpadded });
|
||||
exe.addObjectFile(.{ .cwd_relative = path_unpadded });
|
||||
|
||||
// TODO a way to integrate with system c++ include files here
|
||||
// c++ -E -Wp,-v -xc++ /dev/null
|
||||
if (need_cpp_includes) {
|
||||
// I used these temporarily for testing something but we obviously need a
|
||||
// more general purpose solution here.
|
||||
//exe.root_module.addIncludePath("/nix/store/2lr0fc0ak8rwj0k8n3shcyz1hz63wzma-gcc-11.3.0/include/c++/11.3.0");
|
||||
//exe.root_module.addIncludePath("/nix/store/2lr0fc0ak8rwj0k8n3shcyz1hz63wzma-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu");
|
||||
//exe.addIncludePath("/nix/store/2lr0fc0ak8rwj0k8n3shcyz1hz63wzma-gcc-11.3.0/include/c++/11.3.0");
|
||||
//exe.addIncludePath("/nix/store/2lr0fc0ak8rwj0k8n3shcyz1hz63wzma-gcc-11.3.0/include/c++/11.3.0/x86_64-unknown-linux-gnu");
|
||||
}
|
||||
}
|
||||
|
||||
fn addCMakeLibraryList(mod: *std.Build.Module, list: []const u8) void {
|
||||
fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
|
||||
var it = mem.tokenizeScalar(u8, list, ';');
|
||||
while (it.next()) |lib| {
|
||||
if (mem.startsWith(u8, lib, "-l")) {
|
||||
mod.linkSystemLibrary(lib["-l".len..], .{});
|
||||
} else if (mod.resolved_target.?.result.os.tag == .windows and
|
||||
exe.linkSystemLibrary(lib["-l".len..]);
|
||||
} else if (exe.rootModuleTarget().os.tag == .windows and
|
||||
mem.endsWith(u8, lib, ".lib") and !fs.path.isAbsolute(lib))
|
||||
{
|
||||
mod.linkSystemLibrary(lib[0 .. lib.len - ".lib".len], .{});
|
||||
exe.linkSystemLibrary(lib[0 .. lib.len - ".lib".len]);
|
||||
} else {
|
||||
mod.addObjectFile(.{ .cwd_relative = lib });
|
||||
exe.addObjectFile(.{ .cwd_relative = lib });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1117,7 +1054,6 @@ const clang_libs = [_][]const u8{
|
||||
"clangAST",
|
||||
"clangParse",
|
||||
"clangSema",
|
||||
"clangAPINotes",
|
||||
"clangBasic",
|
||||
"clangEdit",
|
||||
"clangLex",
|
||||
@@ -1129,8 +1065,6 @@ const clang_libs = [_][]const u8{
|
||||
"clangToolingCore",
|
||||
"clangExtractAPI",
|
||||
"clangSupport",
|
||||
"clangInstallAPI",
|
||||
"clangAST",
|
||||
};
|
||||
const lld_libs = [_][]const u8{
|
||||
"lldMinGW",
|
||||
@@ -1149,10 +1083,8 @@ const llvm_libs = [_][]const u8{
|
||||
"LLVMXRay",
|
||||
"LLVMLibDriver",
|
||||
"LLVMDlltoolDriver",
|
||||
"LLVMTextAPIBinaryReader",
|
||||
"LLVMCoverage",
|
||||
"LLVMLineEditor",
|
||||
"LLVMSandboxIR",
|
||||
"LLVMXCoreDisassembler",
|
||||
"LLVMXCoreCodeGen",
|
||||
"LLVMXCoreDesc",
|
||||
@@ -1252,7 +1184,6 @@ const llvm_libs = [_][]const u8{
|
||||
"LLVMAArch64Desc",
|
||||
"LLVMAArch64Utils",
|
||||
"LLVMAArch64Info",
|
||||
"LLVMOrcDebugging",
|
||||
"LLVMOrcJIT",
|
||||
"LLVMWindowsDriver",
|
||||
"LLVMMCJIT",
|
||||
@@ -1272,7 +1203,6 @@ const llvm_libs = [_][]const u8{
|
||||
"LLVMMCDisassembler",
|
||||
"LLVMLTO",
|
||||
"LLVMPasses",
|
||||
"LLVMHipStdPar",
|
||||
"LLVMCFGuard",
|
||||
"LLVMCoroutines",
|
||||
"LLVMipo",
|
||||
@@ -1280,15 +1210,11 @@ const llvm_libs = [_][]const u8{
|
||||
"LLVMLinker",
|
||||
"LLVMInstrumentation",
|
||||
"LLVMFrontendOpenMP",
|
||||
"LLVMFrontendOffloading",
|
||||
"LLVMFrontendOpenACC",
|
||||
"LLVMFrontendHLSL",
|
||||
"LLVMFrontendDriver",
|
||||
"LLVMExtensions",
|
||||
"LLVMDWARFLinkerParallel",
|
||||
"LLVMDWARFLinkerClassic",
|
||||
"LLVMDWARFLinker",
|
||||
"LLVMCodeGenData",
|
||||
"LLVMGlobalISel",
|
||||
"LLVMMIRParser",
|
||||
"LLVMAsmPrinter",
|
||||
@@ -1330,69 +1256,3 @@ const llvm_libs = [_][]const u8{
|
||||
"LLVMSupport",
|
||||
"LLVMDemangle",
|
||||
};
|
||||
|
||||
fn generateLangRef(b: *std.Build) std.Build.LazyPath {
|
||||
const doctest_exe = b.addExecutable(.{
|
||||
.name = "doctest",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("tools/doctest.zig"),
|
||||
.target = b.graph.host,
|
||||
.optimize = .Debug,
|
||||
}),
|
||||
});
|
||||
|
||||
var dir = b.build_root.handle.openDir("doc/langref", .{ .iterate = true }) catch |err| {
|
||||
std.debug.panic("unable to open '{}doc/langref' directory: {s}", .{
|
||||
b.build_root, @errorName(err),
|
||||
});
|
||||
};
|
||||
defer dir.close();
|
||||
|
||||
var wf = b.addWriteFiles();
|
||||
|
||||
var it = dir.iterateAssumeFirstIteration();
|
||||
while (it.next() catch @panic("failed to read dir")) |entry| {
|
||||
if (std.mem.startsWith(u8, entry.name, ".") or entry.kind != .file)
|
||||
continue;
|
||||
|
||||
const out_basename = b.fmt("{s}.out", .{std.fs.path.stem(entry.name)});
|
||||
const cmd = b.addRunArtifact(doctest_exe);
|
||||
cmd.addArgs(&.{
|
||||
"--zig", b.graph.zig_exe,
|
||||
// TODO: enhance doctest to use "--listen=-" rather than operating
|
||||
// in a temporary directory
|
||||
"--cache-root", b.cache_root.path orelse ".",
|
||||
});
|
||||
cmd.addArgs(&.{ "--zig-lib-dir", b.fmt("{}", .{b.graph.zig_lib_directory}) });
|
||||
cmd.addArgs(&.{"-i"});
|
||||
cmd.addFileArg(b.path(b.fmt("doc/langref/{s}", .{entry.name})));
|
||||
|
||||
cmd.addArgs(&.{"-o"});
|
||||
_ = wf.addCopyFile(cmd.addOutputFileArg(out_basename), out_basename);
|
||||
}
|
||||
|
||||
const docgen_exe = b.addExecutable(.{
|
||||
.name = "docgen",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("tools/docgen.zig"),
|
||||
.target = b.graph.host,
|
||||
.optimize = .Debug,
|
||||
}),
|
||||
});
|
||||
|
||||
const docgen_cmd = b.addRunArtifact(docgen_exe);
|
||||
docgen_cmd.addArgs(&.{"--code-dir"});
|
||||
docgen_cmd.addDirectoryArg(wf.getDirectory());
|
||||
|
||||
docgen_cmd.addFileArg(b.path("doc/langref.html.in"));
|
||||
return docgen_cmd.addOutputFileArg("langref.html");
|
||||
}
|
||||
|
||||
fn superHtmlCheck(b: *std.Build, html_file: std.Build.LazyPath) *std.Build.Step {
|
||||
const run_superhtml = b.addSystemCommand(&.{
|
||||
"superhtml", "check",
|
||||
});
|
||||
run_superhtml.addFileArg(html_file);
|
||||
run_superhtml.expectExitCode(0);
|
||||
return &run_superhtml.step;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// The Zig compiler is not intended to be consumed as a package.
|
||||
// The sole purpose of this manifest file is to test the compiler.
|
||||
.{
|
||||
.name = .zig,
|
||||
.name = "zig",
|
||||
.version = "0.0.0",
|
||||
.dependencies = .{
|
||||
.standalone_test_cases = .{
|
||||
@@ -12,5 +12,4 @@
|
||||
},
|
||||
},
|
||||
.paths = .{""},
|
||||
.fingerprint = 0xc1ce108124179e16,
|
||||
}
|
||||
|
||||
@@ -8,29 +8,30 @@ set -e
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.203+d3bc1cfc4"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/local/bin:$PATH"
|
||||
export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-debug
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
@@ -48,26 +49,39 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
# TODO: move this to a build.zig step (check-fmt)
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-debug/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-debug/bin/zig build \
|
||||
-Dtarget=arm-linux-musleabihf \
|
||||
-Dno-lib
|
||||
|
||||
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
|
||||
# TODO: add -fqemu back to this line
|
||||
stage3-debug/bin/zig build test docs \
|
||||
--maxrss 24696061952 \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$PWD/../lib" \
|
||||
-Denable-superhtml
|
||||
--zig-lib-dir "$PWD/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
# TODO: move this to a build.zig flag (-Denable-tidy)
|
||||
tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
|
||||
|
||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||
stage3-debug/bin/zig build update-zig1
|
||||
|
||||
rm -rf ../build-new
|
||||
mkdir ../build-new
|
||||
cd ../build-new
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
|
||||
@@ -8,29 +8,30 @@ set -e
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.203+d3bc1cfc4"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/local/bin:$PATH"
|
||||
export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-release
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
@@ -48,42 +49,39 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
# TODO: move this to a build.zig step (check-fmt)
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-release/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-release
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-release/bin/zig build \
|
||||
-Dtarget=arm-linux-musleabihf \
|
||||
-Dno-lib
|
||||
|
||||
# No -fqemu and -fwasmtime here as they're covered by the x86_64-linux scripts.
|
||||
# TODO: add -fqemu back to this line
|
||||
stage3-release/bin/zig build test docs \
|
||||
--maxrss 24696061952 \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$PWD/../lib" \
|
||||
-Denable-superhtml
|
||||
--zig-lib-dir "$PWD/../lib"
|
||||
|
||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||
stage3-release/bin/zig build \
|
||||
--prefix stage4-release \
|
||||
-Denable-llvm \
|
||||
-Dno-lib \
|
||||
-Doptimize=ReleaseFast \
|
||||
-Dstrip \
|
||||
-Dtarget=$TARGET \
|
||||
-Duse-zig-libcxx \
|
||||
-Dversion-string="$(stage3-release/bin/zig version)"
|
||||
|
||||
# diff returns an error code if the files differ.
|
||||
echo "If the following command fails, it means nondeterminism has been"
|
||||
echo "introduced, making stage3 and stage4 no longer byte-for-byte identical."
|
||||
diff stage3-release/bin/zig stage4-release/bin/zig
|
||||
# Look for HTML errors.
|
||||
# TODO: move this to a build.zig flag (-Denable-tidy)
|
||||
tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
|
||||
|
||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||
stage3-release/bin/zig build update-zig1
|
||||
|
||||
rm -rf ../build-new
|
||||
mkdir ../build-new
|
||||
cd ../build-new
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
|
||||
@@ -9,16 +9,10 @@ set -e
|
||||
ZIGDIR="$PWD"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.467+0345d7866"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
if [ ! -d "$PREFIX" ]; then
|
||||
cd $HOME
|
||||
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
fi
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
@@ -26,15 +20,15 @@ cd $ZIGDIR
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
PATH="$HOME/local/bin:$PATH" cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
|
||||
@@ -9,16 +9,10 @@ set -e
|
||||
ZIGDIR="$PWD"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.467+0345d7866"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
if [ ! -d "$PREFIX" ]; then
|
||||
cd $HOME
|
||||
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
fi
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
@@ -26,15 +20,15 @@ cd $ZIGDIR
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
PATH="$HOME/local/bin:$PATH" cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
$TARGET = "$($Env:ARCH)-windows-gnu"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.12.0-dev.2087+e9a18010b"
|
||||
$MCPU = "baseline"
|
||||
$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
||||
$PREFIX_PATH = "$(Get-Location)\..\$ZIG_LLVM_CLANG_LLD_NAME"
|
||||
@@ -30,16 +30,17 @@ if ((git rev-parse --is-shallow-repository) -eq "true") {
|
||||
git fetch --unshallow # `git describe` won't work on a shallow repo
|
||||
}
|
||||
|
||||
Write-Output "Building from source..."
|
||||
Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore
|
||||
New-Item -Path 'build-release' -ItemType Directory
|
||||
Set-Location -Path 'build-release'
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
$Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
|
||||
$Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
|
||||
|
||||
Write-Output "Building from source..."
|
||||
New-Item -Path 'build-release' -ItemType Directory
|
||||
Set-Location -Path 'build-release'
|
||||
|
||||
# CMake gives a syntax error when file paths with backward slashes are used.
|
||||
# Here, we use forward slashes only to work around this.
|
||||
& cmake .. `
|
||||
@@ -68,22 +69,3 @@ Write-Output "Main test suite..."
|
||||
-Dskip-non-native `
|
||||
-Denable-symlinks-windows
|
||||
CheckLastExitCode
|
||||
|
||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||
Write-Output "Build and compare stage4..."
|
||||
& "stage3-release\bin\zig.exe" build `
|
||||
--prefix stage4-release `
|
||||
-Denable-llvm `
|
||||
-Dno-lib `
|
||||
-Doptimize=ReleaseFast `
|
||||
-Dstrip `
|
||||
-Dtarget="$TARGET" `
|
||||
-Duse-zig-libcxx `
|
||||
-Dversion-string="$(stage3-release\bin\zig version)"
|
||||
CheckLastExitCode
|
||||
|
||||
# Compare-Object returns an error code if the files differ.
|
||||
Write-Output "If the following command fails, it means nondeterminism has been"
|
||||
Write-Output "introduced, making stage3 and stage4 no longer byte-for-byte identical."
|
||||
Compare-Object (Get-Content stage3-release\bin\zig.exe) (Get-Content stage4-release\bin\zig.exe)
|
||||
CheckLastExitCode
|
||||
|
||||
@@ -8,34 +8,37 @@ set -e
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.203+d3bc1cfc4"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v29.0.0-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-9.2.0-rc1/bin:$HOME/local/bin:$PATH"
|
||||
export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-8.2.1/bin:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
# Test building from source without LLVM.
|
||||
git clean -fd
|
||||
rm -rf zig-out
|
||||
cc -o bootstrap bootstrap.c
|
||||
./bootstrap
|
||||
./zig2 build -Dno-lib
|
||||
./zig-out/bin/zig test test/behavior.zig
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-debug
|
||||
mkdir build-debug
|
||||
cd build-debug
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
|
||||
@@ -54,6 +57,12 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
# TODO: move this to a build.zig step (check-fmt)
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-debug/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-debug/bin/zig build \
|
||||
-Dtarget=arm-linux-musleabihf \
|
||||
@@ -61,21 +70,26 @@ stage3-debug/bin/zig build \
|
||||
|
||||
stage3-debug/bin/zig build test docs \
|
||||
--maxrss 21000000000 \
|
||||
-Dlldb=$HOME/deps/lldb-zig/Debug-e0a42bb34/bin/lldb \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$PWD/../lib" \
|
||||
-Denable-superhtml
|
||||
--zig-lib-dir "$PWD/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
# TODO: move this to a build.zig flag (-Denable-tidy)
|
||||
tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
|
||||
|
||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||
stage3-debug/bin/zig build update-zig1
|
||||
|
||||
rm -rf ../build-new
|
||||
mkdir ../build-new
|
||||
cd ../build-new
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
|
||||
@@ -8,34 +8,37 @@ set -e
|
||||
ARCH="$(uname -m)"
|
||||
TARGET="$ARCH-linux-musl"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.203+d3bc1cfc4"
|
||||
PREFIX="$HOME/deps/$CACHE_BASENAME"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
export PATH="$HOME/deps/wasmtime-v29.0.0-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-9.2.0-rc1/bin:$HOME/local/bin:$PATH"
|
||||
export PATH="$HOME/deps/wasmtime-v10.0.2-$ARCH-linux:$HOME/deps/qemu-linux-x86_64-8.2.1/bin:$PATH"
|
||||
|
||||
# Make the `zig version` number consistent.
|
||||
# This will affect the cmake command below.
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
# Test building from source without LLVM.
|
||||
git clean -fd
|
||||
rm -rf zig-out
|
||||
cc -o bootstrap bootstrap.c
|
||||
./bootstrap
|
||||
./zig2 build -Dno-lib
|
||||
./zig-out/bin/zig test test/behavior.zig
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
rm -rf build-release
|
||||
mkdir build-release
|
||||
cd build-release
|
||||
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_INSTALL_PREFIX="stage3-release" \
|
||||
@@ -54,6 +57,13 @@ unset CXX
|
||||
|
||||
ninja install
|
||||
|
||||
# TODO: move this to a build.zig step (check-fmt)
|
||||
echo "Looking for non-conforming code formatting..."
|
||||
stage3-release/bin/zig fmt --check .. \
|
||||
--exclude ../test/cases/ \
|
||||
--exclude ../build-debug \
|
||||
--exclude ../build-release
|
||||
|
||||
# simultaneously test building self-hosted without LLVM and with 32-bit arm
|
||||
stage3-release/bin/zig build \
|
||||
-Dtarget=arm-linux-musleabihf \
|
||||
@@ -61,14 +71,16 @@ stage3-release/bin/zig build \
|
||||
|
||||
stage3-release/bin/zig build test docs \
|
||||
--maxrss 21000000000 \
|
||||
-Dlldb=$HOME/deps/lldb-zig/Release-e0a42bb34/bin/lldb \
|
||||
-fqemu \
|
||||
-fwasmtime \
|
||||
-Dstatic-llvm \
|
||||
-Dtarget=native-native-musl \
|
||||
--search-prefix "$PREFIX" \
|
||||
--zig-lib-dir "$PWD/../lib" \
|
||||
-Denable-superhtml
|
||||
--zig-lib-dir "$PWD/../lib"
|
||||
|
||||
# Look for HTML errors.
|
||||
# TODO: move this to a build.zig flag (-Denable-tidy)
|
||||
tidy --drop-empty-elements no -qe "../zig-out/doc/langref.html"
|
||||
|
||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||
stage3-release/bin/zig build \
|
||||
@@ -89,9 +101,12 @@ diff stage3-release/bin/zig stage4-release/bin/zig
|
||||
# Ensure that updating the wasm binary from this commit will result in a viable build.
|
||||
stage3-release/bin/zig build update-zig1
|
||||
|
||||
rm -rf ../build-new
|
||||
mkdir ../build-new
|
||||
cd ../build-new
|
||||
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
|
||||
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
|
||||
|
||||
|
||||
@@ -6,16 +6,17 @@ set -e
|
||||
ZIGDIR="$PWD"
|
||||
TARGET="$ARCH-macos-none"
|
||||
MCPU="baseline"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.12.0-dev.467+0345d7866"
|
||||
PREFIX="$HOME/$CACHE_BASENAME"
|
||||
JOBS="-j3"
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
if [ ! -d "$PREFIX" ]; then
|
||||
cd $HOME
|
||||
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
fi
|
||||
rm -rf $PREFIX
|
||||
cd $HOME
|
||||
|
||||
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
|
||||
tar xf "$CACHE_BASENAME.tar.xz"
|
||||
|
||||
ZIG="$PREFIX/bin/zig"
|
||||
|
||||
cd $ZIGDIR
|
||||
|
||||
@@ -24,21 +25,24 @@ cd $ZIGDIR
|
||||
git fetch --unshallow || true
|
||||
git fetch --tags
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
# Test building from source without LLVM.
|
||||
git clean -fd
|
||||
rm -rf zig-out
|
||||
cc -o bootstrap bootstrap.c
|
||||
./bootstrap
|
||||
./zig2 build -Dno-lib
|
||||
./zig-out/bin/zig test test/behavior.zig
|
||||
|
||||
rm -rf build
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
|
||||
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
|
||||
|
||||
cmake .. \
|
||||
-DCMAKE_PREFIX_PATH="$PREFIX" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
$TARGET = "$($Env:ARCH)-windows-gnu"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.12.0-dev.2073+402fe565a"
|
||||
$MCPU = "baseline"
|
||||
$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
||||
$PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
|
||||
$ZIG = "$PREFIX_PATH\bin\zig.exe"
|
||||
$ZIG_LIB_DIR = "$(Get-Location)\lib"
|
||||
|
||||
if (!(Test-Path "$PREFIX_PATH.zip")) {
|
||||
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
|
||||
Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$PREFIX_PATH.zip"
|
||||
|
||||
Write-Output "Extracting..."
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem ;
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$PREFIX_PATH.zip", "$PREFIX_PATH\..")
|
||||
}
|
||||
|
||||
function CheckLastExitCode {
|
||||
if (!$?) {
|
||||
exit 1
|
||||
@@ -30,13 +20,8 @@ if ((git rev-parse --is-shallow-repository) -eq "true") {
|
||||
git fetch --unshallow # `git describe` won't work on a shallow repo
|
||||
}
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
$Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
|
||||
$Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
|
||||
|
||||
Write-Output "Building from source..."
|
||||
Remove-Item -Path 'build-debug' -Recurse -Force -ErrorAction Ignore
|
||||
New-Item -Path 'build-debug' -ItemType Directory
|
||||
Set-Location -Path 'build-debug'
|
||||
|
||||
@@ -89,8 +74,8 @@ CheckLastExitCode
|
||||
-femit-bin="compiler_rt-x86_64-windows-msvc.c" `
|
||||
--dep build_options `
|
||||
-target x86_64-windows-msvc `
|
||||
-Mroot="..\lib\compiler_rt.zig" `
|
||||
-Mbuild_options="config.zig"
|
||||
--mod root ..\lib\compiler_rt.zig `
|
||||
--mod build_options config.zig
|
||||
CheckLastExitCode
|
||||
|
||||
Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
||||
|
||||
@@ -1,20 +1,10 @@
|
||||
$TARGET = "$($Env:ARCH)-windows-gnu"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.14.0-dev.1622+2ac543388"
|
||||
$ZIG_LLVM_CLANG_LLD_NAME = "zig+llvm+lld+clang-$TARGET-0.12.0-dev.2073+402fe565a"
|
||||
$MCPU = "baseline"
|
||||
$ZIG_LLVM_CLANG_LLD_URL = "https://ziglang.org/deps/$ZIG_LLVM_CLANG_LLD_NAME.zip"
|
||||
$PREFIX_PATH = "$($Env:USERPROFILE)\$ZIG_LLVM_CLANG_LLD_NAME"
|
||||
$ZIG = "$PREFIX_PATH\bin\zig.exe"
|
||||
$ZIG_LIB_DIR = "$(Get-Location)\lib"
|
||||
|
||||
if (!(Test-Path "$PREFIX_PATH.zip")) {
|
||||
Write-Output "Downloading $ZIG_LLVM_CLANG_LLD_URL"
|
||||
Invoke-WebRequest -Uri "$ZIG_LLVM_CLANG_LLD_URL" -OutFile "$PREFIX_PATH.zip"
|
||||
|
||||
Write-Output "Extracting..."
|
||||
Add-Type -AssemblyName System.IO.Compression.FileSystem ;
|
||||
[System.IO.Compression.ZipFile]::ExtractToDirectory("$PREFIX_PATH.zip", "$PREFIX_PATH\..")
|
||||
}
|
||||
|
||||
function CheckLastExitCode {
|
||||
if (!$?) {
|
||||
exit 1
|
||||
@@ -30,13 +20,8 @@ if ((git rev-parse --is-shallow-repository) -eq "true") {
|
||||
git fetch --unshallow # `git describe` won't work on a shallow repo
|
||||
}
|
||||
|
||||
# Override the cache directories because they won't actually help other CI runs
|
||||
# which will be testing alternate versions of zig, and ultimately would just
|
||||
# fill up space on the hard drive for no reason.
|
||||
$Env:ZIG_GLOBAL_CACHE_DIR="$(Get-Location)\zig-global-cache"
|
||||
$Env:ZIG_LOCAL_CACHE_DIR="$(Get-Location)\zig-local-cache"
|
||||
|
||||
Write-Output "Building from source..."
|
||||
Remove-Item -Path 'build-release' -Recurse -Force -ErrorAction Ignore
|
||||
New-Item -Path 'build-release' -ItemType Directory
|
||||
Set-Location -Path 'build-release'
|
||||
|
||||
@@ -69,25 +54,6 @@ Write-Output "Main test suite..."
|
||||
-Denable-symlinks-windows
|
||||
CheckLastExitCode
|
||||
|
||||
# Ensure that stage3 and stage4 are byte-for-byte identical.
|
||||
Write-Output "Build and compare stage4..."
|
||||
& "stage3-release\bin\zig.exe" build `
|
||||
--prefix stage4-release `
|
||||
-Denable-llvm `
|
||||
-Dno-lib `
|
||||
-Doptimize=ReleaseFast `
|
||||
-Dstrip `
|
||||
-Dtarget="$TARGET" `
|
||||
-Duse-zig-libcxx `
|
||||
-Dversion-string="$(stage3-release\bin\zig version)"
|
||||
CheckLastExitCode
|
||||
|
||||
# Compare-Object returns an error code if the files differ.
|
||||
Write-Output "If the following command fails, it means nondeterminism has been"
|
||||
Write-Output "introduced, making stage3 and stage4 no longer byte-for-byte identical."
|
||||
Compare-Object (Get-Content stage3-release\bin\zig.exe) (Get-Content stage4-release\bin\zig.exe)
|
||||
CheckLastExitCode
|
||||
|
||||
Write-Output "Build x86_64-windows-msvc behavior tests using the C backend..."
|
||||
& "stage3-release\bin\zig.exe" test `
|
||||
..\test\behavior.zig `
|
||||
@@ -107,8 +73,8 @@ CheckLastExitCode
|
||||
-femit-bin="compiler_rt-x86_64-windows-msvc.c" `
|
||||
--dep build_options `
|
||||
-target x86_64-windows-msvc `
|
||||
-Mroot="..\lib\compiler_rt.zig" `
|
||||
-Mbuild_options="config.zig"
|
||||
--mod root ..\lib\compiler_rt.zig `
|
||||
--mod build_options config.zig
|
||||
CheckLastExitCode
|
||||
|
||||
Import-Module "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
|
||||
|
||||
@@ -17,10 +17,9 @@ find_path(CLANG_INCLUDE_DIRS NAMES clang/Frontend/ASTUnit.h
|
||||
if(${LLVM_LINK_MODE} STREQUAL "shared")
|
||||
find_library(CLANG_LIBRARIES
|
||||
NAMES
|
||||
libclang-cpp.so.19
|
||||
libclang-cpp.so.19.1
|
||||
clang-cpp-19.0
|
||||
clang-cpp190
|
||||
libclang-cpp.so.17
|
||||
clang-cpp-17.0
|
||||
clang-cpp170
|
||||
clang-cpp
|
||||
NAMES_PER_DIR
|
||||
HINTS "${LLVM_LIBDIRS}"
|
||||
@@ -56,7 +55,6 @@ else()
|
||||
FIND_AND_ADD_CLANG_LIB(clangAST)
|
||||
FIND_AND_ADD_CLANG_LIB(clangParse)
|
||||
FIND_AND_ADD_CLANG_LIB(clangSema)
|
||||
FIND_AND_ADD_CLANG_LIB(clangAPINotes)
|
||||
FIND_AND_ADD_CLANG_LIB(clangBasic)
|
||||
FIND_AND_ADD_CLANG_LIB(clangEdit)
|
||||
FIND_AND_ADD_CLANG_LIB(clangLex)
|
||||
@@ -68,8 +66,6 @@ else()
|
||||
FIND_AND_ADD_CLANG_LIB(clangToolingCore)
|
||||
FIND_AND_ADD_CLANG_LIB(clangExtractAPI)
|
||||
FIND_AND_ADD_CLANG_LIB(clangSupport)
|
||||
FIND_AND_ADD_CLANG_LIB(clangInstallAPI)
|
||||
FIND_AND_ADD_CLANG_LIB(clangAST)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
|
||||
@@ -9,21 +9,21 @@
|
||||
find_path(LLD_INCLUDE_DIRS NAMES lld/Common/Driver.h
|
||||
HINTS ${LLVM_INCLUDE_DIRS}
|
||||
PATHS
|
||||
/usr/lib/llvm-19/include
|
||||
/usr/local/llvm190/include
|
||||
/usr/local/llvm19/include
|
||||
/usr/local/opt/llvm@19/include
|
||||
/opt/homebrew/opt/llvm@19/include
|
||||
/usr/lib/llvm-17/include
|
||||
/usr/local/llvm170/include
|
||||
/usr/local/llvm17/include
|
||||
/usr/local/opt/llvm@17/include
|
||||
/opt/homebrew/opt/llvm@17/include
|
||||
/mingw64/include)
|
||||
|
||||
find_library(LLD_LIBRARY NAMES lld-19.0 lld190 lld NAMES_PER_DIR
|
||||
find_library(LLD_LIBRARY NAMES lld-17.0 lld170 lld NAMES_PER_DIR
|
||||
HINTS ${LLVM_LIBDIRS}
|
||||
PATHS
|
||||
/usr/lib/llvm-19/lib
|
||||
/usr/local/llvm190/lib
|
||||
/usr/local/llvm19/lib
|
||||
/usr/local/opt/llvm@19/lib
|
||||
/opt/homebrew/opt/llvm@19/lib
|
||||
/usr/lib/llvm-17/lib
|
||||
/usr/local/llvm170/lib
|
||||
/usr/local/llvm17/lib
|
||||
/usr/local/opt/llvm@17/lib
|
||||
/opt/homebrew/opt/llvm@17/lib
|
||||
)
|
||||
if(EXISTS ${LLD_LIBRARY})
|
||||
set(LLD_LIBRARIES ${LLD_LIBRARY})
|
||||
@@ -34,11 +34,11 @@ else()
|
||||
HINTS ${LLVM_LIBDIRS}
|
||||
PATHS
|
||||
${LLD_LIBDIRS}
|
||||
/usr/lib/llvm-19/lib
|
||||
/usr/local/llvm190/lib
|
||||
/usr/local/llvm19/lib
|
||||
/usr/local/opt/llvm@19/lib
|
||||
/opt/homebrew/opt/llvm@19/lib
|
||||
/usr/lib/llvm-17/lib
|
||||
/usr/local/llvm170/lib
|
||||
/usr/local/llvm17/lib
|
||||
/usr/local/opt/llvm@17/lib
|
||||
/opt/homebrew/opt/llvm@17/lib
|
||||
/mingw64/lib
|
||||
/c/msys64/mingw64/lib
|
||||
c:/msys64/mingw64/lib)
|
||||
|
||||
@@ -12,17 +12,14 @@
|
||||
if(ZIG_USE_LLVM_CONFIG)
|
||||
set(LLVM_CONFIG_ERROR_MESSAGES "")
|
||||
while(1)
|
||||
# If this variable is not unset, the same result is returned even though
|
||||
# the ignore list has changed, causing the configure process to not
|
||||
# terminate when the right LLVM version is not found.
|
||||
unset(LLVM_CONFIG_EXE CACHE)
|
||||
find_program(LLVM_CONFIG_EXE
|
||||
NAMES llvm-config-19 llvm-config-19.0 llvm-config190 llvm-config19 llvm-config NAMES_PER_DIR
|
||||
NAMES llvm-config-17 llvm-config-17.0 llvm-config170 llvm-config17 llvm-config NAMES_PER_DIR
|
||||
PATHS
|
||||
"/mingw64/bin"
|
||||
"/c/msys64/mingw64/bin"
|
||||
"c:/msys64/mingw64/bin"
|
||||
"C:/Libraries/llvm-19.0.0/bin")
|
||||
"C:/Libraries/llvm-17.0.0/bin")
|
||||
|
||||
if ("${LLVM_CONFIG_EXE}" STREQUAL "LLVM_CONFIG_EXE-NOTFOUND")
|
||||
if (NOT LLVM_CONFIG_ERROR_MESSAGES STREQUAL "")
|
||||
@@ -40,9 +37,9 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
get_filename_component(LLVM_CONFIG_DIR "${LLVM_CONFIG_EXE}" DIRECTORY)
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 19 OR "${LLVM_CONFIG_VERSION}" VERSION_EQUAL 20 OR "${LLVM_CONFIG_VERSION}" VERSION_GREATER 20)
|
||||
if("${LLVM_CONFIG_VERSION}" VERSION_LESS 17 OR "${LLVM_CONFIG_VERSION}" VERSION_EQUAL 18 OR "${LLVM_CONFIG_VERSION}" VERSION_GREATER 18)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "expected LLVM 19.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "expected LLVM 17.x but found ${LLVM_CONFIG_VERSION} using ${LLVM_CONFIG_EXE}")
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
list(APPEND CMAKE_IGNORE_PATH "${LLVM_CONFIG_DIR}")
|
||||
@@ -63,12 +60,12 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
ERROR_VARIABLE LLVM_CONFIG_ERROR
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
if (LLVM_CONFIG_ERROR)
|
||||
if (LLVM_CONFIG_ERROR)
|
||||
# Save the error message, in case this is the last llvm-config we find
|
||||
if (ZIG_SHARED_LLVM)
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 19.x found at ${LLVM_CONFIG_EXE} does not support linking as a shared library")
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 17.x found at ${LLVM_CONFIG_EXE} does not support linking as a shared library")
|
||||
else()
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 19.x found at ${LLVM_CONFIG_EXE} does not support linking as a static library")
|
||||
list(APPEND LLVM_CONFIG_ERROR_MESSAGES "LLVM 17.x found at ${LLVM_CONFIG_EXE} does not support linking as a static library")
|
||||
endif()
|
||||
|
||||
# Ignore this directory and try the search again
|
||||
@@ -176,6 +173,7 @@ if(ZIG_USE_LLVM_CONFIG)
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
string(REPLACE " " ";" LLVM_INCLUDE_DIRS "${LLVM_INCLUDE_DIRS_SPACES}")
|
||||
|
||||
link_directories("${CMAKE_PREFIX_PATH}/lib")
|
||||
link_directories("${LLVM_LIBDIRS}")
|
||||
else()
|
||||
# Here we assume that we're cross compiling with Zig, of course. No reason
|
||||
@@ -197,10 +195,8 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXRay)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLibDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDlltoolDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMTextAPIBinaryReader)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCoverage)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLineEditor)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMSandboxIR)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreCodeGen)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMXCoreDesc)
|
||||
@@ -300,7 +296,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAArch64Desc)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAArch64Utils)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAArch64Info)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcDebugging)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMOrcJIT)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMWindowsDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCJIT)
|
||||
@@ -320,7 +315,6 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMCDisassembler)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLTO)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMPasses)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMHipStdPar)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCFGuard)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCoroutines)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMipo)
|
||||
@@ -328,15 +322,11 @@ else()
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMLinker)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMInstrumentation)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFrontendOpenMP)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFrontendOffloading)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFrontendOpenACC)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFrontendHLSL)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMFrontendDriver)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMExtensions)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDWARFLinkerParallel)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDWARFLinkerClassic)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMDWARFLinker)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMCodeGenData)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMGlobalISel)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMMIRParser)
|
||||
FIND_AND_ADD_LLVM_LIB(LLVMAsmPrinter)
|
||||
|
||||
13
cmake/c_flag_overrides.cmake
Normal file
13
cmake/c_flag_overrides.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
if(MSVC)
|
||||
set(CMAKE_C_FLAGS_DEBUG_INIT
|
||||
"/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
|
||||
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL_INIT
|
||||
"/MT /O1 /Ob1 /D NDEBUG")
|
||||
|
||||
set(CMAKE_C_FLAGS_RELEASE_INIT
|
||||
"/MT /O2 /Ob1 /D NDEBUG")
|
||||
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO_INIT
|
||||
"/MT /Zi /O2 /Ob1 /D NDEBUG")
|
||||
endif()
|
||||
13
cmake/cxx_flag_overrides.cmake
Normal file
13
cmake/cxx_flag_overrides.cmake
Normal file
@@ -0,0 +1,13 @@
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG_INIT
|
||||
"/D_DEBUG /MTd /Zi /Ob0 /Od /RTC1")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL_INIT
|
||||
"/MT /O1 /Ob1 /D NDEBUG")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE_INIT
|
||||
"/MT /O2 /Ob1 /D NDEBUG")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT
|
||||
"/MT /Zi /O2 /Ob1 /D NDEBUG")
|
||||
endif()
|
||||
@@ -1,7 +1,7 @@
|
||||
set(ZIG_INSTALL_ARGS build --prefix "${CMAKE_INSTALL_PREFIX}" ${ZIG_BUILD_ARGS})
|
||||
set(ZIG_INSTALL_ARGS build ${ZIG_BUILD_ARGS} --prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
execute_process(
|
||||
COMMAND "${ZIG_EXECUTABLE}" ${ZIG_INSTALL_ARGS}
|
||||
WORKING_DIRECTORY "${ZIG2_WORKING_DIR}"
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
RESULT_VARIABLE _result)
|
||||
|
||||
if(_result)
|
||||
|
||||
@@ -10,7 +10,7 @@ build.zig.
|
||||
|
||||
### `name`
|
||||
|
||||
Enum literal. Required.
|
||||
String. Required.
|
||||
|
||||
This is the default name used by packages depending on this one. For example,
|
||||
when a user runs `zig fetch --save <url>`, this field is used as the key in the
|
||||
@@ -20,42 +20,12 @@ will stick with this provided value.
|
||||
It is redundant to include "zig" in this name because it is already within the
|
||||
Zig package namespace.
|
||||
|
||||
Must be a valid bare Zig identifier (don't `@` me), limited to 32 bytes.
|
||||
|
||||
Together with `fingerprint`, this represents a globally unique package identifier.
|
||||
|
||||
### `fingerprint`
|
||||
|
||||
Together with `name`, this represents a globally unique package identifier. This
|
||||
field is auto-initialized by the toolchain when the package is first created,
|
||||
and then *never changes*. This allows Zig to unambiguously detect when one
|
||||
package is an updated version of another.
|
||||
|
||||
When forking a Zig project, this fingerprint should be regenerated if the upstream
|
||||
project is still maintained. Otherwise, the fork is *hostile*, attempting to
|
||||
take control over the original project's identity. The fingerprint can be regenerated
|
||||
by deleting the field and running `zig build`.
|
||||
|
||||
This 64-bit integer is the combination of a 32-bit id component and a 32-bit
|
||||
checksum.
|
||||
|
||||
The id component within the fingerprint has these restrictions:
|
||||
|
||||
`0x00000000` is reserved for legacy packages.
|
||||
|
||||
`0xffffffff` is reserved to represent "naked" packages.
|
||||
|
||||
The checksum is computed from `name` and serves to protect Zig users from
|
||||
accidental id collisions.
|
||||
|
||||
### `version`
|
||||
|
||||
String. Required.
|
||||
|
||||
[semver](https://semver.org/)
|
||||
|
||||
Limited to 32 bytes.
|
||||
|
||||
### `minimum_zig_version`
|
||||
|
||||
String. Optional.
|
||||
@@ -77,8 +47,7 @@ String.
|
||||
|
||||
When updating this field to a new URL, be sure to delete the corresponding
|
||||
`hash`, otherwise you are communicating that you expect to find the old hash at
|
||||
the new URL. If the contents of a URL change this will result in a hash mismatch
|
||||
which will prevent zig from using it.
|
||||
the new URL.
|
||||
|
||||
#### `hash`
|
||||
|
||||
|
||||
6024
doc/langref.html.in
6024
doc/langref.html.in
File diff suppressed because it is too large
Load Diff
@@ -1,60 +0,0 @@
|
||||
pub fn syscall1(number: usize, arg1: usize) usize {
|
||||
// Inline assembly is an expression which returns a value.
|
||||
// the `asm` keyword begins the expression.
|
||||
return asm
|
||||
// `volatile` is an optional modifier that tells Zig this
|
||||
// inline assembly expression has side-effects. Without
|
||||
// `volatile`, Zig is allowed to delete the inline assembly
|
||||
// code if the result is unused.
|
||||
volatile (
|
||||
// Next is a comptime string which is the assembly code.
|
||||
// Inside this string one may use `%[ret]`, `%[number]`,
|
||||
// or `%[arg1]` where a register is expected, to specify
|
||||
// the register that Zig uses for the argument or return value,
|
||||
// if the register constraint strings are used. However in
|
||||
// the below code, this is not used. A literal `%` can be
|
||||
// obtained by escaping it with a double percent: `%%`.
|
||||
// Often multiline string syntax comes in handy here.
|
||||
\\syscall
|
||||
// Next is the output. It is possible in the future Zig will
|
||||
// support multiple outputs, depending on how
|
||||
// https://github.com/ziglang/zig/issues/215 is resolved.
|
||||
// It is allowed for there to be no outputs, in which case
|
||||
// this colon would be directly followed by the colon for the inputs.
|
||||
:
|
||||
// This specifies the name to be used in `%[ret]` syntax in
|
||||
// the above assembly string. This example does not use it,
|
||||
// but the syntax is mandatory.
|
||||
[ret]
|
||||
// Next is the output constraint string. This feature is still
|
||||
// considered unstable in Zig, and so LLVM/GCC documentation
|
||||
// must be used to understand the semantics.
|
||||
// http://releases.llvm.org/10.0.0/docs/LangRef.html#inline-asm-constraint-string
|
||||
// https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
|
||||
// In this example, the constraint string means "the result value of
|
||||
// this inline assembly instruction is whatever is in $rax".
|
||||
"={rax}"
|
||||
// Next is either a value binding, or `->` and then a type. The
|
||||
// type is the result type of the inline assembly expression.
|
||||
// If it is a value binding, then `%[ret]` syntax would be used
|
||||
// to refer to the register bound to the value.
|
||||
(-> usize),
|
||||
// Next is the list of inputs.
|
||||
// The constraint for these inputs means, "when the assembly code is
|
||||
// executed, $rax shall have the value of `number` and $rdi shall have
|
||||
// the value of `arg1`". Any number of input parameters is allowed,
|
||||
// including none.
|
||||
: [number] "{rax}" (number),
|
||||
[arg1] "{rdi}" (arg1),
|
||||
// Next is the list of clobbers. These declare a set of registers whose
|
||||
// values will not be preserved by the execution of this assembly code.
|
||||
// These do not include output or input registers. The special clobber
|
||||
// value of "memory" means that the assembly writes to arbitrary undeclared
|
||||
// memory locations - not only the memory pointed to by a declared indirect
|
||||
// output. In this example we list $rcx and $r11 because it is known the
|
||||
// kernel syscall does not preserve these registers.
|
||||
: "rcx", "r11"
|
||||
);
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,18 +0,0 @@
|
||||
//! Because this file contains fields, it is a type which is intended to be instantiated, and so
|
||||
//! is named in TitleCase instead of snake_case by convention.
|
||||
|
||||
foo: u32,
|
||||
bar: u64,
|
||||
|
||||
/// `@This()` can be used to refer to this struct type. In files with fields, it is quite common to
|
||||
/// name the type here, so it can be easily referenced by other declarations in this file.
|
||||
const TopLevelFields = @This();
|
||||
|
||||
pub fn init(val: u32) TopLevelFields {
|
||||
return .{
|
||||
.foo = val,
|
||||
.bar = val * 10,
|
||||
};
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,13 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
pub fn main() void {
|
||||
const byte: u8 = 255;
|
||||
|
||||
const ov = @addWithOverflow(byte, 10);
|
||||
if (ov[1] != 0) {
|
||||
print("overflowed result: {}\n", .{ov[0]});
|
||||
} else {
|
||||
print("result: {}\n", .{ov[0]});
|
||||
}
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,16 +0,0 @@
|
||||
const Node = struct {
|
||||
next: ?*Node,
|
||||
name: []const u8,
|
||||
};
|
||||
|
||||
var node_a = Node{
|
||||
.next = null,
|
||||
.name = "Node A",
|
||||
};
|
||||
|
||||
var node_b = Node{
|
||||
.next = &node_a,
|
||||
.name = "Node B",
|
||||
};
|
||||
|
||||
// syntax
|
||||
@@ -1,9 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
var x: i32 = undefined;
|
||||
x = 1;
|
||||
print("{d}", .{x});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,26 +0,0 @@
|
||||
const Threshold = struct {
|
||||
minimum: f32 = 0.25,
|
||||
maximum: f32 = 0.75,
|
||||
|
||||
const Category = enum { low, medium, high };
|
||||
|
||||
fn categorize(t: Threshold, value: f32) Category {
|
||||
assert(t.maximum >= t.minimum);
|
||||
if (value < t.minimum) return .low;
|
||||
if (value > t.maximum) return .high;
|
||||
return .medium;
|
||||
}
|
||||
};
|
||||
|
||||
pub fn main() !void {
|
||||
var threshold: Threshold = .{
|
||||
.maximum = 0.20,
|
||||
};
|
||||
const category = threshold.categorize(0.90);
|
||||
try std.io.getStdOut().writeAll(@tagName(category));
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
const assert = std.debug.assert;
|
||||
|
||||
// exe=fail
|
||||
@@ -1,17 +0,0 @@
|
||||
const base64 = @import("std").base64;
|
||||
|
||||
export fn decode_base_64(
|
||||
dest_ptr: [*]u8,
|
||||
dest_len: usize,
|
||||
source_ptr: [*]const u8,
|
||||
source_len: usize,
|
||||
) usize {
|
||||
const src = source_ptr[0..source_len];
|
||||
const dest = dest_ptr[0..dest_len];
|
||||
const base64_decoder = base64.standard.Decoder;
|
||||
const decoded_size = base64_decoder.calcSizeForSlice(src) catch unreachable;
|
||||
base64_decoder.decode(dest[0..decoded_size], src) catch unreachable;
|
||||
return decoded_size;
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,13 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "example",
|
||||
.root_source_file = b.path("example.zig"),
|
||||
.optimize = optimize,
|
||||
});
|
||||
b.default_step.dependOn(&exe.step);
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,24 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const lib = b.addSharedLibrary(.{
|
||||
.name = "mathtest",
|
||||
.root_source_file = b.path("mathtest.zig"),
|
||||
.version = .{ .major = 1, .minor = 0, .patch = 0 },
|
||||
});
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "test",
|
||||
});
|
||||
exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
|
||||
exe.linkLibrary(lib);
|
||||
exe.linkSystemLibrary("c");
|
||||
|
||||
b.default_step.dependOn(&exe.step);
|
||||
|
||||
const run_cmd = exe.run();
|
||||
|
||||
const test_step = b.step("test", "Test the program");
|
||||
test_step.dependOn(&run_cmd.step);
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,18 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn build(b: *std.Build) void {
|
||||
const obj = b.addObject(.{
|
||||
.name = "base64",
|
||||
.root_source_file = b.path("base64.zig"),
|
||||
});
|
||||
|
||||
const exe = b.addExecutable(.{
|
||||
.name = "test",
|
||||
});
|
||||
exe.addCSourceFile(.{ .file = b.path("test.c"), .flags = &.{"-std=c99"} });
|
||||
exe.addObject(obj);
|
||||
exe.linkSystemLibrary("c");
|
||||
b.installArtifact(exe);
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,35 +0,0 @@
|
||||
pub const CallModifier = enum {
|
||||
/// Equivalent to function call syntax.
|
||||
auto,
|
||||
|
||||
/// Equivalent to async keyword used with function call syntax.
|
||||
async_kw,
|
||||
|
||||
/// Prevents tail call optimization. This guarantees that the return
|
||||
/// address will point to the callsite, as opposed to the callsite's
|
||||
/// callsite. If the call is otherwise required to be tail-called
|
||||
/// or inlined, a compile error is emitted instead.
|
||||
never_tail,
|
||||
|
||||
/// Guarantees that the call will not be inlined. If the call is
|
||||
/// otherwise required to be inlined, a compile error is emitted instead.
|
||||
never_inline,
|
||||
|
||||
/// Asserts that the function call will not suspend. This allows a
|
||||
/// non-async function to call an async function.
|
||||
no_async,
|
||||
|
||||
/// Guarantees that the call will be generated with tail call optimization.
|
||||
/// If this is not possible, a compile error is emitted instead.
|
||||
always_tail,
|
||||
|
||||
/// Guarantees that the call will be inlined at the callsite.
|
||||
/// If this is not possible, a compile error is emitted instead.
|
||||
always_inline,
|
||||
|
||||
/// Evaluates the call at compile-time. If the call cannot be completed at
|
||||
/// compile-time, a compile error is emitted instead.
|
||||
compile_time,
|
||||
};
|
||||
|
||||
// syntax
|
||||
@@ -1,11 +0,0 @@
|
||||
const c = @cImport({
|
||||
// See https://github.com/ziglang/zig/issues/515
|
||||
@cDefine("_NO_CRT_STDIO_INLINE", "1");
|
||||
@cInclude("stdio.h");
|
||||
});
|
||||
pub fn main() void {
|
||||
_ = c.printf("hello\n");
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
// link_libc
|
||||
@@ -1,8 +0,0 @@
|
||||
const parseU64 = @import("error_union_parsing_u64.zig").parseU64;
|
||||
|
||||
fn doAThing(str: []u8) void {
|
||||
const number = parseU64(str, 10) catch 13;
|
||||
_ = number; // ...
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,8 +0,0 @@
|
||||
const parseU64 = @import("error_union_parsing_u64.zig").parseU64;
|
||||
|
||||
fn doAThing(str: []u8) !void {
|
||||
const number = parseU64(str, 10) catch |err| return err;
|
||||
_ = number; // ...
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,18 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
const Foo = union {
|
||||
float: f32,
|
||||
int: u32,
|
||||
};
|
||||
|
||||
pub fn main() void {
|
||||
var f = Foo{ .int = 42 };
|
||||
bar(&f);
|
||||
}
|
||||
|
||||
fn bar(f: *Foo) void {
|
||||
f.* = Foo{ .float = 12.34 };
|
||||
std.debug.print("value: {}\n", .{f.float});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,16 +0,0 @@
|
||||
const Foo = struct {};
|
||||
fn doSomethingWithFoo(foo: *Foo) void {
|
||||
_ = foo;
|
||||
}
|
||||
|
||||
fn doAThing(optional_foo: ?*Foo) void {
|
||||
// do some stuff
|
||||
|
||||
if (optional_foo) |foo| {
|
||||
doSomethingWithFoo(foo);
|
||||
}
|
||||
|
||||
// do some stuff
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,13 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
|
||||
defer arena.deinit();
|
||||
|
||||
const allocator = arena.allocator();
|
||||
|
||||
const ptr = try allocator.create(i32);
|
||||
std.debug.print("ptr={*}\n", .{ptr});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,12 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
// Comments in Zig start with "//" and end at the next LF byte (end of line).
|
||||
// The line below is a comment and won't be executed.
|
||||
|
||||
//print("Hello?", .{});
|
||||
|
||||
print("Hello, world!\n", .{}); // another comment
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,11 +0,0 @@
|
||||
fn max(comptime T: type, a: T, b: T) T {
|
||||
return if (a > b) a else b;
|
||||
}
|
||||
fn gimmeTheBiggerFloat(a: f32, b: f32) f32 {
|
||||
return max(f32, a, b);
|
||||
}
|
||||
fn gimmeTheBiggerInteger(a: u64, b: u64) u64 {
|
||||
return max(u64, a, b);
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,4 +0,0 @@
|
||||
const builtin = @import("builtin");
|
||||
const separator = if (builtin.os.tag == .windows) '\\' else '/';
|
||||
|
||||
// syntax
|
||||
@@ -1,7 +0,0 @@
|
||||
fn max(a: bool, b: bool) bool {
|
||||
{
|
||||
return a or b;
|
||||
}
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,15 +0,0 @@
|
||||
const x = 1234;
|
||||
|
||||
fn foo() void {
|
||||
// It works at file scope as well as inside functions.
|
||||
const y = 5678;
|
||||
|
||||
// Once assigned, an identifier cannot be changed.
|
||||
y += 1;
|
||||
}
|
||||
|
||||
pub fn main() void {
|
||||
foo();
|
||||
}
|
||||
|
||||
// exe=build_fail
|
||||
@@ -1,22 +0,0 @@
|
||||
const std = @import("std");
|
||||
const expect = std.testing.expect;
|
||||
const print = std.debug.print;
|
||||
|
||||
test "defer unwinding" {
|
||||
print("\n", .{});
|
||||
|
||||
defer {
|
||||
print("1 ", .{});
|
||||
}
|
||||
defer {
|
||||
print("2 ", .{});
|
||||
}
|
||||
if (false) {
|
||||
// defers are not run if they are never executed.
|
||||
defer {
|
||||
print("3 ", .{});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test
|
||||
@@ -1,18 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
fn swizzleRgbaToBgra(rgba: [4]u8) [4]u8 {
|
||||
// readable swizzling by destructuring
|
||||
const r, const g, const b, const a = rgba;
|
||||
return .{ b, g, r, a };
|
||||
}
|
||||
|
||||
pub fn main() void {
|
||||
const pos = [_]i32{ 1, 2 };
|
||||
const x, const y = pos;
|
||||
print("x = {}, y = {}\n", .{x, y});
|
||||
|
||||
const orange: [4]u8 = .{ 255, 165, 0, 255 };
|
||||
print("{any}\n", .{swizzleRgbaToBgra(orange)});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,22 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
const digits = [_]i8 { 3, 8, 9, 0, 7, 4, 1 };
|
||||
|
||||
const min, const max = blk: {
|
||||
var min: i8 = 127;
|
||||
var max: i8 = -128;
|
||||
|
||||
for (digits) |digit| {
|
||||
if (digit < min) min = digit;
|
||||
if (digit > max) max = digit;
|
||||
}
|
||||
|
||||
break :blk .{ min, max };
|
||||
};
|
||||
|
||||
print("min = {}", .{ min });
|
||||
print("max = {}", .{ max });
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,21 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
var x: u32 = undefined;
|
||||
|
||||
const tuple = .{ 1, 2, 3 };
|
||||
|
||||
x, var y : u32, const z = tuple;
|
||||
|
||||
print("x = {}, y = {}, z = {}\n", .{x, y, z});
|
||||
|
||||
// y is mutable
|
||||
y = 100;
|
||||
|
||||
// You can use _ to throw away unwanted values.
|
||||
_, x, _ = tuple;
|
||||
|
||||
print("x = {}", .{x});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,14 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
fn divmod(numerator: u32, denominator: u32) struct { u32, u32 } {
|
||||
return .{ numerator / denominator, numerator % denominator };
|
||||
}
|
||||
|
||||
pub fn main() void {
|
||||
const div, const mod = divmod(10, 3);
|
||||
|
||||
print("10 / 3 = {}\n", .{div});
|
||||
print("10 % 3 = {}\n", .{mod});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,27 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
var x: u32 = undefined;
|
||||
var y: u32 = undefined;
|
||||
var z: u32 = undefined;
|
||||
|
||||
const tuple = .{ 1, 2, 3 };
|
||||
|
||||
x, y, z = tuple;
|
||||
|
||||
print("tuple: x = {}, y = {}, z = {}\n", .{x, y, z});
|
||||
|
||||
const array = [_]u32{ 4, 5, 6 };
|
||||
|
||||
x, y, z = array;
|
||||
|
||||
print("array: x = {}, y = {}, z = {}\n", .{x, y, z});
|
||||
|
||||
const vector: @Vector(3, u32) = .{ 7, 8, 9 };
|
||||
|
||||
x, y, z = vector;
|
||||
|
||||
print("vector: x = {}, y = {}, z = {}\n", .{x, y, z});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,16 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
// emulate punpckldq
|
||||
pub fn unpack(x: @Vector(4, f32), y: @Vector(4, f32)) @Vector(4, f32) {
|
||||
const a, const c, _, _ = x;
|
||||
const b, const d, _, _ = y;
|
||||
return .{ a, b, c, d };
|
||||
}
|
||||
|
||||
pub fn main() void {
|
||||
const x: @Vector(4, f32) = .{ 1.0, 2.0, 3.0, 4.0 };
|
||||
const y: @Vector(4, f32) = .{ 5.0, 6.0, 7.0, 8.0 };
|
||||
print("{}", .{unpack(x, y)});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,19 +0,0 @@
|
||||
/// A structure for storing a timestamp, with nanosecond precision (this is a
|
||||
/// multiline doc comment).
|
||||
const Timestamp = struct {
|
||||
/// The number of seconds since the epoch (this is also a doc comment).
|
||||
seconds: i64, // signed so we can represent pre-1970 (not a doc comment)
|
||||
/// The number of nanoseconds past the second (doc comment again).
|
||||
nanos: u32,
|
||||
|
||||
/// Returns a `Timestamp` struct representing the Unix epoch; that is, the
|
||||
/// moment of 1970 Jan 1 00:00:00 UTC (this is a doc comment too).
|
||||
pub fn unixEpoch() Timestamp {
|
||||
return Timestamp{
|
||||
.seconds = 0,
|
||||
.nanos = 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
// syntax
|
||||
@@ -1,20 +0,0 @@
|
||||
/// `std.start` imports this file using `@import("root")`, and uses this declaration as the program's
|
||||
/// user-provided entry point. It can return any of the following types:
|
||||
/// * `void`
|
||||
/// * `E!void`, for any error set `E`
|
||||
/// * `u8`
|
||||
/// * `E!u8`, for any error set `E`
|
||||
/// Returning a `void` value from this function will exit with code 0.
|
||||
/// Returning a `u8` value from this function will exit with the given status code.
|
||||
/// Returning an error value from this function will print an Error Return Trace and exit with code 1.
|
||||
pub fn main() void {
|
||||
std.debug.print("Hello, World!\n", .{});
|
||||
}
|
||||
|
||||
// If uncommented, this declaration would suppress the usual std.start logic, causing
|
||||
// the `main` declaration above to be ignored.
|
||||
//pub const _start = {};
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,6 +0,0 @@
|
||||
const Foo = enum(c_int) { a, b, c };
|
||||
export fn entry(foo: Foo) void {
|
||||
_ = foo;
|
||||
}
|
||||
|
||||
// obj
|
||||
@@ -1,7 +0,0 @@
|
||||
const Foo = enum { a, b, c };
|
||||
export fn entry(foo: Foo) void {
|
||||
_ = foo;
|
||||
}
|
||||
|
||||
// obj=parameter of type 'enum_export_error.Foo' not allowed in function with calling convention 'x86_64_sysv'
|
||||
// target=x86_64-linux
|
||||
@@ -1,41 +0,0 @@
|
||||
pub fn main() !void {
|
||||
try foo(12);
|
||||
}
|
||||
|
||||
fn foo(x: i32) !void {
|
||||
if (x >= 5) {
|
||||
try bar();
|
||||
} else {
|
||||
try bang2();
|
||||
}
|
||||
}
|
||||
|
||||
fn bar() !void {
|
||||
if (baz()) {
|
||||
try quux();
|
||||
} else |err| switch (err) {
|
||||
error.FileNotFound => try hello(),
|
||||
}
|
||||
}
|
||||
|
||||
fn baz() !void {
|
||||
try bang1();
|
||||
}
|
||||
|
||||
fn quux() !void {
|
||||
try bang2();
|
||||
}
|
||||
|
||||
fn hello() !void {
|
||||
try bang2();
|
||||
}
|
||||
|
||||
fn bang1() !void {
|
||||
return error.FileNotFound;
|
||||
}
|
||||
|
||||
fn bang2() !void {
|
||||
return error.PermissionDenied;
|
||||
}
|
||||
|
||||
// exe=fail
|
||||
@@ -1,41 +0,0 @@
|
||||
const std = @import("std");
|
||||
const maxInt = std.math.maxInt;
|
||||
|
||||
pub fn parseU64(buf: []const u8, radix: u8) !u64 {
|
||||
var x: u64 = 0;
|
||||
|
||||
for (buf) |c| {
|
||||
const digit = charToDigit(c);
|
||||
|
||||
if (digit >= radix) {
|
||||
return error.InvalidChar;
|
||||
}
|
||||
|
||||
// x *= radix
|
||||
var ov = @mulWithOverflow(x, radix);
|
||||
if (ov[1] != 0) return error.OverFlow;
|
||||
|
||||
// x += digit
|
||||
ov = @addWithOverflow(ov[0], digit);
|
||||
if (ov[1] != 0) return error.OverFlow;
|
||||
x = ov[0];
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
fn charToDigit(c: u8) u8 {
|
||||
return switch (c) {
|
||||
'0'...'9' => c - '0',
|
||||
'A'...'Z' => c - 'A' + 10,
|
||||
'a'...'z' => c - 'a' + 10,
|
||||
else => maxInt(u8),
|
||||
};
|
||||
}
|
||||
|
||||
test "parse u64" {
|
||||
const result = try parseU64("1234", 10);
|
||||
try std.testing.expect(result == 1234);
|
||||
}
|
||||
|
||||
// test
|
||||
@@ -1,3 +0,0 @@
|
||||
export fn @"A function name that is a complete sentence."() void {}
|
||||
|
||||
// obj
|
||||
@@ -1,7 +0,0 @@
|
||||
comptime {
|
||||
@export(&internalName, .{ .name = "foo", .linkage = .strong });
|
||||
}
|
||||
|
||||
fn internalName() callconv(.c) void {}
|
||||
|
||||
// obj
|
||||
@@ -1,3 +0,0 @@
|
||||
export fn foo() void {}
|
||||
|
||||
// obj
|
||||
@@ -1,12 +0,0 @@
|
||||
const assert = @import("std").debug.assert;
|
||||
|
||||
fn fibonacci(index: i32) i32 {
|
||||
//if (index < 2) return index;
|
||||
return fibonacci(index - 1) + fibonacci(index - 2);
|
||||
}
|
||||
|
||||
test "fibonacci" {
|
||||
try comptime assert(fibonacci(7) == 13);
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,14 +0,0 @@
|
||||
const floating_point = 123.0E+77;
|
||||
const another_float = 123.0;
|
||||
const yet_another = 123.0e+77;
|
||||
|
||||
const hex_floating_point = 0x103.70p-5;
|
||||
const another_hex_float = 0x103.70;
|
||||
const yet_another_hex_float = 0x103.70P-5;
|
||||
|
||||
// underscores may be placed between two digits as a visual separator
|
||||
const lightspeed = 299_792_458.000_000;
|
||||
const nanosecond = 0.000_000_001;
|
||||
const more_hex = 0x1234_5678.9ABC_CDEFp-10;
|
||||
|
||||
// syntax
|
||||
@@ -1,12 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
extern fn foo_strict(x: f64) f64;
|
||||
extern fn foo_optimized(x: f64) f64;
|
||||
|
||||
pub fn main() void {
|
||||
const x = 0.001;
|
||||
print("optimized = {}\n", .{foo_optimized(x)});
|
||||
print("strict = {}\n", .{foo_strict(x)});
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,15 +0,0 @@
|
||||
const std = @import("std");
|
||||
const big = @as(f64, 1 << 40);
|
||||
|
||||
export fn foo_strict(x: f64) f64 {
|
||||
return x + big - big;
|
||||
}
|
||||
|
||||
export fn foo_optimized(x: f64) f64 {
|
||||
@setFloatMode(.optimized);
|
||||
return x + big - big;
|
||||
}
|
||||
|
||||
// obj
|
||||
// optimize=ReleaseFast
|
||||
// disable_cache
|
||||
@@ -1,7 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
const inf = std.math.inf(f32);
|
||||
const negative_inf = -std.math.inf(f64);
|
||||
const nan = std.math.nan(f128);
|
||||
|
||||
// syntax
|
||||
@@ -1,15 +0,0 @@
|
||||
fn List(comptime T: type) type {
|
||||
return struct {
|
||||
items: []T,
|
||||
len: usize,
|
||||
};
|
||||
}
|
||||
|
||||
// The generic List data structure can be instantiated by passing in a type:
|
||||
var buffer: [10]i32 = undefined;
|
||||
var list = List(i32){
|
||||
.items = &buffer,
|
||||
.len = 0,
|
||||
};
|
||||
|
||||
// syntax
|
||||
@@ -1,11 +0,0 @@
|
||||
const parseU64 = @import("error_union_parsing_u64.zig").parseU64;
|
||||
|
||||
fn doAThing(str: []u8) void {
|
||||
const number = parseU64(str, 10) catch blk: {
|
||||
// do things
|
||||
break :blk 13;
|
||||
};
|
||||
_ = number; // number is now initialized
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,8 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
const stdout = std.io.getStdOut().writer();
|
||||
try stdout.print("Hello, {s}!\n", .{"world"});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,7 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() void {
|
||||
std.debug.print("Hello, world!\n", .{});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,14 +0,0 @@
|
||||
const @"identifier with spaces in it" = 0xff;
|
||||
const @"1SmallStep4Man" = 112358;
|
||||
|
||||
const c = @import("std").c;
|
||||
pub extern "c" fn @"error"() void;
|
||||
pub extern "c" fn @"fstat$INODE64"(fd: c.fd_t, buf: *c.Stat) c_int;
|
||||
|
||||
const Color = enum {
|
||||
red,
|
||||
@"really red",
|
||||
};
|
||||
const color: Color = .@"really red";
|
||||
|
||||
// syntax
|
||||
@@ -1,34 +0,0 @@
|
||||
pub fn main() noreturn {
|
||||
const msg = "hello world\n";
|
||||
_ = syscall3(SYS_write, STDOUT_FILENO, @intFromPtr(msg), msg.len);
|
||||
_ = syscall1(SYS_exit, 0);
|
||||
unreachable;
|
||||
}
|
||||
|
||||
pub const SYS_write = 1;
|
||||
pub const SYS_exit = 60;
|
||||
|
||||
pub const STDOUT_FILENO = 1;
|
||||
|
||||
pub fn syscall1(number: usize, arg1: usize) usize {
|
||||
return asm volatile ("syscall"
|
||||
: [ret] "={rax}" (-> usize),
|
||||
: [number] "{rax}" (number),
|
||||
[arg1] "{rdi}" (arg1),
|
||||
: "rcx", "r11"
|
||||
);
|
||||
}
|
||||
|
||||
pub fn syscall3(number: usize, arg1: usize, arg2: usize, arg3: usize) usize {
|
||||
return asm volatile ("syscall"
|
||||
: [ret] "={rax}" (-> usize),
|
||||
: [number] "{rax}" (number),
|
||||
[arg1] "{rdi}" (arg1),
|
||||
[arg2] "{rsi}" (arg2),
|
||||
[arg3] "{rdx}" (arg3),
|
||||
: "rcx", "r11"
|
||||
);
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
// target=x86_64-linux
|
||||
@@ -1,11 +0,0 @@
|
||||
test "inline function call" {
|
||||
if (foo(1200, 34) != 1234) {
|
||||
@compileError("bad");
|
||||
}
|
||||
}
|
||||
|
||||
inline fn foo(a: i32, b: i32) i32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// test
|
||||
@@ -1,9 +0,0 @@
|
||||
fn isFieldOptional(comptime T: type, field_index: usize) !bool {
|
||||
const fields = @typeInfo(T).@"struct".fields;
|
||||
return switch (field_index) {
|
||||
inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .optional,
|
||||
else => return error.IndexOutOfBounds,
|
||||
};
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,13 +0,0 @@
|
||||
const decimal_int = 98222;
|
||||
const hex_int = 0xff;
|
||||
const another_hex_int = 0xFF;
|
||||
const octal_int = 0o755;
|
||||
const binary_int = 0b11110000;
|
||||
|
||||
// underscores may be placed between two digits as a visual separator
|
||||
const one_billion = 1_000_000_000;
|
||||
const binary_mask = 0b1_1111_1111;
|
||||
const permissions = 0o7_5_5;
|
||||
const big_address = 0xFF80_0000_0000_0000;
|
||||
|
||||
// syntax
|
||||
@@ -1,5 +0,0 @@
|
||||
/// doc-comment
|
||||
//! top-level doc-comment
|
||||
const std = @import("std");
|
||||
|
||||
// obj=expected type expression, found 'a document comment'
|
||||
@@ -1,10 +0,0 @@
|
||||
pub export fn main(argc: c_int, argv: [*]const [*:0]const u8) c_int {
|
||||
const args = argv[0..@intCast(argc)];
|
||||
std.debug.print("Hello! argv[0] is '{s}'\n", .{args[0]});
|
||||
return 0;
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
// exe=succeed
|
||||
// link_libc
|
||||
@@ -1,10 +0,0 @@
|
||||
pub export fn foo() c_int {
|
||||
var a: c_int = 1;
|
||||
_ = &a;
|
||||
var b: c_int = 2;
|
||||
_ = &b;
|
||||
return a + b;
|
||||
}
|
||||
pub const MAKELOCAL = @compileError("unable to translate C expr: unexpected token .Equal"); // macro.c:1:9
|
||||
|
||||
// syntax
|
||||
@@ -1,10 +0,0 @@
|
||||
extern fn print(i32) void;
|
||||
|
||||
export fn add(a: i32, b: i32) void {
|
||||
print(a + b);
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
// target=wasm32-freestanding
|
||||
// additional_option=-fno-entry
|
||||
// additional_option=--export=add
|
||||
@@ -1,14 +0,0 @@
|
||||
const math = @import("std").math;
|
||||
const print = @import("std").debug.print;
|
||||
pub fn main() !void {
|
||||
var byte: u8 = 255;
|
||||
|
||||
byte = if (math.add(u8, byte, 1)) |result| result else |err| {
|
||||
print("unable to add one: {s}\n", .{@errorName(err)});
|
||||
return err;
|
||||
};
|
||||
|
||||
print("result: {}\n", .{byte});
|
||||
}
|
||||
|
||||
// exe=fail
|
||||
@@ -1,5 +0,0 @@
|
||||
export fn add(a: i32, b: i32) i32 {
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,10 +0,0 @@
|
||||
const hello_world_in_c =
|
||||
\\#include <stdio.h>
|
||||
\\
|
||||
\\int main(int argc, char **argv) {
|
||||
\\ printf("hello world\n");
|
||||
\\ return 0;
|
||||
\\}
|
||||
;
|
||||
|
||||
// syntax
|
||||
@@ -1,11 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
pub fn main() void {
|
||||
var y: i32 = 5678;
|
||||
|
||||
y += 1;
|
||||
|
||||
print("{d}", .{y});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,11 +0,0 @@
|
||||
fn cmpxchgStrongButNotAtomic(comptime T: type, ptr: *T, expected_value: T, new_value: T) ?T {
|
||||
const old_value = ptr.*;
|
||||
if (old_value == expected_value) {
|
||||
ptr.* = new_value;
|
||||
return null;
|
||||
} else {
|
||||
return old_value;
|
||||
}
|
||||
}
|
||||
|
||||
// syntax
|
||||
@@ -1,3 +0,0 @@
|
||||
const optional_value: ?i32 = null;
|
||||
|
||||
// syntax
|
||||
@@ -1,7 +0,0 @@
|
||||
// normal integer
|
||||
const normal_int: i32 = 1234;
|
||||
|
||||
// optional integer
|
||||
const optional_int: ?i32 = 5678;
|
||||
|
||||
// syntax
|
||||
@@ -1,18 +0,0 @@
|
||||
pub fn main() void {
|
||||
@setRuntimeSafety(true);
|
||||
var x: u8 = 255;
|
||||
// Let's overflow this integer!
|
||||
x += 1;
|
||||
}
|
||||
|
||||
pub const panic = std.debug.FullPanic(myPanic);
|
||||
|
||||
fn myPanic(msg: []const u8, first_trace_addr: ?usize) noreturn {
|
||||
_ = first_trace_addr;
|
||||
std.debug.print("Panic! {s}\n", .{msg});
|
||||
std.process.exit(1);
|
||||
}
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
// exe=fail
|
||||
@@ -1,33 +0,0 @@
|
||||
const Writer = struct {
|
||||
pub fn printValue(self: *Writer, value: anytype) !void {
|
||||
switch (@typeInfo(@TypeOf(value))) {
|
||||
.int => {
|
||||
return self.writeInt(value);
|
||||
},
|
||||
.float => {
|
||||
return self.writeFloat(value);
|
||||
},
|
||||
.pointer => {
|
||||
return self.write(value);
|
||||
},
|
||||
else => {
|
||||
@compileError("Unable to print type '" ++ @typeName(@TypeOf(value)) ++ "'");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn write(self: *Writer, value: []const u8) !void {
|
||||
_ = self;
|
||||
_ = value;
|
||||
}
|
||||
fn writeInt(self: *Writer, value: anytype) !void {
|
||||
_ = self;
|
||||
_ = value;
|
||||
}
|
||||
fn writeFloat(self: *Writer, value: anytype) !void {
|
||||
_ = self;
|
||||
_ = value;
|
||||
}
|
||||
};
|
||||
|
||||
// syntax
|
||||
@@ -1,79 +0,0 @@
|
||||
const Writer = struct {
|
||||
/// Calls print and then flushes the buffer.
|
||||
pub fn print(self: *Writer, comptime format: []const u8, args: anytype) anyerror!void {
|
||||
const State = enum {
|
||||
start,
|
||||
open_brace,
|
||||
close_brace,
|
||||
};
|
||||
|
||||
comptime var start_index: usize = 0;
|
||||
comptime var state = State.start;
|
||||
comptime var next_arg: usize = 0;
|
||||
|
||||
inline for (format, 0..) |c, i| {
|
||||
switch (state) {
|
||||
State.start => switch (c) {
|
||||
'{' => {
|
||||
if (start_index < i) try self.write(format[start_index..i]);
|
||||
state = State.open_brace;
|
||||
},
|
||||
'}' => {
|
||||
if (start_index < i) try self.write(format[start_index..i]);
|
||||
state = State.close_brace;
|
||||
},
|
||||
else => {},
|
||||
},
|
||||
State.open_brace => switch (c) {
|
||||
'{' => {
|
||||
state = State.start;
|
||||
start_index = i;
|
||||
},
|
||||
'}' => {
|
||||
try self.printValue(args[next_arg]);
|
||||
next_arg += 1;
|
||||
state = State.start;
|
||||
start_index = i + 1;
|
||||
},
|
||||
's' => {
|
||||
continue;
|
||||
},
|
||||
else => @compileError("Unknown format character: " ++ [1]u8{c}),
|
||||
},
|
||||
State.close_brace => switch (c) {
|
||||
'}' => {
|
||||
state = State.start;
|
||||
start_index = i;
|
||||
},
|
||||
else => @compileError("Single '}' encountered in format string"),
|
||||
},
|
||||
}
|
||||
}
|
||||
comptime {
|
||||
if (args.len != next_arg) {
|
||||
@compileError("Unused arguments");
|
||||
}
|
||||
if (state != State.start) {
|
||||
@compileError("Incomplete format string: " ++ format);
|
||||
}
|
||||
}
|
||||
if (start_index < format.len) {
|
||||
try self.write(format[start_index..format.len]);
|
||||
}
|
||||
try self.flush();
|
||||
}
|
||||
|
||||
fn write(self: *Writer, value: []const u8) !void {
|
||||
_ = self;
|
||||
_ = value;
|
||||
}
|
||||
pub fn printValue(self: *Writer, value: anytype) !void {
|
||||
_ = self;
|
||||
_ = value;
|
||||
}
|
||||
fn flush(self: *Writer) !void {
|
||||
_ = self;
|
||||
}
|
||||
};
|
||||
|
||||
// syntax
|
||||
@@ -1,10 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
const a_number: i32 = 1234;
|
||||
const a_string = "foobar";
|
||||
|
||||
pub fn main() void {
|
||||
print("here is a string: '{s}' here is a number: {}\n", .{ a_string, a_number });
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,11 +0,0 @@
|
||||
const print = @import("std").debug.print;
|
||||
|
||||
const a_number: i32 = 1234;
|
||||
const a_string = "foobar";
|
||||
const fmt = "here is a string: '{s}' here is a number: {}\n";
|
||||
|
||||
pub fn main() void {
|
||||
print(fmt, .{ a_string, a_number });
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,15 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub const json = struct {
|
||||
pub const JsonValue = union(enum) {
|
||||
number: f64,
|
||||
boolean: bool,
|
||||
// ...
|
||||
};
|
||||
};
|
||||
|
||||
pub fn main() void {
|
||||
std.debug.print("{s}\n", .{@typeName(json.JsonValue)});
|
||||
}
|
||||
|
||||
// exe=succeed
|
||||
@@ -1,13 +0,0 @@
|
||||
const expect = @import("std").testing.expect;
|
||||
test "attempt to swap array elements with array initializer" {
|
||||
var arr: [2]u32 = .{ 1, 2 };
|
||||
arr = .{ arr[1], arr[0] };
|
||||
// The previous line is equivalent to the following two lines:
|
||||
// arr[0] = arr[1];
|
||||
// arr[1] = arr[0];
|
||||
// So this fails!
|
||||
try expect(arr[0] == 2); // succeeds
|
||||
try expect(arr[1] == 1); // fails
|
||||
}
|
||||
|
||||
// test_error=
|
||||
@@ -1,12 +0,0 @@
|
||||
const expectEqual = @import("std").testing.expectEqual;
|
||||
test "result type propagates through struct initializer" {
|
||||
const S = struct { x: u32 };
|
||||
const val: u64 = 123;
|
||||
const s: S = .{ .x = @intCast(val) };
|
||||
// .{ .x = @intCast(val) } has result type `S` due to the type annotation
|
||||
// @intCast(val) has result type `u32` due to the type of the field `S.x`
|
||||
// val has no result type, as it is permitted to be any integer type
|
||||
try expectEqual(@as(u32, 123), s.x);
|
||||
}
|
||||
|
||||
// test
|
||||
@@ -1,11 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() void {
|
||||
var a: u32 = 10;
|
||||
var b: u32 = 3;
|
||||
_ = .{ &a, &b };
|
||||
const c = @divExact(a, b);
|
||||
std.debug.print("value: {}\n", .{c});
|
||||
}
|
||||
|
||||
// exe=fail
|
||||
@@ -1,11 +0,0 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() void {
|
||||
var a: u32 = 1;
|
||||
var b: u32 = 0;
|
||||
_ = .{ &a, &b };
|
||||
const c = a / b;
|
||||
std.debug.print("value: {}\n", .{c});
|
||||
}
|
||||
|
||||
// exe=fail
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user