Issue 137219
Summary [lld][ThinLTO][Arm] Spurious (?) "linking two modules of different target triples" when mixing Thumb and Armv8.2
Labels lld
Assignees
Reporter Sentimentron
    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:

```sh
#!/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?
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to