Skip to content

Commit 1fbf23d

Browse files
committed
removing m64 from root-config for arm64
1 parent c2acb2c commit 1fbf23d

2 files changed

Lines changed: 59 additions & 40 deletions

File tree

ci/build.sh

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ ls -l $compile_log
3232
ls -l $test_log
3333

3434

35-
echo " > Geant-config: $(which geant4-config) : $(geant4-config --version)" > $setup_log
36-
echo " > Root-config: $(which root-config) : $(root-config --version)" >> $setup_log
35+
echo " > Geant-config: $(which geant4-config) : $(geant4-config --version)" | tee $setup_log
36+
echo " > Root-config: $(which root-config) : $(root-config --version)" | tee -a $setup_log
3737

3838
setup_options=" --native-file=core.ini $meson_option -Dprefix=$GEMC --wipe "
3939

40-
echo " > Running build Configure with setup build options: $setup_options" >> $setup_log
40+
echo " > Running build Configure with setup build options: $setup_options" | tee -a $setup_log
4141
meson setup build $=setup_options >> $setup_log
4242
if [ $? -ne 0 ]; then
4343
echo "Build Configure failed. Log: "
@@ -48,12 +48,12 @@ else
4848
echo ; echo
4949
fi
5050

51-
echo " > Applying patch to version 0.8.0" >> $setup_log
51+
echo " > Applying patch to version 0.8.0" | tee -a $setup_log
5252
meson subprojects update yaml-cpp --reset
5353
meson setup --reconfigure build
5454

5555
cd build || exit 1
56-
echo " > Running meson compile -v -j $max_threads" > $compile_log
56+
echo " > Running meson compile -v -j $max_threads" | tee $compile_log
5757
meson compile -v -j $max_threads >> $compile_log
5858
if [ $? -ne 0 ]; then
5959
echo "Compile failed. Log: "
@@ -65,10 +65,10 @@ else
6565
fi
6666

6767

68-
echo " > Current directory: $(pwd) content:" >> $compile_log
68+
echo " > Current directory: $(pwd) content:" | tee -a $compile_log
6969
ls -l >> $compile_log
7070

71-
echo " > Running meson install" >> $compile_log
71+
echo " > Running meson install" | tee -a $compile_log
7272
meson install >> $compile_log
7373
if [ $? -ne 0 ]; then
7474
echo "Install failed. Log: "
@@ -79,31 +79,24 @@ else
7979
echo ; echo
8080
fi
8181

82-
echo " > $GEMC recursive content:" >> $compile_log
82+
echo " > $GEMC recursive content:" | tee -a $compile_log
8383
ls -lR $GEMC >> $compile_log
8484

8585
# if $1 is NOT one of sanitize option, run meson test
8686
if [[ $1 != @(address|thread|undefined|memory|leak) ]]; then
87-
echo " > Running meson test" > $test_log
87+
echo " > Running meson test" | tee $test_log
8888
meson test -j 1 --print-errorlogs --no-rebuild --num-processes 1 >> $test_log
89-
if [ $? -ne 0 ]; then
90-
echo "Test failed. Log: "
91-
cat $test_log
92-
echo Test Failure
93-
exit 1
94-
else
95-
echo Install Successful
96-
echo ; echo
97-
fi
89+
echo Successful: $(cat $test_log | grep "Ok:" | awk '{print $2}')
90+
echo Failures: $(cat $test_log | grep "Fail:" | awk '{print $2}')
9891
fi
9992

10093
echo
101-
echo " ldd of $GEMC/bin/gemc:" >> $compile_log | tee -a
94+
echo " ldd of $GEMC/bin/gemc:" | tee -a $compile_log
10295

10396
# if on unix, use ldd , if on mac, use otool -L
10497
if [[ "$(uname)" == "Darwin" ]]; then
10598
otool -L $GEMC/bin/gemc
10699
else
107-
ldd $GEMC/bin/gemc >> $compile_log | tee -a
100+
ldd $GEMC/bin/gemc | tee -a $compile_log
108101
fi
109102

meson/install_geant4_root_pkgconfig.py

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
#!/usr/bin/env python3
22
"""
3-
Generate pkgconfig (.pc) files for Geant4 and (optionally) ROOT.
3+
Generate pkg-config (.pc) files for Geant4 and (optionally) ROOT.
44
55
Usage:
6-
./generate_pc.py <installprefix>
6+
./generate_pc.py <install-prefix>
77
88
Example:
99
./generate_pc.py /opt/gemc
1010
"""
1111
import subprocess
1212
import shutil
1313
import sys
14+
import platform
1415
from pathlib import Path
1516
from typing import List, Optional
1617

1718
print(f"[debug] Python version: {sys.version}")
1819
print(f"[debug] Python executable: {sys.executable}")
19-
20+
print(f"[debug] Detected machine: {platform.machine()}")
2021

