Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to build the executable binary in Ubuntu 20.04 for both gcc and clang #138

Open
NomadXD opened this issue Dec 7, 2020 · 10 comments

Comments

@NomadXD
Copy link

NomadXD commented Dec 7, 2020

Hello, I am trying to build the http filter with envoy v1.16.0 . I tried using both gcc and clang but still no luck.

GCC

My specs are as follows.

  • bazel 3.4.1
  • gcc 9.3.0
  • gcc++ 9.3.0

When I try to build using the following commands,

git clone https://github.com/envoyproxy/envoy-filter-example.git
cd envoy-filter-example
git submodule update --init
cd envoy
git checkout v1.16.0
cd ..
bazel build //http-filter-example:envoy --config=clang

I get the following error.

ERROR: /home/khadija/.cache/bazel/_bazel_khadija/67b71b3527ed4854635b017e6b6cd642/external/com_googlesource_quiche/BUILD.bazel:2170:17: C++ compilation of rule '@com_googlesource_quiche//:quic_core_framer_lib' failed (Exit 1): gcc failed: error executing command 
  (cd /home/khadija/.cache/bazel/_bazel_khadija/67b71b3527ed4854635b017e6b6cd642/sandbox/linux-sandbox/2634/execroot/envoy_filter_example && \
  exec env - \
    BAZEL_LINKLIBS=-l%:libstdc++.a \
    BAZEL_LINKOPTS=-lm \
    CC=gcc \
    CXX=g++ \
    PATH=/home/khadija/.cache/bazelisk/downloads/bazelbuild/bazel-3.4.1-linux-x86_64/bin:/usr/lib/llvm-8/bin:/home/khadija/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin \
    PWD=/proc/self/cwd \`

[-Werror=sign-compare]
 5546 |         static_cast<size_t>(writer->remaining() - ecn_size) <
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 5547 |             QuicDataWriter::GetVarInt62Len(gap) +
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~            
 5548 |                 QuicDataWriter::GetVarInt62Len(ack_range)) {
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    
At global scope:
cc1plus: error: unrecognized command line option '-Wno-range-loop-analysis' [-Werror]
cc1plus: all warnings being treated as errors
Target //:envoy failed to build

Clang

I followed the instructions on bazel/ReadMe to download and configure Clang+llvm.

git clone https://github.com/envoyproxy/envoy-filter-example.git
cd envoy-filter-example
git submodule update --init
cd envoy
git checkout v1.16.0
bazel/setup_clang.sh ~/Downloads/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04
cd ..
bazel build //http-filter-example:envoy --config=clang

But I am getting the following error.

ERROR: /home/khadija/.cache/bazel/_bazel_khadija/b8963e6f21a84c9e75cda0cff04a3eb5/external/envoy/source/common/common/BUILD:321:23: C++ compilation of rule '@envoy//source/common/common:thread_impl_lib_posix' failed (Exit 1) gcc failed: error executing command /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer '-std=c++0x' -MD -MF ... (remaining 70 argument(s) skipped)

Use --sandbox_debug to see verbose messages from the sandbox
gcc: error: unrecognized command line option '-fno-limit-debug-info'
gcc: error: unrecognized command line option '-Wgnu-conditional-omitted-operand'
gcc: error: unrecognized command line option '-Wc++2a-extensions'; did you mean '-fms-extensions'?
gcc: error: unrecognized command line option '-Wrange-loop-analysis'
Target //http-filter-example:envoy failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.718s, Critical Path: 0.40s
INFO: 0 processes.
FAILED: Build did NOT complete successfully

Any idea ? I was using envoy v1.14.0 and it works fine. But with v1.16.0, I can't build using both gcc and clang. Tried for few days and still no luck.

@pgeler
Copy link

pgeler commented Dec 14, 2020

same issue, at first view, looks like something with bazel or sub-targets this repository is exploiting 🤯 .
Does anybody look at this?

@pgeler
Copy link

pgeler commented Dec 15, 2020

dbg config is building almost fine, but failing at linking stage, with bazel "fatal error: cannot execute '/usr/lib/gcc/x86_64-linux-gnu/9/cc1plus': execv: Argument list too long"

I'm not a bazel expert...

@NomadXD
Copy link
Author

NomadXD commented Dec 15, 2020

@pgeler I was trying to build v1.16.0 and that Quiche build failure was fixed after 1.16.0. So I tried to build from the master and I'm not getting the Quiche build failure but getting the exact same error you mentioned.

@NomadXD
Copy link
Author

NomadXD commented Dec 15, 2020

@pgeler Anyway I was able to build successfully with clang. Can help you with that if you are okay with building using clang.

@pgeler
Copy link

pgeler commented Dec 15, 2020 via email

@NomadXD
Copy link
Author

NomadXD commented Dec 15, 2020

@pgeler okay cool. let me know if you get across the issue

@pgeler
Copy link

pgeler commented Dec 16, 2020

those are my observations:

  1. bazel with clang is using argument file for link and compilation, while gcc is using direct list of arguments and both approaches are working fine for main project
  2. bazel superproject approach is almost doubling number of arguments for compilation and linking stage, so that clang build is passing successfully on this project while gcc is failing with "too many arguments" at later linking stage

I'm not sure what forcing this behavior for clang and gcc... sounds like some bazel stuff ... but need a hint from somebody who knows it well

most of my problems with ubuntu 20.04, on top of envoy requirements were solved by apt install lld llvm python-ispython3 clang-tools + envoy/bazel/setup_clang.sh from root repository

ps. all of above applicable to "fastbuild" and I'm sure for "dbg", while "opt" has it's own challenges but those are more to main envoy repository

@yunkai123
Copy link

@pgeler apt install lld llvm python-ispython3 clang-tools + envoy/bazel/setup_clang.sh from root repository. That also works for me, thanks.

@NomadXD
Copy link
Author

NomadXD commented Jan 29, 2021

@yunkai123 thanks. I fixed it some other way. #139

@NomadXD
Copy link
Author

NomadXD commented Jan 29, 2021

@yunkai123 Were you able to generate compile_commands.json for the custom filters you write outside envoy ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants