]> git.proxmox.com Git - rustc.git/blame - src/ci/run.sh
New upstream version 1.62.1+dfsg1
[rustc.git] / src / ci / run.sh
CommitLineData
abe05a73 1#!/usr/bin/env bash
476ff2be
SL
2
3set -e
4
83c7162d
XL
5if [ -n "$CI_JOB_NAME" ]; then
6 echo "[CI_JOB_NAME=$CI_JOB_NAME]"
7fi
8
8bb4bdeb
XL
9if [ "$NO_CHANGE_USER" = "" ]; then
10 if [ "$LOCAL_USER_ID" != "" ]; then
11 useradd --shell /bin/bash -u $LOCAL_USER_ID -o -c "" -m user
12 export HOME=/home/user
13 unset LOCAL_USER_ID
14 exec su --preserve-environment -c "env PATH=$PATH \"$0\"" user
15 fi
476ff2be
SL
16fi
17
8faf50e0
XL
18# only enable core dump on Linux
19if [ -f /proc/sys/kernel/core_pattern ]; then
20 ulimit -c unlimited
21fi
22
3dfed10e
XL
23# There was a bad interaction between "old" 32-bit binaries on current 64-bit
24# kernels with selinux enabled, where ASLR mmap would sometimes choose a low
25# address and then block it for being below `vm.mmap_min_addr` -> `EACCES`.
26# This is probably a kernel bug, but setting `ulimit -Hs` works around it.
27# See also `dist-i686-linux` where this setting is enabled.
28if [ "$SET_HARD_RLIMIT_STACK" = "1" ]; then
29 rlimit_stack=$(ulimit -Ss)
30 if [ "$rlimit_stack" != "" ]; then
31 ulimit -Hs "$rlimit_stack"
32 fi
33fi
34
8bb4bdeb
XL
35ci_dir=`cd $(dirname $0) && pwd`
36source "$ci_dir/shared.sh"
37
ba9703b0
XL
38if command -v python > /dev/null; then
39 PYTHON="python"
40elif command -v python3 > /dev/null; then
41 PYTHON="python3"
42else
43 PYTHON="python2"
44fi
45
3c0e092e 46if ! isCI || isCiBranch auto || isCiBranch beta || isCiBranch try; then
94b46f34 47 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests"
7cac9316
XL
48fi
49
32a655c1 50RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
32a655c1 51RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
8bb4bdeb 52RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
0bf4aa26 53RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-native-static"
a1dfa0c6 54RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.codegen-units-std=1"
8bb4bdeb 55
5869c6ff
XL
56# Only produce xz tarballs on CI. gz tarballs will be generated by the release
57# process by recompressing the existing xz ones. This decreases the storage
58# space required for CI artifacts.
59RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --dist-compression-formats=xz"
60
8bb4bdeb
XL
61if [ "$DIST_SRC" = "" ]; then
62 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"
63fi
32a655c1 64
dfeec247
XL
65# Always set the release channel for bootstrap; this is normally not important (i.e., only dist
66# builds would seem to matter) but in practice bootstrap wants to know whether we're targeting
67# master, beta, or stable with a build to determine whether to run some checks (notably toolstate).
17df50a5 68export RUST_RELEASE_CHANNEL=$(releaseChannel)
dfeec247
XL
69RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
70
dc9dc135 71if [ "$DEPLOY$DEPLOY_ALT" = "1" ]; then
32a655c1 72 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
b7449926 73 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
dc9dc135 74 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --debuginfo-level-std=1"
32a655c1
SL
75
76 if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
77 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
8bb4bdeb 78 elif [ "$DEPLOY_ALT" != "" ]; then
e74abb32
XL
79 if [ "$NO_PARALLEL_COMPILER" = "" ]; then
80 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.parallel-compiler"
81 fi
abe05a73 82 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
0bf4aa26 83 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
32a655c1
SL
84 fi
85else
ea8adc8c
XL
86 # We almost always want debug assertions enabled, but sometimes this takes too
87 # long for too little benefit, so we just turn them off.
88 if [ "$NO_DEBUG_ASSERTIONS" = "" ]; then
89 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-debug-assertions"
90 fi
32a655c1 91
3c0e092e
XL
92 # Same for overflow checks
93 if [ "$NO_OVERFLOW_CHECKS" = "" ]; then
94 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-overflow-checks"
95 fi
96
32a655c1
SL
97 # In general we always want to run tests with LLVM assertions enabled, but not
98 # all platforms currently support that, so we have an option to disable.
99 if [ "$NO_LLVM_ASSERTIONS" = "" ]; then
100 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
101 fi
0bf4aa26
XL
102
103 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
104fi
105
106if [ "$RUST_RELEASE_CHANNEL" = "nightly" ] || [ "$DIST_REQUIRE_ALL_TOOLS" = "" ]; then
107 RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-missing-tools"
476ff2be
SL
108fi
109
1b1a35ee
XL
110export COMPILETEST_NEEDS_ALL_LLVM_COMPONENTS=1
111
e1599b0c
XL
112# Print the date from the local machine and the date from an external source to
113# check for clock drifts. An HTTP URL is used instead of HTTPS since on Azure
114# Pipelines it happened that the certificates were marked as expired.
115datecheck() {
116 echo "== clock drift check =="
117 echo -n " local time: "
118 date
119 echo -n " network time: "
3c0e092e 120 curl -fs --head http://ci-caches.rust-lang.org | grep ^Date: \
e1599b0c
XL
121 | sed 's/Date: //g' || true
122 echo "== end clock drift check =="
123}
124datecheck
125trap datecheck EXIT
126
0531ce1d
XL
127# We've had problems in the past of shell scripts leaking fds into the sccache
128# server (#48192) which causes Cargo to erroneously think that a build script
129# hasn't finished yet. Try to solve that problem by starting a very long-lived
130# sccache server at the start of the build, but no need to worry if this fails.
131SCCACHE_IDLE_TIMEOUT=10800 sccache --start-server || true
132
83c7162d 133if [ "$RUN_CHECK_WITH_PARALLEL_QUERIES" != "" ]; then
9fa01778 134 $SRC/configure --enable-parallel-compiler
ba9703b0 135 CARGO_INCREMENTAL=0 $PYTHON ../x.py check
0531ce1d
XL
136 rm -f config.toml
137 rm -rf build
138fi
139
32a655c1 140$SRC/configure $RUST_CONFIGURE_ARGS
7cac9316 141
8bb4bdeb 142retry make prepare
476ff2be 143
0531ce1d
XL
144# Display the CPU and memory information. This helps us know why the CI timing
145# is fluctuating.
e74abb32 146if isMacOS; then
0531ce1d
XL
147 system_profiler SPHardwareDataType || true
148 sysctl hw || true
476ff2be
SL
149 ncpus=$(sysctl -n hw.ncpu)
150else
0531ce1d
XL
151 cat /proc/cpuinfo || true
152 cat /proc/meminfo || true
32a655c1 153 ncpus=$(grep processor /proc/cpuinfo | wc -l)
476ff2be
SL
154fi
155
32a655c1
SL
156if [ ! -z "$SCRIPT" ]; then
157 sh -x -c "$SCRIPT"
476ff2be 158else
7cac9316 159 do_make() {
7cac9316 160 echo "make -j $ncpus $1"
0531ce1d 161 make -j $ncpus $1
7cac9316 162 local retval=$?
7cac9316
XL
163 return $retval
164 }
165
7cac9316 166 do_make "$RUST_CHECK_TARGET"
476ff2be 167fi
dc9dc135
XL
168
169sccache --show-stats || true