Topic: Building wolfcrypt with clang 13 for a cross ARM/thumb target

Could anyone advise how to configure to build wolfcrypt using clang (version 13) for an ARM/thumb target machine please?

The clang target triple is "thumbv7em-none-eabihf", but where do I specify that so it gets passed to clang's "--target" argument?

My host machine is 64-bit Ubuntu Linux.

Many thanks,
Rod

Share

Re: Building wolfcrypt with clang 13 for a cross ARM/thumb target

Hello Rod,

Please review the section on cross compiling in the wolfSSL User Manual:
https://www.wolfssl.com/docs/wolfssl-ma … users%20on

Let us know if there are questions.

Re: Building wolfcrypt with clang 13 for a cross ARM/thumb target

I checked that manual and didn't really understand what I need to do.

Do I need to set CC to "clang" or "clang --target=thumb7em-none-eabihf"

and so I need to set --host and/or --target on the ./configure command?

I have tried several of these combinations with no luck. It either just fails to configure,
or it configures, builds but always produces x86_64 binaries...

Thanks,
  Rod

Share

Re: Building wolfcrypt with clang 13 for a cross ARM/thumb target

GENERIC EXAMPLE:

./configure \
CC="/path/to/your/toolchain/toolchain-gcc" \
AR="/path/to/your/toolchain/toolchain-ar" \
AS="/path/to/your/toolchain/toolchain-gcc" \
RANLIB="/path/to/your/toolchain/toolchain-ranlib" \
LD="/path/to/your/toolchain/toolchain-ld" \
--host=<your host> \
--target=<your target> \
<your other configure options here> \
CFLAGS="-mcpu=<your cpu definition here> \
<other cflags here>" \
LIBS="<libs>"

SPECIFIC EXAMPLE:

./configure \
CC="/usr/local/gcc_arm/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc" \
AR="/usr/local/gcc_arm/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-ar" \
AS="/usr/local/gcc_arm/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-gcc" \
RANLIB="/usr/local/gcc_arm/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-ranlib" \
LD="/usr/local/gcc_arm/gcc-arm-none-eabi-7-2017-q4-major/bin/arm-none-eabi-ld" \
--host=arm-none-eabi \
--enable-aesgcm --enable-ecc \
CFLAGS="-mcpu=cortex-m4 \
-Os -specs=rdimon.specs"  \
LIBS="-Wl,--start-group -lm -lgcc -lc -lrdimon -Wl,--end-group"

Re: Building wolfcrypt with clang 13 for a cross ARM/thumb target

Ok... I tried:

./configure \
CC="clang" \
AR="llvm-ar" \
AS="llvm-as" \
RANLIB="llvm-ranlib" \
LD="llvm-link" \
--enable-ecc \
CFLAGS="-O1 --target=thumbv7em-none-eabihf"
LIBS=""

and got:

checking for gcc... clang
checking whether the C compiler works... no
configure: error: in `/home/rchapman/prog/wolfssl-5.1.1-commercial':
configure: error: C compiler cannot create executables
See `config.log' for more details

The specific error in config.log is

configure:3930: clang -O1 --target=thumbv7em-none-eabihf     conftest.c  >&5
clang: error: unable to execute command: Executable "ld.lld" doesn't exist!
clang: error: ld.lld command failed with exit code 1 (use -v to see invocation)

Share

6 (edited by rodders 2022-01-11 14:38:44)

Re: Building wolfcrypt with clang 13 for a cross ARM/thumb target

I'm making more progress now. I eventually realised that configure's "--host" option is incredibly confusing - it really means "the target that we're compiling this tool or library for..." It only really makes sense if you're configuring to build a compiler, not a library like wolfcrypt...

Share