Skip to content

Commit a4646af

Browse files
committed
fix for the apply of the HWLOC security patch
1 parent 57e8199 commit a4646af

File tree

2 files changed

+135
-16
lines changed

2 files changed

+135
-16
lines changed

.github/workflows/reusable_codeql.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# CodeQL static analysis
2+
name: CodeQL
3+
4+
on: workflow_call
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
BUILD_DIR : "${{github.workspace}}/build"
11+
INSTL_DIR : "${{github.workspace}}/../install-dir"
12+
13+
jobs:
14+
analyze:
15+
name: Analyze
16+
permissions:
17+
security-events: write
18+
env:
19+
VCPKG_PATH: "${{github.workspace}}/build/vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/build/vcpkg/packages/tbb_x64-windows;${{github.workspace}}/build/vcpkg/packages/jemalloc_x64-windows"
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
os: [windows-latest]
24+
25+
# TODO revert
26+
runs-on: ["codeql-test", "Windows"]
27+
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
31+
with:
32+
fetch-depth: 0
33+
34+
- name: aaa
35+
if: matrix.os == 'windows-latest'
36+
run: echo $env:path
37+
shell: pwsh
38+
39+
- name: Check for Python >= 3.10
40+
id: check_python
41+
run: |
42+
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
43+
if ($pythonCommand) {
44+
$pythonVersion = python --version 2>&1
45+
$versionPattern = 'Python (\d+)\.(\d+)\.(\d+)'
46+
echo $pythonVersion
47+
if ($pythonVersion -match $versionPattern) {
48+
$major = [int]$matches[1]
49+
$minor = [int]$matches[2]
50+
if ($major -gt 3 -or ($major -eq 3 -and $minor -ge 10)) {
51+
echo "##[set-output name=python_exists;]true"
52+
}
53+
}
54+
}
55+
shell: pwsh
56+
57+
- name: Setup Python 3.10
58+
if: steps.check_python.outputs.python_exists != 'true'
59+
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
60+
with:
61+
python-version: "3.10"
62+
63+
- name: Initialize CodeQL
64+
uses: github/codeql-action/init@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2
65+
with:
66+
languages: cpp
67+
68+
- name: "[Win] Initialize vcpkg"
69+
if: matrix.os == 'windows-latest'
70+
uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5
71+
with:
72+
vcpkgGitCommitId: 3dd44b931481d7a8e9ba412621fa810232b66289
73+
vcpkgDirectory: ${{env.BUILD_DIR}}/vcpkg
74+
vcpkgJsonGlob: '**/vcpkg.json'
75+
76+
- name: "[Win] Install dependencies"
77+
if: matrix.os == 'windows-latest'
78+
run: |
79+
vcpkg install
80+
echo $env:path
81+
python3 -m pip install -r third_party/requirements.txt
82+
shell: pwsh
83+
84+
- name: "[Lin] Install apt packages"
85+
if: matrix.os == 'ubuntu-latest'
86+
run: |
87+
sudo apt-get update
88+
sudo apt-get install -y cmake clang libhwloc-dev libnuma-dev libjemalloc-dev libtbb-dev
89+
90+
# Latest distros do not allow global pip installation
91+
- name: "[Lin] Install Python requirements in venv"
92+
if: matrix.os == 'ubuntu-latest'
93+
run: |
94+
python3 -m venv .venv
95+
. .venv/bin/activate
96+
echo "$PATH" >> $GITHUB_PATH
97+
python3 -m pip install -r third_party/requirements.txt
98+
99+
- name: Configure CMake
100+
run: >
101+
cmake
102+
-B ${{env.BUILD_DIR}}
103+
${{matrix.extra_build_option}}
104+
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
105+
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
106+
-DUMF_FORMAT_CODE_STYLE=OFF
107+
-DUMF_DEVELOPER_MODE=ON
108+
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
109+
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
110+
-DUMF_BUILD_CUDA_PROVIDER=ON
111+
-DUMF_TESTS_FAIL_ON_SKIP=ON
112+
113+
- name: Build
114+
run: cmake --build ${{env.BUILD_DIR}} --config Release -j
115+
116+
- name: Perform CodeQL Analysis
117+
uses: github/codeql-action/analyze@b7bf0a3ed3ecfa44160715d7c442788f65f0f923 # v3.23.2

