Skip to content

Aws lc fips build fixes#43953

Open
kpramesh2212 wants to merge 3 commits intoenvoyproxy:mainfrom
kpramesh2212:aws-lc-fips-build-fixes
Open

Aws lc fips build fixes#43953
kpramesh2212 wants to merge 3 commits intoenvoyproxy:mainfrom
kpramesh2212:aws-lc-fips-build-fixes

Conversation

@kpramesh2212
Copy link
Copy Markdown

Use of generative AI

I used generative AI to help fix the AWS-LC FIPS build. I am not a C++ developer, so this PR should be reviewed carefully before merging. I was able to compile Envoy successfully with the changes below, but I may not have fully understood all implications. Please review thoroughly.


Additional Description

This PR fixes several build failures encountered when building Envoy with --config=aws-lc-fips, particularly on aarch64 and in container/CI environments. These fixes address the build infrastructure issues that prevent the AWS-LC FIPS build from completing.

Note for native aarch64 builds: The build also requires BAZEL_USE_HOST_SYSROOT=True (set as an environment variable before building). This is an existing Envoy option documented in bazel/repo.bzl and is not changed in this PR.


Risk Level

Low – changes are limited to build configuration and external dependency setup, not runtime code.


Testing

Production build (successful):

bazel build -c opt //source/exe:envoy-static \
  --config=aws-lc-fips \
  --config=sizeopt \
  --define=no_debug_info=1 \
  --copt=-ffunction-sections \
  --copt=-fdata-sections \
  --linkopt=-Wl,--gc-sections \
  --linkopt=-Wl,-s \
  --strip=always \
  --fission=no \
  --jobs=63

Debug build (successful):

bazel build //source/exe:envoy-static --config=aws-lc-fips --spawn_strategy=standalone

Environment: Native aarch64 Linux build with BAZEL_USE_HOST_SYSROOT=True exported.


Docs Changes

None. Consider documenting BAZEL_USE_HOST_SYSROOT=True for native aarch64 AWS-LC FIPS builds in a follow-up.


Release Notes

build: Fix AWS-LC FIPS build for aarch64 and container environments (Go deps, tar extraction, sandbox)

Platform Specific Features

  • Linux aarch64 (native build)
  • Linux x86_64 (expected to work; not tested)

Fixes #43904


BUILD machine

NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.3.20240312"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"

EXPLANATION OF CHANGES (for review comments or PR description)

  1. Go dependency resolution (bazel/dependency_imports.bzl)

    • Problem: com_github_spf13_afero and com_github_lyft_protoc_gen_star_v2
      import golang.org/x/text and golang.org/x/tools, but Gazelle didn't resolve
      them, causing "missing strict dependencies" errors.
    • Change: Added build_directives to tell Gazelle how to resolve these
      imports to @org_golang_x_text and @org_golang_x_tools. Also added
      org_golang_x_tools go_repository if it wasn't present.
  2. Tar ownership (bazel/external/aws_lc.genrule_cmd)

    • Problem: The AWS-LC FIPS build downloads and extracts Clang, Go, Ninja,
      and CMake tarballs. These archives contain ownership metadata (uid 11827,
      gid 9000). In containers or sandboxes, those uid/gid don't exist, so tar
      fails with "Cannot change ownership: Invalid argument".
    • Change: Added --no-same-owner to all 5 tar commands so extracted files
      use the current user's uid/gid. Safe for build toolchains and works in
      restricted environments.
  3. AWS-LC genrule sandbox (bazel/external/aws_lc.BUILD)

    • Problem: The AWS-LC genrule runs CMake, which writes files during
      configure. Bazel's sandbox makes the execroot read-only for some actions,
      causing "Read-only file system" when CMake runs configure_file.
    • Change: Added tags = ["no-sandbox"] to the AWS-LC genrule so it runs
      outside the sandbox. Only this genrule is affected; other build actions
      remain sandboxed.
  4. Host sysroot (environment variable - not a code change)

    • Problem: On native aarch64, the hermetic sysroot may not have the
      expected libc layout, causing linker errors like "cannot find
      /lib/aarch64-linux-gnu/libc.so.6".
    • Change: Use BAZEL_USE_HOST_SYSROOT=True (existing Envoy option) to use
      the host's libc. Document this for native aarch64 builds.

SUMMARY TABLE

File Change Purpose
bazel/dependency_imports.bzl build_directives Fix Go "missing strict dependencies"
bazel/external/aws_lc.genrule_cmd --no-same-owner on tar Fix tar ownership errors in containers
bazel/external/aws_lc.BUILD tags = ["no-sandbox"] Fix CMake "Read-only file system"
Environment BAZEL_USE_HOST_SYSROOT=True Use host libc on native aarch64 (document)

================================================================================

@repokitteh-read-only
Copy link
Copy Markdown

Hi @kpramesh2212, welcome and thank you for your contribution.

We will try to review your Pull Request as quickly as possible.

