To crosscompile with clang, you pass the intended target as a parameter to the compiler, e.g. clang -target aarch64-linux-gnu -o test-forarm.o test.c.
clang -target aarch64-linux-gnu -o test-forarm.o test.c
Doing that in a typical autoconf project results in commands like (s)libtool --tag=CC --mode=compile clang -target riscv64-openmandriva-linux-gnu --sysroot /usr/riscv64-openmandriva-linux-gnu -DHAVE_CONFIG_H -I. -I.. -I. -I.. -fPIC -DPIC -W -Wall -Wshadow -Wno-format-truncation -Wundef -D_GNU_SOURCE -O2 -march=rv64imafdc -mabi=lp64d -c -o test.lo test.c
(s)libtool --tag=CC --mode=compile clang -target riscv64-openmandriva-linux-gnu --sysroot /usr/riscv64-openmandriva-linux-gnu -DHAVE_CONFIG_H -I. -I.. -I. -I.. -fPIC -DPIC -W -Wall -Wshadow -Wno-format-truncation -Wundef -D_GNU_SOURCE -O2 -march=rv64imafdc -mabi=lp64d -c -o test.lo test.c
When doing this with slibtool, it complains slibtool-shared: error: -target is not a synonym for --target
slibtool-shared: error: -target is not a synonym for --target
It's true that clang -target isn't a synonym for (s)libtool --target -- instead, it is an option that should be passed to the compiler unmodified, without erroring out.
-target
--target
Hi! Looks like we missed your original posting. If you can, please join the project's irc channel: #slibtool @ oftc -- for a real-time discussion of the best way to address this. Nonetheless, here are a few options that come to mind:
I find the first option better since it's more generic, will just need to ensure that there are no undesired side effects. Any thoughts?
Fixed as of commit 80b4319. Thanks again for the catch!
Metadata Update from @midipix: - Issue status updated to: Closed (was: Open)
To complete the picture: some command-line arguments cannot simply be passed on to the compiler, which happens to be the case with -target/--target, specifically since slibtool must be able to identify the target for which it is compiling or linking.
Non-special switches, such as clan'g -save-temps, are indeed passed through without any complaints 🙂
Login to comment on this ticket.