Skip to content

Commit 925b88f

Browse files
committed
Merge branch 'master' into file-uris
2 parents 8409968 + 0a6cd25 commit 925b88f

File tree

2,984 files changed

+87076
-88010
lines changed

Some content is hidden

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

2,984 files changed

+87076
-88010
lines changed

.github/workflows/ci.yaml

+8-8
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,33 @@ jobs:
4141
uses: actions/checkout@v3
4242
- name: Build and Test
4343
run: sh ci/aarch64-linux-release.sh
44-
x86_64-macos-debug:
44+
x86_64-macos-release:
4545
runs-on: "macos-11"
4646
env:
4747
ARCH: "x86_64"
4848
steps:
4949
- name: Checkout
5050
uses: actions/checkout@v3
5151
- name: Build and Test
52-
run: ci/x86_64-macos-debug.sh
53-
x86_64-macos-release:
54-
runs-on: "macos-11"
52+
run: ci/x86_64-macos-release.sh
53+
aarch64-macos-debug:
54+
runs-on: [self-hosted, macOS, aarch64]
5555
env:
56-
ARCH: "x86_64"
56+
ARCH: "aarch64"
5757
steps:
5858
- name: Checkout
5959
uses: actions/checkout@v3
6060
- name: Build and Test
61-
run: ci/x86_64-macos-release.sh
62-
aarch64-macos:
61+
run: ci/aarch64-macos-debug.sh
62+
aarch64-macos-release:
6363
runs-on: [self-hosted, macOS, aarch64]
6464
env:
6565
ARCH: "aarch64"
6666
steps:
6767
- name: Checkout
6868
uses: actions/checkout@v3
6969
- name: Build and Test
70-
run: ci/aarch64-macos.sh
70+
run: ci/aarch64-macos-release.sh
7171
x86_64-windows-debug:
7272
runs-on: windows-latest
7373
env:

CMakeLists.txt

+16-7
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ if(ZIG_AR_WORKAROUND)
120120
string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
121121
endif()
122122

