Skip to content

Commit

Permalink
Merge branch 'master' into file-uris
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamGoertz committed Jun 29, 2023
2 parents 8409968 + 0a6cd25 commit 925b88f
Show file tree
Hide file tree
Showing 2,984 changed files with 87,076 additions and 88,010 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,33 @@ jobs:
uses: actions/checkout@v3
- name: Build and Test
run: sh ci/aarch64-linux-release.sh
x86_64-macos-debug:
x86_64-macos-release:
runs-on: "macos-11"
env:
ARCH: "x86_64"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build and Test
run: ci/x86_64-macos-debug.sh
x86_64-macos-release:
runs-on: "macos-11"
run: ci/x86_64-macos-release.sh
aarch64-macos-debug:
runs-on: [self-hosted, macOS, aarch64]
env:
ARCH: "x86_64"
ARCH: "aarch64"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build and Test
run: ci/x86_64-macos-release.sh
aarch64-macos:
run: ci/aarch64-macos-debug.sh
aarch64-macos-release:
runs-on: [self-hosted, macOS, aarch64]
env:
ARCH: "aarch64"
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Build and Test
run: ci/aarch64-macos.sh
run: ci/aarch64-macos-release.sh
x86_64-windows-debug:
runs-on: windows-latest
env:
Expand Down
23 changes: 16 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ if(ZIG_AR_WORKAROUND)
string(REPLACE "<CMAKE_AR>" "<CMAKE_AR> ar" CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_CXX_ARCHIVE_CREATE})
endif()

set(ZIG_PIE off CACHE BOOL "produce a position independent zig executable")

find_package(llvm 16)
find_package(clang 16)
find_package(lld 16)
Expand Down Expand Up @@ -374,7 +376,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfdi.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfsi.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/fixxfti.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_to_int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_from_float.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdidf.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdihf.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/floatdisf.zig"
Expand Down Expand Up @@ -415,7 +417,7 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/getf2.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/gexf2.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/int_to_float.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/float_from_int.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log10.zig"
"${CMAKE_SOURCE_DIR}/lib/compiler_rt/log2.zig"
Expand Down Expand Up @@ -592,8 +594,10 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/src/link/MachO/dead_strip.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/eh_frame.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/fat.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/hasher.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/load_commands.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/thunks.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/uuid.zig"
"${CMAKE_SOURCE_DIR}/src/link/MachO/zld.zig"
"${CMAKE_SOURCE_DIR}/src/link/Plan9.zig"
"${CMAKE_SOURCE_DIR}/src/link/Plan9/aout.zig"
Expand Down Expand Up @@ -671,7 +675,12 @@ if(ZIG_STATIC)
endif()

add_library(zigcpp STATIC ${ZIG_CPP_SOURCES})
set_target_properties(zigcpp PROPERTIES COMPILE_FLAGS ${EXE_CXX_FLAGS})
if(ZIG_PIE)
set(ZIGCPP_CXX_FLAGS "${EXE_CXX_FLAGS} -fPIC")
else()
set(ZIGCPP_CXX_FLAGS "${EXE_CXX_FLAGS}")
endif()
set_target_properties(zigcpp PROPERTIES COMPILE_FLAGS ${ZIGCPP_CXX_FLAGS})

