-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[contrib][vcl] Fix VCL builds with GCC #37075
Conversation
CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to |
@florincoras This is what I ultimately ended up doing to make GCC builds of Envoy work. Please take a look. |
There were a few issues with building Envoy with VCL. The fist issue is that vppinfra library is built with LTO enabled. While there is nothing wrong with enabling LTO, it apparently triggers some bug in GCC - during linking one of the LTO passes just consumes all the memory in the system and eventually crashes without finishing ( I tried to build Envoy on a system with 256GiB of memory and it wasn't enough, so it's way past what is reasonable). To workaround the issue I updated vpp_vcl.patch to conditionally disable LTO when building using GCC. Once LTO was disabled I hit another issue - the order of libraries in linker command line does matter, at least in the world of Unix-like systems. Normally, Bazel can figure out the right order, but with VPP static libraries that are built by CMake Bazel has no information to figure out what is the proper order of those libraries. And that ultimately resulted in linking failures. I considered a few options to address the issue: 1. Use alwayslink = True - while it should be the simplest and the least surprising solution to the problem, apparently, alwayslink does not do anything for static libraries, so this option does not work 2. Maintain the right order of libraries in the BUILD file - that works, but it's unusual when order of targets in Bazel srcs and deps matters, so to avoid surprising behaviour I didn't go for that option 3. Use genrule and combine different static libraries into a single static library - it should work in theory, but I couldn't refer to the ar tool from genrule and abandon this option. 4. Use --start-group and --end-group linker options to tell to the linker that all those static libraries should be considered a single unit - that is the option I implemented in this change. Signed-off-by: Mikhail Krinkin <[email protected]>
94c8e14
to
ef21fe9
Compare
Thanks @krinkinmu! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks @krinkinmu
Commit Message:
There were a few issues with building Envoy with VCL. The fist issue is that vppinfra library is built with LTO enabled. While there is nothing wrong with enabling LTO, it apparently triggers some bug in GCC - during linking one of the LTO passes just consumes all the memory in the system and eventually crashes without finishing ( I tried to build Envoy on a system with 256GiB of memory and it wasn't enough, so it's way past what is reasonable).
To workaround the issue I updated vpp_vcl.patch to conditionally disable LTO when building using GCC.
Once LTO was disabled I hit another issue - the order of libraries in linker command line does matter, at least in the world of Unix-like systems.
Normally, Bazel can figure out the right order, but with VPP static libraries that are built by CMake Bazel has no information to figure out what is the proper order of those libraries. And that ultimately resulted in linking failures.
I considered a few options to address the issue:
ar
tool from genrule and abandoned this optionAdditional Description:
This is part of the work done to fix gcc builds of Envoy tracked in #31807. This change by itself does not address the issue completely yet, but it moves us a bit closer.
Risk Level: Low
Testing: builds with --config=gcc and --config=docker-gcc
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A