danieljprice / phantom

Phantom Smoothed Particle Hydrodynamics and Magnetohydrodynamics code
https://phantomsph.github.io
Other
103 stars 223 forks source link

(build) fix a bunch of weird link failures with ifort on Mac OS #420

Closed danieljprice closed 1 year ago

danieljprice commented 1 year ago

Type of PR: Build failures fixed, closes #292 and #293

Description: A bunch of phantom utilities fail to compile using ifort on Mac OS, with typical errors like:

Undefined symbols for architecture x86_64:
  "_options_mp_alpha_", referenced from:
      _readwrite_dumps_fortran_mp_fill_header_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_fortran_mp_write_smalldump_fortran_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_fortran_mp_write_fulldump_fortran_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_common_mp_check_arrays_ in libphantom.a(readwrite_dumps_common.o)
  "_options_mp_alphab_", referenced from:
      _readwrite_dumps_fortran_mp_fill_header_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_fortran_mp_write_smalldump_fortran_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_fortran_mp_write_fulldump_fortran_ in libphantom.a(readwrite_dumps_fortran.o)
  "_options_mp_alphau_", referenced from:
      _readwrite_dumps_fortran_mp_fill_header_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_fortran_mp_write_smalldump_fortran_ in libphantom.a(readwrite_dumps_fortran.o)
      _readwrite_dumps_fortran_mp_write_fulldump_fortran_ in libphantom.a(readwrite_dumps_fortran.o)

this is a weird failure as these .o files are clearly present in the library being linked. It is ONLY an issue with ifort and ONLY on a Mac, possibly due to some conflict with the linker being used?

the workaround in any case is to add the relevant .o files explicitly in the object file list for the utilities being linked. This is rather ugly but better than the build failing. It also seems random which .o files need to be added

Testing (on an intel Mac):

export SYSTEM=ifort
export SETUP=test
make setup
make analysis
make moddump
make utils

Did you run the bots? no

Did you update relevant documentation in the docs directory? no