Skip to content

drop a few unsupported CFLAGS for clang #1090

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

yamt
Copy link
Contributor

@yamt yamt commented Apr 7, 2025

No description provided.

@geky-bot
Copy link
Collaborator

geky-bot commented Apr 7, 2025

Tests passed ✓, Code: 17116 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 812 B (+0.0%)
Code Stack Structs Coverage
Default 17116 B (+0.0%) 1448 B (+0.0%) 812 B (+0.0%) Lines 2432/2594 lines (+0.0%)
Readonly 6230 B (+0.0%) 448 B (+0.0%) 812 B (+0.0%) Branches 1279/1610 branches (-0.0%)
Threadsafe 17968 B (+0.0%) 1448 B (+0.0%) 820 B (+0.0%) Benchmarks
Multiversion 17188 B (+0.0%) 1448 B (+0.0%) 816 B (+0.0%) Readed 29369693876 B (+0.0%)
Migrate 18780 B (+0.0%) 1752 B (+0.0%) 816 B (+0.0%) Proged 1482874766 B (+0.0%)
Error-asserts 17896 B (+0.0%) 1440 B (+0.0%) 812 B (+0.0%) Erased 1568888832 B (+0.0%)

@geky
Copy link
Member

geky commented May 1, 2025

Hi @yamt, thanks for the PR, sorry about the late response.

I'm not so sure on this one. When they break, shell commands can be confusing in Makefiles (I'm not sure what compiler wouldn't support --version, but still).

It also breaks stack measurement, though there's no way around that...

Thoughts on ifeq ($(findstring clang,$(CC)),clang)? Or an explicit NO_STACK or CLANG env variable?

@geky
Copy link
Member

geky commented May 1, 2025

Or an explicit NO_STACK

Actually, maybe NO_CALLGRAPH or NO_SU, NO_STACK could be interpreted weirdly (and NO_CI would be even worse!)

@yamt
Copy link
Contributor Author

yamt commented May 2, 2025

Thoughts on ifeq ($(findstring clang,$(CC)),clang)?

on macOS, clang has a few names including "gcc" and "cc".

spacetanuki% /usr/bin/gcc --version  
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: x86_64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
spacetanuki% /usr/bin/cc --version 
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: x86_64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
spacetanuki% /usr/bin/clang --version
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: x86_64-apple-darwin24.4.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
spacetanuki% 

@geky
Copy link
Member

geky commented May 2, 2025

on macOS, clang has a few names including "gcc" and "cc".

Ah... I get it, but if you force one compiler to cosplay as another you should probably expect some weird errors...

I don't like it, but this does seem like the only way for make test to work out-of-the-box on Mac...

@yamt
Copy link
Contributor Author

yamt commented May 2, 2025

on macOS, clang has a few names including "gcc" and "cc".

Ah... I get it, but if you force one compiler to cosplay as another you should probably expect some weird errors...

earlier versions of xcode had a real gcc.
i guess it was necessary for them to smooth the migration to clang.

I don't like it, but this does seem like the only way for make test to work out-of-the-box on Mac...

i don't like it either.
but it seems like a common practice for traditional make users.
cmake uses even more complex approach for its CMAKE_C_COMPILER_ID.
(actually process some code to see predefined macros.)

@geky
Copy link
Member

geky commented May 5, 2025

cmake uses even more complex approach for its CMAKE_C_COMPILER_ID.
(actually process some code to see predefined macros.)

Oh no! Anything but cmake!

i don't like it either.
but it seems like a common practice for traditional make users.

After sleeping on it, I think you're right. This does seem like the only route for make test to work out of the box on Mac. And that is useful.

Will bring this in on the next patch release. Thanks for the PR!

@geky geky added the next patch label May 5, 2025
@geky geky added next minor needs minor version new functionality only allowed in minor versions and removed next patch labels May 8, 2025
@geky
Copy link
Member

geky commented May 8, 2025

Bumping to needs-minor. Not sure if Makefile-only changes need a minor release, but there will probably be a minor release soon.

@geky
Copy link
Member

geky commented May 8, 2025

