admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

ADMB v13.0 can not be compiled on Linux arm64 #277

Closed jonrh closed 1 year ago

jonrh commented 1 year ago

Compiling ADMB v13.0 and the dev-13.1 branch fails on Linux (Ubuntu) running on a 64 bit ARM processor:

make contrib-libs
make[4]: Entering directory '/home/ubuntu/admb/contrib'
make --directory=ecolib CXXFLAGS= LDFLAGS= OPTION= CONTRIB_OBJS_DIR=../../build/objects-x86_64-linux-g++11
make[5]: Entering directory '/home/ubuntu/admb/contrib/ecolib'
../../admb -c  -o ../../build/objects-x86_64-linux-g++11/saflp-contrib-Gompertz.obj Gompertz.cpp
*** Compile: Gompertz.cpp
g++ -c -std=c++17 -O3 -D_USE_MATH_DEFINES -I. -I"/home/ubuntu/admb/build/admb/include" -o../../build/objects-x86_64-linux-g++11/saflp-contrib-Gompertz.obj Gompertz.cpp

Assembler messages:
Fatal error: can't create ../../build/objects-x86_64-linux-g++11/saflp-contrib-Gompertz.obj: No such file or directory
Error: Could not compile Gompertz.cpp

make[5]: *** [../admb-rules.mak:37: ../../build/objects-x86_64-linux-g++11/saflp-contrib-Gompertz.obj] Error 1
make[5]: Leaving directory '/home/ubuntu/admb/contrib/ecolib'
make[4]: *** [GNUmakefile:291: contrib-ecolib] Error 2
make[4]: Leaving directory '/home/ubuntu/admb/contrib'
make[3]: *** [GNUmakefile:162: all] Error 2
make[3]: Leaving directory '/home/ubuntu/admb/contrib'
make[2]: *** [Makefile:99: g++-contribs] Error 2
make[2]: Leaving directory '/home/ubuntu/admb'
make[1]: *** [Makefile:93: g++-dist] Error 2
make[1]: Leaving directory '/home/ubuntu/admb'
make: *** [Makefile:5: dist] Error 2

The relevant bit from that error message seems to be that ../../build/objects-x86_64-linux-g++11/saflp-contrib-Gompertz.obj does not exist. Note the incorrect architecture part of the path that reads x86_64 (64 bit Intel/AMD). In previous steps in the compilation that architecture part was correctly set to arm64. Example lines from earlier in the compilation:

g++ -c -std=c++17 -O3 -Wall -Wextra -Wconversion -Wno-unused-parameter -D_USE_MATH_DEFINES -I../build/admb/include -o ../build/objects-arm64-linux-g++11/saflp-linad99-fvar_a10.obj linad99/fvar_a10.cpp
g++ -c -std=c++17 -O3 -Wall -Wextra -Wconversion -Wno-unused-parameter -D_USE_MATH_DEFINES -I../build/admb/include -o ../build/objects-arm64-linux-g++11/saflp-linad99-fvar_a11.obj linad99/fvar_a11.cpp
g++ -c -std=c++17 -O3 -Wall -Wextra -Wconversion -Wno-unused-parameter -D_USE_MATH_DEFINES -I../build/admb/include -o ../build/objects-arm64-linux-g++11/saflp-linad99-fvar_a13.obj linad99/fvar_a13.cpp

Looks like the fault may be on lines 62-66 in the file amdb/contrib/GNUmakefile:

ifeq ($(UNAME_S),Linux)
  ifeq (i686,$(findstring i686,$(shell $(CXX) -dumpmachine)))
    OSNAME=-i686-linux
  else
    OSNAME=-x86_64-linux
  endif
endif

Here the architecture defaults to x86_64 if it is not i686 which trips up the compilation inside amdb/contrib/. ARM is not an option. For comparison in the file amdb/src/GNUmakefile the arm64 architecture is handled correctly:

ifeq ($(UNAME_S),Linux)
  ifeq (i686,$(findstring i686,$(shell $(CXX) -dumpmachine)))
    OSNAME=-i686-linux
  else
    ifeq (x86_64,$(findstring x86_64,$(shell $(CXX) -dumpmachine)))
      OSNAME=-x86_64-linux
    else
      OSNAME=-arm64-linux
    endif
  endif
endif

Tested on:

johnoel commented 1 year ago

Thank @jonrh for catching that.