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

ci: always set values for command line defines #5126

Merged
merged 2 commits into from
Feb 21, 2025

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Feb 18, 2025

Release Summary:

Resolved issues:

resolves #5116 (comment)

Description of changes:

gcc, clang, and every compiler on godbolt that I could test with set any command-line define to 1 by default. But that's apparently not part of any spec, so a compiler could theoretically do something different. It's also arguably "magical" behavior: without reading the right clang or gcc documentation, it's unclear that it's happening.

I'm thinking that it would be clearer to just explicitly set defines to 1.

It's also technically safer, but honestly probably not that much safer. While I was trying to find any sort of spec, I found this memorable quote: "The C Standard does not mandate this behavior but it would take a perverse compiler to not mimic the original pcc as all others have for 40 years including gcc and clang." The "perverse" compiler would also have to specifically use "0" as its default, because any non-0 value would work just fine in any #ifs and just not setting any value at all would cause compilation of any #ifs to fail.

Testing:

The script passes for the updated CMakeLists.txt.
The script fails for the old CMakeLists.txt with: https://github.com/lrstewart/s2n/actions/runs/13402258346/job/37435368302?pr=61

Command line define is missing value: Compilers SHOULD set a default value of 1 when no default is given, but that behavior is not required by any official spec. Set a value just in case. For example: -DS2N_FOO=1 instead of -DS2N_FOO.
Found: 
166:-DS2N_EXPORTS)
198:-DS2N_BUILD_RELEASE)
312:-D${PROBE_NAME})
422:-DS2N_INTERN_LIBCRYPTO)
FAILED Grep For Simple Mistakes check

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

@github-actions github-actions bot added the s2n-core team label Feb 18, 2025
@lrstewart lrstewart force-pushed the define_paranoia branch 2 times, most recently from c1bcbbc to cbe7507 Compare February 18, 2025 23:42
@lrstewart lrstewart marked this pull request as ready for review February 18, 2025 23:53
@lrstewart lrstewart requested a review from dougch as a code owner February 18, 2025 23:53
@lrstewart lrstewart requested a review from goatgoose February 18, 2025 23:54
Copy link
Contributor

@dougch dougch left a comment

Choose a reason for hiding this comment

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

Safety first.

@@ -134,7 +134,7 @@ bindir ?= $(exec_prefix)/bin
libdir ?= $(exec_prefix)/lib64
includedir ?= $(exec_prefix)/include

feature_probe = $(shell $(CC) $(CFLAGS) $(shell cat $(S2N_ROOT)/tests/features/GLOBAL.flags) $(shell cat $(S2N_ROOT)/tests/features/$(1).flags) -c -o tmp.o $(S2N_ROOT)/tests/features/$(1).c > /dev/null 2>&1 && echo "-D$(1)"; rm tmp.o > /dev/null 2>&1)
feature_probe = $(shell $(CC) $(CFLAGS) $(shell cat $(S2N_ROOT)/tests/features/GLOBAL.flags) $(shell cat $(S2N_ROOT)/tests/features/$(1).flags) -c -o tmp.o $(S2N_ROOT)/tests/features/$(1).c > /dev/null 2>&1 && echo "-D$(1)=1"; rm tmp.o > /dev/null 2>&1)
Copy link
Contributor

Choose a reason for hiding this comment

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

this line is hideous.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can cease to exist if we finish the cmake migration ;)

@lrstewart lrstewart added this pull request to the merge queue Feb 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 19, 2025
@lrstewart lrstewart added this pull request to the merge queue Feb 19, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 19, 2025
@lrstewart lrstewart enabled auto-merge February 19, 2025 19:20
@lrstewart lrstewart disabled auto-merge February 19, 2025 19:20
@lrstewart lrstewart enabled auto-merge February 20, 2025 23:55
@lrstewart lrstewart added this pull request to the merge queue Feb 21, 2025
Merged via the queue into aws:main with commit 21cefc1 Feb 21, 2025
46 checks passed
@lrstewart lrstewart deleted the define_paranoia branch February 21, 2025 02:34
dougch pushed a commit to dougch/s2n-tls that referenced this pull request Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants