Skip to content

Commit 5f5142f

Browse files
committed
using shared libraries for subbprojects assimp when using sanitizers, and better build.sh
1 parent 57f8cff commit 5f5142f

3 files changed

Lines changed: 75 additions & 67 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 50 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ on:
88
schedule:
99
- cron: '20 2 * * 5'
1010

11-
# default geant4 version.
12-
env:
13-
DEFAULT_CONTAINER: ghcr.io/gemc/g4install:11.4.0-ubuntu-24.04
14-
1511
jobs:
1612
analyze:
1713
name: Analyze (${{ matrix.language }})
@@ -22,7 +18,7 @@ jobs:
2218
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
2319
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
2420
# Use a container with G4 installed
25-
container: ${{ env.DEFAULT_CONTAINER }}
21+
container: ghcr.io/gemc/g4install:11.4.0-ubuntu-24.04
2622

2723
permissions:
2824
# required for all workflows
@@ -35,18 +31,16 @@ jobs:
3531
actions: read
3632
contents: read
3733

38-
39-
4034
strategy:
4135
fail-fast: false
4236
matrix:
4337
include:
44-
- language: actions
45-
build-mode: none
46-
- language: c-cpp
47-
build-mode: manual
48-
- language: python
49-
build-mode: none
38+
- language: actions
39+
build-mode: none
40+
- language: c-cpp
41+
build-mode: manual
42+
- language: python
43+
build-mode: none
5044
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift'
5145
# Use `c-cpp` to analyze code written in C, C++ or both
5246
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
@@ -58,51 +52,51 @@ jobs:
5852
# Skip this entire job if the commit was made by the merge queue bot
5953
if: github.event.head_commit.committer.name != 'github-merge-queue[bot]'
6054
steps:
61-
- name: Checkout repository
62-
uses: actions/checkout@v4
55+
- name: Checkout repository
56+
uses: actions/checkout@v4
6357

64-
# Add any setup steps before running the `GitHub/codeql-action/init` action.
65-
# This includes steps like installing compilers or runtimes (`actions/setup-node`
66-
# or others). This is typically only required for manual builds.
67-
# - name: Setup runtime (example)
68-
# uses: actions/setup-example@v1
58+
# Add any setup steps before running the `GitHub/codeql-action/init` action.
59+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
60+
# or others). This is typically only required for manual builds.
61+
# - name: Setup runtime (example)
62+
# uses: actions/setup-example@v1
6963

70-
# Initializes the CodeQL tools for scanning.
71-
- name: Initialize CodeQL
72-
uses: github/codeql-action/init@v3
73-
with:
74-
languages: ${{ matrix.language }}
75-
build-mode: ${{ matrix.build-mode }}
76-
config-file: .github/codeql_config.yml
77-
# If you wish to specify custom queries, you can do so here or in a config file.
78-
# By default, queries listed here will override any specified in a config file.
79-
# Prefix the list here with "+" to use these queries and those in the config file.
64+
# Initializes the CodeQL tools for scanning.
65+
- name: Initialize CodeQL
66+
uses: github/codeql-action/init@v3
67+
with:
68+
languages: ${{ matrix.language }}
69+
build-mode: ${{ matrix.build-mode }}
70+
config-file: .github/codeql_config.yml
71+
# If you wish to specify custom queries, you can do so here or in a config file.
72+
# By default, queries listed here will override any specified in a config file.
73+
# Prefix the list here with "+" to use these queries and those in the config file.
8074

81-
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
82-
# queries: security-extended,security-and-quality
75+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
76+
# queries: security-extended,security-and-quality
8377

84-
# If the analyze step fails for one of the languages you are analyzing with
85-
# "We were unable to automatically build your code", modify the matrix above
86-
# to set the build mode to "manual" for that language. Then modify this step
87-
# to build your code.
88-
# ℹ️ Command-line programs to run using the OS shell.
89-
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
90-
- if: matrix.build-mode == 'manual'
91-
shell: bash
92-
run: |
93-
echo "Starting manual build for CodeQL..."
94-
95-
export DOCKER_ENTRYPOINT_SOURCE_ONLY=1
96-
. /usr/local/bin/docker-entrypoint.sh
97-
module load geant4/"${{ matrix.g4v }}"
98-
99-
./ci/build.sh "${{ matrix.sanitizer }}"
100-
101-
echo "Manual build finished."
78+
# If the analyze step fails for one of the languages you are analyzing with
79+
# "We were unable to automatically build your code", modify the matrix above
80+
# to set the build mode to "manual" for that language. Then modify this step
81+
# to build your code.
82+
# ℹ️ Command-line programs to run using the OS shell.
83+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
84+
- if: matrix.build-mode == 'manual'
85+
shell: bash
86+
run: |
87+
echo "Starting manual build for CodeQL..."
88+
89+
export DOCKER_ENTRYPOINT_SOURCE_ONLY=1
90+
. /usr/local/bin/docker-entrypoint.sh
91+
module load geant4
92+
93+
./ci/build.sh
94+
95+
echo "Manual build finished."
10296
103-
- name: Perform CodeQL Analysis
104-
uses: github/codeql-action/analyze@v3
105-
env:
106-
LD_PRELOAD: "" # suppress trace‑library warning
107-
with:
108-
category: "/language:${{matrix.language}}"
97+
- name: Perform CodeQL Analysis
98+
uses: github/codeql-action/analyze@v3
99+
env:
100+
LD_PRELOAD: "" # suppress trace‑library warning
101+
with:
102+
category: "/language:${{matrix.language}}"

