From 23af4fa71f493f8db72ab688f818f6fe9cba6485 Mon Sep 17 00:00:00 2001 From: Fanny Zotter <83457682+fannyzotter@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:35:33 +0200 Subject: [PATCH] added clang-17 back to ubuntuClang pipeline (#334) * enforce clang in ci --------- Co-authored-by: F Zotter --- .github/workflows/testUbuntuClang.yml | 16 +++++++++++----- Intern/rayx-core/CMakeLists.txt | 5 ++++- Intern/rayx-core/src/Core.h | 8 +++++++- Intern/rayx-core/src/Tracer/DeviceConfig.h | 2 +- .../src/UserInterface/BeamlineDesignHandler.cpp | 2 +- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/workflows/testUbuntuClang.yml b/.github/workflows/testUbuntuClang.yml index 2aeef142..f037220e 100644 --- a/.github/workflows/testUbuntuClang.yml +++ b/.github/workflows/testUbuntuClang.yml @@ -23,12 +23,19 @@ jobs: wget https://apt.llvm.org/llvm.sh chmod u+x llvm.sh sudo ./llvm.sh 17 + sudo apt-get install --yes libomp-17-dev - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DWERROR=YES -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DRAYX_ENABLE_CUDA=OFF - + run: | + CC="clang-17" CXX="clang++-17" cmake -B ${{github.workspace}}/build \ + -DWERROR=YES \ + -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -DRAYX_ENABLE_CUDA=OFF \ + -DCMAKE_CXX_FLAGS="-fopenmp -Werror" \ + -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/llvm-17/lib -lomp" + - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: CXX="clang++-17 -Werror" cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} - name: Run working-directory: ${{github.workspace}} @@ -38,5 +45,4 @@ jobs: - name: Test working-directory: ${{github.workspace}}/build/bin/release - run: ./rayx-core-tst -x - + run: ./rayx-core-tst -x \ No newline at end of file diff --git a/Intern/rayx-core/CMakeLists.txt b/Intern/rayx-core/CMakeLists.txt index f5e59d61..f4b3527e 100644 --- a/Intern/rayx-core/CMakeLists.txt +++ b/Intern/rayx-core/CMakeLists.txt @@ -100,7 +100,7 @@ if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE $<$:${MSVC_CUDA_FLAGS}>) target_compile_definitions(${PROJECT_NAME} PRIVATE _CRT_SECURE_NO_WARNINGS) else() - message(STATUS "GCC") + message(STATUS "GCC or Clang") target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra) target_compile_options(${PROJECT_NAME} PRIVATE $<$:-Wpedantic>) @@ -134,7 +134,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(COMPILE_PLATFORM RAYX_PLATFORM_GCC) elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") set(COMPILE_PLATFORM RAYX_PLATFORM_MSVC) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(COMPILE_PLATFORM RAYX_PLATFORM_CLANG) else() + message(STATUS "Use undefined compiler: ${CMAKE_CXX_COMPILER_ID}") set(COMPILE_PLATFORM RAYX_PLATFORM_UNKNOWN) endif() diff --git a/Intern/rayx-core/src/Core.h b/Intern/rayx-core/src/Core.h index fdb0de1d..cb767ab4 100644 --- a/Intern/rayx-core/src/Core.h +++ b/Intern/rayx-core/src/Core.h @@ -27,13 +27,19 @@ #else #define RAYX_API #endif +#elif defined(RAYX_PLATFORM_CLANG) // Clang +#ifdef RAYX_BUILD_DLL +#define RAYX_API __attribute__((visibility("default"))) +#else +#define RAYX_API +#endif #else // do nothing and hope for the best? #ifdef RAYX_BUILD_DLL #define RAYX_API #else #define RAYX_API #endif -#pragma warning Unknown dynamic link import / export semantics. +#pragma warning Unknown dynamic link import / export semantics #endif // make string comparison available for msvc compiler diff --git a/Intern/rayx-core/src/Tracer/DeviceConfig.h b/Intern/rayx-core/src/Tracer/DeviceConfig.h index 635aad32..835d85ad 100644 --- a/Intern/rayx-core/src/Tracer/DeviceConfig.h +++ b/Intern/rayx-core/src/Tracer/DeviceConfig.h @@ -49,7 +49,7 @@ struct RAYX_API DeviceConfig { std::vector devices; private: - const DeviceType m_fetchedDeviceType; + DeviceType m_fetchedDeviceType; }; } // namespace RAYX diff --git a/Intern/rayx-ui/src/UserInterface/BeamlineDesignHandler.cpp b/Intern/rayx-ui/src/UserInterface/BeamlineDesignHandler.cpp index 1bbb7a87..652014eb 100644 --- a/Intern/rayx-ui/src/UserInterface/BeamlineDesignHandler.cpp +++ b/Intern/rayx-ui/src/UserInterface/BeamlineDesignHandler.cpp @@ -151,7 +151,7 @@ void BeamlineDesignHandler::createInputField(const std::string& key, RAYX::Desig } if (ImGui::BeginCombo("##combo", currentItem >= 0 ? RAYX::ElementStringMap[currentEl].c_str() : "")) { - int n = 0; + [[maybe_unused]] int n = 0; for (const auto& pair : RAYX::ElementStringMap) { bool isSelected = (currentEl == pair.first); if (ImGui::Selectable(pair.second.c_str(), isSelected)) {