aws / aws-lc

AWS-LC is a general-purpose cryptographic library maintained by the AWS Cryptography team for AWS and their customers. It іs based on code from the Google BoringSSL project and the OpenSSL project.
Other
372 stars 114 forks source link

Fails to compile with clang 17 #1444

Closed theoparis closed 7 months ago

theoparis commented 8 months ago

Problem:

AWS-LC fails to compile with clang 17 due to two issues. One issue is an alignas error, and the other is a warning that is an issue due to Werror.

According to https://lists.llvm.org/pipermail/llvm-bugs/2018-July/066920.html it seems like gcc doesn't detect the alignas issue as a problem.

Relevant details

AWS-LC commit: 7f76c042e978fc975d59ffac435a57b3a1055c71

Build log:

/home/theo/Documents/theos/build/_deps/aws-lc-src/crypto/bio/errno.c:89:25: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand]
   89 |       errno == EALREADY ||
/home/theo/Documents/theos/build/_deps/aws-lc-src/crypto/poly1305/poly1305_vec.c:32:14: error: 'alignas' attribute cannot be applied to types
   32 | static const alignas(16) uint32_t poly1305_x64_sse2_message_mask[4] = {
      |              ^
/home/theo/Documents/theos/build/_deps/aws-lc-src/crypto/poly1305/poly1305_vec.c:34:14: error: 'alignas' attribute cannot be applied to types
   34 | static const alignas(16) uint32_t poly1305_x64_sse2_5[4] = {5, 0, 5, 0};
      |              ^
/home/theo/Documents/theos/build/_deps/aws-lc-src/crypto/poly1305/poly1305_vec.c:35:14: error: 'alignas' attribute cannot be applied to types
   35 | static const alignas(16) uint32_t poly1305_x64_sse2_1shl128[4] = {
/home/theo/Documents/theos/build/_deps/aws-lc-src/crypto/fipsmodule/ec/p256-nistz-table.h:25:14: error: 'alignas' attribute cannot be applied to types
   25 | static const alignas(4096) PRECOMP256_ROW ecp_nistz256_precomputed[37] = {
      |              ^

This is offtopic, but since this is based on openssl code does that mean it has to be relinked with every program or can it be used a drop in replacement for OpenSSL in existing prebuilt programs (assuming they don't rely on 3.0+ APIs)?

theoparis commented 8 months ago

This might be a c23 standard issue actually. I set cmake_c_standard to fix libarchive but it seems to break aws-lc.

samuel40791765 commented 7 months ago

Hi, thanks for reaching out!

I tried building off the tip of main with clang 17.0.6 on an x86_64 instance and everything seems to fine on my end. Both the debug and release build compile fine. Could you share the specific clang version were you using?

Output:

+ cmake ../aws-lc -GNinja -B/home/ubuntu/workplace/aws-lc/test_build_dir -DCMAKE_INSTALL_PREFIX=/home/ubuntu/workplace/aws-lc/test_build_dir/
-- The C compiler identification is Clang 17.0.6
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is Clang 17.0.6
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Perl: /usr/bin/perl (found version "5.30.0") 
-- Checking for module 'libunwind-generic'
--   No package 'libunwind-generic' found
libunwind not found. Disabling unwind tests.
-- stdalign_check.c probe is positive, enabling AWS_LC_STDALIGN_AVAILABLE
-- builtin_swap_check.c probe is positive, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/cc
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Generating test executable mem_test.
-- Generating test executable mem_set_test.
-- Generating test executable dynamic_loading_test.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/workplace/aws-lc/test_build_dir
+ ninja -j8 -C test_build_dir run_tests
ninja: Entering directory `test_build_dir'
[536/540] cd /home/ubuntu/workplace/aws-lc && cd ssl/test/runner && /usr/local/go/bin/go t...r-test-file /home/ubuntu/workplace/aws-lc/ssl/test/runner/ssl_transfer/test_case_names.tx
0/0/992/1000/9280
0/0/992/1000/9280
0/0/993/1000/9280
0/0/1993/2000/9280
0/0/2992/3000/9280
0/0/2992/3000/9280
0/0/2992/3000/9280
0/0/2992/3000/9280
0/0/2993/3000/9280
0/0/3992/4000/9280
0/0/3993/4000/9280
0/0/4992/5000/9280
0/0/4992/5000/9280
0/0/4992/5000/9280
0/0/4993/5000/9280
0/0/5992/6000/9280
0/0/5992/6000/9280
0/0/5992/6000/9280
0/0/5993/6000/9280
0/0/6992/7000/9280
0/0/6992/7000/9280
0/0/6993/7000/9280
0/0/7992/8000/9280
0/0/7992/8000/9280
0/0/7993/8000/9280
0/0/8992/9000/9280
0/0/8993/9000/9280
0/0/9280/9280/9280

PASS
ok      boringssl.googlesource.com/boringssl/ssl/test/runner    21.535s
[539/540] cd /home/ubuntu/workplace/aws-lc && /usr/local/go/bin/go test ./ssl/test/runner/...al/go/bin/go run util/all_tests.go -build-dir /home/ubuntu/workplace/aws-lc/test_build_di
ok      boringssl.googlesource.com/boringssl/ssl/test/runner/hpke   0.082s
ok      boringssl.googlesource.com/boringssl/util/ar    0.004s
crypto/crypto_test [shard 6/8]
crypto/crypto_test [shard 5/8]
crypto/crypto_test [shard 7/8]
crypto/crypto_test --gtest_filter=Crypto.OnDemandIntegrityTest (custom environment)
crypto/crypto_test [shard 4/8]
crypto/crypto_test [shard 8/8]
crypto/crypto_test --gtest_also_run_disabled_tests --gtest_filter=RSATest.DISABLED_BlindingCacheConcurrency
crypto/crypto_test [shard 2/8]
crypto/crypto_test [shard 1/8]
crypto/urandom_test
crypto/crypto_test --fork_unsafe_buffering --gtest_filter=RandTest.*:-RandTest.Fork
crypto/crypto_test --gtest_filter=RandTest.* (custom environment)
crypto/crypto_test --gtest_filter=ForkDetect.* (custom environment)
crypto/urandom_test (custom environment)
ssl/ssl_test [shard 1/8]
ssl/ssl_test [shard 2/8]
crypto/urandom_test (custom environment)
ssl/ssl_test [shard 3/8]
ssl/ssl_test [shard 4/8]
ssl/ssl_test [shard 6/8]
ssl/ssl_test [shard 5/8]
ssl/ssl_test [shard 7/8]
crypto/mem_test
crypto/mem_set_test
crypto/dynamic_loading_test
ssl/ssl_test [shard 8/8]
ssl/integration_test
crypto/crypto_test [shard 3/8]
crypto/urandom_test (custom environment)
crypto/urandom_test (custom environment)
crypto/crypto_test --gtest_also_run_disabled_tests --gtest_filter=BNTest.DISABLED_WycheproofPrimality
crypto/urandom_test (custom environment)

All tests passed!

As for your question, AWS-LC is not ABI stable or ABI compatible with OpenSSL. This means programs cannot directly swap out OpenSSL with AWS-LC without recompiling.

github-actions[bot] commented 7 months ago

This issue has not received a response in 1 week. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled.

theoparis commented 7 months ago

Hi, thanks for reaching out!

I tried building off the tip of main with clang 17.0.6 on an x86_64 instance and everything seems to fine on my end. Both the debug and release build compile fine. Could you share the specific clang version were you using?

Output:

+ cmake ../aws-lc -GNinja -B/home/ubuntu/workplace/aws-lc/test_build_dir -DCMAKE_INSTALL_PREFIX=/home/ubuntu/workplace/aws-lc/test_build_dir/
-- The C compiler identification is Clang 17.0.6
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is Clang 17.0.6
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Perl: /usr/bin/perl (found version "5.30.0") 
-- Checking for module 'libunwind-generic'
--   No package 'libunwind-generic' found
libunwind not found. Disabling unwind tests.
-- stdalign_check.c probe is positive, enabling AWS_LC_STDALIGN_AVAILABLE
-- builtin_swap_check.c probe is positive, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
-- Check if the system is big endian
-- Searching 16 bit integer
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of unsigned short
-- Check size of unsigned short - done
-- Using unsigned short
-- Check if the system is big endian - little endian
-- The ASM compiler identification is Clang
-- Found assembler: /usr/bin/cc
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Generating test executable mem_test.
-- Generating test executable mem_set_test.
-- Generating test executable dynamic_loading_test.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/workplace/aws-lc/test_build_dir
+ ninja -j8 -C test_build_dir run_tests
ninja: Entering directory `test_build_dir'
[536/540] cd /home/ubuntu/workplace/aws-lc && cd ssl/test/runner && /usr/local/go/bin/go t...r-test-file /home/ubuntu/workplace/aws-lc/ssl/test/runner/ssl_transfer/test_case_names.tx
0/0/992/1000/9280
0/0/992/1000/9280
0/0/993/1000/9280
0/0/1993/2000/9280
0/0/2992/3000/9280
0/0/2992/3000/9280
0/0/2992/3000/9280
0/0/2992/3000/9280
0/0/2993/3000/9280
0/0/3992/4000/9280
0/0/3993/4000/9280
0/0/4992/5000/9280
0/0/4992/5000/9280
0/0/4992/5000/9280
0/0/4993/5000/9280
0/0/5992/6000/9280
0/0/5992/6000/9280
0/0/5992/6000/9280
0/0/5993/6000/9280
0/0/6992/7000/9280
0/0/6992/7000/9280
0/0/6993/7000/9280
0/0/7992/8000/9280
0/0/7992/8000/9280
0/0/7993/8000/9280
0/0/8992/9000/9280
0/0/8993/9000/9280
0/0/9280/9280/9280

PASS
ok    boringssl.googlesource.com/boringssl/ssl/test/runner    21.535s
[539/540] cd /home/ubuntu/workplace/aws-lc && /usr/local/go/bin/go test ./ssl/test/runner/...al/go/bin/go run util/all_tests.go -build-dir /home/ubuntu/workplace/aws-lc/test_build_di
ok    boringssl.googlesource.com/boringssl/ssl/test/runner/hpke   0.082s
ok    boringssl.googlesource.com/boringssl/util/ar    0.004s
crypto/crypto_test [shard 6/8]
crypto/crypto_test [shard 5/8]
crypto/crypto_test [shard 7/8]
crypto/crypto_test --gtest_filter=Crypto.OnDemandIntegrityTest (custom environment)
crypto/crypto_test [shard 4/8]
crypto/crypto_test [shard 8/8]
crypto/crypto_test --gtest_also_run_disabled_tests --gtest_filter=RSATest.DISABLED_BlindingCacheConcurrency
crypto/crypto_test [shard 2/8]
crypto/crypto_test [shard 1/8]
crypto/urandom_test
crypto/crypto_test --fork_unsafe_buffering --gtest_filter=RandTest.*:-RandTest.Fork
crypto/crypto_test --gtest_filter=RandTest.* (custom environment)
crypto/crypto_test --gtest_filter=ForkDetect.* (custom environment)
crypto/urandom_test (custom environment)
ssl/ssl_test [shard 1/8]
ssl/ssl_test [shard 2/8]
crypto/urandom_test (custom environment)
ssl/ssl_test [shard 3/8]
ssl/ssl_test [shard 4/8]
ssl/ssl_test [shard 6/8]
ssl/ssl_test [shard 5/8]
ssl/ssl_test [shard 7/8]
crypto/mem_test
crypto/mem_set_test
crypto/dynamic_loading_test
ssl/ssl_test [shard 8/8]
ssl/integration_test
crypto/crypto_test [shard 3/8]
crypto/urandom_test (custom environment)
crypto/urandom_test (custom environment)
crypto/crypto_test --gtest_also_run_disabled_tests --gtest_filter=BNTest.DISABLED_WycheproofPrimality
crypto/urandom_test (custom environment)

All tests passed!

As for your question, AWS-LC is not ABI stable or ABI compatible with OpenSSL. This means programs cannot directly swap out OpenSSL with AWS-LC without recompiling.

Alright good to know. I think I had set the Cmake c standard to 23 which is probably what caused these issues and not the clang version.