ci/build.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,15 @@ fi
5959
show_gemc_installation
6060

6161
# if $1 is NOT one of sanitize option, run meson test
62-
if [[ $1 != @(address|thread|undefined|leak) ]]; then
63-
echo " > Running meson test with options -C build -j 1 --print-errorlogs --no-rebuild --num-processes 1 " | tee $test_log
64-
meson test -C build -v -j 1 --print-errorlogs --no-rebuild --num-processes 1 >> $test_log
65-
echo " - Successful: $(cat $test_log | grep "Ok:" | awk '{print $2}')"
66-
echo " - Failures: $(cat $test_log | grep "Fail:" | awk '{print $2}')"
67-
echo " > Complete test log: $test_log"
68-
fi
62+
case "$1" in
63+
address|thread|undefined|leak)
64+
# sanitizer option -> do NOT run meson test
65+
;;
66+
*)
67+
echo " > Running meson test with options -C build -j 1 --print-errorlogs --no-rebuild --num-processes 1" | tee -a "$test_log"
68+
meson test -C build -v -j 1 --print-errorlogs --no-rebuild --num-processes 1 >> "$test_log"
69+
echo " - Successful: $(grep -m1 'Ok:' "$test_log" | awk '{print $2}')"
70+
echo " - Failures: $(grep -m1 'Fail:' "$test_log" | awk '{print $2}')"
71+
echo " > Complete test log: $test_log"
72+
;;
73+
esac

meson/meson.build

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if (not root_dep.found()) and (not root_opt.disabled())
4444
modules : ['ROOT::Core', 'ROOT::RIO', 'ROOT::Tree', 'ROOT::Hist'],
4545
required : false
4646
)
47-
message( 'root-config found. root_dep dependency added')
47+
message('root-config found. root_dep dependency added')
4848
else
4949
if root_opt.enabled()
5050
warning('ROOT was explicitly enabled (-Droot=enabled) but root-config was not found.')
@@ -58,11 +58,11 @@ endif
5858
# geant4.pc if not found
5959
fs = import('fs')
6060
gemc_prefix = get_option('prefix')
61-
geant4_pc_path = gemc_prefix / 'lib/pkgconfig'
61+
geant4_pc_path = gemc_prefix / 'lib/pkgconfig'
6262
geant4_pc = geant4_pc_path / 'geant4.pc'
63-
g4_pkgconfig_script = meson.project_source_root() / 'meson/g4_pkgconfig.py'
63+
g4_pkgconfig_script = meson.project_source_root() / 'meson/g4_pkgconfig.py'
6464
if not fs.exists(geant4_pc)
65-
message('geant4.pc not found in ' + geant4_pc + ', running install script to install it in ' + gemc_prefix )
65+
message('geant4.pc not found in ' + geant4_pc + ', running install script to install it in ' + gemc_prefix)
6666
run_command(g4_pkgconfig_script, gemc_prefix, check : true)
6767
endif
6868
geant4_dep = dependency('geant4', version : '>=11.3.2')
@@ -104,15 +104,24 @@ cmake_opts.add_cmake_defines({
104104
'CMAKE_POLICY_VERSION_MINIMUM' : '4.0',
105105
})
106106

107+
sanitize = get_option('b_sanitize') # string option: 'none', 'address', 'undefined', etc.
108+
109+
# only use shared libraries if a sanitizer option is passed
110+
# this will avoid duplicate symbols errors when sanitizer is used, coming from static library usage
111+
use_sharedl = (sanitize != 'none')
112+
113+
107114
if host_machine.system() == 'darwin'
108115
# there's a macro collision in Assimp’s bundled zlib on macOS.
109116
# Using system zlib is fine on macos
110117
cmake_opts.add_cmake_defines({
118+
'BUILD_SHARED_LIBS': use_sharedl,
111119
'ASSIMP_BUILD_ZLIB' : false,
112120
})
113121
else
114122
# Ubuntu: zlib is not compiled with fPic on the system. Let Assimp compile it.
115123
cmake_opts.add_cmake_defines({
124+
'BUILD_SHARED_LIBS': use_sharedl,
116125
'ASSIMP_BUILD_ZLIB' : true,
117126
})
118127
endif

0 commit comments

Comments
 (0)