In the meantime, please take a look at the contribution guidelines if you have not done so already.

🐱

Caused by: #43953 was opened by kpramesh2212.

see: more, trace.

@repokitteh-read-only repokitteh-read-only bot added the deps Approval required for changes to Envoy's external dependencies label Mar 13, 2026
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @RyanTheOptimist

🐱

Caused by: #43953 was opened by kpramesh2212.

see: more, trace.

@paul-r-gall
Copy link
Copy Markdown
Contributor

@kpramesh2212 please apply DCO and merge main.

See

## Fixing DCO
for intstructions on DCO.

Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

thanks for working on this @kpramesh2212

],
cmd = "$(location {}) $(location crypto/libcrypto.a) $(location ssl/libssl.a)".format("@envoy//bazel/external:aws_lc.genrule_cmd"),
tools = ["@envoy//bazel/external:aws_lc.genrule_cmd"],
tags = ["no-sandbox"],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think this is wrong/unnecessary

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@phlax I am working on this will update the PR once I fix it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@phlax I have removed that tag and changed the AWS_LC cmd to get it compiling

Copy link
Copy Markdown
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

/wait

continue;
}

#ifdef OPENSSL_IS_BORINGSSL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do not think you need this ifdef, since compiler will have no issue convert non const type to const. But not the other way around. I would just ad a comment that aws+lc needs non const input to X509_NAME_dup

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@yanavlasov i have removed that block

