Has anyone successfully rebuilt G4 10.07.p04 on Apple Silicon?

Geant4 Version: 10.07.p04
Operating System: macOS Tahoe 26.2
Compiler/Version: Apple clang version 17.0.0 (clang-1700.6.3.2)
CMake Version: 4.2.1


I’ve upgraded my obsolete MacBook Pro (mid-2012 series, MacOS 10.15.7) to a new machine with an Apple M5 chip (macOS Tahoe). In order to continue my experiment’s migration process, I need to rebuild Geant4 10.07.p04 as well as the latest G4 11.4.0.

After regenerating the CMake configuration, I was able to successfully build 10.07.p04 with make and make install. However, when I try to link our applications against it, I get failures for all of the libraries:

ld: warning: ignoring file '/Applications/GEANT4/geant4.10.07.p04/lib/Geant4-10.7.4/Darwin-clang/libG4GMocren.dylib': found architecture 'x86_64', required architecture 'arm64'

I suspect the problem is that there’s a “–arch=x86_64” embedded somewhere in G4’s MacOS configuration, but I’m not sure where to look. I know that G4 10.07 pre-dates the new Apple chips, so I wouldn’t expect there to be explicit support, but I think if I remove the “–arch” option entirely, the build will default to the correct “arm64”, or I can do a replacement.

If Ben or someone can point me in the right direction, I should be able to figure out the details.

I’ve been trying to clean things up and make sure all my tools are correct, but there is still something very strange. I had forgotten to turn on MT previously, so I did that (i.e. -DGEANT4_BUILD_MULTITHREADED=ON). Now I can’t get past the CMake configure step!

 CMake Error at cmake/Modules/G4BuildSettings.cmake:251 (message):
   Configured compiler /usr/bin/c++ does not support thread local storage
 Call Stack (most recent call first):
   cmake/Modules/G4CMakeMain.cmake:53 (include)
   CMakeLists.txt:51 (include)

 Configuring incomplete, errors occurred!

This doesn’t make any sense to me. I’m definitely using one of the “Supported and Tested Platforms”, which means there’s something wrong with my installation. I have XCode 26.2 (matching the Tahoe version number), and I did install the XCode command line tools so I could build everything.

My CMake 4.2.1 is installed via Homebrew (/opt/homebrew/bin/cmake). Is that correct, or is this stomping on the XCode version?

So with some thrashing about, I found an entry in my 10.07.p04 CMakeCache.txt file:

{michaels-mbp:75} grep TLS CMakeCache.txt
//Test HAVE_TLS
HAVE_TLS:INTERNAL=

I tried setting that manually at the command line:

$ ccmake . -DHAVE_TLS=ON

and that eliminated the error about not supporting thread local storage. Before I claim this is a true solution, I’d like to get some feedback on whether I’m missing something.

Hi Mike, I’ve just tried myself on my (Sequoia, but clang-1700.6.3.2 and the same CMake version installed through homebrew), using the same setup apart from qt5 that you posted in Rebuilding "everything" after MacOS upgrade?, and the needed patch to g4tools.

I don’t get the misconfiguration of HAVE_TLS. The code that tests this is really just

__thread int i; int main(){return 0;}

so just to check there’s no setup issue, you could try compiling that on the command line just to check the raw compiler (/usr/bin/c++, which should be clang++ under the hood.)accepts it.

It’s just possible this is a CMake caching issue, though that should be stable across switching MT on/off.

I have no idea why it built with x86_64! You could run the build of Geant4 itself again with make VERBOSE=1 to check what -arch flag it’s adding. On mine, I do get a -arch arm64.

Happy New Year, Ben, and thanks for getting back to me!

Yup, compiles just fine. What I ended up doing for the thread issue was to set -DHAVE_TLS=ON. The arch error went away also with a clean rebuild, so I’m not sure what was going on.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.