Subject: bug#78854: Cross-Compiling: ld.lld - "clang_rt.crtbegin.o is incompatible with elf32-littlearm"

From: NR <[email-masked]>
Date: Fri, 20 Jun 2025 18:27:53 -0500

```
       host-triplet:   armv6-pc-linux-gnu
       shell:          /bin/sh
       compiler:       /<pathTo>/toolchain/bin/clang
       compiler flags: -pipe --target=armv6-pc-linux-gnu
--sysroot=/<pathTo>/sysroot -mfloat-abi=soft
-Wno-unused-command-line-argument
       linker:         /<pathTo>/toolchain/bin/ld.lld (gnu? yes)
       version:        libtool (GNU libtool) 2.5.4.1-baa1-dirty
       automake:       automake (GNU automake) 1.17
       autoconf:       autoconf (GNU Autoconf) 2.72
```

For some reason, libtool isn't specifying the target for ld.lld:
ld.lld: error: /<pathTo>/toolchain/lib/clang/21/lib/x86_64-unknown-linux-gnu/clang_rt.crtbegin.o
is incompatible with elf32-littlearm

```
/bin/sh ./libtool  --tag=CC   --mode=link
/<pathTo>/toolchain/bin/clang -Wall -Wextra -Walloca
-Wbad-function-cast -Wcast-align -Wcast-qual -Wconversion -Wformat=2
-Wformat-signedness -Wmissing-declarations -Wmissing-prototypes
-Wnested-externs -Wnull-dereference -Wold-style-definition
-Wpointer-arith -Wshadow -Wstrict-overflow=2 -Wstrict-prototypes
-Wundef -Wvla -Wwrite-strings -Wpedantic -Werror -fno-plt -pipe
--target=armv6-pc-linux-gnu --sysroot=/<pathTo>/sysroot
-mfloat-abi=soft -Wno-unused-command-line-argument -version-info 2:0:1
-Wl,--version-script,./libcrypt.map -Wl,-z,defs -Wl,-z,text
-Wl,-z,relro -Wl,-z,now -pipe --target=armv6-pc-linux-gnu
--sysroot=/<pathTo>/sysroot -o libcrypt.la -rpath /usr/lib
lib/libcrypt_la-alg-des-tables.lo lib/libcrypt_la-alg-des.lo
lib/libcrypt_la-alg-gost3411-2012-core.lo
lib/libcrypt_la-alg-gost3411-2012-hmac.lo
lib/libcrypt_la-alg-hmac-sha1.lo lib/libcrypt_la-alg-md4.lo
lib/libcrypt_la-alg-md5.lo lib/libcrypt_la-alg-sha1.lo
lib/libcrypt_la-alg-sha256.lo lib/libcrypt_la-alg-sha512.lo
lib/libcrypt_la-alg-yescrypt-common.lo
lib/libcrypt_la-alg-yescrypt-opt.lo lib/libcrypt_la-crypt-bcrypt.lo
lib/libcrypt_la-crypt-des.lo lib/libcrypt_la-crypt-gensalt-static.lo
lib/libcrypt_la-crypt-gost-yescrypt.lo lib/libcrypt_la-crypt-md5.lo
lib/libcrypt_la-crypt-nthash.lo lib/libcrypt_la-crypt-pbkdf1-sha1.lo
lib/libcrypt_la-crypt-scrypt.lo lib/libcrypt_la-crypt-sha256.lo
lib/libcrypt_la-crypt-sha512.lo lib/libcrypt_la-crypt-static.lo
lib/libcrypt_la-crypt-sunmd5.lo lib/libcrypt_la-crypt-yescrypt.lo
lib/libcrypt_la-crypt.lo lib/libcrypt_la-util-base64.lo
lib/libcrypt_la-util-gensalt-sha.lo
lib/libcrypt_la-util-get-random-bytes.lo
lib/libcrypt_la-util-make-failure-token.lo
lib/libcrypt_la-util-xbzero.lo lib/libcrypt_la-util-xstrcpy.lo
lib/libcrypt_la-crypt-des-obsolete.lo
libtool: link: /<pathTo>/toolchain/bin/clang -shared  -fPIC -DPIC
lib/.libs/libcrypt_la-alg-des-tables.o lib/.libs/libcrypt_la-alg-des.o
lib/.libs/libcrypt_la-alg-gost3411-2012-core.o
lib/.libs/libcrypt_la-alg-gost3411-2012-hmac.o
lib/.libs/libcrypt_la-alg-hmac-sha1.o lib/.libs/libcrypt_la-alg-md4.o
lib/.libs/libcrypt_la-alg-md5.o lib/.libs/libcrypt_la-alg-sha1.o
lib/.libs/libcrypt_la-alg-sha256.o lib/.libs/libcrypt_la-alg-sha512.o
lib/.libs/libcrypt_la-alg-yescrypt-common.o
lib/.libs/libcrypt_la-alg-yescrypt-opt.o
lib/.libs/libcrypt_la-crypt-bcrypt.o lib/.libs/libcrypt_la-crypt-des.o
lib/.libs/libcrypt_la-crypt-gensalt-static.o
lib/.libs/libcrypt_la-crypt-gost-yescrypt.o
lib/.libs/libcrypt_la-crypt-md5.o lib/.libs/libcrypt_la-crypt-nthash.o
lib/.libs/libcrypt_la-crypt-pbkdf1-sha1.o
lib/.libs/libcrypt_la-crypt-scrypt.o
lib/.libs/libcrypt_la-crypt-sha256.o
lib/.libs/libcrypt_la-crypt-sha512.o
lib/.libs/libcrypt_la-crypt-static.o
lib/.libs/libcrypt_la-crypt-sunmd5.o
lib/.libs/libcrypt_la-crypt-yescrypt.o lib/.libs/libcrypt_la-crypt.o
lib/.libs/libcrypt_la-util-base64.o
lib/.libs/libcrypt_la-util-gensalt-sha.o
lib/.libs/libcrypt_la-util-get-random-bytes.o
lib/.libs/libcrypt_la-util-make-failure-token.o
lib/.libs/libcrypt_la-util-xbzero.o
lib/.libs/libcrypt_la-util-xstrcpy.o
lib/.libs/libcrypt_la-crypt-des-obsolete.o    -Werror
--sysroot=/<pathTo>/sysroot -mfloat-abi=soft -Wl,--version-script
-Wl,./libcrypt.map -Wl,-z -Wl,defs -Wl,-z -Wl,text -Wl,-z -Wl,relro
-Wl,-z -Wl,now --sysroot=/<pathTo>/sysroot   -Wl,-soname
-Wl,libcrypt.so.1 -o .libs/libcrypt.so.1.1.0
```

Note how `--target=armv6-pc-linux-gnu --sysroot=<...>` was set with
the first clang command, but only `--sysroot` exists with the
subsequent clang command for linking.