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 consistency between CC and CMake builds #525

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

justsmth
Copy link
Contributor

@justsmth justsmth commented Sep 18, 2024

Description of changes:

The "CMake builder" now defers to the "CC builder" logic to determine which flags are appropriate for the compiler in the build environment. (Restores the usage of -ffile-prefix-map compiler option with CMake build, which had been disabled in a previous PR.)

Testing

Tested with GCC 7.2
❯ cc --version
cc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
...
❯ AWS_LC_SYS_CMAKE_BUILDER=1 cargo test -p aws-lc-sys --release
...
test result: ok. 95 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/sanity-tests.rs (target/release/deps/sanity_tests-84b2d0ab2e249e0a)

running 2 tests
test error_checking ... ok
test test_fips_mode ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests aws_lc_sys

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
❯ AWS_LC_SYS_CMAKE_BUILDER=1 cargo test -p aws-lc-rs --release
...

test result: ok. 22 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 0.82s

Tested on MacOS (aarch64)
❯ AWS_LC_SYS_CMAKE_BUILDER=1 cargo test -p aws-lc-sys --release
...
test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests aws_lc_sys

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
...
❯ strings target/release/build/aws-lc-sys-60dcdc2e10876109/out/build/artifacts/libaws_lc_0_21_2_crypto.a | grep justsmth || echo "nothing here"
nothing here

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.

@justsmth justsmth requested a review from a team as a code owner September 18, 2024 18:46
@justsmth justsmth marked this pull request as draft September 18, 2024 18:46
@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.52%. Comparing base (c358484) to head (887ab74).
Report is 81 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #525      +/-   ##
==========================================
- Coverage   95.80%   92.52%   -3.28%     
==========================================
  Files          61       67       +6     
  Lines        8143     9277    +1134     
  Branches        0     9277    +9277     
==========================================
+ Hits         7801     8584     +783     
- Misses        342      422      +80     
- Partials        0      271     +271     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@justsmth justsmth force-pushed the cmake-cc-build-align branch 7 times, most recently from 94e174c to c2d7c14 Compare September 18, 2024 21:09
@justsmth justsmth changed the title Better align the CC and CMake builds Improve alignment of CC and CMake builds Sep 19, 2024
@justsmth justsmth force-pushed the cmake-cc-build-align branch 4 times, most recently from f5aa492 to edee779 Compare September 23, 2024 15:20
@justsmth justsmth marked this pull request as ready for review September 23, 2024 15:26
@justsmth justsmth force-pushed the cmake-cc-build-align branch 7 times, most recently from 535b712 to 9e6ad38 Compare September 23, 2024 17:17
@justsmth justsmth changed the title Improve alignment of CC and CMake builds Improve consistency between CC and CMake builds Sep 23, 2024
@justsmth justsmth force-pushed the cmake-cc-build-align branch 6 times, most recently from c8a982d to 44f4793 Compare September 24, 2024 13:57
@justsmth justsmth force-pushed the cmake-cc-build-align branch 15 times, most recently from 1d55237 to eb69105 Compare September 24, 2024 19:18
@justsmth justsmth force-pushed the cmake-cc-build-align branch from eb69105 to ac66bda Compare September 25, 2024 18:29
else
exit 1; # FAIL - we expected to find "runner" (i.e., a path)
fi
- if: ${{ matrix.gcc_version == '8' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why we check this specific version?

Copy link
Contributor Author

@justsmth justsmth Sep 25, 2024

Choose a reason for hiding this comment

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

The -ffile-prefix-map option (which can strip build environment paths from the resulting binary) is only supported on GCC v8 and later. Our use of this flags was causing failures for projects building with CMake and an older GCC compiler.

This tests verifies that the path where the build is being performed (which is under the "runner"s home directory) is not found in the release binary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah that makes sense, I didn't realize this test dimension was intertwined with the flag. A comment here might help since the knowledge is a bit specific, but not absolutely required.

@justsmth justsmth force-pushed the cmake-cc-build-align branch from ac66bda to 0e968e3 Compare September 25, 2024 19:03
@justsmth justsmth force-pushed the cmake-cc-build-align branch from 0e968e3 to b0d6e7e Compare September 25, 2024 19:08
samuel40791765
samuel40791765 previously approved these changes Sep 25, 2024
else
exit 1; # FAIL - we expected to find "runner" (i.e., a path)
fi
- if: ${{ matrix.gcc_version == '8' }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah that makes sense, I didn't realize this test dimension was intertwined with the flag. A comment here might help since the knowledge is a bit specific, but not absolutely required.

@justsmth justsmth merged commit c401134 into aws:main Sep 26, 2024
228 of 232 checks passed
@justsmth justsmth deleted the cmake-cc-build-align branch September 26, 2024 19:16
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