-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Envoy with aws_lc on Power (ppc64le) (#38403)
Signed-off-by: James Jenkins <James.Jenkins@ibm.com>
- Loading branch information
Showing
18 changed files
with
483 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
cc_library( | ||
name = "crypto", | ||
srcs = [ | ||
"crypto/libcrypto.a", | ||
], | ||
hdrs = glob(["include/openssl/*.h"]), | ||
defines = ["BORINGSSL_FIPS"], | ||
includes = ["include"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
cc_library( | ||
name = "ssl", | ||
srcs = [ | ||
"ssl/libssl.a", | ||
], | ||
hdrs = glob(["include/openssl/*.h"]), | ||
includes = ["include"], | ||
visibility = ["//visibility:public"], | ||
deps = [":crypto"], | ||
) | ||
|
||
genrule( | ||
name = "build", | ||
srcs = glob(["**"]), | ||
outs = [ | ||
"crypto/libcrypto.a", | ||
"ssl/libssl.a", | ||
], | ||
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"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
export CXXFLAGS='' | ||
export LDFLAGS='' | ||
|
||
# BoringSSL build as described in the Security Policy for BoringCrypto module (2022-05-06): | ||
# https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp4407.pdf | ||
|
||
OS=`uname` | ||
ARCH=`uname -m` | ||
# This works only on Linux-x86_64, Linux-ppc64le, and Linux-aarch64. | ||
|
||
if [[ "$OS" != "Linux" || ("$ARCH" != "x86_64" && "$ARCH" != "aarch64" && "$ARCH" != "ppc64le") ]]; then | ||
echo "ERROR: AWS-LC FIPS is currently supported only on Linux-x86_64, Linux-ppc64le, and Linux-aarch64." | ||
exit 1 | ||
fi | ||
|
||
|
||
# Bazel magic. | ||
# ROOT=$(dirname $(rootpath boringssl/BUILDING.md))/.. | ||
ROOT=./external | ||
pushd "$ROOT" | ||
|
||
# Build tools requirements (from section 12.1 of https://csrc.nist.gov/CSRC/media/projects/cryptographic-module-validation-program/documents/security-policies/140sp4407.pdf): | ||
# - Clang compiler version 12.0.0 (https://releases.llvm.org/download.html) | ||
# - Go programming language version 1.16.5 (https://golang.org/dl/) | ||
# - Ninja build system version 1.10.2 (https://github.com/ninja-build/ninja/releases) | ||
# - Cmake version 3.20.1 (https://cmake.org/download/) | ||
|
||
# Override $PATH for build tools, to avoid picking up anything else. | ||
export PATH="$(dirname `which cmake`):/usr/bin:/bin" | ||
|
||
# Clang | ||
VERSION=14.0.0 | ||
if [[ "$ARCH" == "x86_64" ]]; then | ||
PLATFORM="x86_64-linux-gnu-ubuntu-20.04" | ||
SHA256=61582215dafafb7b576ea30cc136be92c877ba1f1c31ddbbd372d6d65622fef5 | ||
elif [[ "$ARCH" == "ppc64le" ]]; then | ||
PLATFORM="powerpc64le-linux-ubuntu-18.04" | ||
SHA256=2d504c4920885c86b306358846178bc2232dfac83b47c3b1d05861a8162980e6 | ||
else | ||
PLATFORM="aarch64-linux-gnu" | ||
SHA256=1792badcd44066c79148ffeb1746058422cc9d838462be07e3cb19a4b724a1ee | ||
fi | ||
|
||
curl -sLO https://github.com/llvm/llvm-project/releases/download/llvmorg-"$VERSION"/clang+llvm-"$VERSION"-"$PLATFORM".tar.xz | ||
tar xf clang+llvm-"$VERSION"-"$PLATFORM".tar.xz | ||
|
||
export HOME="$PWD" | ||
printf "set(CMAKE_C_COMPILER \"clang\")\nset(CMAKE_CXX_COMPILER \"clang++\")\n" > ${HOME}/toolchain | ||
export PATH="$PWD/clang+llvm-$VERSION-$PLATFORM/bin:$PATH" | ||
|
||
if [[ `clang --version | head -1 | awk '{print $3}'` != "$VERSION" ]]; then | ||
echo "ERROR: Clang version doesn't match. Expected: ${VERSION}, Got: $(clang --version)" | ||
exit 1 | ||
fi | ||
|
||
# Go | ||
VERSION=1.18.1 | ||
if [[ "$ARCH" == "x86_64" ]]; then | ||
PLATFORM="linux-amd64" | ||
SHA256=b3b815f47ababac13810fc6021eb73d65478e0b2db4b09d348eefad9581a2334 | ||
elif [[ "$ARCH" == "ppc64le" ]]; then | ||
PLATFORM="linux-ppc64le" | ||
SHA256=33db623d1eecf362fe365107c12efc90eff0b9609e0b3345e258388019cb552a | ||
else | ||
PLATFORM="linux-arm64" | ||
SHA256=56a91851c97fb4697077abbca38860f735c32b38993ff79b088dac46e4735633 | ||
fi | ||
|
||
curl -sLO https://dl.google.com/go/go"$VERSION"."$PLATFORM".tar.gz \ | ||
&& echo "$SHA256" go"$VERSION"."$PLATFORM".tar.gz | sha256sum --check | ||
tar xf go"$VERSION"."$PLATFORM".tar.gz | ||
|
||
export GOPATH="$PWD/gopath" | ||
export GOROOT="$PWD/go" | ||
export PATH="$GOPATH/bin:$GOROOT/bin:$PATH" | ||
|
||
if [[ `go version | awk '{print $3}'` != "go$VERSION" ]]; then | ||
echo "ERROR: Go version doesn't match." | ||
exit 1 | ||
fi | ||
|
||
# Ninja | ||
VERSION=1.10.2 | ||
SHA256=ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed | ||
curl -sLO https://github.com/ninja-build/ninja/archive/refs/tags/v"$VERSION".tar.gz \ | ||
&& echo "$SHA256" v"$VERSION".tar.gz | sha256sum --check | ||
tar -xvf v"$VERSION".tar.gz | ||
cd ninja-"$VERSION" | ||
python3 ./configure.py --bootstrap | ||
|
||
export PATH="$PWD:$PATH" | ||
|
||
if [[ `ninja --version` != "$VERSION" ]]; then | ||
echo "ERROR: Ninja version doesn't match." | ||
exit 1 | ||
fi | ||
cd .. | ||
|
||
# CMake | ||
VERSION=3.22.1 | ||
if [[ "$ARCH" != "ppc64le" ]]; then | ||
if [[ "$ARCH" == "x86_64" ]]; then | ||
PLATFORM="linux-x86_64" | ||
SHA256=73565c72355c6652e9db149249af36bcab44d9d478c5546fd926e69ad6b43640 | ||
else | ||
PLATFORM="linux-aarch64" | ||
SHA256=601443375aa1a48a1a076bda7e3cca73af88400463e166fffc3e1da3ce03540b | ||
fi | ||
|
||
curl -sLO https://github.com/Kitware/CMake/releases/download/v"$VERSION"/cmake-"$VERSION"-"$PLATFORM".tar.gz \ | ||
&& echo "$SHA256" cmake-"$VERSION"-"$PLATFORM".tar.gz | sha256sum --check | ||
tar xf cmake-"$VERSION"-"$PLATFORM".tar.gz | ||
export PATH="$PWD/cmake-$VERSION-$PLATFORM/bin:$PATH" | ||
else | ||
PLATFORM="linux-ppc64le" | ||
echo "Building cmake for ppc64le" | ||
|
||
curl -sL -o cmake-$VERSION-$PLATFORM.tar.gz https://github.com/Kitware/CMake/releases/download/v"$VERSION"/cmake-"$VERSION".tar.gz | ||
tar xf cmake-"$VERSION"-"$PLATFORM".tar.gz | ||
|
||
cd cmake-"$VERSION" | ||
./bootstrap && make | ||
export PATH="$PWD/bin:$PATH" | ||
cd .. | ||
fi | ||
|
||
if [[ `cmake --version | head -n1` != "cmake version $VERSION" ]]; then | ||
echo "PATH: $PATH" | ||
echo "PLATFORM: $PLATFORM" | ||
echo "ERROR: CMake version doesn't match. Expected: ${VERSION}, Got: $(cmake --version | head -n1)" | ||
exit 1 | ||
fi | ||
|
||
echo "Cmake installed successfully" | ||
echo "PWD: $PWD" | ||
|
||
# Clean after previous build. | ||
rm -rf aws_lc/build | ||
|
||
# Build BoringSSL. | ||
cd aws_lc | ||
|
||
# Setting -fPIC only affects the compilation of the non-module code in libcrypto.a, | ||
# because the FIPS module itself is already built with -fPIC. | ||
mkdir build && cd build && cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=${HOME}/toolchain -DFIPS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" .. | ||
ninja | ||
export GTEST_FILTER="-SSLTest.HostMatching" | ||
#ninja run_tests | ||
./crypto/crypto_test | ||
|
||
echo "created build directory and built aws_lc with ninja" | ||
|
||
# Verify correctness of the FIPS build. | ||
if [[ `tool/bssl isfips` != "1" ]]; then | ||
echo "ERROR: BoringSSL tool didn't report FIPS build." | ||
exit 1 | ||
fi | ||
|
||
# Move compiled libraries to the expected destinations. | ||
popd | ||
mv $ROOT/aws_lc/build/crypto/libcrypto.a $1 | ||
mv $ROOT/aws_lc/build/ssl/libssl.a $2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.