target_link_libraries(zigcpp LINK_PUBLIC
${CLANG_LIBRARIES}
Expand Down Expand Up @@ -813,7 +822,7 @@ else()
set(ZIG_NO_LANGREF_ARG "")
endif()
if(ZIG_SINGLE_THREADED)
set(ZIG_SINGLE_THREADED_ARG "-fsingle-threaded")
set(ZIG_SINGLE_THREADED_ARG "-Dsingle-threaded")
else()
set(ZIG_SINGLE_THREADED_ARG "")
endif()
Expand All @@ -823,10 +832,10 @@ else()
set(ZIG_STATIC_ARG "")
endif()

if(CMAKE_POSITION_INDEPENDENT_CODE)
set(ZIG_PIE_ARG="-Dpie")
if(CMAKE_POSITION_INDEPENDENT_CODE OR ZIG_PIE)
set(ZIG_PIE_ARG "-Dpie")
else()
set(ZIG_PIE_ARG="")
set(ZIG_PIE_ARG "")
endif()

set(ZIG_BUILD_ARGS
Expand Down
35 changes: 18 additions & 17 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fs = std.fs;
const InstallDirectoryOptions = std.Build.InstallDirectoryOptions;
const assert = std.debug.assert;

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

pub fn build(b: *std.Build) !void {
Expand All @@ -30,6 +30,7 @@ pub fn build(b: *std.Build) !void {
const test_step = b.step("test", "Run all the tests");
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;
const skip_install_langref = b.option(bool, "no-langref", "skip copying of langref to the installation prefix") orelse skip_install_lib_files;
const no_bin = b.option(bool, "no-bin", "skip emitting compiler binary") orelse false;

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

if (!skip_install_lib_files) {
b.installDirectory(InstallDirectoryOptions{
.source_dir = "lib",
.source_dir = .{ .path = "lib" },
.install_dir = .lib,
.install_subdir = "zig",
.exclude_extensions = &[_][]const u8{
Expand Down Expand Up @@ -166,6 +167,7 @@ pub fn build(b: *std.Build) !void {
exe.pie = pie;
exe.sanitize_thread = sanitize_thread;
exe.entitlements = entitlements;
if (no_bin) exe.emit_bin = .no_emit;

exe.build_id = b.option(
std.Build.Step.Compile.BuildId,
Expand Down Expand Up @@ -197,7 +199,7 @@ pub fn build(b: *std.Build) !void {
exe_options.addOption(bool, "llvm_has_xtensa", llvm_has_xtensa);
exe_options.addOption(bool, "force_gpa", force_gpa);
exe_options.addOption(bool, "only_c", only_c);
exe_options.addOption(bool, "omit_pkg_fetching_code", only_c);
exe_options.addOption(bool, "only_core_functionality", only_c);

if (link_libc) {
exe.linkLibC();
Expand Down Expand Up @@ -235,12 +237,12 @@ pub fn build(b: *std.Build) !void {
},
2 => {
// Untagged development build (e.g. 0.10.0-dev.2025+ecf0050a9).
var it = mem.split(u8, git_describe, "-");
var it = mem.splitScalar(u8, git_describe, '-');
const tagged_ancestor = it.first();
const commit_height = it.next().?;
const commit_id = it.next().?;

const ancestor_ver = try std.builtin.Version.parse(tagged_ancestor);
const ancestor_ver = try std.SemanticVersion.parse(tagged_ancestor);
if (zig_version.order(ancestor_ver) != .gt) {
std.debug.print("Zig version '{}' must be greater than tagged ancestor '{}'\n", .{ zig_version, ancestor_ver });
std.process.exit(1);
Expand Down Expand Up @@ -280,7 +282,7 @@ pub fn build(b: *std.Build) !void {
// That means we also have to rely on stage1 compiled c++ files. We parse config.h to find
// the information passed on to us from cmake.
if (cfg.cmake_prefix_path.len > 0) {
var it = mem.tokenize(u8, cfg.cmake_prefix_path, ";");
var it = mem.tokenizeScalar(u8, cfg.cmake_prefix_path, ';');
while (it.next()) |path| {
b.addSearchPrefix(path);
}
Expand Down Expand Up @@ -354,7 +356,7 @@ pub fn build(b: *std.Build) !void {
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, "omit_pkg_fetching_code", true);
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);
Expand Down Expand Up @@ -469,9 +471,8 @@ pub fn build(b: *std.Build) !void {
.skip_non_native = skip_non_native,
.skip_cross_glibc = skip_cross_glibc,
.skip_libc = skip_libc,
// I observed a value of 3398275072 on my M1, and multiplied by 1.1 to
// get this amount:
.max_rss = 3738102579,
// I observed a value of 4572626944 on the M2 CI.
.max_rss = 5029889638,
}));

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

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

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

const run_opt = b.addSystemCommand(&.{
"wasm-opt",
Expand Down Expand Up @@ -685,7 +686,7 @@ fn addCxxKnownPath(
if (!std.process.can_spawn)
return error.RequiredLibraryNotFound;
const path_padded = b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) });
var tokenizer = mem.tokenize(u8, path_padded, "\r\n");
var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n");
const path_unpadded = tokenizer.next().?;
if (mem.eql(u8, path_unpadded, objname)) {
if (errtxt) |msg| {
Expand All @@ -708,7 +709,7 @@ fn addCxxKnownPath(
}

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

var lines_it = mem.tokenize(u8, config_h_text, "\r\n");
var lines_it = mem.tokenizeAny(u8, config_h_text, "\r\n");
while (lines_it.next()) |line| {
inline for (mappings) |mapping| {
if (mem.startsWith(u8, line, mapping.prefix)) {
var it = mem.split(u8, line, "\"");
var it = mem.splitScalar(u8, line, '"');
_ = it.first(); // skip the stuff before the quote
const quoted = it.next().?; // the stuff inside the quote
@field(ctx, mapping.field) = toNativePathSep(b, quoted);
}
}
if (mem.startsWith(u8, line, "#define ZIG_LLVM_LINK_MODE ")) {
var it = mem.split(u8, line, "\"");
var it = mem.splitScalar(u8, line, '"');
_ = it.next().?; // skip the stuff before the quote
const quoted = it.next().?; // the stuff inside the quote
ctx.llvm_linkage = if (mem.eql(u8, quoted, "shared")) .dynamic else .static;
Expand Down
24 changes: 10 additions & 14 deletions ci/x86_64-macos-debug.sh → ci/aarch64-macos-debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,14 @@
set -x
set -e

# Script assumes the presence of the following:
# s3cmd

ZIGDIR="$(pwd)"
TARGET="$ARCH-macos-none"
MCPU="baseline"
CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.11.0-dev.2441+eb19f73af"
PREFIX="$HOME/$CACHE_BASENAME"
JOBS="-j3"

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
Expand All @@ -26,7 +21,6 @@ git config core.abbrev 9
git fetch --unshallow || true
git fetch --tags

rm -rf build
mkdir build
cd build

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

cmake .. \
PATH="$HOME/local/bin:$PATH" cmake .. \
-DCMAKE_INSTALL_PREFIX="stage3-debug" \
-DCMAKE_PREFIX_PATH="$PREFIX" \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER="$ZIG;cc;-target;$TARGET;-mcpu=$MCPU" \
-DCMAKE_CXX_COMPILER="$ZIG;c++;-target;$TARGET;-mcpu=$MCPU" \
-DZIG_TARGET_TRIPLE="$TARGET" \
-DZIG_TARGET_MCPU="$MCPU" \
-DZIG_STATIC=ON
-DZIG_STATIC=ON \
-GNinja

make $JOBS install
$HOME/local/bin/ninja install

stage3/bin/zig build test docs \
stage3-debug/bin/zig build test docs \
--zig-lib-dir "$(pwd)/../lib" \
-Denable-macos-sdk \
-Dstatic-llvm \
-Dskip-non-native \
--search-prefix "$PREFIX"

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

0 comments on commit 925b88f

Please sign in to comment.