From 4fc24061196ae8015a47ffeb8f08b4fab7b6d71d Mon Sep 17 00:00:00 2001 From: Michel Heily Date: Tue, 28 Jan 2025 12:09:45 +0200 Subject: [PATCH] aws-lc-fips-sys: Default to clang compiler The underlying aws-lc library is broken when built with FIPS support on GCC-14, which comes by default with many Linux distributions. When this crate is used as a sub-dependency, the users' only workaround is to force all C/C++ code on other crates to also be compiled with clang by setting the CC/CXX environment variables. This change circumvents the issue by setting the CC/CXX environment variables in the crate build script. This is a temporary workaround until the underlying issue is resolved: https://github.com/aws/aws-lc/issues/2010 Signed-off-by: Michel Heily --- aws-lc-fips-sys/builder/cmake_builder.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aws-lc-fips-sys/builder/cmake_builder.rs b/aws-lc-fips-sys/builder/cmake_builder.rs index a9ef4ab42a9..01f555a6fb6 100644 --- a/aws-lc-fips-sys/builder/cmake_builder.rs +++ b/aws-lc-fips-sys/builder/cmake_builder.rs @@ -93,6 +93,16 @@ impl CmakeBuilder { const GOCACHE_DIR_NAME: &'static str = "go-cache"; #[allow(clippy::too_many_lines)] fn prepare_cmake_build(&self) -> cmake::Config { + // Set the compiler to clang if CC/CXX are not set + // TODO: this is a workaround until aws-lc fixes build on GGC-14 + // See https://github.com/aws/aws-lc/issues/201 + if env::var("CC").is_err() { + env::set_var("CC", "clang"); + } + if env::var("CXX").is_err() { + env::set_var("CXX", "clang++"); + } + env::set_var( "GOCACHE", self.out_dir.join(Self::GOCACHE_DIR_NAME).as_os_str(),