I've also added the NO_GCC variable. This should still be implicitly set if --version contains "clang", but allows other, non-gcc, users to explicitly disable the GCC-specific flag.

Let me know if this tweak causes any problems on your end.

@geky-bot
Copy link
Collaborator

geky-bot commented May 8, 2025

Tests passed ✓, Code: 17116 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 812 B (+0.0%)
Code Stack Structs Coverage
Default 17116 B (+0.0%) 1448 B (+0.0%) 812 B (+0.0%) Lines 2432/2594 lines (+0.0%)
Readonly 6230 B (+0.0%) 448 B (+0.0%) 812 B (+0.0%) Branches 1279/1610 branches (-0.0%)
Threadsafe 17968 B (+0.0%) 1448 B (+0.0%) 820 B (+0.0%) Benchmarks
Multiversion 17188 B (+0.0%) 1448 B (+0.0%) 816 B (+0.0%) Readed 29369693876 B (+0.0%)
Migrate 18780 B (+0.0%) 1752 B (+0.0%) 816 B (+0.0%) Proged 1482874766 B (+0.0%)
Error-asserts 17896 B (+0.0%) 1440 B (+0.0%) 812 B (+0.0%) Erased 1568888832 B (+0.0%)

Makefile Outdated
@@ -18,6 +18,12 @@ VALGRIND ?= valgrind
GDB ?= gdb
PERF ?= perf

# guess clang or gcc (clang sometimes masquerades as gcc because of
# course it does)
ifeq ($(shell $(CC) --version | grep clang),clang)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i don't think this works because the line contains more characters than just clang.

spacetanuki% cc --version | grep clang
Apple clang version 17.0.0 (clang-1700.0.13.3)
spacetanuki% 

Copy link
Member

Choose a reason for hiding this comment

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

AH, I was trying to avoid the double-negative and thought this was make's findstring. Reverted to ifneq. Good catch!

And actually tested with CC=clang this time..

This is the same as the implicit Clang => NO_GCC behavior introduced by
yamt, but with an explicit variable that can be assigned by users using
other, non-gcc, compilers:

  $ NO_GCC=1 make

Note, stack measurements are currently GCC specific:

  $ NO_GCC=1 make stack
  ... snip ...
  FileNotFoundError: [Errno 2] No such file or directory: 'lfs.ci'
  make: *** [Makefile:494: lfs.stack.csv] Error 1
Thanks to yamt, GCC-specific flags should now be disabled if compiling
with clang. Dropping the explicit flags also doubles as a test that the
NO_GCC inference works.
@geky
Copy link
Member

geky commented May 8, 2025

I also just remembered we already have Clang in CI, to catch Clang-specific warnings, but it was implemented using explicit CFLAGS.

I dropped the explicit CFLAGS so now this inference should actually be tested (which would've caught my above mistake).

Let me know if anything else looks wrong.

@geky-bot
Copy link
Collaborator

geky-bot commented May 8, 2025

Tests passed ✓, Code: 17116 B (+0.0%), Stack: 1448 B (+0.0%), Structs: 812 B (+0.0%)
Code Stack Structs Coverage
Default 17116 B (+0.0%) 1448 B (+0.0%) 812 B (+0.0%) Lines 2432/2594 lines (+0.0%)
Readonly 6230 B (+0.0%) 448 B (+0.0%) 812 B (+0.0%) Branches 1279/1610 branches (-0.0%)
Threadsafe 17968 B (+0.0%) 1448 B (+0.0%) 820 B (+0.0%) Benchmarks
Multiversion 17188 B (+0.0%) 1448 B (+0.0%) 816 B (+0.0%) Readed 29369693876 B (+0.0%)
Migrate 18780 B (+0.0%) 1752 B (+0.0%) 816 B (+0.0%) Proged 1482874766 B (+0.0%)
Error-asserts 17896 B (+0.0%) 1440 B (+0.0%) 812 B (+0.0%) Erased 1568888832 B (+0.0%)

@yamt
Copy link
Contributor Author

yamt commented May 8, 2025

Let me know if anything else looks wrong.

looks fine to me. thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs minor version new functionality only allowed in minor versions next minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants