forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwee8.genrule_cmd
120 lines (107 loc) · 3.86 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
#!/bin/bash
set -e
# This works only on Linux-{x86_64,s390x,aarch64} and macOS-x86_64.
case "$$(uname -s)-$$(uname -m)" in
Linux-x86_64|Linux-s390x|Linux-aarch64|Darwin-x86_64)
;;
*)
echo "ERROR: wee8 is currently supported only on Linux-{x86_64,s390x,aarch64} and macOS-x86_64." >&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"
if [[ ( `uname` == "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"
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 [[ `uname -m` == "aarch64" ]]; then
WEE8_BUILD_ARGS+=" target_cpu=\"arm64\""
fi
# Build wee8.
if [[ -f /etc/centos-release ]] && [[ $$(cat /etc/centos-release) =~ "CentOS Linux release 7" ]] && [[ -x "$$(command -v gn)" ]]; then
# Using system default gn tools
# This is done only for CentOS 7, as it has an old version of GLIBC which is otherwise incompatible
gn=$$(command -v gn)
elif [[ "$$(uname -s)" == "Darwin" ]]; then
gn=buildtools/mac/gn
elif [[ "$$(uname -s)-$$(uname -m)" == "Linux-x86_64" ]]; then
gn=buildtools/linux64/gn
else
# Using system default gn tools
gn=$$(command -v gn)
fi
if [[ "$$(uname -s)" == "Darwin" ]]; then
ninja=third_party/depot_tools/ninja
elif [[ "$$(uname -s)-$$(uname -m)" == "Linux-x86_64" ]]; then
ninja=third_party/depot_tools/ninja
else
# Using system default ninja tools
ninja=$$(command -v ninja)
fi
"$$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)