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)...@@ -12,7 +12,7 @@ if(NOT CMAKE_BUILD_TYPE)
12endif()12endif()
1313
14if(NOT CMAKE_INSTALL_PREFIX)14if(NOT CMAKE_INSTALL_PREFIX)
15 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage2" CACHE STRING15 set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/stage3" CACHE STRING
16 "Directory to install zig to" FORCE)16 "Directory to install zig to" FORCE)
17endif()17endif()
1818
...@@ -65,6 +65,9 @@ if("${ZIG_VERSION}" STREQUAL "")...@@ -65,6 +65,9 @@ if("${ZIG_VERSION}" STREQUAL "")
65endif()65endif()
66message(STATUS "Configuring zig version ${ZIG_VERSION}")66message(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
68set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")71set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)")
69set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries")72set(ZIG_SHARED_LLVM off CACHE BOOL "Prefer linking against shared LLVM libraries")
70set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries")73set(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")...@@ -333,7 +336,7 @@ set(ZIG_CONFIG_H_OUT "${CMAKE_BINARY_DIR}/config.h")
333set(ZIG_CONFIG_ZIG_OUT "${CMAKE_BINARY_DIR}/config.zig")336set(ZIG_CONFIG_ZIG_OUT "${CMAKE_BINARY_DIR}/config.zig")
334337
335# This is our shim which will be replaced by stage1.zig.338# This is our shim which will be replaced by stage1.zig.
336set(ZIG0_SOURCES339set(ZIG1_SOURCES
337 "${CMAKE_SOURCE_DIR}/src/stage1/zig0.cpp"340 "${CMAKE_SOURCE_DIR}/src/stage1/zig0.cpp"
338)341)
339342
...@@ -373,9 +376,9 @@ set(ZIG_CPP_SOURCES...@@ -373,9 +376,9 @@ set(ZIG_CPP_SOURCES
373 # https://github.com/ziglang/zig/issues/6363376 # https://github.com/ziglang/zig/issues/6363
374 "${CMAKE_SOURCE_DIR}/src/windows_sdk.cpp"377 "${CMAKE_SOURCE_DIR}/src/windows_sdk.cpp"
375)378)
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.
377# This list is generated by building zig and then clearing the zig-cache directory,380# 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 looking381# then manually running the build-obj command (see BUILD_ZIG2_ARGS), and then looking
379# in the zig-cache directory for the compiler-generated list of zig file dependencies.382# in the zig-cache directory for the compiler-generated list of zig file dependencies.
380set(ZIG_STAGE2_SOURCES383set(ZIG_STAGE2_SOURCES
381 "${ZIG_CONFIG_ZIG_OUT}"384 "${ZIG_CONFIG_ZIG_OUT}"
...@@ -942,40 +945,51 @@ if(MSVC OR MINGW)...@@ -942,40 +945,51 @@ if(MSVC OR MINGW)
942endif()945endif()
943946
944if("${ZIG_EXECUTABLE}" STREQUAL "")947if("${ZIG_EXECUTABLE}" STREQUAL "")
945 add_executable(zig0 ${ZIG0_SOURCES})948 add_executable(zig1 ${ZIG1_SOURCES})
946 set_target_properties(zig0 PROPERTIES949 set_target_properties(zig1 PROPERTIES
947 COMPILE_FLAGS ${EXE_CFLAGS}950 COMPILE_FLAGS ${EXE_CFLAGS}
948 LINK_FLAGS ${EXE_LDFLAGS}951 LINK_FLAGS ${EXE_LDFLAGS}
949 )952 )
950 target_link_libraries(zig0 zigstage1)953 target_link_libraries(zig1 zigstage1)
951endif()954endif()
952955
953if(MSVC)956if(MSVC)
954 set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.obj")957 set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.obj")
955else()958else()
956 set(ZIG1_OBJECT "${CMAKE_BINARY_DIR}/zig1.o")959 set(ZIG2_OBJECT "${CMAKE_BINARY_DIR}/zig2.o")
957endif()960endif()
958if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")961if("${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)
960else()965else()
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")
962endif()972endif()
963if(ZIG_SINGLE_THREADED)973if(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")
965else()980else()
966 set(ZIG1_SINGLE_THREADED_ARG "")981 set(ZIG_STATIC_ARG "")
967endif()982endif()
968983
969set(BUILD_ZIG1_ARGS984set(BUILD_ZIG2_ARGS
970 "src/stage1.zig"985 "src/stage1.zig"
971 -target "${ZIG_TARGET_TRIPLE}"986 --name zig2
972 "-mcpu=${ZIG_TARGET_MCPU}"
973 --name zig1
974 --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"987 --zig-lib-dir "${CMAKE_SOURCE_DIR}/lib"
975 "-femit-bin=${ZIG1_OBJECT}"988 "-femit-bin=${ZIG2_OBJECT}"
976 -fcompiler-rt989 -fcompiler-rt
977 "${ZIG1_RELEASE_ARG}"990 ${ZIG_SINGLE_THREADED_ARG}
978 "${ZIG1_SINGLE_THREADED_ARG}"991 -target "${ZIG_TARGET_TRIPLE}"
992 -mcpu "${ZIG_TARGET_MCPU}"
979 -lc993 -lc
980 --pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"994 --pkg-begin build_options "${ZIG_CONFIG_ZIG_OUT}"
981 --pkg-end995 --pkg-end
...@@ -985,68 +999,64 @@ set(BUILD_ZIG1_ARGS...@@ -985,68 +999,64 @@ set(BUILD_ZIG1_ARGS
985999
986if("${ZIG_EXECUTABLE}" STREQUAL "")1000if("${ZIG_EXECUTABLE}" STREQUAL "")
987 add_custom_command(1001 add_custom_command(
988 OUTPUT "${ZIG1_OBJECT}"1002 OUTPUT "${ZIG2_OBJECT}"
989 COMMAND zig0 ${BUILD_ZIG1_ARGS}1003 COMMAND zig1 ${BUILD_ZIG2_ARGS}
990 DEPENDS zig0 "${ZIG_STAGE2_SOURCES}"1004 DEPENDS zig1 "${ZIG_STAGE2_SOURCES}"
991 COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"1005 COMMENT STATUS "Building stage2 object ${ZIG2_OBJECT}"
992 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"1006 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
993 )1007 )
994 set(ZIG_EXECUTABLE "${zig_BINARY_DIR}/zig")
995 if (WIN32)1008 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")
997 endif()1012 endif()
998else()1013else()
999 add_custom_command(1014 add_custom_command(
1000 OUTPUT "${ZIG1_OBJECT}"1015 OUTPUT "${ZIG2_OBJECT}"
1001 COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG1_ARGS}1016 COMMAND "${ZIG_EXECUTABLE}" "build-obj" ${BUILD_ZIG2_ARGS}
1002 DEPENDS ${ZIG_STAGE2_SOURCES}1017 DEPENDS ${ZIG_STAGE2_SOURCES}
1003 COMMENT STATUS "Building self-hosted component ${ZIG1_OBJECT}"1018 COMMENT STATUS "Building stage2 component ${ZIG2_OBJECT}"
1004 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"1019 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
1005 )1020 )
1006endif()1021endif()
10071022
1008# cmake won't let us configure an executable without C sources.1023# 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 PROPERTIES1026set_target_properties(zig2 PROPERTIES
1012 COMPILE_FLAGS ${EXE_CFLAGS}1027 COMPILE_FLAGS ${EXE_CFLAGS}
1013 LINK_FLAGS ${EXE_LDFLAGS}1028 LINK_FLAGS ${EXE_LDFLAGS}
1014)1029)
1015target_link_libraries(zig zigstage1)1030target_link_libraries(zig2 zigstage1)
1016if(MSVC)1031if(MSVC)
1017 target_link_libraries(zig ntdll.lib)1032 target_link_libraries(zig2 ntdll.lib)
1018elseif(MINGW)1033elseif(MINGW)
1019 target_link_libraries(zig ntdll)1034 target_link_libraries(zig2 ntdll)
1020endif()1035endif()
10211036
1022install(TARGETS zig DESTINATION bin)1037# Dummy install command so that the "install" target is not missing.
10231038# This is redundant from the "stage3" custom target below.
1024set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL
1025 "Disable copying lib/ files to install prefix during the build phase")
1026
1027if(NOT ZIG_SKIP_INSTALL_LIB_FILES)1039if(NOT ZIG_SKIP_INSTALL_LIB_FILES)
1028 set(ZIG_INSTALL_ARGS "build"1040 install(FILES "lib/compiler_rt.zig" DESTINATION "lib/zig")
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()
1052endif()1041endif()
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...@@ -34,6 +34,7 @@ git fetch --tags
34mkdir build34mkdir build
35cd build35cd build
36cmake .. \36cmake .. \
37 -DCMAKE_INSTALL_PREFIX="stage3-release" \
37 -DCMAKE_PREFIX_PATH="$PREFIX" \38 -DCMAKE_PREFIX_PATH="$PREFIX" \
38 -DCMAKE_BUILD_TYPE=Release \39 -DCMAKE_BUILD_TYPE=Release \
39 -DZIG_TARGET_TRIPLE="$TARGET" \40 -DZIG_TARGET_TRIPLE="$TARGET" \
...@@ -47,15 +48,6 @@ unset CXX...@@ -47,15 +48,6 @@ unset CXX
4748
48make $JOBS install49make $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
59stage3-release/bin/zig build test docs \51stage3-release/bin/zig build test docs \
60 -Denable-macos-sdk \52 -Denable-macos-sdk \
61 -Dstatic-llvm \53 -Dstatic-llvm \
ci/azure/pipelines.yml-12
...@@ -10,17 +10,6 @@ jobs:...@@ -10,17 +10,6 @@ jobs:
10 - script: ci/azure/macos_script10 - script: ci/azure/macos_script
11 name: main11 name: main
12 displayName: 'Build and test'12 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'
24- job: BuildWindows13- job: BuildWindows
25 timeoutInMinutes: 36014 timeoutInMinutes: 360
26 pool:15 pool:
...@@ -155,7 +144,6 @@ jobs:...@@ -155,7 +144,6 @@ jobs:
155- job: OnMasterSuccess144- job: OnMasterSuccess
156 dependsOn:145 dependsOn:
157 - BuildMacOS146 - BuildMacOS
158 - BuildMacOS_arm64
159 - BuildWindows147 - BuildWindows
160 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))148 condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
161 strategy:149 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 @@...@@ -1,17 +1,16 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5# Probe CPU/brand details.6ARCH="$(uname -m)"
6# TODO: `lscpu` is changing package names in EDGE to `util-linux-misc`7INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
7apk update8
8apk add util-linux9export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
9echo "lscpu:"
10lscpu | sed 's,^, : ,'
1110
12PREFIX="/deps/local"11PREFIX="/deps/local"
13ZIG="$PREFIX/bin/zig"12ZIG="$PREFIX/bin/zig"
14TARGET="$TRIPLEARCH-linux-musl"13TARGET="$ARCH-linux-musl"
15MCPU="baseline"14MCPU="baseline"
1615
17export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"16export CC="$ZIG cc -target $TARGET -mcpu=$MCPU"
...@@ -30,8 +29,8 @@ cat <<'ENDFILE' >$PREFIX/bin/ranlib...@@ -30,8 +29,8 @@ cat <<'ENDFILE' >$PREFIX/bin/ranlib
30/deps/local/bin/zig ranlib $@29/deps/local/bin/zig ranlib $@
31ENDFILE30ENDFILE
3231
33chmod +x $PREFIX/bin/ar32chmod +x "$PREFIX/bin/ar"
34chmod +x $PREFIX/bin/ranlib33chmod +x "$PREFIX/bin/ranlib"
3534
36# Make the `zig version` number consistent.35# Make the `zig version` number consistent.
37# This will affect the cmake command below.36# This will affect the cmake command below.
...@@ -43,6 +42,7 @@ mkdir build...@@ -43,6 +42,7 @@ mkdir build
43cd build42cd build
44cmake .. \43cmake .. \
45 -DCMAKE_PREFIX_PATH="$PREFIX" \44 -DCMAKE_PREFIX_PATH="$PREFIX" \
45 -DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX" \
46 -DCMAKE_BUILD_TYPE=Release \46 -DCMAKE_BUILD_TYPE=Release \
47 -DCMAKE_AR="$PREFIX/bin/ar" \47 -DCMAKE_AR="$PREFIX/bin/ar" \
48 -DCMAKE_RANLIB="$PREFIX/bin/ranlib" \48 -DCMAKE_RANLIB="$PREFIX/bin/ranlib" \
...@@ -56,12 +56,3 @@ cmake .. \...@@ -56,12 +56,3 @@ cmake .. \
56unset CC56unset CC
57unset CXX57unset CXX
58samu install58samu 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 @@...@@ -1,6 +1,12 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
5
6ARCH="$(uname -m)"
7INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
8
9export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
410
5if [ -n "$DRONE_PULL_REQUEST" ]; then11if [ -n "$DRONE_PULL_REQUEST" ]; then
6 exit 012 exit 0
...@@ -12,16 +18,16 @@ pip3 install s3cmd...@@ -12,16 +18,16 @@ pip3 install s3cmd
1218
13cd build19cd build
1420
15mv ../LICENSE "$DISTDIR/"21mv ../LICENSE "$INSTALL_PREFIX/"
16mv ../zig-cache/langref.html "$DISTDIR/"22mv ../zig-cache/langref.html "$INSTALL_PREFIX/"
17mv "$DISTDIR/bin/zig" "$DISTDIR/"23mv "$INSTALL_PREFIX/bin/zig" "$INSTALL_PREFIX/"
18rmdir "$DISTDIR/bin"24rmdir "$INSTALL_PREFIX/bin"
1925
20GITBRANCH="$DRONE_BRANCH"26GITBRANCH="$DRONE_BRANCH"
21VERSION="$("$DISTDIR/zig" version)"27VERSION="$("$INSTALL_PREFIX/zig" version)"
22DIRNAME="zig-linux-$TRIPLEARCH-$VERSION"28DIRNAME="zig-linux-$ARCH-$VERSION"
23TARBALL="$DIRNAME.tar.xz"29TARBALL="$DIRNAME.tar.xz"
24mv "$DISTDIR" "$DIRNAME"30mv "$INSTALL_PREFIX" "$DIRNAME"
25tar cfJ "$TARBALL" "$DIRNAME"31tar cfJ "$TARBALL" "$DIRNAME"
2632
27s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/33s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
...@@ -35,7 +41,7 @@ echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE...@@ -35,7 +41,7 @@ echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
35echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE41echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
36echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE42echo "\"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"
39if [ "$GITBRANCH" = "master" ]; then45if [ "$GITBRANCH" = "master" ]; then
40 # avoid leaking oauth token46 # avoid leaking oauth token
41 set +x47 set +x
ci/drone/test_linux_behavior+10-5
...@@ -1,8 +1,13 @@...@@ -1,8 +1,13 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5./build/zig build test-behavior -Dskip-non-native6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
6./build/zig build test-compiler-rt -Dskip-non-native7ZIG="$INSTALL_PREFIX/bin/zig"
7./build/zig build test-fmt8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
8./build/zig build docs9
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 @@...@@ -1,6 +1,11 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5./build/zig build -Dskip-non-native # test building self-hosted without LLVM6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
6./build/zig build -Dskip-non-native test-cases7ZIG="$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 @@...@@ -1,11 +1,16 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5./build/zig build test-universal-libc -Dskip-non-native6INSTALL_PREFIX="$DRONE_WORKSPACE/stage3-release"
6./build/zig build test-compare-output -Dskip-non-native7ZIG="$INSTALL_PREFIX/bin/zig"
7./build/zig build test-standalone -Dskip-non-native -Dskip-release-safe8export ZIG_GLOBAL_CACHE_DIR="$DRONE_WORKSPACE/zig-cache"
8./build/zig build test-stack-traces -Dskip-non-native9
9./build/zig build test-cli -Dskip-non-native10$ZIG build test-universal-libc -Dskip-non-native
10./build/zig build test-asm-link -Dskip-non-native11$ZIG build test-compare-output -Dskip-non-native
11./build/zig build test-translate-c -Dskip-non-native12$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 @@...@@ -1,5 +1,10 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5./build/zig build test-std -Dskip-release-safe -Dskip-release-fast -Dskip-release-small -Dskip-non-native6INSTALL_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 @@...@@ -1,5 +1,10 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5./build/zig build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-small -Dskip-non-native -Dskip-single-threaded6INSTALL_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 @@...@@ -1,5 +1,10 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -x
4set -e
45
5./build/zig build test-std -Dskip-debug -Dskip-release-fast -Dskip-release-small -Dskip-non-native -Dskip-single-threaded6INSTALL_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 @@...@@ -1,11 +1,16 @@
1#!/bin/sh1#!/bin/sh
22
3. ./ci/drone/linux_script_base3set -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
5# Empirically, this takes about 55 minutes on the CI, and is the bottleneck10# Empirically, this takes about 55 minutes on the CI, and is the bottleneck
6# causing timeouts. So this is disabled in favor of running a smaller set11# causing timeouts. So this is disabled in favor of running a smaller set
7# of ReleaseSmall std lib tests.12# of ReleaseSmall std lib tests.
8# ./build/zig build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast -Dskip-non-native13# $ZIG build test-std -Dskip-debug -Dskip-release-safe -Dskip-release-fast -Dskip-non-native
914
10./build/zig test lib/std/std.zig -OReleaseSmall15$ZIG test lib/std/std.zig -OReleaseSmall
11./build/zig test lib/std/std.zig -OReleaseSmall -lc16$ZIG test lib/std/std.zig -OReleaseSmall -lc
ci/srht/freebsd_script+17-17
...@@ -31,6 +31,8 @@ export TERM=dumb...@@ -31,6 +31,8 @@ export TERM=dumb
3131
32mkdir build32mkdir build
33cd build33cd build
34
35
34cmake .. \36cmake .. \
35 -DCMAKE_BUILD_TYPE=Release \37 -DCMAKE_BUILD_TYPE=Release \
36 -DCMAKE_PREFIX_PATH=$PREFIX \38 -DCMAKE_PREFIX_PATH=$PREFIX \
...@@ -38,40 +40,38 @@ cmake .. \...@@ -38,40 +40,38 @@ cmake .. \
38 -DZIG_TARGET_MCPU="$MCPU" \40 -DZIG_TARGET_MCPU="$MCPU" \
39 -DZIG_STATIC=ON \41 -DZIG_STATIC=ON \
40 -GNinja42 -GNinja
41samu install
4243
43# TODO: eliminate this workaround. Without this, zig does not end up passing44# TODO: eliminate this workaround. Without this, zig does not end up passing
44# -isystem /usr/include when building libc++, resulting in #include <sys/endian.h>45# -isystem /usr/include when building libc++, resulting in #include <sys/endian.h>
45# "file not found" errors.46# "file not found" errors.
46stage2/bin/zig libc >libc.txt47echo "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 \55ZIG_LIBC="$ZIG_LIBC_TXT" samu install
49 --prefix stage3-release \
50 --search-prefix "$PREFIX" \
51 -Dstatic-llvm \
52 -Drelease \
53 -Dstrip \
54 -Dtarget="$TARGET" \
55 -Denable-stage1
5656
57# Here we skip some tests to save time.57# Here we skip some tests to save time.
58stage3-release/bin/zig build test docs \58stage3/bin/zig build test docs \
59 -Dstatic-llvm \59 -Dstatic-llvm \
60 --search-prefix "$PREFIX" \60 --search-prefix "$PREFIX" \
61 -Dskip-stage1 \61 -Dskip-stage1 \
62 -Dskip-non-native62 -Dskip-non-native
6363
64if [ -f ~/.s3cfg ]; then64if [ -f ~/.s3cfg ]; then
65 mv ../LICENSE stage3-release/65 mv ../LICENSE stage3/
66 mv ../zig-cache/langref.html stage3-release/66 mv ../zig-cache/langref.html stage3/
67 mv stage3-release/bin/zig stage3-release/67 mv stage3/bin/zig stage3/
68 rmdir stage3-release/bin68 rmdir stage3/bin
6969
70 GITBRANCH=$(basename $GITHUB_REF)70 GITBRANCH=$(basename $GITHUB_REF)
71 VERSION=$(stage3-release/zig version)71 VERSION=$(stage3/zig version)
72 DIRNAME="zig-freebsd-x86_64-$VERSION"72 DIRNAME="zig-freebsd-x86_64-$VERSION"
73 TARBALL="$DIRNAME.tar.xz"73 TARBALL="$DIRNAME.tar.xz"
74 mv stage3-release "$DIRNAME"74 mv stage3 "$DIRNAME"
75 tar cfJ "$TARBALL" "$DIRNAME"75 tar cfJ "$TARBALL" "$DIRNAME"
7676
77 s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/77 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:...@@ -9,17 +9,33 @@ workspace:
9 path: /workspace9 path: /workspace
1010
11steps:11steps:
12- name: configure_git
13 image: ci/debian-amd64:11.1-9
14 commands:
15 - ./ci/zinc/configure_git
16
12- name: test_stage3_debug17- name: test_stage3_debug
13 image: ci/debian-amd64:11.1-818 depends_on:
19 - configure_git
20 image: ci/debian-amd64:11.1-9
14 commands:21 commands:
15 - ./ci/zinc/linux_test_stage3_debug.sh22 - ./ci/zinc/linux_test_stage3_debug
1623
17- name: test_stage3_release24- name: test_stage3_release
18 image: ci/debian-amd64:11.1-825 depends_on:
26 - configure_git
27 image: ci/debian-amd64:11.1-9
19 commands:28 commands:
20 - ./ci/zinc/linux_test_stage3_release.sh29 - ./ci/zinc/linux_test_stage3_release
2130
22- name: package31- 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
23 depends_on:39 depends_on:
24 - test_stage3_debug40 - test_stage3_debug
25 - test_stage3_release41 - test_stage3_release
...@@ -28,13 +44,40 @@ steps:...@@ -28,13 +44,40 @@ steps:
28 - master44 - master
29 event:45 event:
30 - push46 - push
31 image: ci/debian-amd64:11.1-847 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
32 environment:66 environment:
33 AWS_ACCESS_KEY_ID:67 AWS_ACCESS_KEY_ID:
34 from_secret: AWS_ACCESS_KEY_ID68 from_secret: AWS_ACCESS_KEY_ID
35 AWS_SECRET_ACCESS_KEY:69 AWS_SECRET_ACCESS_KEY:
36 from_secret: AWS_SECRET_ACCESS_KEY70 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:
37 SRHT_OAUTH_TOKEN:80 SRHT_OAUTH_TOKEN:
38 from_secret: SRHT_OAUTH_TOKEN81 from_secret: SRHT_OAUTH_TOKEN
39 commands:82 commands:
40 - ./ci/zinc/linux_package.sh83 - ./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 {...@@ -43,7 +43,11 @@ pub const Header = extern struct {
43 instructions_len: u32,43 instructions_len: u32,
44 string_bytes_len: u32,44 string_bytes_len: u32,
45 extra_len: u32,45 extra_len: u32,
4646 /// 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,
47 stat_inode: std.fs.File.INode,51 stat_inode: std.fs.File.INode,
48 stat_size: u64,52 stat_size: u64,
49 stat_mtime: i128,53 stat_mtime: i128,