]> OCCT Git - occt.git/commitdiff
Testing - Add a new compilation on Clang without PCH #540
authorPasukhin Dmitry <dpasukhi@opencascade.com>
Sat, 17 May 2025 20:08:49 +0000 (21:08 +0100)
committerGitHub <noreply@github.com>
Sat, 17 May 2025 20:08:49 +0000 (21:08 +0100)
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
.github/workflows/build-and-test-multiplatform.yml
adm/cmake/occt_defs_flags.cmake

index f081d17f3c2d2ee668c92418795535cb50965eb0..468ac12bd339f72b8030e7d1872645d19cb3128f 100644 (file)
@@ -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)
index 17a9474c4668860ba7d883884f790d1cde7e37cd..ef8e16f6f6ee86d341a13121604dd84f399d1bf5 100644 (file)
@@ -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
index 9802101623f507cc6200146dd6f1717d734c91e9..5bd3313d3c499da301523219016c34b1fb8db856 100644 (file)
@@ -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")