DMTF / spdm-emu

BSD 3-Clause "New" or "Revised" License
31 stars 42 forks source link

Build error on aarch64 & GCC toolchain (maccumulate-outgoing-args, mno-red-zone) #337

Closed dhopf closed 7 months ago

dhopf commented 7 months ago

My platform NVIDIA Jetson AGX Orin Developer Kit

user@ubuntu:$ uname -a
Linux ubuntu 5.10.192-tegra #1 SMP PREEMPT Mon Feb 19 20:19:53 PST 2024 aarch64 aarch64 aarch64 GNU/Linux

user@ubuntu:$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/aarch64-linux-gnu/9/lto-wrapper
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.2' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.2)

The issue Based on the discussion in our libspdm issue (#2584) - especially the reply by @steven-bellock (https://github.com/DMTF/libspdm/issues/2584#issuecomment-1964454990) -, I issued the following commands in order to build the spdm-emu project:

user@ubuntu:$ git clone https://github.com/DMTF/spdm-emu.git
[...]
user@ubuntu:$ cd spdm-emu
user@ubuntu:~/spdm-emu$ git submodule update --init --recursive
[...]
user@ubuntu:~/spdm-emu$ mkdir build
user@ubuntu:~/spdm-emu$ cd build
user@ubuntu:~/spdm-emu/build$ cmake -DARCH=aarch64 -DTOOLCHAIN=GCC -DTARGET=Release -DCRYPTO=openssl ..
-- The C compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
#########################
## Build Configuration ##
#########################
CMAKE_GENERATOR = Unix Makefiles
ARCH = aarch64
TOOLCHAIN = GCC
GCOV = OFF
TARGET = Release
CRYPTO = openssl
ENABLE_BINARY_BUILD=0; Building openssl library from source.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/conti/spdm-emu/build
user@ubuntu:~/spdm-emu/build$ make copy_sample_key
Scanning dependencies of target copy_sample_key
Built target copy_sample_key
user@ubuntu:~/spdm-emu/build$ make
Scanning dependencies of target cryptlib_openssl
[  0%] Building C object out/cryptlib_openssl.out/CMakeFiles/cryptlib_openssl.dir/cipher/aead_aes_gcm.c.o
gcc: error: unrecognized command line option ‘-maccumulate-outgoing-args’
gcc: error: unrecognized command line option ‘-mno-red-zone’
make[2]: *** [out/cryptlib_openssl.out/CMakeFiles/cryptlib_openssl.dir/build.make:63: out/cryptlib_openssl.out/CMakeFiles/cryptlib_openssl.dir/cipher/aead_aes_gcm.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:899: out/cryptlib_openssl.out/CMakeFiles/cryptlib_openssl.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

Judging by @alistair23 's reply in that issue (https://github.com/DMTF/libspdm/issues/2584#issuecomment-1963233389), -maccumulate-outgoing-args and -mno-red-zone should not even be used for the aarch64 build!?

Is my cmake command wrong, or is that a bug? I previously used exactly the same cmake command line in my separate clone of libspdm and there the lib builds without issues.

Thanks!

steven-bellock commented 7 months ago

This is the same issue that the libspdm build flags had.