envoy: Unable to build Envoy with Bazel

Title: Unable to build Envoy with Bazel

Description: I was getting started with Envoy, and followed the Quick start build for developers. Installed bazel, golang, buildifier, other required dependencies with Homebrew, fetched the source and built all the external dependencies successfully.

Upon running bazel build //source/exe:envoy-static from Envoy directory, the build doesn’t complete successfully, I get: gcc: error: unrecognized command line option '-fobjc-link-runtime'. Below is the screenshot of the verbose version:

image

I guess the issue is with gcc and not with Envoy, is there any known fix for this?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Closing for now. Please hop into Slack #osx-dev room for futher help.

Sadly no, the same error still persists. Using Ubuntu in VirtualBox to play with Envoy as of now.

Were you ever able to get this working?

I followed the bazel hello world tutorial, all 3 exercises run smoothly. I uninstalled entire Homebrew related packages, and installed just these coreutils, wget, cmake, libtool, automake alone, and ran it, still the same ld error.

You may need to bazel clean --expunge if you’ve changed your C/C++ toolchain to something else. You should also verify that g++ --version matches, since BoringSSL and Envoy use g++. And finally, since the log above shows /usr/local/bin/c++ being invoked, consider moving or removing whatever that is.

Great. I’m okay with using the default compiler which comes with XCode. I’ve run brew uninstall gcc, deleted the gcc at usr/local/bin/gcc which was installed manually. Now running gcc --version shows me Apple LLVM version 9.0.0 (clang-900.0.39.2). I hope this is the default compiler that comes by XCode? I still get the error though. Isn’t my uninstallation complete?

Found the issue. BoringSSL’s cmake config hardcodes -stdlib=libc++ when building on Apple platforms. This will be fixed for Envoy when we stop using cmake to build BoringSSL (https://github.com/envoyproxy/envoy/pull/2652).

Note that there are other problems that will prevent you from building Envoy on MacOS with a self-installed compiler. Libevent depends on some MacOS system headers, which use macros not supported by stock GCC. I didn’t try using Homebrew-managed Clang, but expect similar issues will be hit there.

My recommendation is to stick with the compiler installed by XCode. It may be possible to make libevent build on a MacOS platform with non-standard compilers, but you’re going to spend a lot of time digging around in low-level compiler flags to make it happen.

Hmm, the BoringSSL build’s cmakefile is invoking /usr/local/bin/c++. I’ve never seen that on a Mac before – is it from Homebrew? I’m also confused about where -stdlib=libc++ could be coming from, it’s not set by Bazel or Envoy and grep didn’t have any hits in the BoringSSL code.

I feel like there must be a disconnect between the CC and CXX environment variables, vs your path. I’ll try installing gcc 7.3 locally and attempt to reproduce the issue.

Updated gcc to 7.3.0 and ran again. Still the same. gcc: error: unrecognized command line option '-fobjc-link-runtime'; did you mean '-fgnu-runtime'?