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

Use earliest latest compilers #7968

Merged

Conversation

gowthamsk-arm
Copy link
Contributor

@gowthamsk-arm gowthamsk-arm commented Jul 20, 2023

Closes #7891

Needs Mbed-TLS/mbedtls-test#118 to be merged, otherwise the CI won't pass.

This PR has adds following changes:

  • The Ubuntu 16.04 and 22.04 docker images in mbedtls-test have been updated with earliest and latest versions of gcc and clang respectively. This PR adds the components and support functions required for the CI to run these compilers. For FreeBSD, we invoke the function by name so a condition is added to disable the existing test_clang_opt function for Linux.

  • Running clang-16 on mbedtls reports warnings of type "-Wstrict-prototypes". This patch fixes these warnings by adding void to functions with no arguments.

PR checklist

@gowthamsk-arm gowthamsk-arm self-assigned this Jul 20, 2023
@gowthamsk-arm gowthamsk-arm added enhancement component-platform Portability layer and build scripts size-s Estimated task size: small (~2d) priority-medium Medium priority - this can be reviewed as time permits needs-ci Needs to pass CI tests labels Jul 20, 2023
@gowthamsk-arm
Copy link
Contributor Author

@gowthamsk-arm
Copy link
Contributor Author

@gowthamsk-arm gowthamsk-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review needs-ci Needs to pass CI tests and removed needs-ci Needs to pass CI tests labels Jul 25, 2023
@@ -418,7 +418,7 @@ exit:
/* END_CASE */

