rjones30 / HDGeant4

Geant4 simulation for the GlueX experiment
1 stars 8 forks source link

Davidl osx #11

Closed faustus123 closed 7 years ago

faustus123 commented 7 years ago

Here is the e-mail I originally sent to Richard on 4/11/2017 describing the changes in this branch:


Hi Richard,

I spent a little time getting HDGeant4 to compile and run on Mac OS X. This required several changes which I summarize below. I pushed the revisions to a branch named “davidl_OSX” in the JeffersonLab/HDGeant4 repository. I did not make an official pull request since I thought you might want to take some time to review the changes and perhaps integrate the OS X parts in a different way. The GNUmakefile in particular.

I was able to compile and run hdgeant4 with the built-in particle gun generator and it produced an hddm file which had something in it. I have not gone as far as checking the content in any detail but expect that I have gotten past the biggest hurdles.

I did this using Mac OS X 10.11 (El Capitan) which is one version behind the latest Mac OS X. I also used the native compiler that comes with Xcode8. To get this to work though I had to move up to Geant4 10.03.p01 (see below).

Here is a summary of the changes:

  1. Created a separate GNUmakefile.OSX . Your original has several of ELF/Linux specific things in it. Pretty much anything using -Wl to pass special arguments to the linker will not be portable. There weren’t too many changes, but enough that I wanted to let you decide how best to integrate them. It’s possible we could just leave this as a separate makefile for OS X.

  2. Disabled use of clock_gettime(CLOCK_THREAD_CPUTIME_ID, …) if CLOCK_THREAD_CPUTIME_ID is not defined. Apparently this is present in the latest OS X (10.12) so I did it in such a way that if CLOCK_THREAD_CPUTIME_ID is defined, then it will compile as you wrote it. Otherwise, it will compile it such that the assert will fail if that code is ever called.

  3. Replaced #include with #include which is apparently more generic. OS X does not have malloc.h

  4. Added a G4.10.03.p01fixes directory. I went to some trouble here to diff your fixes files with the source from 10.02.p02 so I could see where you made the changes and then insert them into the same files copied from the 10.03.p01 source. I believe these should be useful for compiling on Linux as well. It was require for me though since I had to move up to 10.03.p01.

  5. Added G4MTHepRandom.cc to the fixes directory. This was needed to resolve a strange run time link error for G4MTHepRandom::getTheTableSeeds(long*, int). There is an extensive comment at the top of the file. The bottom line though is that the meat of the file is only compiled if APPLE is defined so this shouldn’t affect other platforms.

  6. Replaced “theParticleIterator” with “GetParticleIterator()” in GlueXPhysicsList.cc. This looks to be a change from 10.02 to 10.03 so something more clever may need to be done if both versions are to be simultaneously supported.

  7. Added a README.OSX file. This is by no means exhaustive but wanted to document a few tricks for others trying to get this running on OS X.

That’s it for now. I will be working off of this branch for the time being so if I come up with other changes, I’ll let you know where I put them so you can merge them at your own pace.

Regards, -David