Skip to content

Commit

Permalink
build: support building wee8 with Clang/libc++ and GCC. (envoyproxy#151)
Browse files Browse the repository at this point in the history
While there, make build args more readable.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
  • Loading branch information
PiotrSikora committed Aug 25, 2019
1 parent 8f5993e commit f4aae5f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ build:clang-msan --copt -fsanitize-memory-track-origins=2
# TODO(cmluciano) fix and re-enable _LIBCPP_VERSION testing for TCMALLOC in Envoy::Stats::TestUtil::hasDeterministicMallocStats
# and update stats_integration_test with appropriate m_per_cluster value
build:libc++ --action_env=CXXFLAGS=-stdlib=libc++
build:libc++ --action_env=LDFLAGS=-stdlib=libc++
build:libc++ --action_env=BAZEL_CXXOPTS=-stdlib=libc++
build:libc++ --action_env=BAZEL_LINKLIBS=-l%:libc++.a:-l%:libc++abi.a:-lm
build:libc++ --host_linkopt=-fuse-ld=lld
Expand Down
38 changes: 37 additions & 1 deletion bazel/external/wee8.genrule_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,44 @@ pushd $$ROOT/wee8
# Clean after previous build.
rm -rf out/wee8

# Export compiler configuration.
if [[ ( `uname` == "Darwin" && $${CXX-} == "" ) || $${CXX-} == *"clang"* ]]; then
export IS_CLANG=true
export CC=$${CC:-clang}
export CXX=$${CXX:-clang++}
else
export IS_CLANG=false
export CC=$${CC:-gcc}
export CXX=$${CXX:-g++}
fi

export AR=$${AR:-ar}
export NM=$${NM:-nm}

# Release build.
WEE8_BUILD_ARGS+=" is_debug=false"
# Clang or not Clang, that is the question.
WEE8_BUILD_ARGS+=" is_clang=$$IS_CLANG"
# Disable custom compiler plugins.
WEE8_BUILD_ARGS+=" clang_use_chrome_plugins=false"
# 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"

# Build wee8.
AR=ar NM=nm third_party/depot_tools/gn gen out/wee8 --args='v8_use_external_startup_data=false v8_enable_i18n_support=false v8_enable_gdbjit=false v8_expose_symbols=true is_component_build=false is_debug=false clang_use_chrome_plugins=false use_sysroot=false use_custom_libcxx=false use_glib=false custom_toolchain="//build/toolchain/linux/unbundle:default"'
third_party/depot_tools/gn gen out/wee8 --args="$$WEE8_BUILD_ARGS"
third_party/depot_tools/ninja -C out/wee8 wee8

# Move compiled library to the expected destinations.
Expand Down

0 comments on commit f4aae5f

Please sign in to comment.