Skip to content

Commit d165f17

Browse files
committed
Merge branch 'master' into Sentinel-instead-of-Z
2 parents 6d2e76b + e0dc2e4 commit d165f17

File tree

340 files changed

+52315
-57370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+52315
-57370
lines changed

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ contact_links:
55
- name: Question
66
about: Please use one of the community spaces for questions or general discussions.
77
url: https://github.com/ziglang/zig/wiki/Community
8+
- name: C Translation
9+
about: "Issues related to `zig translate-c` and `@cImport` are tracked separately."
10+
url: https://github.com/ziglang/translate-c/
811
- name: Copilot and Other LLMs
912
about: Please do not use GitHub Copilot or any other LLM to write an issue.
1013
url: https://github.com/ziglang/zig/wiki/Writing-Issues-with-Copilot-and-Other-LLMs

.github/workflows/ci-pr-riscv64-linux.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/ci.yaml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,6 @@ jobs:
5050
uses: actions/checkout@v4
5151
- name: Build and Test
5252
run: sh ci/aarch64-linux-release.sh
53-
riscv64-linux-debug:
54-
if: github.event_name == 'push'
55-
timeout-minutes: 420
56-
runs-on: [self-hosted, Linux, riscv64]
57-
steps:
58-
- name: Checkout
59-
uses: actions/checkout@v4
60-
- name: Build and Test
61-
run: sh ci/riscv64-linux-debug.sh
62-
riscv64-linux-release:
63-
if: github.event_name == 'push'
64-
timeout-minutes: 420
65-
runs-on: [self-hosted, Linux, riscv64]
66-
steps:
67-
- name: Checkout
68-
uses: actions/checkout@v4
69-
- name: Build and Test
70-
run: sh ci/riscv64-linux-release.sh
71-
x86_64-macos-release:
72-
runs-on: "macos-13"
73-
env:
74-
ARCH: "x86_64"
75-
steps:
76-
- name: Checkout
77-
uses: actions/checkout@v4
78-
- name: Build and Test
79-
run: ci/x86_64-macos-release.sh
8053
aarch64-macos-debug:
8154
runs-on: [self-hosted, macOS, aarch64]
8255
env:

CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ set(ZIG_CPP_SOURCES
197197
# These are planned to stay even when we are self-hosted.
198198
src/zig_llvm.cpp
199199
src/zig_llvm-ar.cpp
200-
src/zig_clang.cpp
201200
src/zig_clang_driver.cpp
202201
src/zig_clang_cc1_main.cpp
203202
src/zig_clang_cc1as_main.cpp
@@ -502,7 +501,6 @@ set(ZIG_STAGE2_SOURCES
502501
lib/std/zig/Server.zig
503502
lib/std/zig/WindowsSdk.zig
504503
lib/std/zig/Zir.zig
505-
lib/std/zig/c_builtins.zig
506504
lib/std/zig/string_literal.zig
507505
lib/std/zig/system.zig
508506
lib/std/zig/system/NativePaths.zig
@@ -537,7 +535,6 @@ set(ZIG_STAGE2_SOURCES
537535
src/Value.zig
538536
src/Zcu.zig
539537
src/Zcu/PerThread.zig
540-
src/clang.zig
541538
src/clang_options.zig
542539
src/clang_options_data.zig
543540
src/codegen.zig
@@ -583,6 +580,7 @@ set(ZIG_STAGE2_SOURCES
583580
src/link/Elf/relocatable.zig
584581
src/link/Elf/relocation.zig
585582
src/link/Elf/synthetic_sections.zig
583+
src/link/Elf2.zig
586584
src/link/Goff.zig
587585
src/link/LdScript.zig
588586
src/link/Lld.zig
@@ -612,6 +610,7 @@ set(ZIG_STAGE2_SOURCES
612610
src/link/MachO/synthetic.zig
613611
src/link/MachO/Thunk.zig
614612
src/link/MachO/uuid.zig
613+
src/link/MappedFile.zig
615614
src/link/Queue.zig
616615
src/link/StringTable.zig
617616
src/link/Wasm.zig
@@ -639,7 +638,6 @@ set(ZIG_STAGE2_SOURCES
639638
src/register_manager.zig
640639
src/target.zig
641640
src/tracy.zig
642-
src/translate_c.zig
643641
src/libs/wasi_libc.zig
644642
)
645643

build.zig

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ pub fn build(b: *std.Build) !void {
9090
const skip_libc = b.option(bool, "skip-libc", "Main test suite skips tests that link libc") orelse false;
9191
const skip_single_threaded = b.option(bool, "skip-single-threaded", "Main test suite skips tests that are single-threaded") orelse false;
9292
const skip_compile_errors = b.option(bool, "skip-compile-errors", "Main test suite skips compile error tests") orelse false;
93-
const skip_translate_c = b.option(bool, "skip-translate-c", "Main test suite skips translate-c tests") orelse false;
94-
const skip_run_translated_c = b.option(bool, "skip-run-translated-c", "Main test suite skips run-translated-c tests") orelse skip_translate_c;
9593
const skip_freebsd = b.option(bool, "skip-freebsd", "Main test suite skips targets with freebsd OS") orelse false;
9694
const skip_netbsd = b.option(bool, "skip-netbsd", "Main test suite skips targets with netbsd OS") orelse false;
9795
const skip_windows = b.option(bool, "skip-windows", "Main test suite skips targets with windows OS") orelse false;
@@ -202,6 +200,7 @@ pub fn build(b: *std.Build) !void {
202200
});
203201
exe.pie = pie;
204202
exe.entitlements = entitlements;
203+
exe.use_new_linker = b.option(bool, "new-linker", "Use the new linker");
205204

206205
const use_llvm = b.option(bool, "use-llvm", "Use the llvm backend");
207206
exe.use_llvm = use_llvm;
@@ -415,7 +414,7 @@ pub fn build(b: *std.Build) !void {
415414
test_step.dependOn(check_fmt);
416415

417416
const test_cases_step = b.step("test-cases", "Run the main compiler test cases");
418-
try tests.addCases(b, test_cases_step, target, .{
417+
try tests.addCases(b, test_cases_step, .{
419418
.test_filters = test_filters,
420419
.test_target_filters = test_target_filters,
421420
.skip_compile_errors = skip_compile_errors,
@@ -427,9 +426,6 @@ pub fn build(b: *std.Build) !void {
427426
.skip_linux = skip_linux,
428427
.skip_llvm = skip_llvm,
429428
.skip_libc = skip_libc,
430-
}, .{
431-
.skip_translate_c = skip_translate_c,
432-
.skip_run_translated_c = skip_run_translated_c,
433429
}, .{
434430
.enable_llvm = enable_llvm,
435431
.llvm_has_m68k = llvm_has_m68k,
@@ -464,28 +460,6 @@ pub fn build(b: *std.Build) !void {
464460
.max_rss = 4000000000,
465461
}));
466462

467-
if (!skip_translate_c) {
468-
test_modules_step.dependOn(tests.addModuleTests(b, .{
469-
.test_filters = test_filters,
470-
.test_target_filters = test_target_filters,
471-
.test_extra_targets = test_extra_targets,
472-
.root_src = "test/c_import.zig",
473-
.name = "c-import",
474-
.desc = "Run the @cImport tests",
475-
.optimize_modes = optimization_modes,
476-
.include_paths = &.{"test/c_import"},
477-
.skip_single_threaded = true,
478-
.skip_non_native = skip_non_native,
479-
.skip_freebsd = skip_freebsd,
480-
.skip_netbsd = skip_netbsd,
481-
.skip_windows = skip_windows,
482-
.skip_macos = skip_macos,
483-
.skip_linux = skip_linux,
484-
.skip_llvm = skip_llvm,
485-
.skip_libc = skip_libc,
486-
}));
487-
}
488-
489463
test_modules_step.dependOn(tests.addModuleTests(b, .{
490464
.test_filters = test_filters,
491465
.test_target_filters = test_target_filters,
@@ -576,7 +550,6 @@ pub fn build(b: *std.Build) !void {
576550
enable_macos_sdk,
577551
enable_ios_sdk,
578552
enable_symlinks_windows,
579-
skip_translate_c,
580553
));
581554
test_step.dependOn(tests.addCAbiTests(b, .{
582555
.test_target_filters = test_target_filters,
@@ -631,6 +604,12 @@ pub fn build(b: *std.Build) !void {
631604
const test_incremental_step = b.step("test-incremental", "Run the incremental compilation test cases");
632605
try tests.addIncrementalTests(b, test_incremental_step);
633606
test_step.dependOn(test_incremental_step);
607+
608+
if (tests.addLibcTests(b, .{
609+
.optimize_modes = optimization_modes,
610+
.test_filters = test_filters,
611+
.test_target_filters = test_target_filters,
612+
})) |test_libc_step| test_step.dependOn(test_libc_step);
634613
}
635614

636615
fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
@@ -725,13 +704,7 @@ fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Modu
725704
.root_source_file = b.path("lib/compiler/aro/aro.zig"),
726705
});
727706

728-
const aro_translate_c_mod = b.createModule(.{
729-
.root_source_file = b.path("lib/compiler/aro_translate_c.zig"),
730-
});
731-
732-
aro_translate_c_mod.addImport("aro", aro_mod);
733707
compiler_mod.addImport("aro", aro_mod);
734-
compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);
735708

736709
return compiler_mod;
737710
}
@@ -1151,7 +1124,6 @@ fn toNativePathSep(b: *std.Build, s: []const u8) []u8 {
11511124
const zig_cpp_sources = [_][]const u8{
11521125
// These are planned to stay even when we are self-hosted.
11531126
"src/zig_llvm.cpp",
1154-
"src/zig_clang.cpp",
11551127
"src/zig_llvm-ar.cpp",
11561128
"src/zig_clang_driver.cpp",
11571129
"src/zig_clang_cc1_main.cpp",

ci/loongarch64-linux-debug.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ stage3-debug/bin/zig build test \
5656
-Dskip-non-native \
5757
-Dtarget=native-native-musl \
5858
--search-prefix "$PREFIX" \
59-
--zig-lib-dir "$PWD/../lib" \
60-
-Dno-langref \
61-
-Dskip-translate-c
59+
--zig-lib-dir "$PWD/../lib"
6260

6361
stage3-debug/bin/zig build \
6462
--prefix stage4-debug \

ci/loongarch64-linux-release.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@ stage3-release/bin/zig build test \
5656
-Dskip-non-native \
5757
-Dtarget=native-native-musl \
5858
--search-prefix "$PREFIX" \
59-
--zig-lib-dir "$PWD/../lib" \
60-
-Dno-langref \
61-
-Dskip-translate-c
59+
--zig-lib-dir "$PWD/../lib"
6260

6361
# Ensure that stage3 and stage4 are byte-for-byte identical.
6462
stage3-release/bin/zig build \

ci/x86_64-freebsd-debug.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/sh
2+
3+
# Requires cmake ninja-build
4+
5+
set -x
6+
set -e
7+
8+
ARCH="x86_64"
9+
TARGET="$ARCH-freebsd-none"
10+
MCPU="baseline"
11+
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.16.0-dev.312+164c598cd"
12+
PREFIX="$HOME/deps/$CACHE_BASENAME"
13+
ZIG="$PREFIX/bin/zig"
14+
15+
# Make the `zig version` number consistent.
16+
# This will affect the cmake command below.
17+
git fetch --unshallow || true
18+
git fetch --tags
19+
20+
# Override the cache directories because they won't actually help other CI runs
21+
# which will be testing alternate versions of zig, and ultimately would just
22+
# fill up space on the hard drive for no reason.
23+
export ZIG_GLOBAL_CACHE_DIR="$PWD/zig-global-cache"
24+
export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
25+
26+
mkdir build-debug
27+
cd build-debug
28+
29+
export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
30+
export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
31+
32+
cmake .. \
33+
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
34+
-DCMAKE_PREFIX_PATH="$PREFIX" \
35+
-DCMAKE_BUILD_TYPE=Debug \
36+
-DZIG_TARGET_TRIPLE="$TARGET" \
37+
-DZIG_TARGET_MCPU="$MCPU" \
38+
-DZIG_STATIC=ON \
39+
-DZIG_NO_LIB=ON \
40+
-GNinja \
41+
-DCMAKE_C_LINKER_DEPFILE_SUPPORTED=FALSE \
42+
-DCMAKE_CXX_LINKER_DEPFILE_SUPPORTED=FALSE
43+
# https://github.com/ziglang/zig/issues/22213
44+
45+
# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
46+
# so that installation and testing do not get affected by them.
47+
unset CC
48+
unset CXX
49+
50+
ninja install
51+
52+
stage3-debug/bin/zig build test docs \
53+
--maxrss 32212254720 \
54+
-Dstatic-llvm \
55+
-Dskip-linux \
56+
-Dskip-netbsd \
57+
-Dskip-windows \
58+
-Dskip-macos \
59+
--search-prefix "$PREFIX" \
60+
--zig-lib-dir "$PWD/../lib"
61+
62+
stage3-debug/bin/zig build \
63+
--prefix stage4-debug \
64+
-Denable-llvm \
65+
-Dno-lib \
66+
-Dtarget=$TARGET \
67+
-Duse-zig-libcxx \
68+
-Dversion-string="$(stage3-debug/bin/zig version)"
69+
70+
stage4-debug/bin/zig test ../test/behavior.zig

0 commit comments

Comments
 (0)