xcist / main

simulation and reconstruction package
BSD 3-Clause "New" or "Revised" License
45 stars 20 forks source link

Cannot rebuild with gcc on Mac with M3 #71

Closed BwKodex closed 3 months ago

BwKodex commented 3 months ago

Trying out the package on a MacBook Pro with an M3 Max processor, I'm trying to follow the instructions in gecatsim/clib_build/readme.md.

I've installed gcc and g++ with home-brew and they are now placed under the directory /opt/homebrew/Cellar/gcc/14.1.0/bin. After replacing the paths in MakeVariables_3 and running the rebuild I get the following error

#gcc -O0 -g -Wall -static -msse -masm=intel -fPIC -c p_nlog_inline.c
/usr/local/opt/gcc/bin/gcc-14 -O0 -g -Wall -static -msse -fPIC -c p_nlog_inline.c
make: /usr/local/opt/gcc/bin/gcc-14: No such file or directory
make: *** [p_nlog_inline.o] Error 1

Is there any more information on how to make this rebuild working? I'm also wondering if there might be a bug somewhere overwriting the path to gcc and g++ specified in MakeVariables_3 since it specifies a different path to gcc-14 in the error message compared to the one I specified in MakeVariables_3?

zhangjy-ge commented 3 months ago

could you try to replace /usr/local/opt/gcc/bin/gcc-14 in Makefile to /opt/homebrew/Cellar/gcc/14.1.0/bin? This is the path to gcc on my computer, so it should be modfied accordingly.

jjobin commented 3 months ago

Typically, the homebrew process would also have created a soft link in /usr/local/bin directory. If so, you could replace the two instances in your MakeMacOS and MakeVariables_3 with this location.

BwKodex commented 3 months ago

Thanks for the quick replies!

@jjobin : In my computer homebrew did not add the symlinks. If I remember it correctly that might be a part of a new default for homebrew.

@zhangjy-ge : I tried your tip and got further. Now it tries to use the correct path for gcc, however, I get stuck on it not recognizing the option -msse. Do you know if there is something else that needs be done for that option to be available?

#gcc -O0 -g -Wall -static -msse -masm=intel -fPIC -c p_nlog_inline.c
/opt/homebrew/Cellar/gcc/14.1.0/bin/gcc-14 -O0 -g -Wall -static -msse -fPIC -c p_nlog_inline.c
gcc-14: error: unrecognized command-line option '-msse'
make: *** [p_nlog_inline.o] Error 1
jjobin commented 3 months ago

Apparently, the -msse flag is for x86 and x86-64 architectures and not for ARM, which is the case if you have M3 on Mac. You can safely remove that flag in your Makefile. Can you try that and let us know how it goes? Thanks for your patience in working through this.

BwKodex commented 3 months ago

Thank you again for your help!

Skipping that flag did the trick! However, I noticed that I also had to recompile the reconstruction/lib/fdk_equiAngle_macos.so for everything to work as expected.

What is your policy in this repo? Would you like me to add som clarifications in the respective README-files about what resolved the problem and do a PR or would you prefer to do this yourselves?

jjobin commented 3 months ago

We welcome help and contributions of any kind. If it's convenient for you, please create a new branch, add the clarifications in the README files, and open a PR against the 'master' branch. If not convenient, that's ok too. We can update the README files based on the discussion in this thread. Thanks again.

jjobin commented 3 months ago

Added some clarification to the readme files in the clib_build and the reconstruction directories. Closing this issue.