Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve gcc-4.8 support/testing #1665

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/docker_images/gcc-4.8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

FROM gcc:4.8

VOLUME ["/awslc"]

COPY awslc_build.sh /
COPY entry.sh /

WORKDIR /

RUN curl -LOk "https://github.com/Kitware/CMake/releases/download/v3.6.3/cmake-3.6.3-Linux-x86_64.tar.gz"
RUN sha256sum cmake-3.6.3-Linux-x86_64.tar.gz | grep -q "9d915d505c07d84b610e1be6242c7cad68b4b7a4090ce85ecf9cec5effa47c43"
RUN tar -C /usr/local -xzf cmake-3.6.3-Linux-x86_64.tar.gz
RUN rm cmake-3.6.3-Linux-x86_64.tar.gz

ENV PATH="${PATH}:/usr/local/cmake-3.6.3-Linux-x86_64/bin"

ENTRYPOINT ["/entry.sh"]
18 changes: 18 additions & 0 deletions .github/docker_images/gcc-4.8/awslc_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex -o pipefail

echo "Building with GCC Version: $(gcc --version)"

BUILD_DIR=$(mktemp -d)
SRC_DIR="${SRC_DIR:-/awslc}"

pushd "${BUILD_DIR}"

cmake "${SRC_DIR}" "-DDISABLE_GO=ON" "-DDISABLE_PERL=ON" "-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX=1"
justsmth marked this conversation as resolved.
Show resolved Hide resolved
make -j 4 ssl

popd # ${BUILD_DIR}
8 changes: 8 additions & 0 deletions .github/docker_images/gcc-4.8/entry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

set -ex -o pipefail

/awslc_build.sh "${argv[@]}"
14 changes: 14 additions & 0 deletions .github/workflows/actions-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,20 @@ jobs:
env
tests/ci/run_openbsd_tests.sh ${{ matrix.args }}
EOF
gcc-4_8:
needs: [sanity-test-run]
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v4
- name: Build Docker Image
working-directory: .github/docker_images/gcc-4.8
run: |
docker build -t "gcc-4.8" .
- name: Build using pre-generated assembly
run: |
docker run -v "${{ github.workspace }}:/awslc" "gcc-4.8"

# TODO: Investigate sudden hanging tests and failures in GHA runners (P114059413)
# MSVC-SDE-32-bit:
Expand Down
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -289,23 +289,26 @@ endmacro()
# can be set to handle such cases.
option(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX "Exclude AVX code from the build" OFF)

# Some assemblers know about AVX but not AVX512 instructions, e.g. gcc 4.8.2.
# Some assemblers know about AVX but not ADX, AVX2 or AVX512 instructions, e.g. gcc 4.8.2.
# This flag can be set to handle such cases.
# Note that the flag's name has "512AVX" instead of "AVX512" so that it doesn't
# include the entire flag -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX and match it
# in the Perl files checks.
# Note:
# * Although this flag name implies an effect on AVX512 instructions, it's also
# intended to avoid generating ADX and AVX2 instructions.
# * This flag name has "512AVX" instead of "AVX512" so that it doesn't
# include the entire flag -DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX and match
# to it in the Perl files checks.
option(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX "Exclude AVX512 code from the build" OFF)

if(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX)
add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX)
add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX)
set(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX ON)
message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX selected, removing AVX optimisations")
message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX selected, removing all AVX optimisations")
endif()

if(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX)
add_definitions(-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX)
message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX selected, removing AVX512 optimisations")
message(STATUS "MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX selected, removing ADX, AVX2 and AVX512 optimisations")
endif()

if (GCC)
Expand Down
2 changes: 1 addition & 1 deletion crypto/curve25519/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {

// If (1) x86_64 or aarch64, (2) linux or apple, and (3) OPENSSL_NO_ASM is not
// set, s2n-bignum path is capable.
#if ((defined(OPENSSL_X86_64) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX)) || \
#if ((defined(OPENSSL_X86_64) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX)) || \
defined(OPENSSL_AARCH64)) && \
(defined(OPENSSL_LINUX) || defined(OPENSSL_APPLE) || \
defined(OPENSSL_OPENBSD)) && \
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ endif()

