To answer my own question: the crt0.o is provided by our target environment for apps using target-specific Makefiles.

For the libmbedcrypto.a crt0.o is obviously not needed but it is needed by the test programs. Using 'make CC=... AR=... lib` to build just the library was sufficient to resolve the problem.


On Tue, 27 May 2025 at 18:55, Steve Glass via mbed-tls <mbed-tls@lists.trustedfirmware.org> wrote:
Hi,

I'm trying to build the mbedtls v3.6.3 for an embedded 386 device. The build is configured as `crypto_baremetal`. In the snippet below I use the make build process with a GCC 11.2 cross toolchain that's installed in `/opt/x-tools/i386-elf but the build process ends with an error:

```
(venv) dev [ /workspaces/mbedtls ]$ make CC=/opt/x-tools/i386-elf/bin/i386-elf-gcc AR=/opt/x-tools/i386-elf/bin/i386-elf-ar
make[1]: Entering directory '/workspaces/mbedtls/library'
  CC    aes.c
  CC    aesni.c
  CC    aesce.c  
  ...
  CC    src/certs.c
  CC    src/psa_test_wrappers.c
  CC    src/test_helpers/ssl_helpers.c
make[1]: Leaving directory '/workspaces/mbedtls/tests'
make[1]: Entering directory '/workspaces/mbedtls/programs'
  CC    aes/crypt_and_hash.c
/opt/x-tools/i386-elf/lib/gcc/i386-elf/11.2.0/../../../../i386-elf/bin/ld: cannot find crt0.o: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:160: aes/crypt_and_hash] Error 1
make[1]: Leaving directory '/workspaces/mbedtls/programs'
make: *** [Makefile:34: programs] Error 2
(venv) dev [ /workspaces/mbedtls ]$  
```
So I have two questions:

This error says it fails to link find crt0.o but the output (library/libmbedcrypto.a) exists and looks ok (altho I've yet to try linking against it). Is the error message spurious or is the library it produced unusable?

Do I really need a version of crt0.o to link successfully? (The same configuration builds with no errors using the host's x64 compiler toolchain - and that toolchain also doesn't have a crt0.o file).

Thanks in advance!
--
mbed-tls mailing list -- mbed-tls@lists.trustedfirmware.org
To unsubscribe send an email to mbed-tls-leave@lists.trustedfirmware.org