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

Build Error cmake/GCC #2584

Open
marinuswhite opened this issue Feb 22, 2024 · 11 comments
Open

Build Error cmake/GCC #2584

marinuswhite opened this issue Feb 22, 2024 · 11 comments
Assignees
Labels
build Build system documentation Improvements or additions to documentation

Comments

@marinuswhite
Copy link

Hello,

I'd like to test SPDM on a Nvidia Jetzson Orin (ARM 64, native Ubuntu).

I followed the instruction steps

  • Cloned the Repository with Sub-modules

  • installed GCC/ARM GNU bare metal as Compiler

  • went into the folders

  • made the build folder

  • tried "cmake -DARCH=(both aarch64/arm) -DTOOLCHAIN=ARM_GNU -DTARGET=Release -DCRYPTO=mbedtls .."
    => "unkown toolchain" , (installed ARM_GNU successfully following the Instructions)

  • tried GCC as Toolchain
    => worked

  • made the sample key

  • then "make"

=>
gcc: error: unrecognized command line option ‘-maccumulate-outgoing-args’
gcc: error: unrecognized command line option ‘-mno-red-zone’
make[2]: *** [out/cryptlib_mbedtls.out/CMakeFiles/cryptlib_mbedtls.dir/build.make:63: out/cryptlib_mbedtls.out/CMakeFiles/cryptlib_mbedtls.dir/cipher/aead_aes_gcm.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:922: out/cryptlib_mbedtls.out/CMakeFiles/cryptlib_mbedtls.dir/all] Error 2
make: *** [Makefile:130: all] Error 2

Tried it several times with different settings, always ends there

May I have overseen something?

Thank you!

@steven-bellock
Copy link
Contributor

@twilfredo or @alistair23 might know. I can look at it more when I get access to an Orin system.

@steven-bellock steven-bellock added the build Build system label Feb 22, 2024
@twilfredo
Copy link
Contributor

I haven't come across this before, but those options ( -maccumulate-outgoing-args & mno-red-zone) don't seem to be specified for aarch64?

@marinuswhite
Copy link
Author

I tried both arm and aarch64, both ended with the mentioned error

@alistair23
Copy link
Contributor

no-red-zone is only added for x86 and accumulate-outgoing-args is similar (x64 or ia32), so you are building for the wrong architecture.

How did you install ARM_GNU? Are you able to provide the full logs from cmake and make?

@dhopf
Copy link

dhopf commented Feb 26, 2024

@alistair23 (I'm a colleague of @marinuswhite)
I think we didn't specifically install something in addition on the NVIDIA Orin. Since the Orin is an arm64 (or - as far as I understood - alternatively named aarch64) architecture, we assumed the standard toolchain should be the arm one compiling for that target architecture.
I'm not at the device currently, but I can look into providing you with the output later this week.

@steven-bellock
Copy link
Contributor

If this is Linux on native aarch64 then you'd use

cmake -DARCH=aarch64 -DTOOLCHAIN=GCC -DTARGET=Release -DCRYPTO=mbedtls ..

@dhopf
Copy link

dhopf commented Feb 28, 2024

Thanks @steven-bellock, that helped greatly.

This combination unfortunately is not described in build.md.
"Build Tools for Linux" in fact states subitem e) with
AARCH64 GCC for AARCH64 only

sudo apt-get install gcc-aarch64-linux-gnu
but in the subsequent "Linux Builds for ARM/AARCH64" section, there is no mention of
For ARM GCC build (aarch64) on Linux
I may create a pull request for that after we verified the correct workflow.

Regarding the actual build

It seems it almost worked. At the end however, I get the following linker error - full logfile (I used openssl als crypto lib, but I hope this shouldn't matter):

Scanning dependencies of target test_size_of_spdm_requester
[ 99%] Building C object unit_test/test_size/test_size_of_spdm_r
[build-output-libspdm.log](https://github.com/DMTF/libspdm/files/14430330/build-output-libspdm.log)
equester/CMakeFiles/test_size_of_spdm_requester.dir/spdm_requester_authentication.c.o
[ 99%] Building C object unit_test/test_size/test_size_of_spdm_requester/CMakeFiles/test_size_of_spdm_requester.dir/spdm_requester_init.c.o
[ 99%] Building C object unit_test/test_size/test_size_of_spdm_requester/CMakeFiles/test_size_of_spdm_requester.dir/spdm_requester_main.c.o
[ 99%] Building C object unit_test/test_size/test_size_of_spdm_requester/CMakeFiles/test_size_of_spdm_requester.dir/spdm_requester_session.c.o
[ 99%] Building C object unit_test/test_size/test_size_of_spdm_requester/CMakeFiles/test_size_of_spdm_requester.dir/support.c.o
[ 99%] Linking C executable ../../../bin/test_size_of_spdm_requester
/usr/bin/ld: /usr/lib/gcc/aarch64-linux-gnu/9/../../../aarch64-linux-gnu/crt1.o: in function `__wrap_main':
(.text+0x38): undefined reference to `main'
collect2: error: ld returned 1 exit status
make[2]: *** [unit_test/test_size/test_size_of_spdm_requester/CMakeFiles/test_size_of_spdm_requester.dir/build.make:156: bin/test_size_of_spdm_requester] Error 1
make[1]: *** [CMakeFiles/Makefile2:5342: unit_test/test_size/test_size_of_spdm_requester/CMakeFiles/test_size_of_spdm_requester.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
-(user@user-orin1:0)-(9 files:120K@build)-(0 jobs)-(08:18)-
-(~/libspdm/build:$)-> 

I didn't check yet if the other executables work fine - those apparently compiled & linked without errors.

@steven-bellock
Copy link
Contributor

See #612 for discussion on build parameters and native / cross compilation. Also, https://github.blog/changelog/2023-10-30-accelerate-your-ci-cd-with-arm-based-hosted-runners-in-github-actions/ may come to free GitHub users so we can add that to CI/CD.

I'll file an issue for the test_size_of_ build error. The other tests will run fine.

@dhopf
Copy link

dhopf commented Feb 29, 2024

I can confirm that I successfully built it on my NVIDIA Jetson AGX Orin Developer Kit.
Inside the created build directory, I issued:

cmake -DARCH=aarch64 -DTOOLCHAIN=GCC -DTARGET=Release -DCRYPTO=openssl ..
make copy_sample_key
make -j12

Thanks @steven-bellock for the swift fixing!

@jyao1
Copy link
Member

jyao1 commented Mar 7, 2024

Is there anything for this issue?
Can we close this one?

@steven-bellock
Copy link
Contributor

The build documentation needs to be clarified, as it is focused on cross-compilation. I can update that.

@steven-bellock steven-bellock self-assigned this Mar 7, 2024
@steven-bellock steven-bellock added the documentation Improvements or additions to documentation label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

6 participants