# s2n-bignum files can be compiled on Unix platforms only (except Apple),
# and on x86_64 and aarch64 systems only.
if((((ARCH STREQUAL "x86_64") AND NOT MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) OR
if((((ARCH STREQUAL "x86_64") AND NOT MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) OR
ARCH STREQUAL "aarch64") AND UNIX)

# Set the source directory for s2n-bignum assembly files
Expand Down
6 changes: 5 additions & 1 deletion crypto/fipsmodule/aes/asm/aesni-xts-avx512.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,10 @@

my $rndsuffix = &random_string();

$code .= ".text\n";
$code .= <<___;
justsmth marked this conversation as resolved.
Show resolved Hide resolved
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.text
___

{
$code.=<<___;
Expand Down Expand Up @@ -3108,6 +3111,7 @@
.byte 0xff, 0xff, 0xff, 0xff, 0xff

.text
#endif
___
} else {
$code .= <<___;
Expand Down
16 changes: 15 additions & 1 deletion crypto/fipsmodule/bn/asm/x86_64-mont.pl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
# versions, but BoringSSL is intended to be used with pre-generated perlasm
# output, so this isn't useful anyway.
$addx = 1;
for (@ARGV) { $addx = 0 if (/-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX/); }
for (@ARGV) { $addx = 0 if (/-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX/); }

# int bn_mul_mont(
$rp="%rdi"; # BN_ULONG *rp,
Expand Down Expand Up @@ -105,8 +105,10 @@
jb .Lmul_enter
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
justsmth marked this conversation as resolved.
Show resolved Hide resolved
leaq OPENSSL_ia32cap_P(%rip),%r11
mov 8(%r11),%r11d
#endif
___
$code.=<<___;
cmp $ap,$bp
Expand Down Expand Up @@ -367,9 +369,11 @@
.Lmul4x_enter:
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
and \$0x80100,%r11d
cmp \$0x80100,%r11d
je .Lmulx4x_enter
#endif
___
$code.=<<___;
push %rbx
Expand Down Expand Up @@ -823,7 +827,9 @@
my ($a0,$a1,$ai)=("%r14","%r15","%rbx");

$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.extern bn_sqrx8x_internal # see x86_64-mont5 module
#endif
___
$code.=<<___;
.extern bn_sqr8x_internal # see x86_64-mont5 module
Expand Down Expand Up @@ -911,6 +917,7 @@
movq %r10, %xmm3 # -$num
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
leaq OPENSSL_ia32cap_P(%rip),%rax
mov 8(%rax),%eax
and \$0x80100,%eax
Expand All @@ -931,6 +938,7 @@

.align 32
.Lsqr8x_nox:
#endif
___
$code.=<<___;
call bn_sqr8x_internal # see x86_64-mont5 module
Expand Down Expand Up @@ -1027,6 +1035,7 @@
my $bp="%rdx"; # original value

$code.=<<___;
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.type bn_mulx4x_mont,\@function,6
.align 32
bn_mulx4x_mont:
Expand Down Expand Up @@ -1388,6 +1397,7 @@
ret
.cfi_endproc
.size bn_mulx4x_mont,.-bn_mulx4x_mont
#endif
___
}}}
$code.=<<___;
Expand Down Expand Up @@ -1551,9 +1561,11 @@
.rva .LSEH_info_bn_sqr8x_mont
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.rva .LSEH_begin_bn_mulx4x_mont
.rva .LSEH_end_bn_mulx4x_mont
.rva .LSEH_info_bn_mulx4x_mont
#endif
___
$code.=<<___;
.section .xdata
Expand All @@ -1573,11 +1585,13 @@
.align 8
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.LSEH_info_bn_mulx4x_mont:
.byte 9,0,0,0
.rva sqr_handler
.rva .Lmulx4x_prologue,.Lmulx4x_body,.Lmulx4x_epilogue # HandlerData[]
.align 8
#endif
___
}

Expand Down
14 changes: 13 additions & 1 deletion crypto/fipsmodule/bn/asm/x86_64-mont5.pl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
# versions, but BoringSSL is intended to be used with pre-generated perlasm
# output, so this isn't useful anyway.
$addx = 1;
for (@ARGV) { $addx = 0 if (/-DMY_ASSEMBLER_IS_TOO_OLD_FOR_AVX/); }
for (@ARGV) { $addx = 0 if (/-DMY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX/); }

# int bn_mul_mont_gather5(
$rp="%rdi"; # BN_ULONG *rp,
Expand Down Expand Up @@ -90,8 +90,10 @@
jnz .Lmul_enter
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
leaq OPENSSL_ia32cap_P(%rip),%r11
mov 8(%r11),%r11d
#endif
___
$code.=<<___;
jmp .Lmul4x_enter
Expand Down Expand Up @@ -473,9 +475,11 @@
.Lmul4x_enter:
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
and \$0x80108,%r11d
cmp \$0x80108,%r11d # check for AD*X+BMI2+BMI1
je .Lmulx4x_enter
#endif
___
$code.=<<___;
push %rbx
Expand Down Expand Up @@ -1106,11 +1110,13 @@
.cfi_def_cfa_register %rax
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
leaq OPENSSL_ia32cap_P(%rip),%r11
mov 8(%r11),%r11d
and \$0x80108,%r11d
cmp \$0x80108,%r11d # check for AD*X+BMI2+BMI1
je .Lpowerx5_enter
#endif
___
$code.=<<___;
push %rbx
Expand Down Expand Up @@ -2109,6 +2115,7 @@
my $bp="%rdx"; # restore original value

$code.=<<___;
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.type bn_mulx4x_mont_gather5,\@function,6
.align 32
bn_mulx4x_mont_gather5:
Expand Down Expand Up @@ -3436,6 +3443,7 @@
ret
.cfi_endproc
.size __bn_postx4x_internal,.-__bn_postx4x_internal
#endif
___
}
}}}
Expand Down Expand Up @@ -3716,13 +3724,15 @@
.rva .LSEH_info_bn_power5
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.rva .LSEH_begin_bn_mulx4x_mont_gather5
.rva .LSEH_end_bn_mulx4x_mont_gather5
.rva .LSEH_info_bn_mulx4x_mont_gather5

.rva .LSEH_begin_bn_powerx5
.rva .LSEH_end_bn_powerx5
.rva .LSEH_info_bn_powerx5
#endif
___
$code.=<<___;
.rva .LSEH_begin_bn_gather5
Expand All @@ -3747,6 +3757,7 @@
.rva .Lpower5_prologue,.Lpower5_body,.Lpower5_epilogue # HandlerData[]
___
$code.=<<___ if ($addx);
#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX
.align 8
.LSEH_info_bn_mulx4x_mont_gather5:
.byte 9,0,0,0
Expand All @@ -3757,6 +3768,7 @@
.byte 9,0,0,0
.rva mul_handler
.rva .Lpowerx5_prologue,.Lpowerx5_body,.Lpowerx5_epilogue # HandlerData[]
#endif
___
$code.=<<___;
.align 8
Expand Down
Loading
Loading