| author | |
| committer | |
| log | 419074a81ba7d7111bae7d07af26aad9c7deeb1f |
| tree | a84ac7699832e56585e18802ac14cb6eeda924a2 |
| parent | 2f42a2617b55c497bc13a44f64a921e6d2620acf |
* build.zig: remove detour through zig0. I'll add it back as an option
later. This means you can build stage1 with a freshly built zig
without detouring through zig0 again.
* remove unused file windows_script.bat
* drone.yml: remove unnecessary steps
* ninja doesn't need a jobs parameter
* build the release version of zig with zig build instead of cmake.
* build stage2 with -Dstatic-llvm -Duse-zig-libcxx7 files changed, 67 insertions(+), 172 deletions(-)
build.zig+9-66| ... | ... | @@ -136,7 +136,7 @@ pub fn build(b: *Builder) !void { |
| 136 | 136 | break :blk 4; |
| 137 | 137 | }; |
| 138 | 138 | |
| 139 | const main_file: ?[]const u8 = if (is_stage1) null else "src/main.zig"; | |
| 139 | const main_file: []const u8 = if (is_stage1) "src/stage1.zig" else "src/main.zig"; | |
| 140 | 140 | |
| 141 | 141 | const exe = b.addExecutable("zig", main_file); |
| 142 | 142 | exe.strip = strip; |
| ... | ... | @@ -245,74 +245,17 @@ pub fn build(b: *Builder) !void { |
| 245 | 245 | softfloat.addCSourceFiles(&softfloat_sources, &[_][]const u8{ "-std=c99", "-O3" }); |
| 246 | 246 | softfloat.single_threaded = single_threaded; |
| 247 | 247 | |
| 248 | const zig0 = b.addExecutable("zig0", null); | |
| 249 | zig0.addCSourceFiles(&.{"src/stage1/zig0.cpp"}, &exe_cflags); | |
| 250 | zig0.addIncludePath("zig-cache/tmp"); // for config.h | |
| 251 | zig0.defineCMacro("ZIG_VERSION_MAJOR", b.fmt("{d}", .{zig_version.major})); | |
| 252 | zig0.defineCMacro("ZIG_VERSION_MINOR", b.fmt("{d}", .{zig_version.minor})); | |
| 253 | zig0.defineCMacro("ZIG_VERSION_PATCH", b.fmt("{d}", .{zig_version.patch})); | |
| 254 | zig0.defineCMacro("ZIG_VERSION_STRING", b.fmt("\"{s}\"", .{version})); | |
| 248 | exe.addIncludePath("src"); | |
| 249 | exe.addIncludePath("deps/SoftFloat-3e/source/include"); | |
| 250 | exe.addIncludePath("deps/SoftFloat-3e-prebuilt"); | |
| 255 | 251 | |
| 256 | for ([_]*std.build.LibExeObjStep{ zig0, exe, test_stage2 }) |artifact| { | |
| 257 | artifact.addIncludePath("src"); | |
| 258 | artifact.addIncludePath("deps/SoftFloat-3e/source/include"); | |
| 259 | artifact.addIncludePath("deps/SoftFloat-3e-prebuilt"); | |
| 252 | exe.defineCMacro("ZIG_LINK_MODE", "Static"); | |
| 260 | 253 | |
| 261 | artifact.defineCMacro("ZIG_LINK_MODE", "Static"); | |
| 254 | exe.addCSourceFiles(&stage1_sources, &exe_cflags); | |
| 255 | exe.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); | |
| 262 | 256 | |
| 263 | artifact.addCSourceFiles(&stage1_sources, &exe_cflags); | |
| 264 | artifact.addCSourceFiles(&optimized_c_sources, &[_][]const u8{ "-std=c99", "-O3" }); | |
| 265 | ||
| 266 | artifact.linkLibrary(softfloat); | |
| 267 | artifact.linkLibCpp(); | |
| 268 | } | |
| 269 | ||
| 270 | try addStaticLlvmOptionsToExe(zig0); | |
| 271 | ||
| 272 | const zig1_obj_ext = target.getObjectFormat().fileExt(target.getCpuArch()); | |
| 273 | const zig1_obj_path = b.pathJoin(&.{ "zig-cache", "tmp", b.fmt("zig1{s}", .{zig1_obj_ext}) }); | |
| 274 | const zig1_compiler_rt_path = b.pathJoin(&.{ b.pathFromRoot("lib"), "std", "special", "compiler_rt.zig" }); | |
| 275 | ||
| 276 | const zig1_obj = zig0.run(); | |
| 277 | zig1_obj.addArgs(&.{ | |
| 278 | "src/stage1.zig", | |
| 279 | "-target", | |
| 280 | try target.zigTriple(b.allocator), | |
| 281 | "-mcpu=baseline", | |
| 282 | "--name", | |
| 283 | "zig1", | |
| 284 | "--zig-lib-dir", | |
| 285 | b.pathFromRoot("lib"), | |
| 286 | b.fmt("-femit-bin={s}", .{b.pathFromRoot(zig1_obj_path)}), | |
| 287 | "-fcompiler-rt", | |
| 288 | "-lc", | |
| 289 | }); | |
| 290 | { | |
| 291 | zig1_obj.addArgs(&.{ "--pkg-begin", "build_options" }); | |
| 292 | zig1_obj.addFileSourceArg(exe_options.getSource()); | |
| 293 | zig1_obj.addArgs(&.{ "--pkg-end", "--pkg-begin", "compiler_rt", zig1_compiler_rt_path, "--pkg-end" }); | |
| 294 | } | |
| 295 | switch (mode) { | |
| 296 | .Debug => {}, | |
| 297 | .ReleaseFast => { | |
| 298 | zig1_obj.addArg("-OReleaseFast"); | |
| 299 | zig1_obj.addArg("--strip"); | |
| 300 | }, | |
| 301 | .ReleaseSafe => { | |
| 302 | zig1_obj.addArg("-OReleaseSafe"); | |
| 303 | zig1_obj.addArg("--strip"); | |
| 304 | }, | |
| 305 | .ReleaseSmall => { | |
| 306 | zig1_obj.addArg("-OReleaseSmall"); | |
| 307 | zig1_obj.addArg("--strip"); | |
| 308 | }, | |
| 309 | } | |
| 310 | if (single_threaded orelse false) { | |
| 311 | zig1_obj.addArg("-fsingle-threaded"); | |
| 312 | } | |
| 313 | ||
| 314 | exe.step.dependOn(&zig1_obj.step); | |
| 315 | exe.addObjectFile(zig1_obj_path); | |
| 257 | exe.linkLibrary(softfloat); | |
| 258 | exe.linkLibCpp(); | |
| 316 | 259 | |
| 317 | 260 | // This is intentionally a dummy path. stage1.zig tries to @import("compiler_rt") in case |
| 318 | 261 | // of being built by cmake. But when built by zig it's gonna get a compiler_rt so that |
ci/azure/windows_script.bat deleted-8| ... | ... | @@ -1,8 +0,0 @@ |
| 1 | @echo on | |
| 2 | SET "SRCROOT=%cd%" | |
| 3 | SET "PREVPATH=%PATH%" | |
| 4 | SET "PREVMSYSTEM=%MSYSTEM%" | |
| 5 | ||
| 6 | set "PATH=%CD:~0,2%\msys64\usr\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem" | |
| 7 | SET "MSYSTEM=MINGW64" | |
| 8 | bash -lc "cd ${SRCROOT} && ci/azure/windows_script" || exit /b |
ci/zinc/drone.yml-12| ... | ... | @@ -9,19 +9,7 @@ workspace: |
| 9 | 9 | path: /workspace |
| 10 | 10 | |
| 11 | 11 | steps: |
| 12 | - name: probe | |
| 13 | image: ci/debian-amd64:11.1-3 | |
| 14 | commands: | |
| 15 | - ./ci/zinc/linux_probe.sh | |
| 16 | ||
| 17 | - name: build | |
| 18 | image: ci/debian-amd64:11.1-3 | |
| 19 | commands: | |
| 20 | - ./ci/zinc/linux_build.sh | |
| 21 | ||
| 22 | 12 | - name: test |
| 23 | depends_on: | |
| 24 | - build | |
| 25 | 13 | image: ci/debian-amd64:11.1-3 |
| 26 | 14 | commands: |
| 27 | 15 | - ./ci/zinc/linux_test.sh |
ci/zinc/linux_base.sh-1| ... | ... | @@ -17,7 +17,6 @@ set -x |
| 17 | 17 | set -e |
| 18 | 18 | |
| 19 | 19 | ARCH="$(uname -m)" |
| 20 | JOBS="-j$(nproc)" | |
| 21 | 20 | |
| 22 | 21 | DEPS_LOCAL="/deps/local" |
| 23 | 22 | WORKSPACE="$DRONE_WORKSPACE" |
ci/zinc/linux_build.sh deleted-72| ... | ... | @@ -1,72 +0,0 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | ZIG="$DEPS_LOCAL/bin/zig" | |
| 6 | TARGET="${ARCH}-linux-musl" | |
| 7 | MCPU="baseline" | |
| 8 | ||
| 9 | # Make the `zig version` number consistent. | |
| 10 | # This will affect the cmake command below. | |
| 11 | git config core.abbrev 9 | |
| 12 | ||
| 13 | # Build debug zig. | |
| 14 | echo "BUILD debug zig with zig:$($ZIG version)" | |
| 15 | ||
| 16 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 17 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 18 | ||
| 19 | mkdir _debug | |
| 20 | cd _debug | |
| 21 | cmake .. \ | |
| 22 | -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ | |
| 23 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 24 | -DCMAKE_BUILD_TYPE=Debug \ | |
| 25 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 26 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 27 | -DZIG_STATIC=ON \ | |
| 28 | -GNinja | |
| 29 | ||
| 30 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | |
| 31 | # so that installation and testing do not get affected by them. | |
| 32 | unset CC | |
| 33 | unset CXX | |
| 34 | ||
| 35 | ninja $JOBS install | |
| 36 | ||
| 37 | ZIG=$DEBUG_STAGING/bin/zig | |
| 38 | ||
| 39 | # Here we rebuild zig but this time using the Zig binary we just now produced to | |
| 40 | # build zig1.o rather than relying on the one built with stage0. See | |
| 41 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 42 | cmake .. -DZIG_EXECUTABLE="$ZIG" | |
| 43 | ninja $JOBS install | |
| 44 | ||
| 45 | cd $WORKSPACE | |
| 46 | ||
| 47 | # Build release zig. | |
| 48 | echo "BUILD release zig with zig:$($ZIG version)" | |
| 49 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 50 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 51 | mkdir _release | |
| 52 | cd _release | |
| 53 | cmake .. \ | |
| 54 | -DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \ | |
| 55 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 56 | -DCMAKE_BUILD_TYPE=Release \ | |
| 57 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 58 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 59 | -DZIG_STATIC=ON \ | |
| 60 | -GNinja | |
| 61 | unset CC | |
| 62 | unset CXX | |
| 63 | ninja $JOBS install | |
| 64 | ||
| 65 | cd $WORKSPACE | |
| 66 | ||
| 67 | # Look for non-conforming code formatting. | |
| 68 | # Formatting errors can be fixed by running `zig fmt` on the files printed here. | |
| 69 | $ZIG fmt --check . | |
| 70 | ||
| 71 | # Explicit exit helps show last command duration. | |
| 72 | exit |
ci/zinc/linux_probe.sh deleted-10| ... | ... | @@ -1,10 +0,0 @@ |
| 1 | #!/bin/sh | |
| 2 | ||
| 3 | . ./ci/zinc/linux_base.sh | |
| 4 | ||
| 5 | # Probe CPU/brand details. | |
| 6 | echo "lscpu:" | |
| 7 | (lscpu | sed 's,^, : ,') 1>&2 | |
| 8 | ||
| 9 | # Explicit exit helps show last command duration. | |
| 10 | exit |
ci/zinc/linux_test.sh+58-3| ... | ... | @@ -2,10 +2,53 @@ |
| 2 | 2 | |
| 3 | 3 | . ./ci/zinc/linux_base.sh |
| 4 | 4 | |
| 5 | ZIG=$DEBUG_STAGING/bin/zig | |
| 5 | ZIG="$DEPS_LOCAL/bin/zig" | |
| 6 | TARGET="${ARCH}-linux-musl" | |
| 7 | MCPU="baseline" | |
| 8 | ||
| 9 | # Make the `zig version` number consistent. | |
| 10 | # This will affect the cmake command below. | |
| 11 | git config core.abbrev 9 | |
| 12 | ||
| 13 | echo "BUILD debug zig with zig:$($ZIG version)" | |
| 14 | ||
| 15 | export CC="$ZIG cc -target $TARGET -mcpu=$MCPU" | |
| 16 | export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU" | |
| 17 | ||
| 18 | mkdir _debug | |
| 19 | cd _debug | |
| 20 | cmake .. \ | |
| 21 | -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \ | |
| 22 | -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \ | |
| 23 | -DCMAKE_BUILD_TYPE=Debug \ | |
| 24 | -DZIG_TARGET_TRIPLE="$TARGET" \ | |
| 25 | -DZIG_TARGET_MCPU="$MCPU" \ | |
| 26 | -DZIG_STATIC=ON \ | |
| 27 | -GNinja | |
| 28 | ||
| 29 | # Now cmake will use zig as the C/C++ compiler. We reset the environment variables | |
| 30 | # so that installation and testing do not get affected by them. | |
| 31 | unset CC | |
| 32 | unset CXX | |
| 33 | ||
| 34 | ninja install | |
| 35 | ||
| 36 | ZIG="$DEBUG_STAGING/bin/zig" | |
| 37 | ||
| 38 | # Here we rebuild zig but this time using the Zig binary we just now produced to | |
| 39 | # build zig1.o rather than relying on the one built with stage0. See | |
| 40 | # https://github.com/ziglang/zig/issues/6830 for more details. | |
| 41 | cmake .. -DZIG_EXECUTABLE="$ZIG" | |
| 42 | ninja install | |
| 43 | ||
| 44 | cd $WORKSPACE | |
| 45 | ||
| 46 | # Look for non-conforming code formatting. | |
| 47 | # Formatting errors can be fixed by running `zig fmt` on the files printed here. | |
| 48 | $ZIG fmt --check . | |
| 6 | 49 | |
| 7 | 50 | # Build stage2 standalone so that we can test stage2 against stage2 compiler-rt. |
| 8 | $ZIG build -p stage2 -Denable-llvm | |
| 51 | $ZIG build -p stage2 -Denable-llvm -Dstatic-llvm -Duse-zig-libcxx | |
| 9 | 52 | |
| 10 | 53 | stage2/bin/zig test test/behavior.zig -I test -fLLVM |
| 11 | 54 | stage2/bin/zig test test/behavior.zig -I test |
| ... | ... | @@ -38,7 +81,7 @@ $ZIG build test-fmt -fqemu -fwasmtime |
| 38 | 81 | $ZIG build test-stage2 -fqemu -fwasmtime |
| 39 | 82 | |
| 40 | 83 | # Produce the experimental std lib documentation. |
| 41 | mkdir -p $RELEASE_STAGING/docs/std | |
| 84 | mkdir -p "$RELEASE_STAGING/docs/std" | |
| 42 | 85 | $ZIG test lib/std/std.zig \ |
| 43 | 86 | --zig-lib-dir lib \ |
| 44 | 87 | -femit-docs=$RELEASE_STAGING/docs/std \ |
| ... | ... | @@ -47,5 +90,17 @@ $ZIG test lib/std/std.zig \ |
| 47 | 90 | # Look for HTML errors. |
| 48 | 91 | tidy --drop-empty-elements no -qe zig-cache/langref.html |
| 49 | 92 | |
| 93 | # Build release zig. | |
| 94 | $ZIG build | |
| 95 | --prefix "RELEASE_STAGING" \ | |
| 96 | --search-prefix "$DEPS_LOCAL" \ | |
| 97 | -Denable-llvm \ | |
| 98 | -Dstatic-llvm \ | |
| 99 | -Drelease \ | |
| 100 | -Dstrip \ | |
| 101 | -Duse-zig-libcxx \ | |
| 102 | -Dtarget="$TARGET" \ | |
| 103 | -Dstage1 | |
| 104 | ||
| 50 | 105 | # Explicit exit helps show last command duration. |
| 51 | 106 | exit |