CMakeLists.txt

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,14 @@ elseif(WINDOWS AND NOT UMF_DISABLE_HWLOC)
131131
set(HWLOC_ENABLE_TESTING OFF)
132132
set(HWLOC_SKIP_LSTOPO ON)
133133
set(HWLOC_SKIP_TOOLS ON)
134-
set(HWLOC_PATCH
135-
git
136-
apply
137-
${PROJECT_SOURCE_DIR}/cmake/fix_coverity_issues.patch
138-
||
139-
(exit 0))
140134

141135
message(STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO}")
142136

143137
FetchContent_Declare(
144138
hwloc_targ
145139
GIT_REPOSITORY ${UMF_HWLOC_REPO}
146140
GIT_TAG ${UMF_HWLOC_TAG}
147-
PATCH_COMMAND ${HWLOC_PATCH} SOURCE_SUBDIR contrib/windows-cmake/
148-
FIND_PACKAGE_ARGS)
141+
SOURCE_SUBDIR contrib/windows-cmake/ FIND_PACKAGE_ARGS)
149142

150143
FetchContent_GetProperties(hwloc_targ)
151144
if(NOT hwloc_targ_POPULATED)
@@ -162,20 +155,13 @@ elseif(WINDOWS AND NOT UMF_DISABLE_HWLOC)
162155
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
163156
elseif(NOT UMF_DISABLE_HWLOC)
164157
include(FetchContent)
165-
set(HWLOC_PATCH
166-
git
167-
apply
168-
${PROJECT_SOURCE_DIR}/cmake/fix_coverity_issues.patch
169-
||
170-
(exit 0))
171158

172159
message(STATUS "Will fetch hwloc from ${UMF_HWLOC_REPO}")
173160

174161
FetchContent_Declare(
175162
hwloc_targ
176163
GIT_REPOSITORY ${UMF_HWLOC_REPO}
177-
GIT_TAG ${UMF_HWLOC_TAG}
178-
PATCH_COMMAND ${HWLOC_PATCH})
164+
GIT_TAG ${UMF_HWLOC_TAG})
179165

180166
FetchContent_GetProperties(hwloc_targ)
181167
if(NOT hwloc_targ_POPULATED)
@@ -222,6 +208,22 @@ elseif(NOT UMF_DISABLE_HWLOC)
222208
message(STATUS " LIBHWLOC_LIBRARY_DIRS = ${LIBHWLOC_LIBRARY_DIRS}")
223209
endif()
224210

211+
if(hwloc_targ_SOURCE_DIR)
212+
# apply security patch for HWLOC
213+
execute_process(
214+
COMMAND git apply ${PROJECT_SOURCE_DIR}/cmake/fix_coverity_issues.patch
215+
WORKING_DIRECTORY ${hwloc_targ_SOURCE_DIR}
216+
OUTPUT_VARIABLE UMF_HWLOC_PATCH_OUTPUT
217+
ERROR_VARIABLE UMF_HWLOC_PATCH_ERROR)
218+
219+
if(UMF_HWLOC_PATCH_OUTPUT)
220+
message(STATUS "HWLOC patch command output:\n${UMF_HWLOC_PATCH_OUTPUT}")
221+
endif()
222+
if(UMF_HWLOC_PATCH_ERROR)
223+
message(WARNING "HWLOC patch command output:\n${UMF_HWLOC_PATCH_ERROR}")
224+
endif()
225+
endif()
226+
225227
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
226228
# set, because in this case the build type is determined after a CMake
227229
# configuration is done (at the build time)

0 commit comments

Comments
 (0)