Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@krinkinmu
Copy link

@krinkinmu krinkinmu commented Dec 5, 2025

What this PR does / why we need it:

It makes changes to the Istio proxy Bazel configs to migrate to using Envoy's hermetic LLVM toolchain for builds. The "hermetic" here means that as part of the build process Bazel will download the LLVM toolchain, including compiler, linker and libraries, and will use them to build.

One thing worth calling out specifically, is that Envoy will also download a sysroot that packages glibc vers 2.28, which is, I think, the same version of glibc that we are currently using, so we still should be able to run the resulting Envoy binary outside of the container environment on old OSes.

NOTE: llvm toolchain itself is not statically built, unfortunately, and not all required libraries come with the toolchain. One library specifically that I noticed might cause problems is libncurses. Clang in the hermetic llvm toolchain is built against libncurses version 5, while some major distributions (i.e., Ubuntu) moved towards version 6.

It does not matter when building inside a container - we use a pretty old base image that should have the required version of the libncurses library, however building things outside the container may require jumping through a few hoops to install the right libraries if the hermetic toolchain is used.

I don't think there is a sensible way to workaround this issue in the hermetic toolchain itself (I wish LLVM folks just released a static version of the toolchain, but alas they don't do that). So IMO the best path forward would be to just allow easy switching between hermetic toolchain and host toolchain, which this PR does not implement yet. However, if we ok in principle with this approach, I can probably add support for that.

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@istio-testing
Copy link
Collaborator

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@istio-testing istio-testing added the do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. label Dec 5, 2025
@istio-policy-bot
Copy link

😊 Welcome @krinkinmu! This is either your first contribution to the Istio proxy repo, or it's been
a while since you've been here.

You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines
by referring to Contributing to Istio.

Thanks for contributing!

Courtesy of your friendly welcome wagon.

@istio-testing istio-testing added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 5, 2025
@krinkinmu
Copy link
Author

/test all

Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean you can finally just run bazel build and it works??? amazing!!

@krinkinmu
Copy link
Author

Does this mean you can finally just run bazel build and it works??? amazing!!

Almost, but there are corner cases. E.g., llvm tools themselves are not built statically, so they still depend on some external libraries, but at the very least installing clang should not be necessary.

And we still need to figure out if we want to go this way or rely on a local toolchain.

@krinkinmu krinkinmu mentioned this pull request Dec 5, 2025
.bazelrc Outdated Show resolved Hide resolved
Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@zirain
Copy link
Member

zirain commented Dec 9, 2025

/test all

@zirain
Copy link
Member

zirain commented Dec 12, 2025

@krinkinmu can you update your PR base on envoyproxy/envoy#42572?

@krinkinmu
Copy link
Author

@zirain will do that later today

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@krinkinmu
Copy link
Author

/test all

@krinkinmu
Copy link
Author

Interesting... It works locally, but not on CI. I need to dig a bit more.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@krinkinmu
Copy link
Author

/test all

@krinkinmu
Copy link
Author

At least it's building now...

@krinkinmu
Copy link
Author

@zirain it looks like it builds. I'd need to double check what it's actually building and that the version of GLIBC it needs is indeed 2.28, but on the surface it looks ok.

@krinkinmu
Copy link
Author

Aha... I missed something in the configuration apparently - it didn't really use the hermetic sysroot and instead used host GLIBC, which is ok when building insider a container, but not what we actually wanted.

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@krinkinmu
Copy link
Author

/test all

@krinkinmu
Copy link
Author

I tested it locally and it builds using the right sysroot with glibc 2.28

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@krinkinmu
Copy link
Author

/test all

Signed-off-by: Mikhail Krinkin <mkrinkin@microsoft.com>
@krinkinmu
Copy link
Author

/test all

@krinkinmu krinkinmu requested a review from zirain December 15, 2025 17:43
@krinkinmu
Copy link
Author

Regarding the libncurses library, looking at the clang binary in the hermetic llvm toolchain it's conviniently adds RUNPATH:

readelf -d bin/clang-18

Dynamic section at offset 0x9c03f28 contains 36 entries:
  Tag        Type                         Name/Value
 0x000000000000001d (RUNPATH)            Library runpath: [$ORIGIN/../lib] 
...
 0x0000000000000001 (NEEDED)             Shared library: [libtinfo.so.5]
...

That means that if we package llvm toolchain with libtinfo.so.5 in the lib directory in the toolchain itself, we should be able to avoid versioning problems. Dynamic linker should search RUNPATH before basically anything else when loading the binary (except for LD_LIBRARY_PATH).

@zirain
Copy link
Member

zirain commented Dec 17, 2025

@krinkinmu what's status of this PR?

@krinkinmu
Copy link
Author

krinkinmu commented Dec 17, 2025 via email

@zirain
Copy link
Member

zirain commented Dec 17, 2025

The PR works on CI and I confirmed that we use 2.28 glibc with this PR. There is one caveat mentioned in the PR description - I can check for options to address that caveat if we agree on the general direction to use hermetic toolchain.

I think using hermetic toolchain is the right direction.
cc @howardjohn @kyessenov WDYT?

@kyessenov
Copy link
Contributor

Yes, of course, using upstream clang would give you clang 18 and better compilation.

@krinkinmu
Copy link
Author

A small update on the issue with libncurses library.

It looks like this is the only weird dependency that causes this problem and LLVM folks said that they removed this dependency in the later version of clang, so say with clang-19 we wouldn't have this problem. However, fixing the latest 18.1.8 release of clang-18 or doing another release (e.g. 18.1.9) is unlikely (LLVM folks made some changes to the process in LLVM 19, so they are not particularly keen on trying to release 18 again).

So two options that make sense to try IMO:

  1. We can try to switch to clang-19, but that's obviously a divergence from upstream Envoy, so we should try to do that in upstream Envoy.
  2. When building locally and not on CI, just use the non-hermetic toolchain available in the host system.

I think if the option 1 works, it would be the best fix - no divergence, newer compiler, should work the same way on CI and on a local computer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Block merging of a PR because it isn't ready yet. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.