Debian Codegraph @

compiler-rt/lib/tsan/go/buildgo.sh

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2
3 set -e
4
5 if [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. Linux`" != "" ]; then
6 HOST_GOOS="linux"
7 if [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. ppc64le`" != "" ]; then
8 HOST_GOARCH="ppc64le"
9 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. x86_64`" != "" ]; then
10 HOST_GOARCH="amd64"
11 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. aarch64`" != "" ]; then
12 HOST_GOARCH="arm64"
13 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. loongarch64`" != "" ]; then
14 HOST_GOARCH="loong64"
15 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. -i mips64`" != "" ]; then
16 if [scip-shell system . . `[`. "`lscpuscip-shell system . . lscpu. | grepscip-shell system . . grep. -i Little`" != "" ]; then
17 HOST_GOARCH="mips64le"
18 else
19 HOST_GOARCH="mips64"
20 fi
21 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. s390x`" != "" ]; then
22 HOST_GOARCH="s390x"
23 fi
24 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. FreeBSD`" != "" ]; then
25 HOST_GOOS="freebsd"
26 HOST_GOARCH="amd64"
27 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. NetBSD`" != "" ]; then
28 HOST_GOOS="netbsd"
29 HOST_GOARCH="amd64"
30 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. Darwin`" != "" ]; then
31 HOST_GOOS="darwin"
32 if [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. x86_64`" != "" ]; then
33 HOST_GOARCH="amd64"
34 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. arm64`" != "" ]; then
35 HOST_GOARCH="arm64"
36 fi
37 elif [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. MINGW`" != "" ]; then
38 HOST_GOOS="windows"
39 HOST_GOARCH="amd64"
40 fi
41
42 GOOS=${GOOS:-$HOST_GOOS}
43 GOARCH=${GOARCH:-$HOST_GOARCH}
44 SUFFIX="${GOOS}_${GOARCH}"
45
46 SRCS="
47 tsan_go.cpp
48 ../rtl/tsan_external.cpp
49 ../rtl/tsan_flags.cpp
50 ../rtl/tsan_interface_atomic.cpp
51 ../rtl/tsan_md5.cpp
52 ../rtl/tsan_report.cpp
53 ../rtl/tsan_rtl.cpp
54 ../rtl/tsan_rtl_access.cpp
55 ../rtl/tsan_rtl_mutex.cpp
56 ../rtl/tsan_rtl_report.cpp
57 ../rtl/tsan_rtl_thread.cpp
58 ../rtl/tsan_rtl_proc.cpp
59 ../rtl/tsan_stack_trace.cpp
60 ../rtl/tsan_suppressions.cpp
61 ../rtl/tsan_sync.cpp
62 ../rtl/tsan_vector_clock.cpp
63 ../../sanitizer_common/sanitizer_allocator.cpp
64 ../../sanitizer_common/sanitizer_common.cpp
65 ../../sanitizer_common/sanitizer_common_libcdep.cpp
66 ../../sanitizer_common/sanitizer_deadlock_detector2.cpp
67 ../../sanitizer_common/sanitizer_file.cpp
68 ../../sanitizer_common/sanitizer_flag_parser.cpp
69 ../../sanitizer_common/sanitizer_flags.cpp
70 ../../sanitizer_common/sanitizer_libc.cpp
71 ../../sanitizer_common/sanitizer_mutex.cpp
72 ../../sanitizer_common/sanitizer_printf.cpp
73 ../../sanitizer_common/sanitizer_suppressions.cpp
74 ../../sanitizer_common/sanitizer_thread_registry.cpp
75 ../../sanitizer_common/sanitizer_stack_store.cpp
76 ../../sanitizer_common/sanitizer_stackdepot.cpp
77 ../../sanitizer_common/sanitizer_stacktrace.cpp
78 ../../sanitizer_common/sanitizer_symbolizer.cpp
79 ../../sanitizer_common/sanitizer_symbolizer_report.cpp
80 ../../sanitizer_common/sanitizer_termination.cpp
81 "
82
83 if [scip-shell system . . `[`. "$GOOS" = "linux" ]; then
84 OSCFLAGS="-fPIC -Wno-maybe-uninitialized"
85 OSLDFLAGS="-lpthread -fPIC -fpie"
86 SRCS="
87 $SRCS
88 ../rtl/tsan_platform_linux.cpp
89 ../../sanitizer_common/sanitizer_posix.cpp
90 ../../sanitizer_common/sanitizer_posix_libcdep.cpp
91 ../../sanitizer_common/sanitizer_procmaps_common.cpp
92 ../../sanitizer_common/sanitizer_procmaps_linux.cpp
93 ../../sanitizer_common/sanitizer_linux.cpp
94 ../../sanitizer_common/sanitizer_linux_libcdep.cpp
95 ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
96 ../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
97 "
98 if [scip-shell system . . `[`. "$GOARCH" = "ppc64le" ]; then
99 ARCHCFLAGS="-m64 -mcpu=power8 -fno-function-sections"
100 elif [scip-shell system . . `[`. "$GOARCH" = "amd64" ]; then
101 if [scip-shell system . . `[`. "$GOAMD64" = "v3" ]; then
102 ARCHCFLAGS="-m64 -msse4.2"
103 else
104 ARCHCFLAGS="-m64 -msse3"
105 fi
106 OSCFLAGS="$OSCFLAGS -ffreestanding -Wno-unused-const-variable -Wno-unknown-warning-option"
107 elif [scip-shell system . . `[`. "$GOARCH" = "arm64" ]; then
108 ARCHCFLAGS=""
109 elif [scip-shell system . . `[`. "$GOARCH" = "mips64le" ]; then
110 ARCHCFLAGS="-mips64 -EL"
111 elif [scip-shell system . . `[`. "$GOARCH" = "mips64" ]; then
112 ARCHCFLAGS="-mips64 -EB"
113 elif [scip-shell system . . `[`. "$GOARCH" = "s390x" ]; then
114 SRCS="$SRCS ../../sanitizer_common/sanitizer_linux_s390.cpp"
115 ARCHCFLAGS=""
116 fi
117 elif [scip-shell system . . `[`. "$GOOS" = "freebsd" ]; then
118 # The resulting object still depends on libc.
119 # We removed this dependency for Go runtime for other OSes,
120 # and we should remove it for FreeBSD as well, but there is no pressing need.
121 DEPENDS_ON_LIBC=1
122 OSCFLAGS="-fno-strict-aliasing -fPIC -Werror"
123 ARCHCFLAGS="-m64"
124 OSLDFLAGS="-lpthread -fPIC -fpie"
125 SRCS="
126 $SRCS
127 ../rtl/tsan_platform_linux.cpp
128 ../../sanitizer_common/sanitizer_posix.cpp
129 ../../sanitizer_common/sanitizer_posix_libcdep.cpp
130 ../../sanitizer_common/sanitizer_procmaps_bsd.cpp
131 ../../sanitizer_common/sanitizer_procmaps_common.cpp
132 ../../sanitizer_common/sanitizer_linux.cpp
133 ../../sanitizer_common/sanitizer_linux_libcdep.cpp
134 ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
135 ../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
136 "
137 elif [scip-shell system . . `[`. "$GOOS" = "netbsd" ]; then
138 # The resulting object still depends on libc.
139 # We removed this dependency for Go runtime for other OSes,
140 # and we should remove it for NetBSD as well, but there is no pressing need.
141 DEPENDS_ON_LIBC=1
142 OSCFLAGS="-fno-strict-aliasing -fPIC -Werror"
143 ARCHCFLAGS="-m64"
144 OSLDFLAGS="-lpthread -fPIC -fpie"
145 SRCS="
146 $SRCS
147 ../rtl/tsan_platform_linux.cpp
148 ../../sanitizer_common/sanitizer_posix.cpp
149 ../../sanitizer_common/sanitizer_posix_libcdep.cpp
150 ../../sanitizer_common/sanitizer_procmaps_bsd.cpp
151 ../../sanitizer_common/sanitizer_procmaps_common.cpp
152 ../../sanitizer_common/sanitizer_linux.cpp
153 ../../sanitizer_common/sanitizer_linux_libcdep.cpp
154 ../../sanitizer_common/sanitizer_netbsd.cpp
155 ../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
156 ../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
157 "
158 elif [scip-shell system . . `[`. "$GOOS" = "darwin" ]; then
159 OSCFLAGS="-fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
160 OSLDFLAGS="-lpthread -fPIC -fpie -mmacosx-version-min=10.7"
161 SRCS="
162 $SRCS
163 ../rtl/tsan_platform_mac.cpp
164 ../../sanitizer_common/sanitizer_mac.cpp
165 ../../sanitizer_common/sanitizer_mac_libcdep.cpp
166 ../../sanitizer_common/sanitizer_posix.cpp
167 ../../sanitizer_common/sanitizer_posix_libcdep.cpp
168 ../../sanitizer_common/sanitizer_procmaps_mac.cpp
169 "
170 if [scip-shell system . . `[`. "$GOARCH" = "amd64" ]; then
171 ARCHCFLAGS="-m64"
172 elif [scip-shell system . . `[`. "$GOARCH" = "arm64" ]; then
173 ARCHCFLAGS=""
174 fi
175 elif [scip-shell system . . `[`. "$GOOS" = "windows" ]; then
176 OSCFLAGS="-Wno-error=attributes -Wno-attributes -Wno-unused-const-variable -Wno-unknown-warning-option"
177 ARCHCFLAGS="-m64"
178 OSLDFLAGS=""
179 SRCS="
180 $SRCS
181 ../rtl/tsan_platform_windows.cpp
182 ../../sanitizer_common/sanitizer_win.cpp
183 "
184 else
185 echoscip-shell system . . echo. Unknown platform
186 exit 1
187 fi
188
189 CC=${CC:-gcc}
190 IN_TMPDIR=${IN_TMPDIR:-0}
191 SILENT=${SILENT:-0}
192
193 if [scip-shell system . . `[`. $IN_TMPDIR != "0" ]; then
194 DIR=$(mktempscip-shell system . . mktemp. -qd /tmp/gotsan.XXXXXXXXXXscip-shell filesystem . . `/tmp/gotsan.XXXXXXXXXX`.)
195 cleanupscip-shell shell llvm-toolchain-19 1:19.1.7-22 cleanup().() {
196 rmscip-shell system . . rm. -rf $DIR
197 }
198 trap cleanup EXIT
199 else
200 DIR=.
201 fi
202
203 SRCS="$SRCS $ADD_SRCS"
204 for F in $SRCS; do
205 echoscip-shell system . . echo. "#line 1 \"$F\""
206 catscip-shell system . . cat. $F
207 done > $DIR/gotsan.cpp
208
209 FLAGS=" -I../rtl -I../.. -I../../sanitizer_common -I../../../include -std=c++17 -Wall -fno-exceptions -fno-rtti -DSANITIZER_GO=1 -DSANITIZER_DEADLOCK_DETECTOR_VERSION=2 $OSCFLAGS $ARCHCFLAGS $EXTRA_CFLAGS"
210 DEBUG_FLAGS="$FLAGS -DSANITIZER_DEBUG=1 -g"
211 FLAGS="$FLAGS -DSANITIZER_DEBUG=0 -O3 -fomit-frame-pointer"
212
213 if [scip-shell system . . `[`. "$DEBUG" = "" ]; then
214 # Do a build test with debug flags.
215 $CC $DIR/gotsan.cpp -c -o $DIR/race_debug_$SUFFIX.syso $DEBUG_FLAGS $CFLAGS
216 else
217 FLAGS="$DEBUG_FLAGS"
218 fi
219
220 if [scip-shell system . . `[`. "$SILENT" != "1" ]; then
221 echoscip-shell system . . echo. $CC gotsan.cpp -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS
222 fi
223 $CC $DIR/gotsan.cpp -c -o $DIR/race_$SUFFIX.syso $FLAGS $CFLAGS
224
225 $CC $OSCFLAGS $ARCHCFLAGS test.c $DIR/race_$SUFFIX.syso -g -o $DIR/test $OSLDFLAGS $LDFLAGS
226
227 # Verify that no libc specific code is present.
228 if [scip-shell system . . `[`. "$DEPENDS_ON_LIBC" != "1" ]; then
229 if nmscip-shell system . . nm. $DIR/race_$SUFFIX.syso | grepscip-shell system . . grep. -q __libc_; then
230 printfscip-shell system . . printf. -- '%s seems to link to libc\n' "race_$SUFFIX.syso"
231 exit 1
232 fi
233 fi
234
235 if [scip-shell system . . `[`. "$SKIP_TEST" = "1" ]; then
236 exit 0
237 fi
238
239 if [scip-shell system . . `[`. "`unamescip-shell system . . uname. -a | grepscip-shell system . . grep. NetBSD`" != "" ]; then
240 # Turn off ASLR in the test binary.
241 /usr/sbin/paxctlscip-shell filesystem . . `/usr/sbin/paxctl`. +a $DIR/test
242 fi
243 export GORACE="exitcode=0 atexit_sleep_ms=0"
244 if [scip-shell system . . `[`. "$SILENT" != "1" ]; then
245 $DIR/test
246 else
247 $DIR/test 2>/dev/nullscip-shell filesystem . . `/dev/null`.
248 fi