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

Fix cross-compilation issues for aws-lc-sys #689

Merged
merged 8 commits into from
Dec 1, 2022

Conversation

samuel40791765
Copy link
Contributor

@samuel40791765 samuel40791765 commented Nov 18, 2022

Issues:

Addresses CryptoAlg-1422

Description of changes:

Call-outs:

Most of the cmake changes were backported from af25856. Added four lines of code to turn off build options

Testing:

Running the script ./generate.sh. Tested the new aws-lc-sys crate with cross. Tests pass and call the correct bindings on the corresponding platform.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and
the ISC license.

@samuel40791765 samuel40791765 marked this pull request as ready for review November 22, 2022 18:44
@samuel40791765 samuel40791765 changed the title Move bindgen out of aws-lc-sys Fix cross-compilation issues for aws-lc-sys Nov 22, 2022
skmcgrail
skmcgrail previously approved these changes Nov 23, 2022
bindings/rust/aws-lc-sys-template/src/lib.rs Outdated Show resolved Hide resolved
bindings/rust/generate/_generate_bindings.sh Outdated Show resolved Hide resolved
@samuel40791765
Copy link
Contributor Author

samuel40791765 commented Nov 29, 2022

Verified against CMake3.0.0 and CMake3.10 that adding build options after the path work. AWS-LC requires a cmake version of at least 3.0.0 to build.

root@d0aa4f57add0:/home/ubuntu/sachiang/workplace/repo/aws-lc# rm -rf test_build_dir && mkdir test_build_dir
root@d0aa4f57add0:/home/ubuntu/sachiang/workplace/repo/aws-lc# cmake ../aws-lc -GNinja "-B`pwd`/test_build_dir" "-DCMAKE_INSTALL_PREFIX=`pwd`/test_build_dir/" -DCMAKE_BUILD_TYPE=Release -DDISABLE_PERL=ON -DDISABLE_GO=ON
-- The C compiler identification is Clang 10.0.0
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- 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 10.0.0
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
pkgconfig not found. Disabling unwind tests.
-- Go not found. Disabling some code generation and using pre-generated code in generated-src/
-- Perl not found. Disabling some code generation and using pre-generated code in generated-src/
-- Test stdalign_check.c passed, enabling AWS_LC_STDALIGN_AVAILABLE
-- Test builtin_swap_check.c passed, 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/clang-10
-- Disabling debug symbols for Clang internal assembler
Copying platform assembly files from /home/ubuntu/sachiang/workplace/repo/aws-lc/generated-src/linux-x86_64/crypto/ to /home/ubuntu/sachiang/workplace/repo/aws-lc/test_build_dir/crypto
-- Looking for include file pthread.h
-- Looking for include file pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- 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 - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Generating test executable mem_test.
-- Generating test executable mem_set_test.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ubuntu/sachiang/workplace/repo/aws-lc/test_build_dir
root@d0aa4f57add0:/home/ubuntu/sachiang/workplace/repo/aws-lc# cmake ../aws-lc -GNinja "-B`pwd`/test_build_dir" "-DCMAKE_INSTALL_PREFIX=`pwd`/test_build_dir/" -DCMAKE_BUILD_TYPE=Release -DDISABLE_PERL=ON -DDISABLE_GO=ON -DFIPS=1
pkgconfig not found. Disabling unwind tests.
-- Go not found. Disabling some code generation and using pre-generated code in generated-src/
-- Perl not found. Disabling some code generation and using pre-generated code in generated-src/
-- Test stdalign_check.c passed, enabling AWS_LC_STDALIGN_AVAILABLE
-- Test builtin_swap_check.c passed, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
-- Test linux_u32.c passed, enabling AWS_LC_URANDOM_U32
CMake Error at CMakeLists.txt:567 (message):
  Building AWS-LC for FIPS requires Go and Perl


-- Configuring incomplete, errors occurred!
See also "/home/ubuntu/sachiang/workplace/repo/aws-lc/test_build_dir/CMakeFiles/CMakeOutput.log".
See also "/home/ubuntu/sachiang/workplace/repo/aws-lc/test_build_dir/CMakeFiles/CMakeError.log".
root@d0aa4f57add0:/home/ubuntu/sachiang/workplace/repo/aws-lc# cmake --version
cmake version 3.1.0

CMake suite maintained and supported by Kitware (kitware.com/cmake).

Comment on lines 28 to 32
# Generate the bindings on the targetted platform as a fallback mechanism.
native_bindings = ["bindgen"]
# Pre-generate the bindings for crate publishing. Cannot be used simultaneously with the
# native_bindings feature. This feature is only intended for internal usage.
generate = ["bindgen"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For the feature that customers see, I think a name like "generate_bindings" would be more accurate. (The bindings will be "native" regardless.)
  • Could we simply remove this "generate" feature from Cargo.toml prior to publishing the crate? Would that prevent its use?
  • If we must keep this feature after publication, could we name it in a way that's more clearly internal-use-only -- like "internal_generate"?

Copy link
Contributor Author

@samuel40791765 samuel40791765 Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Renamed to generate_bindings and internal_generate.
  • I guess we could use a removal script to remove mentions of the generate feature? That would provide additional complications though.
    The best alternative IMO would be to place the internal_generate feature in a separate non-published generate crate, like we were initially doing? Although there will be a bit of duplicate code, that would prevent us exposing this feature externally.

bindings/rust/aws-lc-sys-template/src/lib.rs Outdated Show resolved Hide resolved
bindings/rust/aws-lc-sys-template/build.rs Show resolved Hide resolved
bindings/rust/aws-lc-sys-template/src/lib.rs Outdated Show resolved Hide resolved
justsmth
justsmth previously approved these changes Nov 30, 2022
@samuel40791765 samuel40791765 merged commit 0cf16a9 into aws:main Dec 1, 2022
@samuel40791765 samuel40791765 deleted the pre-generate branch December 1, 2022 22:25
@samuel40791765 samuel40791765 restored the pre-generate branch December 1, 2022 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants