[all-commits] [llvm/llvm-project] 15b65b: [Clang][LoongArch] Add initial LoongArch target an...

Lu Weining via All-commits all-commits at lists.llvm.org
Mon Aug 22 22:49:57 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 15b65bcd65195df8c9c0e84b64a1a825d9901ba6
      https://github.com/llvm/llvm-project/commit/15b65bcd65195df8c9c0e84b64a1a825d9901ba6
  Author: Weining Lu <luweining at loongson.cn>
  Date:   2022-08-23 (Tue, 23 Aug 2022)

  Changed paths:
    M clang/lib/Basic/CMakeLists.txt
    M clang/lib/Basic/Targets.cpp
    A clang/lib/Basic/Targets/LoongArch.cpp
    A clang/lib/Basic/Targets/LoongArch.h
    M clang/lib/Driver/CMakeLists.txt
    A clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
    A clang/lib/Driver/ToolChains/Arch/LoongArch.h
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/Clang.h
    M clang/lib/Driver/ToolChains/Gnu.cpp
    M clang/lib/Driver/ToolChains/Linux.cpp
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/bin/.keep
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/include/.keep
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64d/crtbegin.o
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64f/crtbegin.o
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/base/lp64s/crtbegin.o
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/lib/gcc/loongarch64-unknown-linux-gnu/12.1.0/crtbegin.o
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/bin/ld
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib/.keep
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/loongarch64-unknown-linux-gnu/lib64/.keep
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib/.keep
    A clang/test/Driver/Inputs/multilib_loongarch_linux_sdk/sysroot/usr/lib64/.keep
    M clang/test/Driver/frame-pointer.c
    A clang/test/Driver/loongarch-abi-error.c
    A clang/test/Driver/loongarch-abi.c
    A clang/test/Driver/loongarch-toolchain.c
    A clang/test/Preprocessor/init-loongarch.c

  Log Message:
  -----------
  [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




More information about the All-commits mailing list