/* BEGIN_CASE */
void aes_invalid_mode()
void aes_invalid_mode(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to keep allowing () in test functions. It's a more logical syntax (which C lacks only due to backward compatibility constraint), and if we stop allowing it, we'll likely forget in new work and then get surprised when the CI fails with clang-latest. If we do, then we don't need the massive (in terms of changed lines) changes to *.function.

This only requires a small change in tests/scripts/generate_test_code.py: in parse_function_code, if args is blank (ideally also if args only contains comments, but that's not critical), add void to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Will drop the *.function changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's already code in the script to accept void as meaning no arguments, since 47e2e88. Looking at it now (I'd forgotten how it was done), it seems that we're stripping void if it was present in the source, so we should unconditionally add it when generating. So yes, adding it in gen_from_test_data does sound good.

Copy link
Contributor

Choose a reason for hiding this comment

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

By the way, there are unit tests in tests/scripts/test_generate_test_code.py. If inserting void breaks a unit test, please update the expected result from that test. If inserting void doesn't break an existing unit test, please add one.

@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review labels Jul 25, 2023
@gowthamsk-arm gowthamsk-arm force-pushed the use_earliest_latest_compilers branch from d5a84ff to 0a08d33 Compare July 26, 2023 15:50
The Ubuntu 16.04 and 22.04 docker images have been updated with
earliest and latest versions of gcc and clang respectively.
This patch adds the necessary component and support functions
required for the CI to run these compilers.

For FreeBSD we invoke the function by name so a condition is added
to disable the existing test_clang_opt function for linux.

Signed-off-by: Gowtham Suresh Kumar <[email protected]>
@gowthamsk-arm gowthamsk-arm force-pushed the use_earliest_latest_compilers branch from 0a08d33 to 2ccdc6d Compare July 26, 2023 15:52
Running clang-16 on mbedtls reports warnings of type "-Wstrict-prototypes".
This patch fixes these warnings by adding void to functions with no
arguments. The generate_test_code.py is modified to insert void into test
functions with no arguments in *.function files.

Signed-off-by: Gowtham Suresh Kumar <[email protected]>
@gowthamsk-arm gowthamsk-arm force-pushed the use_earliest_latest_compilers branch from 2ccdc6d to 186731b Compare July 26, 2023 16:12
@gilles-peskine-arm gilles-peskine-arm added needs-ci Needs to pass CI tests needs-preceding-pr Requires another PR to be merged first labels Jul 27, 2023
@gowthamsk-arm gowthamsk-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review and removed needs-work labels Jul 27, 2023
@gowthamsk-arm gowthamsk-arm force-pushed the use_earliest_latest_compilers branch from ec4988b to 6f1977b Compare July 28, 2023 16:09
@gowthamsk-arm gowthamsk-arm removed needs-work needs-ci Needs to pass CI tests labels Jul 31, 2023
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

Just a minor thing

@@ -667,6 +667,11 @@ def parse_function_code(funcs_f, dependencies, suite_dependencies):
code = code.replace(name, 'test_' + name, 1)
name = 'test_' + name

# If a test function has no arguments then add 'void' argument to
# avoid "-Wstrict-prototypes" warnings from clang-16
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: not specifically clang-16. That option has been around at least as far back as Clang 3.5.

Comment on lines 179 to 182
: ${CLANG_LATEST:="clang-16"}
: ${CLANG_EARLIEST:="clang-3.5"}
: ${GCC_LATEST:="gcc-12"}
: ${GCC_EARLIEST:="gcc-4.7"}
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer not to hard-code versions in all.sh, just like we don't hard-code versions of OpenSSL. The CI setup (docker files on Linux) defines the versions we use.

Suggested change
: ${CLANG_LATEST:="clang-16"}
: ${CLANG_EARLIEST:="clang-3.5"}
: ${GCC_LATEST:="gcc-12"}
: ${GCC_EARLIEST:="gcc-4.7"}
: ${CLANG_LATEST:="clang-latest"}
: ${CLANG_EARLIEST:="clang-earlist"}
: ${GCC_LATEST:="gcc-latest"}
: ${GCC_EARLIEST:="gcc-earliest"}

@gilles-peskine-arm gilles-peskine-arm added needs-work and removed needs-review Every commit must be reviewed by at least two team members, labels Jul 31, 2023
@gowthamsk-arm gowthamsk-arm force-pushed the use_earliest_latest_compilers branch from f88b48b to 57713bc Compare July 31, 2023 15:42
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

LGTM except for a typo that prevented the CI from running

@@ -176,7 +176,10 @@ pre_initialize_variables () {
: ${ARMC6_BIN_DIR:=/usr/bin}
: ${ARM_NONE_EABI_GCC_PREFIX:=arm-none-eabi-}
: ${ARM_LINUX_GNUEABI_GCC_PREFIX:=arm-linux-gnueabi-}

: ${CLANG_LATEST:="clang-latest"}
: ${CLANG_EARLIEST:="clang-earlist"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: ${CLANG_EARLIEST:="clang-earlist"}
: ${CLANG_EARLIEST:="clang-earliest"}

and likewise for gcc below.

@gilles-peskine-arm gilles-peskine-arm added the needs-ci Needs to pass CI tests label Jul 31, 2023
@gowthamsk-arm gowthamsk-arm force-pushed the use_earliest_latest_compilers branch from 57713bc to 9da40b8 Compare July 31, 2023 22:19
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, and removed needs-work needs-ci Needs to pass CI tests labels Aug 1, 2023
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

LGTM

@gowthamsk-arm gowthamsk-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, labels Aug 1, 2023
: ${CLANG_LATEST:="clang-latest"}
: ${CLANG_EARLIEST:="clang-earliest"}
: ${GCC_LATEST:="gcc-latest"}
: ${GCC_EARLIEST:="gcc-earliest"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Very minor: there used to be a blank line here, it's still present in the 2.28 branch but not here. Not worth changing if there's nothing else to change.

@gilles-peskine-arm gilles-peskine-arm added this pull request to the merge queue Aug 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Aug 1, 2023
@bensze01 bensze01 added this pull request to the merge queue Aug 1, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 2, 2023
@bensze01 bensze01 added this pull request to the merge queue Aug 2, 2023
Merged via the queue into Mbed-TLS:development with commit 9661f8a Aug 2, 2023
scripts/config.py full
test_build_opt 'full config' clang -O0 -Os -O2
test_build_opt 'full config' "$CLANG_EARLIEST" -O0
Copy link
Contributor

Choose a reason for hiding this comment

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

Why -O0? That's the fastest build, but -O or -O2is faster when doing build and test. Also,-O0` omits some warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, I looked into the changes thoroughly and this was supposed to be -O. :(
Its also mentioned in #7891.

For the earliest compilers, just do a -O build.

Shall I create a new PR for this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll fix it in #9286 which is where I noticed it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports component-platform Portability layer and build scripts enhancement priority-medium Medium priority - this can be reviewed as time permits size-s Estimated task size: small (~2d)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Do a build with earliest and latest compilers
4 participants