authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-08-29 16:52:36-04:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2022-08-29 16:52:36-04:00
loge69973beddcd8a42dbc7ebcfb96187e5a6f61b61
tree61d3360ed907d41f641be96f560d8f0a1fb713fd
parent9cca6728e58351bb34cc7f4880481350a279fede
parent532cfb65e018c216972cb50a82c7a0379934c8cc
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #12508 from ziglang/cmake-stage3

cmake: build stage3 by default

29 files changed, 487 insertions(+), 572 deletions(-)

CMakeLists.txt+76-66
......@@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE)
1212endif()
1313
1414if(NOT CMAKE_INSTALL_PREFIX)
15 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage2" CACHE STRING
15 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage3" CACHE STRING
1616 "Directory to install zig to" FORCE)
1717endif()
1818
......@@ -65,6 +65,9 @@ if("${ZIG_VERSION}" STREQUAL "")
6565endif()
6666message(STATUS "Configuring zig version ${ZIG_VERSION}")
6767
68set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL
69 "Disable copying lib/ files to install prefix during the build phase")
70
6871set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
6972set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries")
7073set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")
......@@ -333,7 +336,7 @@ set(ZIG_CONFIG_H_OUT "${CMAKE_BINARY_DIR}/config.h")
333336set(ZIG_CONFIG_ZIG_OUT "${CMAKE_BINARY_DIR}/config.zig")
334337
335338# This is our shim which will be replaced by stage1.zig.
336set(ZIG0_SOURCES
339set(ZIG1_SOURCES
337340 "${CMAKE_SOURCE_DIR}/src/stage1/zig0.cpp"
338341)
339342
......@@ -373,9 +376,9 @@ set(ZIG_CPP_SOURCES
373376 # https://github.com/ziglang/zig/issues/6363
374377 "${CMAKE_SOURCE_DIR}/src/windows_sdk.cpp"
375378)
376# Needed because we use cmake, not the zig build system, to build zig1.o.
379# Needed because we use cmake, not the zig build system, to build zig2.o.
377380# This list is generated by building zig and then clearing the zig-cache directory,
378# then manually running the build-obj command (see BUILD_ZIG1_ARGS), and then looking
381# then manually running the build-obj command (see BUILD_ZIG2_ARGS), and then looking
379382# in the zig-cache directory for the compiler-generated list of zig file dependencies.
380383set(ZIG_STAGE2_SOURCES
381384 "${ZIG_CONFIG_ZIG_OUT}"
......@@ -942,40 +945,51 @@ if(MSVC OR MINGW)
942945endif()
943946
944947if("${ZIG_EXECUTABLE}" STREQUAL "")
945 add_executable(zig0 ${ZIG0_SOURCES})
946 set_target_properties(zig0 PROPERTIES
948 add_executable(zig1 ${ZIG1_SOURCES})
949 set_target_properties(zig1 PROPERTIES
947950 COMPILE_FLAGS ${EXE_CFLAGS}
948951 LINK_FLAGS ${EXE_LDFLAGS}
949952 )
950 target_link_libraries(zig0 zigstage1)
953 target_link_libraries(zig1 zigstage1)
951954endif()
952955
953956if(MSVC)
954 set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.obj")
957 set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.obj")
955958else()
956 set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.o")
959 set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.o")
957960endif()
958961if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
959 set(ZIG1_RELEASE_ARG "")
962 set(ZIG_RELEASE_ARG "")
963elseif("${CMAKE_BUILD_TYPE}" STREQUAL "RelWithDebInfo")
964 set(ZIG_RELEASE_ARG -Drelease)
960965else()
961 set(ZIG1_RELEASE_ARG -OReleaseFast --strip)
966 set(ZIG_RELEASE_ARG -Drelease -Dstrip)
967endif()
968if(ZIG_SKIP_INSTALL_LIB_FILES)
969 set(ZIG_SKIP_INSTALL_LIB_FILES_ARG "-Dskip-install-lib-files")
970else()
971 set(ZIG_SKIP_INSTALL_LIB_FILES_ARG "-Dskip-install-lib-files=false")
962972endif()
963973if(ZIG_SINGLE_THREADED)
964 set(ZIG1_SINGLE_THREADED_ARG "-fsingle-threaded")
974 set(ZIG_SINGLE_THREADED_ARG "-fsingle-threaded")
975else()
976 set(ZIG_SINGLE_THREADED_ARG "")
977endif()
978if(ZIG_STATIC)
979 set(ZIG_STATIC_ARG "-Duse-zig-libcxx")
965980else()
966 set(ZIG1_SINGLE_THREADED_ARG "")
981 set(ZIG_STATIC_ARG "")
967982endif()
968983
969set(BUILD_ZIG1_ARGS
984set(BUILD_ZIG2_ARGS
970985 "src/stage1.zig"
971 -target "${ZIG_TARGET_TRIPLE}"
972 "-mcpu=${ZIG_TARGET_MCPU}"
973 --name zig1
986 --name zig2
974987 --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
975 "-femit-bin=${ZIG1_OBJECT}"
988 "-femit-bin=${ZIG2_OBJECT}"
976989 -fcompiler-rt
977 "${ZIG1_RELEASE_ARG}"
978 "${ZIG1_SINGLE_THREADED_ARG}"
990 ${ZIG_SINGLE_THREADED_ARG}
991 -target "${ZIG_TARGET_TRIPLE}"
992 -mcpu "${ZIG_TARGET_MCPU}"
979993 -lc
980994 --pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"
981995 --pkg-end
......@@ -985,68 +999,64 @@ set(BUILD_ZIG1_ARGS
985999
9861000if("${ZIG_EXECUTABLE}" STREQUAL "")
9871001 add_custom_command(
988 OUTPUT "${ZIG1_OBJECT}"
989 COMMAND zig0 ${BUILD_ZIG1_ARGS}
990 DEPENDS zig0 "${ZIG_STAGE2_SOURCES}"
991 COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"
992 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
1002 OUTPUT "${ZIG2_OBJECT}"
1003 COMMAND zig1 ${BUILD_ZIG2_ARGS}
1004 DEPENDS zig1 "${ZIG_STAGE2_SOURCES}"
1005 COMMENT STATUS "Building stage2 object ${ZIG2_OBJECT}"
1006 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
9931007 )
994 set(ZIG_EXECUTABLE "${zig_BINARY_DIR}/zig")
9951008 if (WIN32)
996 set(ZIG_EXECUTABLE "${ZIG_EXECUTABLE}.exe")
1009 set(ZIG_EXECUTABLE "${zig2_BINARY_DIR}/zig2.exe")
1010 else()
1011 set(ZIG_EXECUTABLE "${zig2_BINARY_DIR}/zig2")
9971012 endif()
9981013else()
9991014 add_custom_command(
1000 OUTPUT "${ZIG1_OBJECT}"
1001 COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG1_ARGS}
1002 DEPENDS ${ZIG_STAGE2_SOURCES}
1003 COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"
1004 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
1015 OUTPUT "${ZIG2_OBJECT}"
1016 COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG2_ARGS}
1017 DEPENDS ${ZIG_STAGE2_SOURCES}
1018 COMMENT STATUS "Building stage2 component ${ZIG2_OBJECT}"
1019 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
10051020 )
10061021endif()
10071022
10081023# cmake won't let us configure an executable without C sources.
1009add_executable(zig "${CMAKE_SOURCE_DIR}/src/stage1/empty.cpp" "${ZIG1_OBJECT}")
1024add_executable(zig2 "${CMAKE_SOURCE_DIR}/src/stage1/empty.cpp" "${ZIG2_OBJECT}")
10101025
1011set_target_properties(zig PROPERTIES
1026set_target_properties(zig2 PROPERTIES
10121027 COMPILE_FLAGS ${EXE_CFLAGS}
10131028 LINK_FLAGS ${EXE_LDFLAGS}
10141029)
1015target_link_libraries(zig zigstage1)
1030target_link_libraries(zig2 zigstage1)
10161031if(MSVC)
1017 target_link_libraries(zig ntdll.lib)
1032 target_link_libraries(zig2 ntdll.lib)
10181033elseif(MINGW)
1019 target_link_libraries(zig ntdll)
1034 target_link_libraries(zig2 ntdll)
10201035endif()
10211036
1022install(TARGETS zig DESTINATION bin)
1023
1024set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL
1025 "Disable copying lib/ files to install prefix during the build phase")
1026
1037# Dummy install command so that the "install" target is not missing.
1038# This is redundant from the "stage3" custom target below.
10271039if(NOT ZIG_SKIP_INSTALL_LIB_FILES)
1028 set(ZIG_INSTALL_ARGS "build"
1029 --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
1030 "-Dlib-files-only"
1031 --prefix "${CMAKE_INSTALL_PREFIX}"
1032 "-Dconfig_h=${ZIG_CONFIG_H_OUT}"
1033 install
1034 )
1035
1036 # CODE has no effect with Visual Studio build system generator, therefore
1037 # when using Visual Studio build system generator we resort to running
1038 # `zig build install` during the build phase.
1039 if(MSVC)
1040 add_custom_target(zig_install_lib_files ALL
1041 COMMAND zig ${ZIG_INSTALL_ARGS}
1042 DEPENDS zig
1043 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
1044 )
1045 else()
1046 get_target_property(zig_BINARY_DIR zig BINARY_DIR)
1047 install(CODE "set(zig_EXE \"${ZIG_EXECUTABLE}\")")
1048 install(CODE "set(ZIG_INSTALL_ARGS \"${ZIG_INSTALL_ARGS}\")")
1049 install(CODE "set(CMAKE_SOURCE_DIR \"${CMAKE_SOURCE_DIR}\")")
1050 install(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake)
1051 endif()
1040 install(FILES "lib/compiler_rt.zig" DESTINATION "lib/zig")
10521041endif()
1042
1043set(ZIG_INSTALL_ARGS "build"
1044 --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
1045 --prefix "${CMAKE_INSTALL_PREFIX}"
1046 "-Dconfig_h=${ZIG_CONFIG_H_OUT}"
1047 "-Denable-llvm"
1048 "-Denable-stage1"
1049 ${ZIG_RELEASE_ARG}
1050 ${ZIG_STATIC_ARG}
1051 ${ZIG_SKIP_INSTALL_LIB_FILES_ARG}
1052 ${ZIG_SINGLE_THREADED_ARG}
1053 "-Dtarget=${ZIG_TARGET_TRIPLE}"
1054 "-Dcpu=${ZIG_TARGET_MCPU}"
1055)
1056
1057add_custom_target(stage3 ALL
1058 COMMAND zig2 ${ZIG_INSTALL_ARGS}
1059 DEPENDS zig2
1060 COMMENT STATUS "Building stage3"
1061 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
1062)
ci/azure/macos_arm64_script deleted-132
......@@ -1,132 +0,0 @@
1#!/bin/sh
2
3set -x
4set -e
5
6brew update && brew install ncurses s3cmd
7
8ZIGDIR="$(pwd)"
9
10HOST_ARCH="x86_64"
11HOST_TARGET="$HOST_ARCH-macos-none"
12HOST_MCPU="baseline"
13HOST_CACHE_BASENAME="zig+llvm+lld+clang-$HOST_TARGET-0.10.0-dev.2931+bdf3fa12f"
14HOST_PREFIX="$HOME/$HOST_CACHE_BASENAME"
15
16ARCH="aarch64"
17TARGET="$ARCH-macos-none"
18MCPU="apple_a14"
19CACHE_BASENAME="zig+llvm+lld+clang-$TARGET-0.10.0-dev.2931+bdf3fa12f"
20PREFIX="$HOME/$CACHE_BASENAME"
21
22JOBS="-j2"
23
24rm -rf $HOST_PREFIX $PREFIX
25cd $HOME
26
27wget -nv "https://ziglang.org/deps/$HOST_CACHE_BASENAME.tar.xz"
28wget -nv "https://ziglang.org/deps/$CACHE_BASENAME.tar.xz"
29tar xf "$HOST_CACHE_BASENAME.tar.xz"
30tar xf "$CACHE_BASENAME.tar.xz"
31
32cd $ZIGDIR
33
34# Make the `zig version` number consistent.
35# This will affect the cmake command below.
36git config core.abbrev 9
37git fetch --unshallow || true
38git fetch --tags
39
40# Build host zig compiler in debug so that we can get the
41# current version when packaging
42
43ZIG="$HOST_PREFIX/bin/zig"
44
45export CC="$ZIG cc -target $HOST_TARGET -mcpu=$HOST_MCPU"
46export CXX="$ZIG c++ -target $HOST_TARGET -mcpu=$HOST_MCPU"
47
48mkdir build.host
49cd build.host
50cmake .. \
51 -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
52 -DCMAKE_PREFIX_PATH="$HOST_PREFIX" \
53 -DCMAKE_BUILD_TYPE=Release \
54 -DZIG_TARGET_TRIPLE="$HOST_TARGET" \
55 -DZIG_TARGET_MCPU="$HOST_MCPU" \
56 -DZIG_STATIC=ON \
57 -DZIG_OMIT_STAGE2=ON
58
59unset CC
60unset CXX
61
62make $JOBS install
63
64# Build zig compiler cross-compiled for arm64
65cd $ZIGDIR
66
67ZIG="$ZIGDIR/build.host/release/bin/zig"
68
69export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
70export CXX="$ZIG c++ -target $TARGET -mcpu=$MCPU"
71
72mkdir build
73cd build
74cmake .. \
75 -DCMAKE_INSTALL_PREFIX="$(pwd)/release" \
76 -DCMAKE_PREFIX_PATH="$PREFIX" \
77 -DCMAKE_BUILD_TYPE=Release \
78 -DZIG_TARGET_TRIPLE="$TARGET" \
79 -DZIG_TARGET_MCPU="$MCPU" \
80 -DZIG_EXECUTABLE="$ZIG" \
81 -DZIG_STATIC=ON
82
83unset CC
84unset CXX
85
86make $JOBS install
87
88if [ "${BUILD_REASON}" != "PullRequest" ]; then
89 mv ../LICENSE release/
90
91 # We do not run test suite but still need langref.
92 mkdir -p release/docs
93 $ZIG run ../doc/docgen.zig -- $ZIG ../doc/langref.html.in release/docs/langref.html
94
95 # Produce the experimental std lib documentation.
96 mkdir -p release/docs/std
97 $ZIG test ../lib/std/std.zig \
98 --zig-lib-dir ../lib \
99 -femit-docs=release/docs/std \
100 -fno-emit-bin
101
102 mv release/bin/zig release/
103 rmdir release/bin
104
105 VERSION=$(../build.host/release/bin/zig version)
106 DIRNAME="zig-macos-$ARCH-$VERSION"
107 TARBALL="$DIRNAME.tar.xz"
108 mv release "$DIRNAME"
109 tar cfJ "$TARBALL" "$DIRNAME"
110
111 mv "$DOWNLOADSECUREFILE_SECUREFILEPATH" "$HOME/.s3cfg"
112 s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
113
114 SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
115 BYTESIZE=$(wc -c < $TARBALL)
116
117 JSONFILE="macos-$GITBRANCH.json"
118 touch $JSONFILE
119 echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
120 echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
121 echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
122
123 s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
124 s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-macos-$VERSION.json"
125
126 # `set -x` causes these variables to be mangled.
127 # See https://developercommunity.visualstudio.com/content/problem/375679/pipeline-variable-incorrectly-inserts-single-quote.html
128 set +x
129 echo "##vso[task.setvariable variable=tarball;isOutput=true]$TARBALL"
130 echo "##vso[task.setvariable variable=shasum;isOutput=true]$SHASUM"
131 echo "##vso[task.setvariable variable=bytesize;isOutput=true]$BYTESIZE"
132fi
ci/azure/macos_script+1-9
......@@ -34,6 +34,7 @@ git fetch --tags
3434mkdir build
3535cd build
3636cmake .. \
37 -DCMAKE_INSTALL_PREFIX="stage3-release" \
3738 -DCMAKE_PREFIX_PATH="$PREFIX" \
3839 -DCMAKE_BUILD_TYPE=Release \
3940 -DZIG_TARGET_TRIPLE="$TARGET" \
......@@ -47,15 +48,6 @@ unset CXX
4748
4849make $JOBS install
4950
50stage2/bin/zig build \
51 --prefix stage3-release \
52 --search-prefix "$PREFIX" \
53 -Dstatic-llvm \
54 -Drelease \
55 -Dstrip \
56 -Dtarget="$TARGET" \
57 -Denable-stage1
58
5951stage3-release/bin/zig build test docs \
6052 -Denable-macos-sdk \
6153 -Dstatic-llvm \
ci/azure/pipelines.yml-12
......@@ -10,17 +10,6 @@ jobs:
1010 - script: ci/azure/macos_script
1111 name: main
1212 displayName: 'Build and test'
13- job: BuildMacOS_arm64
14 pool:
15 vmImage: 'macOS-11'
16 timeoutInMinutes: 180
17 steps:
18 - task: DownloadSecureFile@1
19 inputs:
20 secureFile: s3cfg
21 - script: ci/azure/macos_arm64_script
22 name: main
23 displayName: 'Build'
2413- job: BuildWindows
2514 timeoutInMinutes: 360
2615 pool:
......@@ -155,7 +144,6 @@ jobs:
155144- job: OnMasterSuccess
156145 dependsOn:
157146 - BuildMacOS
158 - BuildMacOS_arm64
159147 - BuildWindows
160148 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
161149 strategy:
ci/drone/linux_script_base deleted-22
......@@ -1,22 +0,0 @@
1#!/bin/sh
2
3# https://docs.drone.io/pipeline/docker/syntax/workspace/
4#
5# Drone automatically creates a temporary volume, known as your workspace,
6# where it clones your repository. The workspace is the current working
7# directory for each step in your pipeline.
8#
9# Because the workspace is a volume, filesystem changes are persisted between
10# pipeline steps. In other words, individual steps can communicate and share
11# state using the filesystem.
12#
13# Workspace volumes are ephemeral. They are created when the pipeline starts
14# and destroyed after the pipeline completes.
15
16set -x
17set -e
18
19TRIPLEARCH="$(uname -m)"
20DISTDIR="$DRONE_WORKSPACE/dist"
21
22export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
ci/drone/linux_script_build+10-19
......@@ -1,17 +1,16 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5# Probe CPU/brand details.
6# TODO: `lscpu` is changing package names in EDGE to `util-linux-misc`
7apk update
8apk add util-linux
9echo "lscpu:"
10lscpu | sed 's,^, : ,'
6ARCH="$(uname -m)"
7INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
8
9export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
1110
1211PREFIX="/deps/local"
1312ZIG="$PREFIX/bin/zig"
14TARGET="$TRIPLEARCH-linux-musl"
13TARGET="$ARCH-linux-musl"
1514MCPU="baseline"
1615
1716export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
......@@ -30,8 +29,8 @@ cat <<'ENDFILE' >$PREFIX/bin/ranlib
3029/deps/local/bin/zig ranlib $@
3130ENDFILE
3231
33chmod +x $PREFIX/bin/ar
34chmod +x $PREFIX/bin/ranlib
32chmod +x "$PREFIX/bin/ar"
33chmod +x "$PREFIX/bin/ranlib"
3534
3635# Make the `zig version` number consistent.
3736# This will affect the cmake command below.
......@@ -43,6 +42,7 @@ mkdir build
4342cd build
4443cmake .. \
4544 -DCMAKE_PREFIX_PATH="$PREFIX" \
45 -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \
4646 -DCMAKE_BUILD_TYPE=Release \
4747 -DCMAKE_AR="$PREFIX/bin/ar" \
4848 -DCMAKE_RANLIB="$PREFIX/bin/ranlib" \
......@@ -56,12 +56,3 @@ cmake .. \
5656unset CC
5757unset CXX
5858samu install
59
60stage2/bin/zig build \
61 --prefix "$DISTDIR" \
62 --search-prefix "$PREFIX" \
63 -Dstatic-llvm \
64 -Drelease \
65 -Dstrip \
66 -Dtarget="$TARGET" \
67 -Denable-stage1
ci/drone/linux_script_finalize+15-9
......@@ -1,6 +1,12 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
5
6ARCH="$(uname -m)"
7INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
8
9export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
410
511if [ -n "$DRONE_PULL_REQUEST" ]; then
612 exit 0
......@@ -12,16 +18,16 @@ pip3 install s3cmd
1218
1319cd build
1420
15mv ../LICENSE "$DISTDIR/"
16mv ../zig-cache/langref.html "$DISTDIR/"
17mv "$DISTDIR/bin/zig" "$DISTDIR/"
18rmdir "$DISTDIR/bin"
21mv ../LICENSE "$INSTALL_PREFIX/"
22mv ../zig-cache/langref.html "$INSTALL_PREFIX/"
23mv "$INSTALL_PREFIX/bin/zig" "$INSTALL_PREFIX/"
24rmdir "$INSTALL_PREFIX/bin"
1925
2026GITBRANCH="$DRONE_BRANCH"
21VERSION="$("$DISTDIR/zig" version)"
22DIRNAME="zig-linux-$TRIPLEARCH-$VERSION"
27VERSION="$("$INSTALL_PREFIX/zig" version)"
28DIRNAME="zig-linux-$ARCH-$VERSION"
2329TARBALL="$DIRNAME.tar.xz"
24mv "$DISTDIR" "$DIRNAME"
30mv "$INSTALL_PREFIX" "$DIRNAME"
2531tar cfJ "$TARBALL" "$DIRNAME"
2632
2733s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
......@@ -35,7 +41,7 @@ echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
3541echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
3642echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
3743
38s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$TRIPLEARCH-linux-$VERSION.json"
44s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
3945if [ "$GITBRANCH" = "master" ]; then
4046 # avoid leaking oauth token
4147 set +x
ci/drone/test_linux_behavior+10-5
......@@ -1,8 +1,13 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5./build/zig build test-behavior -Dskip-non-native
6./build/zig build test-compiler-rt -Dskip-non-native
7./build/zig build test-fmt
8./build/zig build docs
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9
10$ZIG build test-behavior -Dskip-non-native
11$ZIG build test-compiler-rt -Dskip-non-native
12$ZIG build test-fmt
13$ZIG build docs
ci/drone/test_linux_cases+8-3
......@@ -1,6 +1,11 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5./build/zig build -Dskip-non-native # test building self-hosted without LLVM
6./build/zig build -Dskip-non-native test-cases
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9
10$ZIG build -Dskip-non-native # test building self-hosted without LLVM
11$ZIG build -Dskip-non-native test-cases
ci/drone/test_linux_misc+13-8
......@@ -1,11 +1,16 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5./build/zig build test-universal-libc -Dskip-non-native
6./build/zig build test-compare-output -Dskip-non-native
7./build/zig build test-standalone -Dskip-non-native -Dskip-release-safe
8./build/zig build test-stack-traces -Dskip-non-native
9./build/zig build test-cli -Dskip-non-native
10./build/zig build test-asm-link -Dskip-non-native
11./build/zig build test-translate-c -Dskip-non-native
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9
10$ZIG build test-universal-libc -Dskip-non-native
11$ZIG build test-compare-output -Dskip-non-native
12$ZIG build test-standalone -Dskip-non-native -Dskip-release-safe
13$ZIG build test-stack-traces -Dskip-non-native
14$ZIG build test-cli -Dskip-non-native
15$ZIG build test-asm-link -Dskip-non-native
16$ZIG build test-translate-c -Dskip-non-native
ci/drone/test_linux_std_Debug+7-2
......@@ -1,5 +1,10 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5./build/zig build test-std -Dskip-release-safe -Dskip-release-fast -Dskip-release-small -Dskip-non-native
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9
10$ZIG build test-std -Dskip-release-safe -Dskip-release-fast -Dskip-release-small -Dskip-non-native
ci/drone/test_linux_std_ReleaseFast+7-2
......@@ -1,5 +1,10 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5./build/zig build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small -Dskip-non-native -Dskip-single-threaded
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9
10$ZIG build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small -Dskip-non-native -Dskip-single-threaded
ci/drone/test_linux_std_ReleaseSafe+7-2
......@@ -1,5 +1,10 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
45
5./build/zig build test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small -Dskip-non-native -Dskip-single-threaded
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9
10$ZIG build test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small -Dskip-non-native -Dskip-single-threaded
ci/drone/test_linux_std_ReleaseSmall+9-4
......@@ -1,11 +1,16 @@
11#!/bin/sh
22
3. ./ci/drone/linux_script_base
3set -x
4set -e
5
6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7ZIG="$INSTALL_PREFIX/bin/zig"
8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
49
510# Empirically, this takes about 55 minutes on the CI, and is the bottleneck
611# causing timeouts. So this is disabled in favor of running a smaller set
712# of ReleaseSmall std lib tests.
8# ./build/zig build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast -Dskip-non-native
13# $ZIG build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast -Dskip-non-native
914
10./build/zig test lib/std/std.zig -OReleaseSmall
11./build/zig test lib/std/std.zig -OReleaseSmall -lc
15$ZIG test lib/std/std.zig -OReleaseSmall
16$ZIG test lib/std/std.zig -OReleaseSmall -lc
ci/srht/freebsd_script+17-17
......@@ -31,6 +31,8 @@ export TERM=dumb
3131
3232mkdir build
3333cd build
34
35
3436cmake .. \
3537 -DCMAKE_BUILD_TYPE=Release \
3638 -DCMAKE_PREFIX_PATH=$PREFIX \
......@@ -38,40 +40,38 @@ cmake .. \
3840 -DZIG_TARGET_MCPU="$MCPU" \
3941 -DZIG_STATIC=ON \
4042 -GNinja
41samu install
4243
4344# TODO: eliminate this workaround. Without this, zig does not end up passing
4445# -isystem /usr/include when building libc++, resulting in #include <sys/endian.h>
4546# "file not found" errors.
46stage2/bin/zig libc >libc.txt
47echo "include_dir=/usr/include" >>libc.txt
48echo "sys_include_dir=/usr/include" >>libc.txt
49echo "crt_dir=/usr/lib" >>libc.txt
50echo "msvc_lib_dir=" >>libc.txt
51echo "kernel32_lib_dir=" >>libc.txt
52echo "gcc_dir=" >>libc.txt
53ZIG_LIBC_TXT="$(pwd)/libc.txt"
4754
48ZIG_LIBC=libc.txt stage2/bin/zig build \
49 --prefix stage3-release \
50 --search-prefix "$PREFIX" \
51 -Dstatic-llvm \
52 -Drelease \
53 -Dstrip \
54 -Dtarget="$TARGET" \
55 -Denable-stage1
55ZIG_LIBC="$ZIG_LIBC_TXT" samu install
5656
5757# Here we skip some tests to save time.
58stage3-release/bin/zig build test docs \
58stage3/bin/zig build test docs \
5959 -Dstatic-llvm \
6060 --search-prefix "$PREFIX" \
6161 -Dskip-stage1 \
6262 -Dskip-non-native
6363
6464if [ -f ~/.s3cfg ]; then
65 mv ../LICENSE stage3-release/
66 mv ../zig-cache/langref.html stage3-release/
67 mv stage3-release/bin/zig stage3-release/
68 rmdir stage3-release/bin
65 mv ../LICENSE stage3/
66 mv ../zig-cache/langref.html stage3/
67 mv stage3/bin/zig stage3/
68 rmdir stage3/bin
6969
7070 GITBRANCH=$(basename $GITHUB_REF)
71 VERSION=$(stage3-release/zig version)
71 VERSION=$(stage3/zig version)
7272 DIRNAME="zig-freebsd-x86_64-$VERSION"
7373 TARBALL="$DIRNAME.tar.xz"
74 mv stage3-release "$DIRNAME"
74 mv stage3 "$DIRNAME"
7575 tar cfJ "$TARBALL" "$DIRNAME"
7676
7777 s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
ci/zinc/build_aarch64_macos created+20
......@@ -0,0 +1,20 @@
1#!/bin/sh
2
3set -x
4set -e
5
6RELEASE_STAGING="$DRONE_WORKSPACE/_release/staging"
7TARGET="aarch64-macos-none"
8MCPU="apple_a14"
9INSTALL_PREFIX="$DRONE_WORKSPACE/$TARGET"
10SEARCH_PREFIX="/deps/$TARGET"
11
12"$RELEASE_STAGING/bin/zig" build \
13 --prefix "$INSTALL_PREFIX" \
14 --search-prefix "$SEARCH_PREFIX" \
15 -Dstatic-llvm \
16 -Drelease \
17 -Dstrip \
18 -Dtarget="$TARGET" \
19 -Dmcpu="$MCPU" \
20 -Denable-stage1
ci/zinc/configure_git created+10
......@@ -0,0 +1,10 @@
1#!/bin/sh
2
3set -x
4set -e
5
6# Make the `zig version` number consistent.
7# This will affect the cmake commands that follow.
8# This is in its own script because git does not support this command
9# being run concurrently with itself.
10git config core.abbrev 9
ci/zinc/drone.yml+50-7
......@@ -9,17 +9,33 @@ workspace:
99 path: /workspace
1010
1111steps:
12- name: configure_git
13 image: ci/debian-amd64:11.1-9
14 commands:
15 - ./ci/zinc/configure_git
16
1217- name: test_stage3_debug
13 image: ci/debian-amd64:11.1-8
18 depends_on:
19 - configure_git
20 image: ci/debian-amd64:11.1-9
1421 commands:
15 - ./ci/zinc/linux_test_stage3_debug.sh
22 - ./ci/zinc/linux_test_stage3_debug
1623
1724- name: test_stage3_release
18 image: ci/debian-amd64:11.1-8
25 depends_on:
26 - configure_git
27 image: ci/debian-amd64:11.1-9
1928 commands:
20 - ./ci/zinc/linux_test_stage3_release.sh
29 - ./ci/zinc/linux_test_stage3_release
2130
22- name: package
31- name: build_aarch64_macos
32 depends_on:
33 - test_stage3_release
34 image: ci/debian-amd64:11.1-9
35 commands:
36 - ./ci/zinc/build_aarch64_macos
37
38- name: linux_package
2339 depends_on:
2440 - test_stage3_debug
2541 - test_stage3_release
......@@ -28,13 +44,40 @@ steps:
2844 - master
2945 event:
3046 - push
31 image: ci/debian-amd64:11.1-8
47 image: ci/debian-amd64:11.1-9
48 environment:
49 AWS_ACCESS_KEY_ID:
50 from_secret: AWS_ACCESS_KEY_ID
51 AWS_SECRET_ACCESS_KEY:
52 from_secret: AWS_SECRET_ACCESS_KEY
53 commands:
54 - ./ci/zinc/linux_package
55
56- name: macos_package
57 depends_on:
58 - test_stage3_debug
59 - build_aarch64_macos
60 when:
61 branch:
62 - master
63 event:
64 - push
65 image: ci/debian-amd64:11.1-9
3266 environment:
3367 AWS_ACCESS_KEY_ID:
3468 from_secret: AWS_ACCESS_KEY_ID
3569 AWS_SECRET_ACCESS_KEY:
3670 from_secret: AWS_SECRET_ACCESS_KEY
71 commands:
72 - ./ci/zinc/macos_package
73
74- name: notify_lavahut
75 depends_on:
76 - macos_package
77 - linux_package
78 image: ci/debian-amd64:11.1-9
79 environment:
3780 SRHT_OAUTH_TOKEN:
3881 from_secret: SRHT_OAUTH_TOKEN
3982 commands:
40 - ./ci/zinc/linux_package.sh
83 - ./ci/zinc/notify_lavahut
ci/zinc/linux_base.sh deleted-31
......@@ -1,31 +0,0 @@
1#!/bin/sh
2
3# https://docs.drone.io/pipeline/docker/syntax/workspace/
4#
5# Drone automatically creates a temporary volume, known as your workspace,
6# where it clones your repository. The workspace is the current working
7# directory for each step in your pipeline.
8#
9# Because the workspace is a volume, filesystem changes are persisted between
10# pipeline steps. In other words, individual steps can communicate and share
11# state using the filesystem.
12#
13# Workspace volumes are ephemeral. They are created when the pipeline starts
14# and destroyed after the pipeline completes.
15
16set -x
17set -e
18
19ARCH="$(uname -m)"
20
21DEPS_LOCAL="/deps/local"
22WORKSPACE="$DRONE_WORKSPACE"
23
24DEBUG_STAGING="$WORKSPACE/_debug/staging"
25RELEASE_STAGING="$WORKSPACE/_release/staging"
26
27export PATH=$DEPS_LOCAL/bin:$PATH
28
29# Make the `zig version` number consistent.
30# This will affect the cmake commands that follow.
31git config core.abbrev 9
ci/zinc/linux_package created+45
......@@ -0,0 +1,45 @@
1#!/bin/sh
2
3set -x
4set -e
5
6ARCH="$(uname -m)"
7OS="linux"
8RELEASE_STAGING="$DRONE_WORKSPACE/_release/staging"
9VERSION=$($RELEASE_STAGING/bin/zig version)
10BASENAME="zig-$OS-$ARCH-$VERSION"
11TARBALL="$BASENAME.tar.xz"
12
13# This runs concurrently with the macos_package script, so it should not make
14# any changes to the filesystem that will cause problems for the other script.
15
16cp -r "$RELEASE_STAGING" "$BASENAME"
17
18# Remove the unnecessary bin dir in $prefix/bin/zig
19mv $BASENAME/bin/zig $BASENAME/
20rmdir $BASENAME/bin
21
22# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
23mv $BASENAME/lib/zig $BASENAME/lib2
24rmdir $BASENAME/lib
25mv $BASENAME/lib2 $BASENAME/lib
26
27tar cfJ "$TARBALL" "$BASENAME"
28
29SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
30BYTESIZE=$(wc -c < $TARBALL)
31
32MANIFEST="manifest.json"
33touch $MANIFEST
34echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
35echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
36echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
37
38# Publish artifact.
39s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
40
41# Publish manifest.
42s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-$OS-$VERSION.json"
43
44# Explicit exit helps show last command duration.
45exit
ci/zinc/linux_package.sh deleted-45
......@@ -1,45 +0,0 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5# Remove the unnecessary bin dir in $prefix/bin/zig
6mv $RELEASE_STAGING/bin/zig $RELEASE_STAGING/
7rmdir $RELEASE_STAGING/bin
8
9# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
10mv $RELEASE_STAGING/lib/zig $RELEASE_STAGING/lib2
11rmdir $RELEASE_STAGING/lib
12mv $RELEASE_STAGING/lib2 $RELEASE_STAGING/lib
13
14VERSION=$($RELEASE_STAGING/zig version)
15BASENAME="zig-linux-$ARCH-$VERSION"
16TARBALL="$BASENAME.tar.xz"
17mv "$RELEASE_STAGING" "$BASENAME"
18tar cfJ "$TARBALL" "$BASENAME"
19ls -l "$TARBALL"
20
21SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
22BYTESIZE=$(wc -c < $TARBALL)
23
24MANIFEST="manifest.json"
25touch $MANIFEST
26echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
27echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
28echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
29
30# Publish artifact.
31s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
32
33# Publish manifest.
34s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-linux-$VERSION.json"
35
36# Avoid leaking oauth token.
37set +x
38
39cd $WORKSPACE
40./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
41
42set -x
43
44# Explicit exit helps show last command duration.
45exit
ci/zinc/linux_test_stage3_debug created+61
......@@ -0,0 +1,61 @@
1#!/bin/sh
2
3set -x
4set -e
5
6ARCH="$(uname -m)"
7DEPS_LOCAL="/deps/local"
8OLD_ZIG="$DEPS_LOCAL/bin/zig"
9TARGET="${ARCH}-linux-musl"
10MCPU="baseline"
11
12export PATH=$DEPS_LOCAL/bin:$PATH
13
14echo "building stage3-debug with zig version $($OLD_ZIG version)"
15
16# Override the cache directories so that we don't clobber with the release
17# testing script which is running concurrently and in the same directory.
18# Normally we want processes to cooperate, but in this case we want them isolated.
19export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-cache-local-debug"
20export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-cache-global-debug"
21
22export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
23export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
24
25mkdir build-debug
26cd build-debug
27cmake .. \
28 -DCMAKE_INSTALL_PREFIX="$(pwd)/stage3" \
29 -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
30 -DCMAKE_BUILD_TYPE=Debug \
31 -DZIG_STATIC=ON \
32 -DZIG_USE_LLVM_CONFIG=OFF \
33 -GNinja
34
35# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
36# so that installation and testing do not get affected by them.
37unset CC
38unset CXX
39
40ninja install
41
42echo "Looking for non-conforming code formatting..."
43stage3/bin/zig fmt --check .. \
44 --exclude ../test/cases/ \
45 --exclude ../build-debug \
46 --exclude ../build-release \
47 --exclude "$ZIG_LOCAL_CACHE_DIR" \
48 --exclude "$ZIG_GLOBAL_CACHE_DIR"
49
50# simultaneously test building self-hosted without LLVM and with 32-bit arm
51stage3/bin/zig build -Dtarget=arm-linux-musleabihf
52
53stage3/bin/zig build test \
54 -fqemu \
55 -fwasmtime \
56 -Dstatic-llvm \
57 -Dtarget=native-native-musl \
58 --search-prefix "$DEPS_LOCAL"
59
60# Explicit exit helps show last command duration.
61exit
ci/zinc/linux_test_stage3_debug.sh deleted-61
......@@ -1,61 +0,0 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5OLD_ZIG="$DEPS_LOCAL/bin/zig"
6TARGET="${ARCH}-linux-musl"
7MCPU="baseline"
8
9echo "building stage3-debug with zig version $($OLD_ZIG version)"
10
11# Override the cache directories so that we don't clobber with the release
12# testing script which is running concurrently and in the same directory.
13# Normally we want processes to cooperate, but in this case we want them isolated.
14export ZIG_LOCAL_CACHE_DIR="$(pwd)/zig-cache-local-debug"
15export ZIG_GLOBAL_CACHE_DIR="$(pwd)/zig-cache-global-debug"
16
17export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
18export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
19
20mkdir build-debug
21cd build-debug
22cmake .. \
23 -DCMAKE_INSTALL_PREFIX="$DEBUG_STAGING" \
24 -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
25 -DCMAKE_BUILD_TYPE=Debug \
26 -DZIG_TARGET_TRIPLE="$TARGET" \
27 -DZIG_TARGET_MCPU="$MCPU" \
28 -DZIG_STATIC=ON \
29 -GNinja
30
31# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
32# so that installation and testing do not get affected by them.
33unset CC
34unset CXX
35
36ninja install
37
38cd $WORKSPACE
39
40"$DEBUG_STAGING/bin/zig" build -p stage3 -Denable-stage1 -Dstatic-llvm -Dtarget=native-native-musl --search-prefix "$DEPS_LOCAL"
41
42# simultaneously test building self-hosted without LLVM and with 32-bit arm
43stage3/bin/zig build -Dtarget=arm-linux-musleabihf
44
45echo "Looking for non-conforming code formatting..."
46stage3/bin/zig fmt --check . \
47 --exclude test/cases/ \
48 --exclude build-debug \
49 --exclude build-release \
50 --exclude "$ZIG_LOCAL_CACHE_DIR" \
51 --exclude "$ZIG_GLOBAL_CACHE_DIR"
52
53stage3/bin/zig build test \
54 -fqemu \
55 -fwasmtime \
56 -Dstatic-llvm \
57 -Dtarget=native-native-musl \
58 --search-prefix "$DEPS_LOCAL"
59
60# Explicit exit helps show last command duration.
61exit
ci/zinc/linux_test_stage3_release created+58
......@@ -0,0 +1,58 @@
1#!/bin/sh
2
3set -x
4set -e
5
6ARCH="$(uname -m)"
7DEPS_LOCAL="/deps/local"
8RELEASE_STAGING="$DRONE_WORKSPACE/_release/staging"
9OLD_ZIG="$DEPS_LOCAL/bin/zig"
10TARGET="${ARCH}-linux-musl"
11MCPU="baseline"
12
13export PATH=$DEPS_LOCAL/bin:$PATH
14
15echo "building stage3-release with zig version $($OLD_ZIG version)"
16
17export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
18export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
19
20mkdir build-release
21cd build-release
22cmake .. \
23 -DCMAKE_INSTALL_PREFIX="$RELEASE_STAGING" \
24 -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
25 -DCMAKE_BUILD_TYPE=Release \
26 -DZIG_TARGET_TRIPLE="$TARGET" \
27 -DZIG_TARGET_MCPU="$MCPU" \
28 -DZIG_STATIC=ON \
29 -GNinja
30
31# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
32# so that installation and testing do not get affected by them.
33unset CC
34unset CXX
35
36ninja install
37
38"$RELEASE_STAGING/bin/zig" build test docs \
39 -fqemu \
40 -fwasmtime \
41 -Dstatic-llvm \
42 -Dtarget=native-native-musl \
43 --search-prefix "$DEPS_LOCAL"
44
45# Produce the experimental std lib documentation.
46mkdir -p "$RELEASE_STAGING/docs/std"
47"$RELEASE_STAGING/bin/zig" test ../lib/std/std.zig \
48 -femit-docs=$RELEASE_STAGING/docs/std \
49 -fno-emit-bin
50
51cp ../LICENSE $RELEASE_STAGING/
52cp ../zig-cache/langref.html $RELEASE_STAGING/docs/
53
54# Look for HTML errors.
55tidy --drop-empty-elements no -qe $RELEASE_STAGING/docs/langref.html
56
57# Explicit exit helps show last command duration.
58exit
ci/zinc/linux_test_stage3_release.sh deleted-78
......@@ -1,78 +0,0 @@
1#!/bin/sh
2
3. ./ci/zinc/linux_base.sh
4
5OLD_ZIG="$DEPS_LOCAL/bin/zig"
6TARGET="${ARCH}-linux-musl"
7MCPU="baseline"
8
9echo "building stage3-release with zig version $($OLD_ZIG version)"
10
11export CC="$OLD_ZIG cc -target $TARGET -mcpu=$MCPU"
12export CXX="$OLD_ZIG c++ -target $TARGET -mcpu=$MCPU"
13
14mkdir build-release
15cd build-release
16STAGE2_PREFIX="$(pwd)/stage2"
17cmake .. \
18 -DCMAKE_INSTALL_PREFIX="$STAGE2_PREFIX" \
19 -DCMAKE_PREFIX_PATH="$DEPS_LOCAL" \
20 -DCMAKE_BUILD_TYPE=Release \
21 -DZIG_TARGET_TRIPLE="$TARGET" \
22 -DZIG_TARGET_MCPU="$MCPU" \
23 -DZIG_STATIC=ON \
24 -GNinja
25
26# Now cmake will use zig as the C/C++ compiler. We reset the environment variables
27# so that installation and testing do not get affected by them.
28unset CC
29unset CXX
30
31ninja install
32
33# Here we rebuild zig but this time using the Zig binary we just now produced to
34# build zig1.o rather than relying on the one built with stage0. See
35# https://github.com/ziglang/zig/issues/6830 for more details.
36cmake .. -DZIG_EXECUTABLE="$STAGE2_PREFIX/bin/zig"
37ninja install
38
39# This is the binary we will distribute. We intentionally test this one in this
40# script. If any test failures occur, hopefully they also occur in the debug
41# version of this script for easier troubleshooting. This prevents distribution
42# of a Zig binary that passes tests in debug mode but has a miscompilation in
43# release mode.
44"$STAGE2_PREFIX/bin/zig" build \
45 --prefix "$RELEASE_STAGING" \
46 --search-prefix "$DEPS_LOCAL" \
47 -Dstatic-llvm \
48 -Drelease \
49 -Dstrip \
50 -Dtarget="$TARGET" \
51 -Denable-stage1
52
53cd $WORKSPACE
54
55ZIG="$RELEASE_STAGING/bin/zig"
56
57$ZIG build test docs \
58 -fqemu \
59 -fwasmtime \
60 -Dstatic-llvm \
61 -Dtarget=native-native-musl \
62 --search-prefix "$DEPS_LOCAL"
63
64# Produce the experimental std lib documentation.
65mkdir -p "$RELEASE_STAGING/docs/std"
66$ZIG test lib/std/std.zig \
67 --zig-lib-dir lib \
68 -femit-docs=$RELEASE_STAGING/docs/std \
69 -fno-emit-bin
70
71cp LICENSE $RELEASE_STAGING/
72cp zig-cache/langref.html $RELEASE_STAGING/docs/
73
74# Look for HTML errors.
75tidy --drop-empty-elements no -qe $RELEASE_STAGING/docs/langref.html
76
77# Explicit exit helps show last command duration.
78exit
ci/zinc/macos_package created+49
......@@ -0,0 +1,49 @@
1#!/bin/sh
2
3set -x
4set -e
5
6ARCH="aarch64"
7OS=macos
8ZIG_PREFIX="$DRONE_WORKSPACE/_release/staging"
9VERSION=$($ZIG_PREFIX/bin/zig version)
10TARGET="$ARCH-$OS-none"
11INSTALL_PREFIX="$DRONE_WORKSPACE/$TARGET"
12BASENAME="zig-$OS-$ARCH-$VERSION"
13TARBALL="$BASENAME.tar.xz"
14
15# This runs concurrently with the linux_package script, so it should not make
16# any changes to the filesystem that will cause problems for the other script.
17
18# Remove the unnecessary bin dir in $prefix/bin/zig
19mv $INSTALL_PREFIX/bin/zig $INSTALL_PREFIX/
20rmdir $INSTALL_PREFIX/bin
21
22# Remove the unnecessary zig dir in $prefix/lib/zig/std/std.zig
23mv $INSTALL_PREFIX/lib/zig $INSTALL_PREFIX/lib2
24rmdir $INSTALL_PREFIX/lib
25mv $INSTALL_PREFIX/lib2 $INSTALL_PREFIX/lib
26
27cp -r "$ZIG_PREFIX/docs" "$INSTALL_PREFIX/"
28cp "$ZIG_PREFIX/LICENSE" "$INSTALL_PREFIX/"
29
30mv "$INSTALL_PREFIX" "$BASENAME"
31tar cfJ "$TARBALL" "$BASENAME"
32
33SHASUM=$(sha256sum $TARBALL | cut '-d ' -f1)
34BYTESIZE=$(wc -c < $TARBALL)
35
36MANIFEST="manifest.json"
37touch $MANIFEST
38echo "{\"tarball\": \"$TARBALL\"," >>$MANIFEST
39echo "\"shasum\": \"$SHASUM\"," >>$MANIFEST
40echo "\"size\": \"$BYTESIZE\"}" >>$MANIFEST
41
42# Publish artifact.
43s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
44
45# Publish manifest.
46s3cmd put -P --add-header="cache-control: max-age=0, must-revalidate" "$MANIFEST" "s3://ziglang.org/builds/$ARCH-$OS-$VERSION.json"
47
48# Explicit exit helps show last command duration.
49exit
ci/zinc/notify_lavahut created+9
......@@ -0,0 +1,9 @@
1#!/bin/sh
2
3set +x # Avoid leaking oauth token.
4set -e
5
6ZIG_PREFIX="$DRONE_WORKSPACE/_release/staging"
7VERSION=$($ZIG_PREFIX/bin/zig version)
8cd $DRONE_WORKSPACE
9./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
cmake/install.cmake deleted-37
......@@ -1,37 +0,0 @@
1message("-- Installing: ${CMAKE_INSTALL_PREFIX}/lib")
2
3if(NOT EXISTS ${zig_EXE})
4 message("::")
5 message(":: ERROR: Executable not found")
6 message(":: (execute_process)")
7 message("::")
8 message(":: executable: ${zig_EXE}")
9 message("::")
10 message(FATAL_ERROR)
11endif()
12
13execute_process(COMMAND ${zig_EXE} ${ZIG_INSTALL_ARGS}
14 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
15 RESULT_VARIABLE _result
16)
17if(_result)
18 message("::")
19 message(":: ERROR: ${_result}")
20 message(":: (execute_process)")
21
22 string(REPLACE ";" " " s_INSTALL_LIBSTAGE2_ARGS "${ZIG_INSTALL_ARGS}")
23 message("::")
24 message(":: argv: ${zig_EXE} ${s_INSTALL_LIBSTAGE2_ARGS}")
25
26 set(_args ${zig_EXE} ${ZIG_INSTALL_ARGS})
27 list(LENGTH _args _len)
28 math(EXPR _len "${_len} - 1")
29 message("::")
30 foreach(_i RANGE 0 ${_len})
31 list(GET _args ${_i} _arg)
32 message(":: argv[${_i}]: ${_arg}")
33 endforeach()
34
35 message("::")
36 message(FATAL_ERROR)
37endif()
src/Zir.zig+5-1
......@@ -43,7 +43,11 @@ pub const Header = extern struct {
4343 instructions_len: u32,
4444 string_bytes_len: u32,
4545 extra_len: u32,
46
46 /// We could leave this as padding, however it triggers a Valgrind warning because
47 /// we read and write undefined bytes to the file system. This is harmless, but
48 /// it's essentially free to have a zero field here and makes the warning go away,
49 /// making it more likely that following Valgrind warnings will be taken seriously.
50 unused: u32 = 0,
4751 stat_inode: std.fs.File.INode,
4852 stat_size: u64,
4953 stat_mtime: i128,