Commit 419074a81b
Changed files (7)
ci/azure/windows_script.bat
@@ -1,8 +0,0 @@
-@echo on
-SET "SRCROOT=%cd%"
-SET "PREVPATH=%PATH%"
-SET "PREVMSYSTEM=%MSYSTEM%"
-
-set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem"
-SET "MSYSTEM=MINGW64"
-bash -lc "cd ${SRCROOT} && ci/azure/windows_script" || exit /b
ci/zinc/drone.yml
@@ -9,19 +9,7 @@ workspace:
path: /workspace
steps:
-- name: probe
- image: ci/debian-amd64:11.1-3
- commands:
- - ./ci/zinc/linux_probe.sh
-
-- name: build
- image: ci/debian-amd64:11.1-3
- commands:
- - ./ci/zinc/linux_build.sh
-
- name: test
- depends_on:
- - build
image: ci/debian-amd64:11.1-3
commands:
- ./ci/zinc/linux_test.sh
ci/zinc/linux_base.sh
@@ -17,7 +17,6 @@ set -x
set -e
ARCH="$(uname -m)"
-JOBS="-j$(nproc)"
DEPS_LOCAL="/deps/local"
WORKSPACE="$DRONE_WORKSPACE"
ci/zinc/linux_build.sh
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-. ./ci/zinc/linux_base.sh
-
-ZIG="$DEPS_LOCAL/bin/zig"
-TARGET="${ARCH}-linux-musl"
-MCPU="baseline"
-
-# Make the `zig version` number consistent.
-# This will affect the cmake command below.
-git config core.abbrev 9
-
-# Build debug zig.
-echo "BUILD debug zig with zig:$($ZIG version)"
-
-export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
-export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
-
-mkdir _debug
-cd _debug
-cmake .. \
- -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \
- -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
- -DCMAKE_BUILD_TYPE=Debug \
- -DZIG_TARGET_TRIPLE="$TARGET" \
- -DZIG_TARGET_MCPU="$MCPU" \
- -DZIG_STATIC=ON \
- -GNinja
-
-# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
-# so that installation and testing do not get affected by them.
-unset CC
-unset CXX
-
-ninja $JOBS install
-
-ZIG=$DEBUG_STAGING/bin/zig
-
-# Here we rebuild zig but this time using the Zig binary we just now produced to
-# build zig1.o rather than relying on the one built with stage0. See
-# https://github.com/ziglang/zig/issues/6830 for more details.
-cmake .. -DZIG_EXECUTABLE="$ZIG"
-ninja $JOBS install
-
-cd $WORKSPACE
-
-# Build release zig.
-echo "BUILD release zig with zig:$($ZIG version)"
-export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
-export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
-mkdir _release
-cd _release
-cmake .. \
- -DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \
- -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
- -DCMAKE_BUILD_TYPE=Release \
- -DZIG_TARGET_TRIPLE="$TARGET" \
- -DZIG_TARGET_MCPU="$MCPU" \
- -DZIG_STATIC=ON \
- -GNinja
-unset CC
-unset CXX
-ninja $JOBS install
-
-cd $WORKSPACE
-
-# Look for non-conforming code formatting.
-# Formatting errors can be fixed by running `zig fmt` on the files printed here.
-$ZIG fmt --check .
-
-# Explicit exit helps show last command duration.
-exit
ci/zinc/linux_probe.sh
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-. ./ci/zinc/linux_base.sh
-
-# Probe CPU/brand details.
-echo "lscpu:"
-(lscpu | sed 's,^, : ,') 1>&2
-
-# Explicit exit helps show last command duration.
-exit
ci/zinc/linux_test.sh
@@ -2,10 +2,53 @@
. ./ci/zinc/linux_base.sh
-ZIG=$DEBUG_STAGING/bin/zig
+ZIG="$DEPS_LOCAL/bin/zig"
+TARGET="${ARCH}-linux-musl"
+MCPU="baseline"
+
+# Make the `zig version` number consistent.
+# This will affect the cmake command below.
+git config core.abbrev 9
+
+echo "BUILD debug zig with zig:$($ZIG version)"
+
+export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
+export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
+
+mkdir _debug
+cd _debug
+cmake .. \
+ -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \
+ -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
+ -DCMAKE_BUILD_TYPE=Debug \
+ -DZIG_TARGET_TRIPLE="$TARGET" \
+ -DZIG_TARGET_MCPU="$MCPU" \
+ -DZIG_STATIC=ON \
+ -GNinja
+
+# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
+# so that installation and testing do not get affected by them.
+unset CC
+unset CXX
+
+ninja install
+
+ZIG="$DEBUG_STAGING/bin/zig"
+
+# Here we rebuild zig but this time using the Zig binary we just now produced to
+# build zig1.o rather than relying on the one built with stage0. See
+# https://github.com/ziglang/zig/issues/6830 for more details.
+cmake .. -DZIG_EXECUTABLE="$ZIG"
+ninja install
+
+cd $WORKSPACE
+
+# Look for non-conforming code formatting.
+# Formatting errors can be fixed by running `zig fmt` on the files printed here.
+$ZIG fmt --check .
# Build stage2 standalone so that we can test stage2 against stage2 compiler-rt.
-$ZIG build -p stage2 -Denable-llvm
+$ZIG build -p stage2 -Denable-llvm -Dstatic-llvm -Duse-zig-libcxx
stage2/bin/zig test test/behavior.zig -I test -fLLVM
stage2/bin/zig test test/behavior.zig -I test
@@ -38,7 +81,7 @@ $ZIG build test-fmt -fqemu -fwasmtime
$ZIG build test-stage2 -fqemu -fwasmtime
# Produce the experimental std lib documentation.
-mkdir -p $RELEASE_STAGING/docs/std
+mkdir -p "$RELEASE_STAGING/docs/std"
$ZIG test lib/std/std.zig \
--zig-lib-dir lib \
-femit-docs=$RELEASE_STAGING/docs/std \
@@ -47,5 +90,17 @@ $ZIG test lib/std/std.zig \
# Look for HTML errors.
tidy --drop-empty-elements no -qe zig-cache/langref.html
+# Build release zig.
+$ZIG build
+ --prefix "RELEASE_STAGING" \
+ --search-prefix "$DEPS_LOCAL" \
+ -Denable-llvm \
+ -Dstatic-llvm \
+ -Drelease \
+ -Dstrip \
+ -Duse-zig-libcxx \
+ -Dtarget="$TARGET" \
+ -Dstage1
+
# Explicit exit helps show last command duration.
exit
build.zig
@@ -136,7 +136,7 @@ pub fn build(b: *Builder) !void {
break :blk 4;
};
- const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig";
+ const main_file: []const u8 = if (is_stage1) "src/stage1.zig" else "src/main.zig";
const exe = b.addExecutable("zig", main_file);
exe.strip = strip;
@@ -245,74 +245,17 @@ pub fn build(b: *Builder) !void {
softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" });
softfloat.single_threaded = single_threaded;
- const zig0 = b.addExecutable("zig0", null);
- zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags);
- zig0.addIncludePath("zig-cache/tmp"); // for config.h
- zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major}));
- zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor}));
- zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch}));
- zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version}));
+ exe.addIncludePath("src");
+ exe.addIncludePath("deps/SoftFloat-3e/source/include");
+ exe.addIncludePath("deps/SoftFloat-3e-prebuilt");
- for ([_]*std.build.LibExeObjStep{ zig0, exe, test_stage2 }) |artifact| {
- artifact.addIncludePath("src");
- artifact.addIncludePath("deps/SoftFloat-3e/source/include");
- artifact.addIncludePath("deps/SoftFloat-3e-prebuilt");
+ exe.defineCMacro("ZIG_LINK_MODE", "Static");
- artifact.defineCMacro("ZIG_LINK_MODE", "Static");
+ exe.addCSourceFiles(&stage1_sources, &exe_cflags);
+ exe.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" });
- artifact.addCSourceFiles(&stage1_sources, &exe_cflags);
- artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" });
-
- artifact.linkLibrary(softfloat);
- artifact.linkLibCpp();
- }
-
- try addStaticLlvmOptionsToExe(zig0);
-
- const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch());
- const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) });
- const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" });
-
- const zig1_obj = zig0.run();
- zig1_obj.addArgs(&.{
- "src/stage1.zig",
- "-target",
- try target.zigTriple(b.allocator),
- "-mcpu=baseline",
- "--name",
- "zig1",
- "--zig-lib-dir",
- b.pathFromRoot("lib"),
- b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}),
- "-fcompiler-rt",
- "-lc",
- });
- {
- zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" });
- zig1_obj.addFileSourceArg(exe_options.getSource());
- zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" });
- }
- switch (mode) {
- .Debug => {},
- .ReleaseFast => {
- zig1_obj.addArg("-OReleaseFast");
- zig1_obj.addArg("--strip");
- },
- .ReleaseSafe => {
- zig1_obj.addArg("-OReleaseSafe");
- zig1_obj.addArg("--strip");
- },
- .ReleaseSmall => {
- zig1_obj.addArg("-OReleaseSmall");
- zig1_obj.addArg("--strip");
- },
- }
- if (single_threaded orelse false) {
- zig1_obj.addArg("-fsingle-threaded");
- }
-
- exe.step.dependOn(&zig1_obj.step);
- exe.addObjectFile(zig1_obj_path);
+ exe.linkLibrary(softfloat);
+ exe.linkLibCpp();
// This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case
// of being built by cmake. But when built by zig it's gonna get a compiler_rt so that