2122
# ────────────────────────── helpers ──────────────────────────
2223
def run_config(command: str, option: str) -> str:
@@ -33,19 +34,35 @@ def run_config(command: str, option: str) -> str:
3334
raise
3435

3536

37+
def is_arm64_host() -> bool:
38+
"""Return True on arm64/aarch64 hosts."""
39+
m = platform.machine().lower()
40+
return m in ("aarch64", "arm64")
41+
42+
43+
def strip_arch_unsupported_flags(flags: str) -> str:
44+
"""
45+
On arm64 hosts, remove x86-specific -m* width flags that break compiles.
46+
(Some ROOT builds on Debian/Ubuntu inject '-m64' into --cflags.)
47+
"""
48+
toks = flags.split()
49+
if is_arm64_host():
50+
toks = [t for t in toks if t not in ("-m64", "-m32")]
51+
return " ".join(toks)
52+
53+
3654
def filter_unwanted_flags(flags: str) -> str:
3755
"""Strip out Qt / CLHEP / XercesC / TreePlayer / -Wshadow flags."""
38-
unwanted = {"Qt", "qt", "CLHEP", "clhep",
39-
"xercesc", "XercesC", "TreePlayer", "-Wshadow"}
40-
return " ".join(f for f in flags.split()
41-
if not any(uw in f for uw in unwanted))
56+
unwanted = {"Qt", "qt", "CLHEP", "clhep", "xercesc", "XercesC", "TreePlayer", "-Wshadow"}
57+
return " ".join(f for f in flags.split() if not any(uw in f for uw in unwanted))
4258

4359

44-
def filter_root_flags(flags: str, root_libs: list[str]) -> str:
60+
def filter_root_flags(flags: str, root_libs: List[str]) -> str:
4561
"""Keep only -l<lib> entries matching *root_libs* plus any -L paths."""
46-
return " ".join(f for f in flags.split()
47-
if f.startswith("-L") or
48-
any(f"-l{lib}" in f for lib in root_libs))
62+
return " ".join(
63+
f for f in flags.split()
64+
if f.startswith("-L") or any(f"-l{lib}" in f for lib in root_libs)
65+
)
4966

5067

5168
def generate_pkgconfig(install_prefix: Path,
@@ -55,11 +72,15 @@ def generate_pkgconfig(install_prefix: Path,
5572
description: str,
5673
root_lbs: Optional[List[str]] = None) -> None:
5774
"""Create <install_prefix>/lib/pkgconfig/<output_filename>."""
58-
prefix = run_config(config_cmd, "--prefix")
59-
libs = filter_unwanted_flags(run_config(config_cmd, "--libs"))
60-
cflags = filter_unwanted_flags(run_config(config_cmd, "--cflags"))
75+
prefix = run_config(config_cmd, "--prefix")
76+
libs = filter_unwanted_flags(run_config(config_cmd, "--libs"))
77+
cflags = filter_unwanted_flags(run_config(config_cmd, "--cflags"))
6178
version = run_config(config_cmd, "--version")
6279

80+
# Remove x86-only width flags on arm64 hosts (applies to both cflags and libs, just in case)
81+
cflags = strip_arch_unsupported_flags(cflags)
82+
libs = strip_arch_unsupported_flags(libs)
83+
6384
if config_cmd == "root-config" and root_lbs:
6485
libs = filter_root_flags(libs, root_lbs)
6586

@@ -90,18 +111,23 @@ def check_root_config() -> bool:
90111
if __name__ == "__main__":
91112
# --- 1. parse argument ----------------------------------------------------
92113
if len(sys.argv) != 2:
93-
sys.exit(f"Usage: {sys.argv[0]} <installprefix>")
114+
sys.exit(f"Usage: {sys.argv[0]} <install-prefix>")
94115

95116
install_dir = Path(sys.argv[1]).expanduser().resolve()
96117
if not install_dir.exists():
97118
print(f"Creating installation directory {install_dir}")
98119
install_dir.mkdir(parents=True, exist_ok=True)
99120

100121
# --- 2. generate .pc files -----------------------------------------------
101-
#generate_pkgconfig(install_dir, "geant4-config",
102-
# "geant4.pc", "Geant4", "Geant4 Simulation Toolkit")
122+
# generate_pkgconfig(install_dir, "geant4-config",
123+
# "geant4.pc", "Geant4", "Geant4 Simulation Toolkit")
103124

104125
if check_root_config():
105-
generate_pkgconfig(install_dir, "root-config",
106-
"root.pc", "ROOT", "ROOT Data Analysis Framework",
107-
root_lbs=["RIO", "Tree", "Core", "root"])
126+
generate_pkgconfig(
127+
install_dir,
128+
"root-config",
129+
"root.pc",
130+
"ROOT",
131+
"ROOT Data Analysis Framework",
132+
root_lbs=["RIO", "Tree", "Core", "root"],
133+
)

0 commit comments

Comments
 (0)