Skip to content

build: Support both Clang and GCC toolchains#891

Open
felipek wants to merge 1 commit into
COVESA:masterfrom
felipek:clang_gcc_support
Open

build: Support both Clang and GCC toolchains#891
felipek wants to merge 1 commit into
COVESA:masterfrom
felipek:clang_gcc_support

Conversation

@felipek

@felipek felipek commented Jun 26, 2026

Copy link
Copy Markdown

-Wno-stringop-truncation is a GCC-only warning option. Passing it
unconditionally broke the Clang build, which rejects it as an unknown
warning option (an error under -Werror). Make it GCC-conditional via a
generator expression.

Additionally add a Clang-only block that relaxes the Clang-specific
diagnostics triggered by the same strict flags (-pedantic, -Wconversion):
intentional GNU extensions (gnu11/gnu++17), "()" vs "(void)" prototypes,
and stricter implicit enum/integer narrowing and signedness checks. The
GCC build keeps its full strict -Werror warning set unchanged.

Verified clean (-Werror, 0 warnings) with Apple Clang 21 and GCC 15.2.0.

-Wno-stringop-truncation is a GCC-only warning option. Passing it
unconditionally broke the Clang build, which rejects it as an unknown
warning option (an error under -Werror). Make it GCC-conditional via a
generator expression.

Additionally add a Clang-only block that relaxes the Clang-specific
diagnostics triggered by the same strict flags (-pedantic, -Wconversion):
intentional GNU extensions (gnu11/gnu++17), "()" vs "(void)" prototypes,
and stricter implicit enum/integer narrowing and signedness checks. The
GCC build keeps its full strict -Werror warning set unchanged.

Verified clean (-Werror, 0 warnings) with Apple Clang 21 and GCC 15.2.0.
@felipek

felipek commented Jun 26, 2026

Copy link
Copy Markdown
Author

Hi @alexmohr @minminlittleshrimp please review this as follow-up to c840f29 - there is a very tiny incompatible change requiring gcc (brew) which is not great since people can use standard Apple/Xcode/clang tools with this minor cmake/make change. I have tested it both with GCC and Clang. Thanks!

@alexmohr

Copy link
Copy Markdown
Contributor

Works for me with default cmake arguments thank you. Now that it works with clang we could update the brew file too, so it does not depend on gcc anymore?

@minminlittleshrimp

Copy link
Copy Markdown
Collaborator

IMHO we still support both, and in Apple case here clang still be fine right? homebrew with prevelent using gcc can also alternatively with clang?

I have check with local Clang and this change is valid, and I believe it good to go with the configuring.

Im also deploying 3 more pipelines for clang tidy clang format cppchecker and commit msg format checker s.a. requesting signoff or limit to 72 chars soem kind of, that can help strengthening the automation process

@alexmohr

Copy link
Copy Markdown
Contributor

Yes we still support both with this PR, but as @felipek also mentioned already clang is pretty much the standard way on MacOS, so we could drop the gcc depedency from the brew file and compile it with clang per default. This will only affect users installing via homebrew and you still can build locally with GCC instead.

@felipek

felipek commented Jun 30, 2026

Copy link
Copy Markdown
Author

Hi @minminlittleshrimp @alexmohr yes clang is the Apple standard (llvm/clang are Apple originated projects anyway), gcc requires either brew/MacPorts or something similar. I think it is fine to keep support for both, but it is more testing/coverage, yes...

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.

3 participants