From 54ba6cf0b10c529b14ab91361eeaabea51b4ee65 Mon Sep 17 00:00:00 2001 From: Peter Heywood Date: Thu, 20 Oct 2022 12:02:16 +0100 Subject: [PATCH 1/2] Clang warning suppressions, warning fixes and CI --- .github/workflows/Ubuntu.yml | 26 ++++++++++++++++--- README.md | 2 +- cmake/warnings.cmake | 14 ++++++++-- .../texture/Texture2D_Multisample.h | 2 ++ src/flamegpu/visualiser/ui/Overlay.h | 4 +++ 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Ubuntu.yml b/.github/workflows/Ubuntu.yml index a641305..8caba96 100644 --- a/.github/workflows/Ubuntu.yml +++ b/.github/workflows/Ubuntu.yml @@ -24,16 +24,20 @@ jobs: # optional exclude: can be partial, include: must be specific matrix: cudacxx: - - cuda: "11.7" + - cuda: "11.8" cuda_arch: "35" - hostcxx: gcc-8 - os: ubuntu-20.04 + hostcxx: gcc-10 + os: ubuntu-22.04 + - cuda: "11.8" + cuda_arch: "35" + hostcxx: clang-14 + os: ubuntu-22.04 config: - name: "Release" config: "Release" # Name the job based on matrix/env options - name: "build (${{ matrix.cudacxx.cuda }}, ${{ matrix.config.name }}, ${{ matrix.cudacxx.os }})" + name: "build (${{ matrix.cudacxx.cuda }}, ${{ matrix.cudacxx.hostcxx }}, ${{ matrix.config.name }}, ${{ matrix.cudacxx.os }})" # Define job-wide env constants, and promote matrix elements to env constants for portable steps. env: @@ -66,9 +70,23 @@ jobs: echo "CXX=/usr/bin/g++-${gcc_version}" >> $GITHUB_ENV echo "CUDAHOSTCXX=/usr/bin/g++-${gcc_version}" >> $GITHUB_ENV + - name: Install/Select clang and clang++ + if: ${{ startsWith(env.HOSTCXX, 'clang-')}} + run: | + clang=${{ env.HOSTCXX }} + clang_version=${clang/clang-/} + sudo apt-get install -y clang-${clang_version} clang-tools-${clang_version} + echo "CC=/usr/bin/clang-${clang_version}" >> $GITHUB_ENV + echo "CXX=/usr/bin/clang++-${clang_version}" >> $GITHUB_ENV + echo "CUDAHOSTCXX=/usr/bin/clang++-${clang_version}" >> $GITHUB_ENV + - name: Install Visualisation Dependencies if: ${{ startswith(env.OS, 'ubuntu') && env.VISUALISATION == 'ON' }} run: | + # Install ubuntu-22.04 packages + if [ "$OS" == 'ubuntu-22.04' ]; then + sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype-dev + fi # Install ubuntu-20.04 packages if [ "$OS" == 'ubuntu-20.04' ]; then sudo apt-get install -y libglew-dev libfontconfig1-dev libsdl2-dev libdevil-dev libfreetype-dev diff --git a/README.md b/README.md index 3ddbada..1cba606 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It is unlikely to be useful independently. + [CUDA](https://developer.nvidia.com/cuda-downloads) `>= 11.0` and a Compute Capability `>= 3.5` NVIDIA GPU. + C++17 capable C++ compiler (host), compatible with the installed CUDA version + [Microsoft Visual Studio 2019](https://visualstudio.microsoft.com/) (Windows) - + [make](https://www.gnu.org/software/make/) and [GCC](https://gcc.gnu.org/) `>= 8.1` + + [make](https://www.gnu.org/software/make/) and [GCC](https://gcc.gnu.org/) `>= 8.1` or [Clang](https://clang.llvm.org/) `>= 9` (Linux) + [git](https://git-scm.com/) + [SDL](https://www.libsdl.org/) + [GLM](http://glm.g-truc.net/) *(consistent C++/GLSL vector maths functionality)* diff --git a/cmake/warnings.cmake b/cmake/warnings.cmake index b7893dc..94279d1 100644 --- a/cmake/warnings.cmake +++ b/cmake/warnings.cmake @@ -108,8 +108,18 @@ if(NOT COMMAND flamegpu_visualiser_suppress_some_compiler_warnings) if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.6.0) target_compile_definitions(${SSCW_TARGET} PRIVATE "$<$:__CDPRT_SUPPRESS_SYNC_DEPRECATION_WARNING>") endif() - else() - # Linux specific warning suppressions + elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # Suppress unused function warnigns raised by clang on some vis headers + target_compile_options(${SSCW_TARGET} PRIVATE "$<$:SHELL:-Xcompiler -Wno-unused-function>") + target_compile_options(${SSCW_TARGET} PRIVATE "$<$:-Wno-unused-function>") + # Suppress unused-private-field warnings on Clang, which are falsely emitted in some cases where a private member is used in device code (i.e. ArrayMessage) + target_compile_options(${SSCW_TARGET} PRIVATE "$<$:SHELL:-Xcompiler -Wno-unused-private-field>") + target_compile_options(${SSCW_TARGET} PRIVATE "$<$:-Wno-unused-private-field>") + # Suppress unused-but-set-variable which triggers on some device code, clang 13+ + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0) + target_compile_options(${SSCW_TARGET} PRIVATE "$<$:SHELL:-Xcompiler -Wno-unused-but-set-variable>") + target_compile_options(${SSCW_TARGET} PRIVATE "$<$:-Wno-unused-but-set-variable>") + endif() endif() # Generic OS/host compiler warning suppressions # Ensure NVCC outputs warning numbers diff --git a/src/flamegpu/visualiser/texture/Texture2D_Multisample.h b/src/flamegpu/visualiser/texture/Texture2D_Multisample.h index 3830da1..7cf5b27 100644 --- a/src/flamegpu/visualiser/texture/Texture2D_Multisample.h +++ b/src/flamegpu/visualiser/texture/Texture2D_Multisample.h @@ -81,6 +81,8 @@ class Texture2D_Multisample : public Texture, public RenderTarget { glm::uvec2 dimensions; static const char *RAW_TEXTURE_FLAG; unsigned int samples; + // Bring the non-overriden overloaded resize method into the private scope to resolve clang -Woverloaded-virtual + using RenderTarget::resize; }; } // namespace visualiser diff --git a/src/flamegpu/visualiser/ui/Overlay.h b/src/flamegpu/visualiser/ui/Overlay.h index 17d923f..45c2c72 100644 --- a/src/flamegpu/visualiser/ui/Overlay.h +++ b/src/flamegpu/visualiser/ui/Overlay.h @@ -120,6 +120,10 @@ class OverlayGroup { * By default, if any overlay is visible true is returned */ virtual bool getVisible() const; + /** + * Virtual destructor to resolve Wdelete-non-abstract-non-virtual-dtor warning + */ + virtual ~OverlayGroup() { } }; } // namespace visualiser From b8e875208c1799916e8f2d826a05eb98ef8273ff Mon Sep 17 00:00:00 2001 From: Peter Heywood Date: Thu, 11 Jan 2024 15:59:42 +0000 Subject: [PATCH 2/2] SDL2: fix SDL2 custom target on ubuntu 20.04 for clang --- cmake/dependencies/sdl2.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/dependencies/sdl2.cmake b/cmake/dependencies/sdl2.cmake index 1002ea1..41d660d 100644 --- a/cmake/dependencies/sdl2.cmake +++ b/cmake/dependencies/sdl2.cmake @@ -11,7 +11,7 @@ if(UNIX) # Tested on ubuntu 20.04 / libsdl2-dev 2.0.10+dfsg1-3 if (NOT TARGET SDL2::SDL2) # If we have a ${libdir} from the above find_package sdl2, use that. - if(${libdir}) + if(libdir) set(SDL2_LIBDIR ${libdir}) endif() add_library(SDL2::SDL2 SHARED IMPORTED) @@ -19,7 +19,7 @@ if(UNIX) INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${SDL2_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() + endif() endif() elseif(WIN32) # On windows, always download manually. There are issues with find_package and multi-config generators where a release library will be found, but no debug library, which can break things.