2
2
3
3
set -e
4
4
5
+ if [ " ` uname -a | grep Linux` " != " " ]; then
6
+ HOST_GOOS=" linux"
7
+ if [ " ` uname -a | grep ppc64le` " != " " ]; then
8
+ HOST_GOARCH=" ppc64le"
9
+ elif [ " ` uname -a | grep x86_64` " != " " ]; then
10
+ HOST_GOARCH=" amd64"
11
+ elif [ " ` uname -a | grep aarch64` " != " " ]; then
12
+ HOST_GOARCH=" arm64"
13
+ elif [ " ` uname -a | grep -i mips64` " != " " ]; then
14
+ if [ " ` lscpu | grep -i Little` " != " " ]; then
15
+ HOST_GOARCH=" mips64le"
16
+ else
17
+ HOST_GOARCH=" mips64"
18
+ fi
19
+ elif [ " ` uname -a | grep s390x` " != " " ]; then
20
+ HOST_GOARCH=" s390x"
21
+ fi
22
+ elif [ " ` uname -a | grep FreeBSD` " != " " ]; then
23
+ HOST_GOOS=" freebsd"
24
+ HOST_GOARCH=" amd64"
25
+ elif [ " ` uname -a | grep NetBSD` " != " " ]; then
26
+ HOST_GOOS=" netbsd"
27
+ HOST_GOARCH=" amd64"
28
+ elif [ " ` uname -a | grep Darwin` " != " " ]; then
29
+ HOST_GOOS=" darwin"
30
+ if [ " ` uname -a | grep x86_64` " != " " ]; then
31
+ HOST_GOARCH=" amd64"
32
+ elif [ " ` uname -a | grep arm64` " != " " ]; then
33
+ HOST_GOARCH=" arm64"
34
+ fi
35
+ elif [ " ` uname -a | grep MINGW` " != " " ]; then
36
+ HOST_GOOS=" windows"
37
+ HOST_GOARCH=" amd64"
38
+ fi
39
+
40
+ GOOS=${GOOS:- $HOST_GOOS }
41
+ GOARCH=${GOARCH:- $HOST_GOARCH }
42
+ SUFFIX=" ${GOOS} _${GOARCH} "
43
+
5
44
SRCS="
6
45
tsan_go.cpp
7
46
../rtl/tsan_external.cpp
39
78
../../sanitizer_common/sanitizer_termination.cpp
40
79
"
41
80
42
- if [ " ` uname -a | grep Linux ` " != " " ]; then
81
+ if [ " $GOOS " == " linux " ]; then
43
82
OSCFLAGS=" -fPIC -Wno-maybe-uninitialized"
44
83
OSLDFLAGS=" -lpthread -fPIC -fpie"
45
84
SRCS="
@@ -54,39 +93,30 @@ if [ "`uname -a | grep Linux`" != "" ]; then
54
93
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
55
94
../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
56
95
"
57
- if [ " ` uname -a | grep ppc64le` " != " " ]; then
58
- SUFFIX=" linux_ppc64le"
96
+ if [ " $GOARCH " == " ppc64le" ]; then
59
97
ARCHCFLAGS=" -m64 -mcpu=power8 -fno-function-sections"
60
- elif [ " ` uname -a | grep x86_64` " != " " ]; then
61
- SUFFIX=" linux_amd64"
98
+ elif [ " $GOARCH " == " amd64" ]; then
62
99
if [ " $GOAMD64 " = " v3" ]; then
63
100
ARCHCFLAGS=" -m64 -msse4.2"
64
101
else
65
102
ARCHCFLAGS=" -m64 -msse3"
66
103
fi
67
104
OSCFLAGS=" $OSCFLAGS -ffreestanding -Wno-unused-const-variable -Wno-unknown-warning-option"
68
- elif [ " ` uname -a | grep aarch64` " != " " ]; then
69
- SUFFIX=" linux_arm64"
105
+ elif [ " $GOARCH " == " arm64" ]; then
70
106
ARCHCFLAGS=" "
71
- elif [ " ` uname -a | grep -i mips64` " != " " ]; then
72
- if [ " ` lscpu | grep -i Little` " != " " ]; then
73
- SUFFIX=" linux_mips64le"
74
- ARCHCFLAGS=" -mips64 -EL"
75
- else
76
- SUFFIX=" linux_mips64"
77
- ARCHCFLAGS=" -mips64 -EB"
78
- fi
79
- elif [ " ` uname -a | grep s390x` " != " " ]; then
107
+ elif [ " $GOARCH " == " mips64le" ]; then
108
+ ARCHCFLAGS=" -mips64 -EL"
109
+ elif [ " $GOARCH " == " mips64" ]; then
110
+ ARCHCFLAGS=" -mips64 -EB"
111
+ elif [ " $GOARCH " == " s390x" ]; then
80
112
SRCS=" $SRCS ../../sanitizer_common/sanitizer_linux_s390.cpp"
81
- SUFFIX=" linux_s390x"
82
113
ARCHCFLAGS=" "
83
114
fi
84
- elif [ " ` uname -a | grep FreeBSD ` " != " " ]; then
115
+ elif [ " $GOOS " == " freebsd " ]; then
85
116
# The resulting object still depends on libc.
86
117
# We removed this dependency for Go runtime for other OSes,
87
118
# and we should remove it for FreeBSD as well, but there is no pressing need.
88
119
DEPENDS_ON_LIBC=1
89
- SUFFIX=" freebsd_amd64"
90
120
OSCFLAGS=" -fno-strict-aliasing -fPIC -Werror"
91
121
ARCHCFLAGS=" -m64"
92
122
OSLDFLAGS=" -lpthread -fPIC -fpie"
@@ -102,12 +132,11 @@ elif [ "`uname -a | grep FreeBSD`" != "" ]; then
102
132
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
103
133
../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
104
134
"
105
- elif [ " ` uname -a | grep NetBSD ` " != " " ]; then
135
+ elif [ " $GOOS " == " netbsd " ]; then
106
136
# The resulting object still depends on libc.
107
137
# We removed this dependency for Go runtime for other OSes,
108
138
# and we should remove it for NetBSD as well, but there is no pressing need.
109
139
DEPENDS_ON_LIBC=1
110
- SUFFIX=" netbsd_amd64"
111
140
OSCFLAGS=" -fno-strict-aliasing -fPIC -Werror"
112
141
ARCHCFLAGS=" -m64"
113
142
OSLDFLAGS=" -lpthread -fPIC -fpie"
@@ -124,7 +153,7 @@ elif [ "`uname -a | grep NetBSD`" != "" ]; then
124
153
../../sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
125
154
../../sanitizer_common/sanitizer_stoptheworld_netbsd_libcdep.cpp
126
155
"
127
- elif [ " ` uname -a | grep Darwin ` " != " " ]; then
156
+ elif [ " $GOOS " == " darwin " ]; then
128
157
OSCFLAGS=" -fPIC -Wno-unused-const-variable -Wno-unknown-warning-option -mmacosx-version-min=10.7"
129
158
OSLDFLAGS=" -lpthread -fPIC -fpie -mmacosx-version-min=10.7"
130
159
SRCS="
@@ -136,15 +165,12 @@ elif [ "`uname -a | grep Darwin`" != "" ]; then
136
165
../../sanitizer_common/sanitizer_posix_libcdep.cpp
137
166
../../sanitizer_common/sanitizer_procmaps_mac.cpp
138
167
"
139
- if [ " ` uname -a | grep x86_64` " != " " ]; then
140
- SUFFIX=" darwin_amd64"
168
+ if [ " $GOARCH " == " amd64" ]; then
141
169
ARCHCFLAGS=" -m64"
142
- elif [ " ` uname -a | grep arm64` " != " " ]; then
143
- SUFFIX=" darwin_arm64"
170
+ elif [ " $GOARCH " == " arm64" ]; then
144
171
ARCHCFLAGS=" "
145
172
fi
146
- elif [ " ` uname -a | grep MINGW` " != " " ]; then
147
- SUFFIX=" windows_amd64"
173
+ elif [ " $GOOS " == " windows" ]; then
148
174
OSCFLAGS=" -Wno-error=attributes -Wno-attributes -Wno-unused-const-variable -Wno-unknown-warning-option"
149
175
ARCHCFLAGS=" -m64"
150
176
OSLDFLAGS=" "
@@ -204,6 +230,10 @@ if [ "$DEPENDS_ON_LIBC" != "1" ]; then
204
230
fi
205
231
fi
206
232
233
+ if [ " $SKIP_TEST " == " 1" ]; then
234
+ exit 0
235
+ fi
236
+
207
237
if [ " ` uname -a | grep NetBSD` " != " " ]; then
208
238
# Turn off ASLR in the test binary.
209
239
/usr/sbin/paxctl +a $DIR /test
0 commit comments