From 58481c8946f04b7e6f024a035128a669bbad207d Mon Sep 17 00:00:00 2001 From: David Neto Date: Thu, 13 Mar 2025 17:04:27 -0400 Subject: [PATCH] build.sh: On Linux force use of latest Clang CMake will default to GCC if it's available. Force use of the oldest installed Clang instead. This can be overridden with CC, CXX, and CXXFLAGS Fixed: #8515 --- build.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/build.sh b/build.sh index 06d9a8f5b0ff..7cbacebe78bb 100755 --- a/build.sh +++ b/build.sh @@ -224,6 +224,17 @@ BUILD_CUSTOM_TARGETS= UNAME=$(uname) LC_UNAME=$(echo "${UNAME}" | tr '[:upper:]' '[:lower:]') +if [[ "$LC_UNAME" == "linux" ]]; then + # On Linux both GCC and Clang are commonly available, but CMake + # will default to GCC. + # Force use of Clang, and pick the highest-numbered version. + CLANG_VER=$(ls -1 /usr/include/clang | fgrep -v . | sort -n | tail -1) + export CC=${CC-/usr/bin/clang-$CLANG_VER} + export CXX=${CXX-/usr/bin/clang++-$CLANG_VER} + export CXXFLAGS=${CXXFLAGS--stdlib=libc++} + export COMPILER_OPTION="-DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_CXX_FLAGS=$CXXFLAGS" +fi + # Functions function build_clean { @@ -268,6 +279,7 @@ function build_desktop_target { -DIMPORT_EXECUTABLES_DIR=out \ -DCMAKE_BUILD_TYPE="$1" \ -DCMAKE_INSTALL_PREFIX="../${lc_target}/filament" \ + ${COMPILER_OPTION} \ ${EGL_ON_LINUX_OPTION} \ ${FGVIEWER_OPTION} \ ${WEBGPU_OPTION} \