forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwee8.genrule_cmd
145 lines (129 loc) · 4.62 KB
/
wee8.genrule_cmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
set -e
# Works on Linux-{x86_64,s390x,aarch64,ppc64le} and macOS-{x86_64,arm64}.
ARCH="$$(uname -m)"
SYSTEM="$$(uname -s)"
PLATFORM="$${SYSTEM}-$${ARCH}"
case $${PLATFORM} in
Linux-x86_64|Linux-s390x|Linux-aarch64|Linux-ppc64le)
;;
Darwin-x86_64|Darwin-arm64)
;;
MSYS_NT-*-x86_64)
echo "WARNING: wee8 is currently untested on $${PLATFORM}." >&2
;;
*)
echo "ERROR: wee8 is currently not supported on $${PLATFORM}." >&2
exit 1
esac
# Bazel magic.
ROOT=$$(dirname $(rootpath wee8/BUILD.gn))/..
pushd $$ROOT/wee8
# Clean after previous build.
rm -rf out/wee8
# Export compiler configuration.
export CXXFLAGS="$${CXXFLAGS-} -Wno-sign-compare -Wno-deprecated-copy -Wno-unknown-warning-option -Wno-range-loop-analysis -Wno-shorten-64-to-32"
if [[ ( $${SYSTEM} == "Darwin" && $${CXX-} == "" ) || $${CXX-} == *clang* ]]; then
export IS_CLANG=true
export CC=$${CC:-clang}
export CXX=$${CXX:-clang++}
export CXXFLAGS="$${CXXFLAGS} -Wno-implicit-int-float-conversion -Wno-builtin-assume-aligned-alignment -Wno-final-dtor-non-final-class"
else
export IS_CLANG=false
export CC=$${CC:-gcc}
export CXX=$${CXX:-g++}
fi
export AR=$${AR:-ar}
export NM=$${NM:-nm}
# Hook sanitizers.
if [[ $${ENVOY_ASAN-} == "1" ]]; then
WEE8_BUILD_ARGS+=" is_asan=true"
WEE8_BUILD_ARGS+=" is_lsan=true"
fi
if [[ $${ENVOY_UBSAN_VPTR-} == "1" ]]; then
WEE8_BUILD_ARGS+=" is_ubsan=true"
WEE8_BUILD_ARGS+=" is_ubsan_vptr=true"
fi
if [[ $${ENVOY_MSAN-} == "1" ]]; then
WEE8_BUILD_ARGS+=" is_msan=true"
export LDFLAGS="$${LDFLAGS} -L/opt/libcxx_msan/lib -Wl,-rpath,/opt/libcxx_msan/lib"
fi
if [[ $${ENVOY_TSAN-} == "1" ]]; then
WEE8_BUILD_ARGS+=" is_tsan=true"
export LDFLAGS="$${LDFLAGS} -L/opt/libcxx_tsan/lib -Wl,-rpath,/opt/libcxx_tsan/lib"
fi
# Debug/release build.
if [[ $(COMPILATION_MODE) == "dbg" && $${ENVOY_UBSAN_VPTR-} != "1" && $${ENVOY_MSAN-} != "1" && $${ENVOY_TSAN-} != "1" ]]; then
WEE8_BUILD_ARGS+=" is_debug=true"
WEE8_BUILD_ARGS+=" v8_symbol_level=2"
WEE8_BUILD_ARGS+=" v8_optimized_debug=false"
else
WEE8_BUILD_ARGS+=" is_debug=false"
WEE8_BUILD_ARGS+=" v8_symbol_level=1"
WEE8_BUILD_ARGS+=" v8_enable_handle_zapping=false"
fi
# Clang or not Clang, that is the question.
WEE8_BUILD_ARGS+=" is_clang=$$IS_CLANG"
# Hack to disable bleeding-edge compiler flags.
WEE8_BUILD_ARGS+=" use_xcode_clang=true"
# Use local toolchain.
WEE8_BUILD_ARGS+=" custom_toolchain=\"//build/toolchain/linux/unbundle:default\""
# Use local stdlibc++ / libc++.
WEE8_BUILD_ARGS+=" use_custom_libcxx=false"
# Use local sysroot.
WEE8_BUILD_ARGS+=" use_sysroot=false"
# Disable unused GLib2 dependency.
WEE8_BUILD_ARGS+=" use_glib=false"
# Expose debug symbols.
WEE8_BUILD_ARGS+=" v8_expose_symbols=true"
# Build monolithic library.
WEE8_BUILD_ARGS+=" is_component_build=false"
WEE8_BUILD_ARGS+=" v8_enable_i18n_support=false"
WEE8_BUILD_ARGS+=" v8_enable_gdbjit=false"
WEE8_BUILD_ARGS+=" v8_use_external_startup_data=false"
# Disable read-only heap, since it's leaky and HEAPCHECK complains about it.
# TODO(PiotrSikora): remove when fixed upstream.
WEE8_BUILD_ARGS+=" v8_enable_shared_ro_heap=false"
# Support arm64.
if [[ $${ARCH} == "aarch64" || $${ARCH} == "arm64" ]]; then
WEE8_BUILD_ARGS+=" target_cpu=\"arm64\""
fi
# Support ppc64le.
if [[ $${ARCH} == "ppc64le" ]]; then
WEE8_BUILD_ARGS+=" target_cpu=\"ppc64\""
fi
# Select gn tool for the current platform.
if [[ -f /etc/centos-release ]] && [[ $$(cat /etc/centos-release) =~ "CentOS Linux release 7" ]] && [[ -x "$$(command -v gn)" ]]; then
# Use system default on CentOS 7, as it has an old version of GLIBC which is otherwise incompatible with the prebuilt binary.
gn=$$(command -v gn)
elif [[ $${PLATFORM} == "Darwin-x86_64" ]]; then
gn=buildtools/mac/gn
elif [[ $${PLATFORM} == "Darwin-arm64" ]]; then
gn=buildtools/mac-arm64/gn
elif [[ $${PLATFORM} == "Linux-x86_64" ]]; then
gn=buildtools/linux64/gn
elif [[ $${PLATFORM} == "Linux-aarch64" ]]; then
gn=buildtools/linux-arm64/gn
elif [[ $${PLATFORM} == MSYS_NT-*-x86_64 ]]; then
gn=buildtools/win/gn.exe
else
# Fallback to system default.
gn=$$(command -v gn)
fi
# Select ninja tool for the current platform.
if [[ $${PLATFORM} == "Darwin-x86_64" ]]; then
ninja=third_party/depot_tools/ninja-mac
elif [[ $${PLATFORM} == "Linux-x86_64" ]]; then
ninja=third_party/depot_tools/ninja-linux64
elif [[ $${PLATFORM} == MSYS_NT-*-x86_64 ]]; then
ninja=third_party/depot_tools/ninja.exe
else
# Fallback to system default.
ninja=$$(command -v ninja)
fi
# Build wee8.
"$$gn" gen out/wee8 --args="$$WEE8_BUILD_ARGS"
"$$ninja" -C out/wee8 wee8
# Move compiled library to the expected destinations.
popd
mv $$ROOT/wee8/out/wee8/obj/libwee8.a $(execpath libwee8.a)