Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes ADMB compiling on Linux arm64 #278

Merged
merged 1 commit into from
Dec 7, 2022

Conversation

jonrh
Copy link
Contributor

@jonrh jonrh commented Nov 30, 2022

Fixes issue #277. This is a minimal change that brings the make instructions in line with admb/src/GNUMakefile and admb/scripts/admb.sh.

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
@jonrh jonrh changed the title Issue #277 - Fixes ADMB compiling on Linux arm64 Fixes ADMB compiling on Linux arm64 Nov 30, 2022
@johnoel
Copy link
Contributor

johnoel commented Dec 1, 2022

Thanks @jonrh, Can you also add the changes for admb.sh?

@jonrh
Copy link
Contributor Author

jonrh commented Dec 1, 2022

The equivalent sh/bash Linux architecture checks seem to already be in place so no change should be needed?

admb/scripts/admb:

admb/scripts/admb/admb

Lines 136 to 149 in a65f1c9

if [ "$UNAME_S" == "Linux" ]; then
if [ "$CXX" == "" ]; then
CXX=g++
fi
if [[ "`$CXX -dumpmachine`" =~ "i686" ]]; then
OS_NAME=-i686-linux
else
if [[ "`$CXX -dumpmachine`" =~ "x86_64" ]]; then
OS_NAME=-x86_64-linux
else
OS_NAME=-arm64-linux
fi
fi
fi

admb/scripts/admb.sh:

admb/scripts/admb/admb.sh

Lines 135 to 148 in a65f1c9

if [ "$UNAME_S" == "Linux" ]; then
if [ "$CXX" == "" ]; then
CXX=g++
fi
if [[ "`$CXX -dumpmachine`" =~ "i686" ]]; then
OS_NAME=-i686-linux
else
if [[ "`$CXX -dumpmachine`" =~ "x86_64" ]]; then
OS_NAME=-x86_64-linux
else
OS_NAME=-arm64-linux
fi
fi
fi

Looks like contrib/GNUMakefile just slipped through the cracks in commit 2ffa809.

@johnoel johnoel changed the base branch from main to dev-13.1 December 2, 2022 21:52
@johnoel johnoel merged commit 2f64f71 into admb-project:dev-13.1 Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants