From e668a0d2283263bdd815aaa4c25088798058e1ae Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Sat, 17 May 2025 21:08:49 +0100 Subject: [PATCH] Testing - Add a new compilation on Clang without PCH #540 Updated a main workflow to validate the header and more precise warnings. No PCH helps to validate missed headers. Fixed PCH issue for mac os Extend the parameters for occt build action. --- .github/actions/build-occt/action.yml | 45 ++++++++++++------- .../build-and-test-multiplatform.yml | 19 ++++++++ adm/cmake/occt_defs_flags.cmake | 20 +++++++-- 3 files changed, 64 insertions(+), 20 deletions(-) diff --git a/.github/actions/build-occt/action.yml b/.github/actions/build-occt/action.yml index f081d17f3c..468ac12bd3 100644 --- a/.github/actions/build-occt/action.yml +++ b/.github/actions/build-occt/action.yml @@ -19,6 +19,18 @@ inputs: description: 'Enable VTK' required: false default: 'true' + build-use-pch: + description: 'Enable precompiled headers' + required: false + default: 'true' + build-opt-profile: + description: 'Build optimization profile' + required: false + default: 'Production' + cmake-build-type: + description: 'CMake build type (Release, Debug, etc)' + required: false + default: 'Release' runs: using: "composite" @@ -82,10 +94,10 @@ runs: cmake -T host=x64 ` -D USE_FREETYPE=ON ` -D USE_TK=OFF ` - -D BUILD_USE_PCH=ON ` - -D BUILD_OPT_PROFILE=Production ` + -D BUILD_USE_PCH=${{ inputs.build-use-pch }} ` + -D BUILD_OPT_PROFILE=${{ inputs.build-opt-profile }} ` -D BUILD_INCLUDE_SYMLINK=ON ` - -D CMAKE_BUILD_TYPE=Release ` + -D CMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} ` -D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 ` -D INSTALL_DIR=${{ github.workspace }}/install ` -D USE_D3D=ON ` @@ -100,7 +112,8 @@ runs: -D USE_OPENGL=ON ` -D BUILD_GTEST=ON ` -D BUILD_CPP_STANDARD=C++17 ` - -D INSTALL_GTEST=ON ${{ inputs.additional-cmake-flags }} .. + -D INSTALL_GTEST=ON ` + ${{ inputs.additional-cmake-flags }} .. shell: pwsh - name: Configure OCCT (Windows Clang) @@ -113,10 +126,10 @@ runs: -D CMAKE_CXX_COMPILER=clang++ ` -D USE_FREETYPE=ON ` -D USE_TK=OFF ` - -D BUILD_USE_PCH=ON ` - -D BUILD_OPT_PROFILE=Production ` + -D BUILD_USE_PCH=${{ inputs.build-use-pch }} ` + -D BUILD_OPT_PROFILE=${{ inputs.build-opt-profile }} ` -D BUILD_INCLUDE_SYMLINK=ON ` - -D CMAKE_BUILD_TYPE=Release ` + -D CMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} ` -D 3RDPARTY_DIR=${{ github.workspace }}/3rdparty-vc14-64 ` -D INSTALL_DIR=${{ github.workspace }}/install ` -D USE_D3D=ON ` @@ -132,8 +145,7 @@ runs: -D BUILD_GTEST=ON ` -D BUILD_CPP_STANDARD=C++17 ` -D INSTALL_GTEST=ON ` - -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wno-unknown-warning-option" ` - -D CMAKE_C_FLAGS="-Werror -Wall -Wextra -Wno-unknown-warning-option" ${{ inputs.additional-cmake-flags }} .. + ${{ inputs.additional-cmake-flags }} .. shell: pwsh - name: Configure OCCT (macOS) @@ -144,9 +156,10 @@ runs: cmake -G "Unix Makefiles" \ -D CMAKE_C_COMPILER=${{ inputs.compiler == 'clang' && 'clang' || 'gcc' }} \ -D CMAKE_CXX_COMPILER=${{ inputs.compiler == 'clang' && 'clang++' || 'g++' }} \ - -D BUILD_USE_PCH=ON \ + -D BUILD_USE_PCH=${{ inputs.build-use-pch }} \ + -D BUILD_OPT_PROFILE=${{ inputs.build-opt-profile }} \ -D BUILD_INCLUDE_SYMLINK=ON \ - -D CMAKE_BUILD_TYPE=Release \ + -D CMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} \ -D INSTALL_DIR=${{ github.workspace }}/install \ -D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \ -D USE_RAPIDJSON=ON \ @@ -158,7 +171,7 @@ runs: -D BUILD_CPP_STANDARD=C++17 \ -D INSTALL_GTEST=ON \ -D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" \ - -D CMAKE_C_FLAGS="-Werror -Wall -Wextra" ${{ inputs.additional-cmake-flags }} .. + ${{ inputs.additional-cmake-flags }} .. shell: bash - name: Configure OCCT (Linux) @@ -169,11 +182,11 @@ runs: cmake -G "Unix Makefiles" \ -D CMAKE_C_COMPILER=${{ inputs.compiler == 'clang' && 'clang' || 'gcc' }} \ -D CMAKE_CXX_COMPILER=${{ inputs.compiler == 'clang' && 'clang++' || 'g++' }} \ - -D BUILD_USE_PCH=ON \ + -D BUILD_USE_PCH=${{ inputs.build-use-pch }} \ -D BUILD_INCLUDE_SYMLINK=ON \ - -D BUILD_OPT_PROFILE=Production \ + -D BUILD_OPT_PROFILE=${{ inputs.build-opt-profile }} \ -D USE_TK=OFF \ - -D CMAKE_BUILD_TYPE=Release \ + -D CMAKE_BUILD_TYPE=${{ inputs.cmake-build-type }} \ -D INSTALL_DIR=${{ github.workspace }}/install \ -D 3RDPARTY_RAPIDJSON_DIR=${{ github.workspace }}/rapidjson-858451e5b7d1c56cf8f6d58f88cf958351837e53 \ -D USE_FREETYPE=ON \ @@ -189,7 +202,7 @@ runs: -D BUILD_GTEST=ON \ -D BUILD_CPP_STANDARD=C++17 \ -D INSTALL_GTEST=ON \ - ${{ inputs.compiler == 'clang' && '-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" -D CMAKE_C_FLAGS="-Werror -Wall -Wextra"' || '' }} ${{ inputs.additional-cmake-flags }} .. + ${{ inputs.additional-cmake-flags }} .. shell: bash - name: Build OCCT (Windows) diff --git a/.github/workflows/build-and-test-multiplatform.yml b/.github/workflows/build-and-test-multiplatform.yml index 17a9474c46..ef8e16f6f6 100644 --- a/.github/workflows/build-and-test-multiplatform.yml +++ b/.github/workflows/build-and-test-multiplatform.yml @@ -122,6 +122,25 @@ jobs: compiler: clang artifact-name: install-linux-clang-x64 + prepare-and-build-macos-clang-no-pch: + name: Prepare and Build on macOS with Clang (No PCH) + runs-on: macos-15 + + steps: + - name: Checkout repository + uses: actions/checkout@v4.1.7 + + - name: Build OCCT + uses: ./.github/actions/build-occt + with: + platform: macos + compiler: clang + artifact-name: install-macos-clang-no-pch + build-use-pch: 'false' + build-opt-profile: 'Default' + additional-cmake-flags: '-D CMAKE_CXX_FLAGS="-Werror -Wall -Wextra" -D CMAKE_C_FLAGS="-Werror -Wall -Wextra"' + cmake-build-type: 'Debug' + prepare-and-build-linux-gcc-x64: name: Prepare and Build on Ubuntu with GCC (x64) runs-on: ubuntu-24.04 diff --git a/adm/cmake/occt_defs_flags.cmake b/adm/cmake/occt_defs_flags.cmake index 9802101623..5bd3313d3c 100644 --- a/adm/cmake/occt_defs_flags.cmake +++ b/adm/cmake/occt_defs_flags.cmake @@ -151,15 +151,27 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPIL # /GL (whole program optimization) is similar to -flto (Link Time Optimization) in GCC/Clang. # /GF (eliminate duplicate strings) doesn't have a direct equivalent in GCC/Clang, but the compilers do string pooling automatically. # /Gy (enable function-level linking) is similar to -ffunction-sections in GCC/Clang. - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer -flto -ffunction-sections") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fomit-frame-pointer -flto -ffunction-sections") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fomit-frame-pointer") + + # Apply LTO optimization on all platforms + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -flto") + + # Apply function sections only on non-macOS platforms + if (NOT APPLE) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffunction-sections") + endif() - # Link-Time Code Generation(LTCG) is requared for Whole Program Optimisation(GL) + # Link-Time Code Generation (LTCG) is required for Whole Program Optimization set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -flto") set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -flto") set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -flto") set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -flto") - if (NOT WIN32) + + # Add garbage collection sections only on Linux (not on macOS or Windows) + if (NOT WIN32 AND NOT APPLE) set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--gc-sections") set(CMAKE_STATIC_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} -Wl,--gc-sections") set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} -Wl,--gc-sections") -- 2.39.5