llvm-project/clang/test/Driver/loongarch-abi-error.c
Weining Lu 15b65bcd65 [Clang][LoongArch] Add initial LoongArch target and driver support
With the initial support added, clang can compile `helloworld` C
to executable file for loongarch64. For example:

```
$ cat hello.c
int main() {
  printf("Hello, world!\n");
  return 0;
}
$ clang --target=loongarch64-unknown-linux-gnu --gcc-toolchain=xxx --sysroot=xxx hello.c
```

The output a.out can run within qemu or native machine. For example:

```
$ file ./a.out
./a.out: ELF 64-bit LSB pie executable, LoongArch, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-loongarch-lp64d.so.1, for GNU/Linux 5.19.0, with debug_info, not stripped
$ ./a.out
Hello, world!
```

Currently gcc toolchain and sysroot can be found here:
https://github.com/loongson/build-tools/releases/download/2022.08.11/loongarch64-clfs-5.1-cross-tools-gcc-glibc.tar.xz

Reference: https://github.com/loongson/LoongArch-Documentation
The last commit hash (main branch) is:
99016636af64d02dee05e39974d4c1e55875c45b

Note loongarch32 is not fully tested because there is no reference
gcc toolchain yet.

Differential Revision: https://reviews.llvm.org/D130255
2022-08-23 13:47:22 +08:00

22 lines
1.2 KiB
C

// RUN: not %clang --target=loongarch32-unknown-elf %s -fsyntax-only -mabi=lp64s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA32-LP64S %s
// RUN: not %clang --target=loongarch32-unknown-elf %s -fsyntax-only -mabi=lp64f 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA32-LP64F %s
// RUN: not %clang --target=loongarch32-unknown-elf %s -fsyntax-only -mabi=lp64d 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA32-LP64D %s
// RUN: not %clang --target=loongarch64-unknown-elf %s -fsyntax-only -mabi=ilp32s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA64-ILP32S %s
// RUN: not %clang --target=loongarch64-unknown-elf %s -fsyntax-only -mabi=ilp32f 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA64-ILP32F %s
// RUN: not %clang --target=loongarch64-unknown-elf %s -fsyntax-only -mabi=ilp32d 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-LA64-ILP32D %s
// CHECK-LA32-LP64S: error: unknown target ABI 'lp64s'
// CHECK-LA32-LP64F: error: unknown target ABI 'lp64f'
// CHECK-LA32-LP64D: error: unknown target ABI 'lp64d'
// CHECK-LA64-ILP32S: error: unknown target ABI 'ilp32s'
// CHECK-LA64-ILP32F: error: unknown target ABI 'ilp32f'
// CHECK-LA64-ILP32D: error: unknown target ABI 'ilp32d'