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

GH-45325: [C++] Improved error message when using clang++ without clang #45326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions cpp/cmake_modules/SetupCxxFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ include(CheckCXXSourceCompiles)

message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")

if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this check?
In general, we can't mix C/C++ compilers from different vendores, right?
(Can we mix g++ and clang?)

Copy link
Contributor Author

@WillAyd WillAyd Jan 22, 2025

Choose a reason for hiding this comment

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

Yea mixing g++ and clang is the problem, or vice versa. If you just set -DCMAKE_CXX_COMPILER=clang++ then clang++ will be used for cpp files and gcc will be used for c (assuming gcc is the default)

Copy link
Member

Choose a reason for hiding this comment

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

but wouldn't the following catch that?
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL CMAKE_C_COMPILER_ID)
Why only perform the check if the CMAKE_CXX_COMPILER_ID is 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.

Ah I see what you are saying. I don't know CMake well enough to know if those labels are always expected to be the same. Happy to make that change.

This originally started by locating the "bug" in SetupCxxFlags.cmake, hence the condition in the first place

if(NOT CMAKE_CXX_COMPILER_ID STREQUAL CMAKE_C_COMPILER_ID)
message(FATAL_ERROR "When using clang++ you must also use clang")
endif()
endif()

if(NOT DEFINED ARROW_CPU_FLAG)
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
set(ARROW_CPU_FLAG "emscripten")
Expand Down Expand Up @@ -430,14 +436,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STRE
"Clang")
# Clang options for all builds

# Using Clang with ccache causes a bunch of spurious warnings that are
# purportedly fixed in the next version of ccache. See the following for details:
#
# http://petereisentraut.blogspot.com/2011/05/ccache-and-clang.html
# http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments")

# Avoid error when an unknown warning flag is passed
set(CXX_COMMON_FLAGS "${CXX_COMMON_FLAGS} -Wno-unknown-warning-option")
# Add colors when paired with ninja
Expand Down
Loading