Open
Description
For complicated reasons I'm building a single binary that has some .cc files compiled with -march=armv8.2-a+dotprod
and some with -mthumb
. If ThinLTO is applied to all files, everything's fine. However, if I mix in some pre-compiled -mthumb
files and link again, I get a "linking two modules of different target triples" error. Minimal reproducer:
#!/bin/bash
CLANG=clang
cat > dotprod.c <<- EndOfTestFile
int test_func() {
return 0;
}
EndOfTestFile
cat > test.c <<- EndOfTestFile
extern int test_func();
int main(int argc, char **argv) {
return test_func();
}
EndOfTestFile
$CLANG -flto=thin -c -o dotprod.o -target armv8.2-unknown-linux-android26 -march=armv8.2-a+dotprod dotprod.c
$CLANG -c -o test.o -emit-llvm -target armv7-unknown-linux-android26 -mthumb test.c
$CLANG -shared -nostdlib -fuse-ld=lld -Wl,--fatal-warnings -fPIC --target=arm-linux-androideabi26 dotprod.o test.o -shared -o test1.so
And the output:
ld.lld: error: Linking two modules of different target triples: 'test.o' is 'thumbv7-unknown-linux-android26' whereas 'ld-temp.o' is 'armv8.2a-unknown-linux-android26'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I think however that this should be fine - dotprod is an optional extension in AArch32 Armv8.2 and it's usually OK to mix different Arm architecture versions together. Could the TargetTriple::isCompatibleWith method be adjusted?