123+
set(ZIG_PIE off CACHE BOOL "produce a position independent zig executable")
124+
123125
find_package(llvm 16)
124126
find_package(clang 16)
125127
find_package(lld 16)
@@ -374,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
374376
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig"
375377
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig"
376378
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig"
377-
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig"
379+
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_from_float.zig"
378380
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig"
379381
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig"
380382
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig"
@@ -415,7 +417,7 @@ set(ZIG_STAGE2_SOURCES
415417
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig"
416418
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig"
417419
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig"
418-
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig"
420+
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_from_int.zig"
419421
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig"
420422
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig"
421423
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig"
@@ -592,8 +594,10 @@ set(ZIG_STAGE2_SOURCES
592594
"${CMAKE_SOURCE_DIR}/src/link/MachO/dead_strip.zig"
593595
"${CMAKE_SOURCE_DIR}/src/link/MachO/eh_frame.zig"
594596
"${CMAKE_SOURCE_DIR}/src/link/MachO/fat.zig"
597+
"${CMAKE_SOURCE_DIR}/src/link/MachO/hasher.zig"
595598
"${CMAKE_SOURCE_DIR}/src/link/MachO/load_commands.zig"
596599
"${CMAKE_SOURCE_DIR}/src/link/MachO/thunks.zig"
600+
"${CMAKE_SOURCE_DIR}/src/link/MachO/uuid.zig"
597601
"${CMAKE_SOURCE_DIR}/src/link/MachO/zld.zig"
598602
"${CMAKE_SOURCE_DIR}/src/link/Plan9.zig"
599603
"${CMAKE_SOURCE_DIR}/src/link/Plan9/aout.zig"
@@ -671,7 +675,12 @@ if(ZIG_STATIC)
671675
endif()
672676

673677
add_library(zigcpp STATIC ${ZIG_CPP_SOURCES})
674-
set_target_properties(zigcpp PROPERTIES COMPILE_FLAGS ${EXE_CXX_FLAGS})
678+
if(ZIG_PIE)
679+
set(ZIGCPP_CXX_FLAGS "${EXE_CXX_FLAGS} -fPIC")
680+
else()
681+
set(ZIGCPP_CXX_FLAGS "${EXE_CXX_FLAGS}")
682+
endif()
683+
set_target_properties(zigcpp PROPERTIES COMPILE_FLAGS ${ZIGCPP_CXX_FLAGS})
675684

676685
target_link_libraries(zigcpp LINK_PUBLIC
677686
${CLANG_LIBRARIES}
@@ -813,7 +822,7 @@ else()
813822
set(ZIG_NO_LANGREF_ARG "")
814823
endif()
815824
if(ZIG_SINGLE_THREADED)
816-
set(ZIG_SINGLE_THREADED_ARG "-fsingle-threaded")
825+
set(ZIG_SINGLE_THREADED_ARG "-Dsingle-threaded")
817826
else()
818827
set(ZIG_SINGLE_THREADED_ARG "")
819828
endif()
@@ -823,10 +832,10 @@ else()
823832
set(ZIG_STATIC_ARG "")
824833
endif()
825834

826-
if(CMAKE_POSITION_INDEPENDENT_CODE)
827-
set(ZIG_PIE_ARG="-Dpie")
835+
if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE)
836+
set(ZIG_PIE_ARG "-Dpie")
828837
else()
829-
set(ZIG_PIE_ARG="")
838+
set(ZIG_PIE_ARG "")
830839
endif()
831840

832841
set(ZIG_BUILD_ARGS

build.zig

+18-17
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const fs = std.fs;
99
const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
1010
const assert = std.debug.assert;
1111

12-
const zig_version = std.builtin.Version{ .major = 0, .minor = 11, .patch = 0 };
12+
const zig_version = std.SemanticVersion{ .major = 0, .minor = 11, .patch = 0 };
1313
const stack_size = 32 * 1024 * 1024;
1414

1515
pub fn build(b: *std.Build) !void {
@@ -30,6 +30,7 @@ pub fn build(b: *std.Build) !void {
3030
const test_step = b.step("test", "Run all the tests");
3131
const skip_install_lib_files = b.option(bool, "no-lib", "skip copying of lib/ files and langref to installation prefix. Useful for development") orelse false;
3232
const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
33+
const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;
3334

3435
const docgen_exe = b.addExecutable(.{
3536
.name = "docgen",
@@ -104,7 +105,7 @@ pub fn build(b: *std.Build) !void {
104105

105106
if (!skip_install_lib_files) {
106107
b.installDirectory(InstallDirectoryOptions{
107-
.source_dir = "lib",
108+
.source_dir = .{ .path = "lib" },
108109
.install_dir = .lib,
109110
.install_subdir = "zig",
110111
.exclude_extensions = &[_][]const u8{
@@ -166,6 +167,7 @@ pub fn build(b: *std.Build) !void {
166167
exe.pie = pie;
167168
exe.sanitize_thread = sanitize_thread;
168169
exe.entitlements = entitlements;
170+
if (no_bin) exe.emit_bin = .no_emit;
169171

170172
exe.build_id = b.option(
171173
std.Build.Step.Compile.BuildId,
@@ -197,7 +199,7 @@ pub fn build(b: *std.Build) !void {
197199
exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
198200
exe_options.addOption(bool, "force_gpa", force_gpa);
199201
exe_options.addOption(bool, "only_c", only_c);
200-
exe_options.addOption(bool, "omit_pkg_fetching_code", only_c);
202+
exe_options.addOption(bool, "only_core_functionality", only_c);
201203

202204
if (link_libc) {
203205
exe.linkLibC();
@@ -235,12 +237,12 @@ pub fn build(b: *std.Build) !void {
235237
},
236238
2 => {
237239
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
238-
var it = mem.split(u8, git_describe, "-");
240+
var it = mem.splitScalar(u8, git_describe, '-');
239241
const tagged_ancestor = it.first();
240242
const commit_height = it.next().?;
241243
const commit_id = it.next().?;
242244

243-
const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor);
245+
const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor);
244246
if (zig_version.order(ancestor_ver) != .gt) {
245247
std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver });
246248
std.process.exit(1);
@@ -280,7 +282,7 @@ pub fn build(b: *std.Build) !void {
280282
// That means we also have to rely on stage1 compiled c++ files. We parse config.h to find
281283
// the information passed on to us from cmake.
282284
if (cfg.cmake_prefix_path.len > 0) {
283-
var it = mem.tokenize(u8, cfg.cmake_prefix_path, ";");
285+
var it = mem.tokenizeScalar(u8, cfg.cmake_prefix_path, ';');
284286
while (it.next()) |path| {
285287
b.addSearchPrefix(path);
286288
}
@@ -354,7 +356,7 @@ pub fn build(b: *std.Build) !void {
354356
test_cases_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
355357
test_cases_options.addOption(bool, "force_gpa", force_gpa);
356358
test_cases_options.addOption(bool, "only_c", only_c);
357-
test_cases_options.addOption(bool, "omit_pkg_fetching_code", true);
359+
test_cases_options.addOption(bool, "only_core_functionality", true);
358360
test_cases_options.addOption(bool, "enable_qemu", b.enable_qemu);
359361
test_cases_options.addOption(bool, "enable_wine", b.enable_wine);
360362
test_cases_options.addOption(bool, "enable_wasmtime", b.enable_wasmtime);
@@ -469,9 +471,8 @@ pub fn build(b: *std.Build) !void {
469471
.skip_non_native = skip_non_native,
470472
.skip_cross_glibc = skip_cross_glibc,
471473
.skip_libc = skip_libc,
472-
// I observed a value of 3398275072 on my M1, and multiplied by 1.1 to
473-
// get this amount:
474-
.max_rss = 3738102579,
474+
// I observed a value of 4572626944 on the M2 CI.
475+
.max_rss = 5029889638,
475476
}));
476477

477478
try addWasiUpdateStep(b, version);
@@ -487,7 +488,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
487488
.cpu_arch = .wasm32,
488489
.os_tag = .wasi,
489490
};
490-
target.cpu_features_add.addFeature(@enumToInt(std.Target.wasm.Feature.bulk_memory));
491+
target.cpu_features_add.addFeature(@intFromEnum(std.Target.wasm.Feature.bulk_memory));
491492

492493
const exe = addCompilerStep(b, .ReleaseSmall, target);
493494

@@ -506,7 +507,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
506507
exe_options.addOption(bool, "enable_tracy_callstack", false);
507508
exe_options.addOption(bool, "enable_tracy_allocation", false);
508509
exe_options.addOption(bool, "value_tracing", false);
509-
exe_options.addOption(bool, "omit_pkg_fetching_code", true);
510+
exe_options.addOption(bool, "only_core_functionality", true);
510511

511512
const run_opt = b.addSystemCommand(&.{
512513
"wasm-opt",
@@ -685,7 +686,7 @@ fn addCxxKnownPath(
685686
if (!std.process.can_spawn)
686687
return error.RequiredLibraryNotFound;
687688
const path_padded = b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) });
688-
var tokenizer = mem.tokenize(u8, path_padded, "\r\n");
689+
var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n");
689690
const path_unpadded = tokenizer.next().?;
690691
if (mem.eql(u8, path_unpadded, objname)) {
691692
if (errtxt) |msg| {
@@ -708,7 +709,7 @@ fn addCxxKnownPath(
708709
}
709710

710711
fn addCMakeLibraryList(exe: *std.Build.Step.Compile, list: []const u8) void {
711-
var it = mem.tokenize(u8, list, ";");
712+
var it = mem.tokenizeScalar(u8, list, ';');
712713
while (it.next()) |lib| {
713714
if (mem.startsWith(u8, lib, "-l")) {
714715
exe.linkSystemLibrary(lib["-l".len..]);
@@ -853,18 +854,18 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig {
853854
// .prefix = ZIG_LLVM_LINK_MODE parsed manually below
854855
};
855856

856-
var lines_it = mem.tokenize(u8, config_h_text, "\r\n");
857+
var lines_it = mem.tokenizeAny(u8, config_h_text, "\r\n");
857858
while (lines_it.next()) |line| {
858859
inline for (mappings) |mapping| {
859860
if (mem.startsWith(u8, line, mapping.prefix)) {
860-
var it = mem.split(u8, line, "\"");
861+
var it = mem.splitScalar(u8, line, '"');
861862
_ = it.first(); // skip the stuff before the quote
862863
const quoted = it.next().?; // the stuff inside the quote
863864
@field(ctx, mapping.field) = toNativePathSep(b, quoted);
864865
}
865866
}
866867
if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) {
867-
var it = mem.split(u8, line, "\"");
868+
var it = mem.splitScalar(u8, line, '"');
868869
_ = it.next().?; // skip the stuff before the quote
869870
const quoted = it.next().?; // the stuff inside the quote
870871
ctx.llvm_linkage = if (mem.eql(u8, quoted, "shared")) .dynamic else .static;

ci/x86_64-macos-debug.sh renamed to ci/aarch64-macos-debug.sh

+10-14
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,14 @@
33
set -x
44
set -e
55

6+
# Script assumes the presence of the following:
7+
# s3cmd
8+
69
ZIGDIR="$(pwd)"
710
TARGET="$ARCH-macos-none"
811
MCPU="baseline"
912
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.2441+eb19f73af"
1013
PREFIX="$HOME/$CACHE_BASENAME"
11-
JOBS="-j3"
12-
13-
rm -rf $PREFIX
14-
cd $HOME
15-
16-
curl -L -O "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
17-
tar xf "$CACHE_BASENAME.tar.xz"
18-
1914
ZIG="$PREFIX/bin/zig"
2015

2116
cd $ZIGDIR
@@ -26,7 +21,6 @@ git config core.abbrev 9
2621
git fetch --unshallow || true
2722
git fetch --tags
2823

29-
rm -rf build
3024
mkdir build
3125
cd build
3226

@@ -36,23 +30,25 @@ cd build
3630
export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-global-cache"
3731
export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-local-cache"
3832

39-
cmake .. \
33+
PATH="$HOME/local/bin:$PATH" cmake .. \
34+
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
4035
-DCMAKE_PREFIX_PATH="$PREFIX" \
4136
-DCMAKE_BUILD_TYPE=Debug \
4237
-DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
4338
-DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
4439
-DZIG_TARGET_TRIPLE="$TARGET" \
4540
-DZIG_TARGET_MCPU="$MCPU" \
46-
-DZIG_STATIC=ON
41+
-DZIG_STATIC=ON \
42+
-GNinja
4743

48-
make $JOBS install
44+
$HOME/local/bin/ninja install
4945

50-
stage3/bin/zig build test docs \
46+
stage3-debug/bin/zig build test docs \
5147
--zig-lib-dir "$(pwd)/../lib" \
5248
-Denable-macos-sdk \
5349
-Dstatic-llvm \
5450
-Dskip-non-native \
5551
--search-prefix "$PREFIX"
5652

5753
# Produce the experimental std lib documentation.
58-
stage3/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
54+
stage3-debug/bin/zig test ../lib/std/std.zig -femit-docs -fno-emit-bin --zig-lib-dir ../lib
File renamed without changes.

0 commit comments

Comments
 (0)