Skip to content

fix: Recognize AppleClang to enable recommended compiler flags on macOS#547

Draft
azeey wants to merge 2 commits intogazebosim:mainfrom
azeey:fix_macos_compile_flags
Draft

fix: Recognize AppleClang to enable recommended compiler flags on macOS#547
azeey wants to merge 2 commits intogazebosim:mainfrom
azeey:fix_macos_compile_flags

Conversation

@azeey
Copy link
Copy Markdown
Contributor

@azeey azeey commented Apr 15, 2026

🦟 Bug fix

Summary

While working on gazebosim/gz-physics#946, I noticed that I wasn't getting any compiler warnings locally (on macOS), but they showed up on CI. It turns out the flags used for gcc on Linux and the ones used for clang on macOS are very different. Examples from build.ninja:

macOS

FLAGS = -stdlib=libc++ -O2 -g -DNDEBUG -std=c++17 -arch arm64 -fPIC

But on Linux

FLAGS = -O2 -g -DNDEBUG  -Wall -Wextra -Wno-long-long -Wno-unused-value -Wfloat-equal -Wshadow -Winit-self -Wswitch-default -Wmissing-include-dirs -pedantic  -std=c++17 -fPIC -fvisibility=hidden

Other than the macOS specific flags like -stdlib and -arch, the flags should have been equivalent where possible. The issue was that the compiler ID for Apple's Clang is 'AppleClang', which was not recognized by the scripts. This change ensures that AppleClang is treated similarly to standard Clang, applying the recommended warning flags.

With the new flags, gz-physics emitts additional warnings related to TYPED_TEST_SUITE for the code like the following tests in test/common:

template <class T>
class SimulationFeaturesShapeFeaturesTest :
  public SimulationFeaturesTest<T>{};
using SimulationFeaturesShapeFeaturesTestTypes =
  ::testing::Types<FeaturesShapeFeatures>;
TYPED_TEST_SUITE(SimulationFeaturesShapeFeaturesTest,
                 SimulationFeaturesShapeFeaturesTestTypes);

and the error message is

/Users/addisuzt/ws/rotary/src/gz-physics/test/common_test/simulation_features.cc:989:58: warning: passing no argument for the '...' parameter of a variadic macro is a C++20 extension [-Wvariadic-macro-arguments-omitted]
  989 |                  SimulationFeaturesShapeFeaturesTestTypes);
      |                                                          ^
/Users/addisuzt/ws/rotary/src/gz-physics/test/gtest_vendor/include/gtest/gtest-typed-test.h:191:9: note: macro 'TYPED_TEST_SUITE' defined here
  191 | #define TYPED_TEST_SUITE(CaseName, Types, ...)                          \
      |         ^

dd5ab89 suppresses this warning to match gcc on Linux.

Edit: I've marked this as draft because this causes several warnings in other Gazebo libraries. Once those are all addressed, I'll mark this ready for review.

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the fix (as needed)
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Generated-by" to your commits. (See this policy for more info.)

Generated-by: Gemini 3.0 Pro

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by and Generated-by messages.

Backports: If this is a backport, please use Rebase and Merge instead.

azeey added 2 commits April 14, 2026 21:21
The compiler ID for Apple's Clang is 'AppleClang', which was not recognized by the scripts. This change ensures that AppleClang is treated similarly to standard Clang, applying the recommended warning flags.

Generated-By: Gemini 3.0 Pro
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
This suppresses the warning about variadic macro arguments in gtest, which is triggered by -pedantic on macOS with Clang. This is needed for tests in gz-physics.

Generated-By: Gemini 3.0 Pro
Signed-off-by: Addisu Z. Taddese <addisuzt@intrinsic.ai>
@azeey azeey requested review from j-rivero and scpeters as code owners April 15, 2026 03:11
@azeey azeey marked this pull request as draft April 15, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

1 participant