-
Notifications
You must be signed in to change notification settings - Fork 724
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
Conversation
c1bcbbc
to
cbe7507
Compare
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is hideous.
There was a problem hiding this comment.
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 ;)
60f2430
to
cd97824
Compare
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
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.