Issue building envoy on MacOSX

574 views
Skip to first unread message

Arya C

unread,
Oct 25, 2021, 5:44:22 PM10/25/21
to envoy-users
Hi,

C++/Bazel novice here. I am trying to build Envoy locally on my Mac. Followed the instructions for MacOS here (https://github.com/envoyproxy/envoy/blob/main/bazel/README.md#quick-start-bazel-build-for-developers) and when I did a bazel build envoy, the build failed with the following trace:

ERROR: /private/var/tmp/_bazel_aryac/7315896c03f4109e8989b1b90087ad03/external/com_googlesource_chromium_v8/BUILD.bazel:33:8: Executing genrule @com_googlesource_chromium_v8//:build failed: (Exit 1): bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
/private/var/tmp/_bazel_aryac/7315896c03f4109e8989b1b90087ad03/sandbox/darwin-sandbox/29/execroot/envoy/external/com_googlesource_chromium_v8 /private/var/tmp/_bazel_aryac/7315896c03f4109e8989b1b90087ad03/sandbox/darwin-sandbox/29/execroot/envoy
Done. Made 163 targets from 91 files in 2019ms
ninja: Entering directory `out/wee8'
[1/1281] STAMP obj/v8_version.stamp
<SNIP>
[180/1281] LINK ./bytecode_builtins_list_generator
FAILED: bytecode_builtins_list_generator
python3 "../../build/toolchain/gcc_link_wrapper.py" --output="./bytecode_builtins_list_generator" -- clang++ -fuse-ld=lld -Wl,-fatal_warnings -Wl,--color-diagnostics -stdlib=libc++ -arch x86_64 -no-canonical-prefixes -Werror -isysroot ../../../../../../../../../../../../../../Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -mmacosx-version-min=10.11.0 -Wl,-ObjC -Wl,-dead_strip -o "./bytecode_builtins_list_generator"  @"./bytecode_builtins_list_generator.rsp"
clang++: error: invalid linker name in argument '-fuse-ld=lld'
[181/1281] CXX obj/torque_base/torque-compiler.o
[182/1281] CC obj/third_party/zlib/zlib/deflate.o
[183/1281] CC obj/third_party/zlib/zlib/trees.o
[184/1281] CXX obj/torque_base/type-oracle.o
[185/1281] CXX obj/v8_bigint/mul-fft.o
[186/1281] CXX obj/torque_base/utils.o
[187/1281] CXX obj/torque_base/type-visitor.o
[188/1281] CXX obj/torque_base/types.o
[189/1281] CXX obj/torque_base/torque-parser.o
[190/1281] CXX obj/torque_base/implementation-visitor.o
ninja: build stopped: subcommand failed.
Target //source/exe:envoy-static failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 148.942s, Critical Path: 98.41s
INFO: 2282 processes: 1805 internal, 476 darwin-sandbox, 1 worker.
FAILED: Build did NOT complete successfully

I am not quite sure where to start debugging what went wrong here and some pointers to help will be super helpful.

Thanks,

Arya C

unread,
Oct 25, 2021, 5:54:50 PM10/25/21
to envoy-users
So I tried rerunning the build with the --verbose-failures command (bazel build envoy --verbose_failures), got the following command that seems to have failed(see below). I am still a little perplexed by what may have happened here.

/private/var/tmp/_bazel_aryac/7315896c03f4109e8989b1b90087ad03/external/com_googlesource_chromium_v8/BUILD.bazel:33:8: Executing genrule @com_googlesource_chromium_v8//:build failed: (Exit 1): bash failed: error executing command
  (cd /private/var/tmp/_bazel_aryac/7315896c03f4109e8989b1b90087ad03/sandbox/darwin-sandbox/913/execroot/envoy && \
  exec env - \
    PATH=/usr/local/bin:/opt/local/bin:/usr/bin:/bin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; #!/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 external/com_googlesource_chromium_v8/BUILD.gn)
pushd $ROOT

# 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 CC=${CC:-clang}
  export CXX=${CXX:-clang++}
else
  export CC=${CC:-gcc}
  export CXX=${CXX:-g++}
fi

if ${CXX} --version 2>&1 | grep -q clang ; then
  export IS_CLANG=true
  export CXXFLAGS="${CXXFLAGS} -Wno-implicit-int-float-conversion -Wno-builtin-assume-aligned-alignment -Wno-final-dtor-non-final-class -Wno-invalid-constexpr"
else
  export IS_CLANG=false
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"
  WEE8_BUILD_ARGS+=" msan_track_origins=2"
  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 [[ fastbuild == "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"

# Set target architecture.
if [[ ${ARCH} == "x86_64" ]]; then
  WEE8_BUILD_ARGS+=" target_cpu=\"x64\""
elif [[ ${ARCH} == "aarch64" || ${ARCH} == "arm64" ]]; then
  WEE8_BUILD_ARGS+=" target_cpu=\"arm64\""
elif [[ ${ARCH} == "ppc64le" ]]; then
  WEE8_BUILD_ARGS+=" target_cpu=\"ppc64\""
elif [[ ${ARCH} == "s390x" ]]; then
  WEE8_BUILD_ARGS+=" target_cpu=\"s390x\""
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/out/wee8/obj/libwee8.a bazel-out/darwin-fastbuild/bin/external/com_googlesource_chromium_v8/libwee8.a
')
Execution platform: @local_config_platform//:host

Reply all
Reply to author
Forward
0 new messages