switch (policy.value()) {
using ProtoPolicy = envoy::extensions::transport_sockets::tls::v3::TlsParameters;
case ProtoPolicy::FIPS_202205:
#ifdef OPENSSL_IS_BORINGSSL
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this change also fix a build error, or is it a runtime error? If it is a runtime error, can you move it into a separate PR to keep unrelated changes separate, please?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@yanavlasov Yes without that if block the build is failing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The preferred way to fix these types of build errors is to define something in aws_lc_compat.h for whatever is missing/different in aws-lc.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@ggreenway I have fixed this

Ramesh KP added 2 commits March 19, 2026 12:59
- Upgrade AWS-LC from 1.66.2 to 1.70.0
- Replace runtime tool downloads with Bazel external repos for Clang,
  Go, Ninja, and CMake (per-arch: x86_64, aarch64, ppc64le)
- Fix sandbox: build in writable temp dir with GOCACHE instead of execroot
- Add X509_NAME_dup const_cast for AWS-LC/OpenSSL API compatibility
- Reject FIPS_202205 policy when not using BoringSSL
- Add Gazelle resolve directives for golang.org/x/text and x/tools

Signed-off-by: Ramesh KP <ramesh_kp.kurichi_ponnuswamy@genesys.com>
name = "cmake_bin",
srcs = [
"@aws_lc_cmake_linux_ppc64le//:all",
"@aws_lc_cmake_linux_ppc64le//:bootstrap",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should be agnostic to arch - aws can be used eg on arm also if a fips build is required

also wondering if all this duplication is necessary

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if this works for builds other than ppce, i think this repo is just misnamed - its not ppce-specific

iiuc - it should probably be called fips_cmake_src or similar to be consistent with how we have existing fips repos

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@phlax I have addressed this comment

@kpramesh2212
Copy link
Copy Markdown
Author

I have build envoy in both x86 and arm machines with AWS_LC and build is completing fine

@RyanTheOptimist
Copy link
Copy Markdown
Contributor

Assigning to @phlax who understands this better and is already reviewing :)

Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

/wait


bssl::UniquePtr<X509_NAME> name_dup(X509_NAME_dup(name));
// AWS-LC/OpenSSL require non-const input to X509_NAME_dup; BoringSSL accepts const.
bssl::UniquePtr<X509_NAME> name_dup(X509_NAME_dup(const_cast<X509_NAME*>(name)));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't const-cast; just remove the the const on line 554

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed this

switch (policy.value()) {
using ProtoPolicy = envoy::extensions::transport_sockets::tls::v3::TlsParameters;
case ProtoPolicy::FIPS_202205:
#ifdef OPENSSL_IS_BORINGSSL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The preferred way to fix these types of build errors is to define something in aws_lc_compat.h for whatever is missing/different in aws-lc.

continue;
}

#ifdef OPENSSL_IS_BORINGSSL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

remove const_cast same as above

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

fixed all of these

@kpramesh2212
Copy link
Copy Markdown
Author

@phlax @ggreenway I have fixed all the review comments could you please take a look into this PR please

@kpramesh2212
Copy link
Copy Markdown
Author

@phlax @ggreenway @yanavlasov

Hi! Just following up on this PR. I've incorporated all the requested changes from the previous review.

Whenever you get a chance, I'd appreciate a re-review. Thanks a lot for your help!

Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

the main issue for us reviewing this is that its not supported, and therefore not tested

i think we can probably accomodate this but you will need to reduce the duplication and deps to do so

wrt duplication - also wondering if this cant reuse more existing code - but lets address above first and then consider that possibility

./bootstrap --parallel=$$(nproc)
make -j$$(nproc)
cp bin/cmake $@
""",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
""",
""",
target_compatible_with = select({
"@platforms//cpu:x86_64": ["@platforms//:incompatible"],
"@platforms//cpu:aarch64": ["@platforms//:incompatible"],
"//conditions:default": [],
}),

as these to platforms have already a prebuilt - i think this should be marked as incompatible with them

] + select({
"@platforms//cpu:x86_64": [
"@aws_lc_clang_x86_64//:bin/clang",
"@aws_lc_clang_x86_64//:bin/clang++",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is not correct - for x86 it shoudl use the toolchains_llvm platform - same for aarch64 below

OS=`uname`
ARCH=`uname -m`
OS=$(uname)
ARCH=$(uname -m)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this is definitely an improvement - i think this file still doesnt pass shellcheck tho (annoyingly its not currently tested by ci)

could you run

$ shellcheck -x bazel/external/aws_lc.genrule_cmd

and at least ensure that no new issues are added

echo "PATH: $PATH"
echo "PLATFORM: $PLATFORM"
echo "ERROR: CMake version doesn't match. Expected: ${VERSION}, Got: $(cmake --version | head -n1)"
VERSION=4.2.3
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

fwiw we have removed these version checks from the boringssl fips build as we have adopted a slightly different policy for managing fips (see bazel/SSL.md)

build_file_content = GO_BUILD_CONTENT,
)
external_http_archive(
name = "aws_lc_go_aarch64",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are these go binaries that aws_lc produces - if not they dont want the aws_lc prefix - also wondering why you need to add go binaries for x86/arm when we already have them

urls = ["https://dl.google.com/go/go{version}.linux-arm64.tar.gz"],
),

aws_lc_clang_x86_64 = dict(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as commented above we dont want these deps - its duplicating the toolchain

urls = ["https://github.com/llvm/llvm-project/releases/download/llvmorg-{version}/clang+llvm-{version}-powerpc64le-linux-ubuntu-18.04.tar.xz"],
),

aws_lc_go_x86_64 = dict(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same with these deps - they are unnecessary

strip_prefix = "go",
urls = ["https://dl.google.com/go/go{version}.linux-arm64.tar.gz"],
),
aws_lc_go_ppc64le = dict(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and these next two also should nto be prefixed with aws_lc

@kpramesh2212 kpramesh2212 force-pushed the aws-lc-fips-build-fixes branch from 04922dd to dfd6fc3 Compare March 26, 2026 17:03
@kpramesh2212 kpramesh2212 temporarily deployed to external-contributors March 26, 2026 17:03 — with GitHub Actions Inactive
@kpramesh2212
Copy link
Copy Markdown
Author

@phlax I have fixed all the comments

@kpramesh2212
Copy link
Copy Markdown
Author

@phlax @ggreenway @yanavlasov I have fixed all the comments could you please take a look into this PR once you get a chance

@Medik-GH
Copy link
Copy Markdown

Medik-GH commented Apr 1, 2026

Thanks @kpramesh2212 for these changes! We have been wanting this functionality on our end for a while now. Is there anything I can do to help move this PR along? It seems like FIPS-140-2 is not going to be compliant in September this year so this change is urgently needed.

@phlax @ggreenway @yanavlasov

phlax
phlax previously approved these changes Apr 1, 2026
Copy link
Copy Markdown
Member

@phlax phlax left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for iterating @kpramesh2212

will also need signoff from @ggreenway

@repokitteh-read-only repokitteh-read-only bot removed the deps Approval required for changes to Envoy's external dependencies label Apr 1, 2026
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

/wait

ggreenway
ggreenway previously approved these changes Apr 1, 2026
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Source changes LGTM

Signed-off-by: Ramesh KP <ramesh_kp.kurichi_ponnuswamy@genesys.com>
@kpramesh2212 kpramesh2212 dismissed stale reviews from ggreenway and phlax via 7fbfa4e April 2, 2026 09:01
@kpramesh2212 kpramesh2212 force-pushed the aws-lc-fips-build-fixes branch from dfd6fc3 to 7fbfa4e Compare April 2, 2026 09:01
@kpramesh2212 kpramesh2212 requested a deployment to external-contributors April 2, 2026 09:01 — with GitHub Actions Waiting
@repokitteh-read-only repokitteh-read-only bot added deps Approval required for changes to Envoy's external dependencies and removed waiting labels Apr 2, 2026
@kpramesh2212
Copy link
Copy Markdown
Author

@phlax @ggreenway

Sorry the CI was failing I had to fix it could you please take on look at this change please https://github.com/envoyproxy/envoy/compare/dfd6fc3288ec93e2ef0dd31465c26dd991f700d0..7fbfa4e4a1d63d96d718033cbc1f29422d244d80

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

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AWS-LC FIPS build fails on main branch due to X509_NAME_dup const mismatch

7 participants