Skip to content

Commit

Permalink
Issue #277 - Fixes ADMB compiling on Linux arm64
Browse files Browse the repository at this point in the history
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:
+ Ubuntu running as a Docker container on a Mac with a M2 Apple processor
+ Ubuntu 20.04 running on an t4a.xlarge EC2 AWS instance with a ARM Graviton3 processor
  • Loading branch information
jonrh committed Nov 30, 2022
1 parent a65f1c9 commit e30f4cb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion contrib/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ else
ifeq (i686,$(findstring i686,$(shell $(CXX) -dumpmachine)))
OSNAME=-i686-linux
else
OSNAME=-x86_64-linux
ifeq (x86_64,$(findstring x86_64,$(shell $(CXX) -dumpmachine)))
OSNAME=-x86_64-linux
else
OSNAME=-arm64-linux
endif
endif
endif
ifeq ($(UNAME_S),Darwin)
Expand Down

0 comments on commit e30f4cb

Please sign in to comment.