From 7c584e00d9194473995f195e311682982eba8ccc Mon Sep 17 00:00:00 2001 From: Doug Chapman <54039637+dougch@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:14:58 -0700 Subject: [PATCH] ci: use clang to build awslc (#4794) --- codebuild/bin/install_awslc.sh | 23 +++++++++++++++++------ codebuild/bin/install_awslc_fips_2022.sh | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/codebuild/bin/install_awslc.sh b/codebuild/bin/install_awslc.sh index 6babc5b5765..b7a5bae976c 100755 --- a/codebuild/bin/install_awslc.sh +++ b/codebuild/bin/install_awslc.sh @@ -12,7 +12,7 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -set -e +set -eu pushd "$(pwd)" usage() { @@ -28,7 +28,10 @@ BUILD_DIR=$1 INSTALL_DIR=$2 IS_FIPS=$3 -source codebuild/bin/jobs.sh +if [[ ! -f "$(which clang)" ]]; then + echo "Could not find clang" + exit 1 +fi # These tags represents the latest versions that S2N is compatible # with. It prevents our build system from breaking when AWS-LC @@ -46,10 +49,18 @@ echo "Checking out tag=$AWSLC_VERSION" git clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_VERSION" --depth 1 install_awslc() { - echo "Building with shared library=$1" - cmake ./aws-lc -Bbuild -GNinja -DBUILD_SHARED_LIBS=$1 -DCMAKE_BUILD_TYPE=relwithdebinfo -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" -DFIPS="${IS_FIPS}" - ninja -j "${JOBS}" -C build install - ninja -C build clean + echo "Building with shared library=$1" + cmake ./aws-lc \ + -Bbuild \ + -GNinja \ + -DBUILD_SHARED_LIBS=$1 \ + -DCMAKE_BUILD_TYPE=relwithdebinfo \ + -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=$(which clang) \ + -DCMAKE_CXX_COMPILER=$(which clang++) \ + -DFIPS="${IS_FIPS}" + ninja -j "$(nproc)" -C build install + ninja -C build clean } if [ "$IS_FIPS" != "1" ]; then diff --git a/codebuild/bin/install_awslc_fips_2022.sh b/codebuild/bin/install_awslc_fips_2022.sh index 6a20745010d..b593bd24e39 100755 --- a/codebuild/bin/install_awslc_fips_2022.sh +++ b/codebuild/bin/install_awslc_fips_2022.sh @@ -12,7 +12,7 @@ # express or implied. See the License for the specific language governing # permissions and limitations under the License. -set -e +set -eu pushd "$(pwd)" usage() { @@ -27,7 +27,10 @@ fi BUILD_DIR=$1 INSTALL_DIR=$2 -source codebuild/bin/jobs.sh +if [[ ! -f "$(which clang)" ]]; then + echo "Could not find clang" + exit 1 +fi # There are currently no AWSLC release tags for the 2022 FIPS branch. The # following is the latest commit in this branch as of 8/19/24: @@ -42,8 +45,16 @@ git checkout "${AWSLC_VERSION}" build() { shared=$1 - cmake . -Bbuild -GNinja -DBUILD_SHARED_LIBS="${shared}" -DCMAKE_BUILD_TYPE=relwithdebinfo -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" -DFIPS=1 - ninja -j "${JOBS}" -C build install + cmake . \ + -Bbuild \ + -GNinja \ + -DBUILD_SHARED_LIBS="${shared}" \ + -DCMAKE_BUILD_TYPE=relwithdebinfo \ + -DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \ + -DCMAKE_C_COMPILER=$(which clang) \ + -DCMAKE_CXX_COMPILER=$(which clang++) \ + -DFIPS=1 + ninja -j "$(nproc)" -C build install ninja -C build clean }