[clang] [Clang][Driver][AArch64] Add support for aarch64-amazon-linux triple (PR #109263)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 19 03:38:17 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-driver
Author: Peter Waller (peterwaller-arm)
<details>
<summary>Changes</summary>
I note that the comment nearby says "They are not needed when the user has
correct LLVM_DEFAULT_TARGET_TRIPLE" and "The lists should shrink over time".
The behviour was diverged between X86 and aarch64: prior to this patch,
a standard clang with no configuration works on x86 but not aarch64
amazon linux; the latter fails to find C++ headers and libraries.
---
Full diff: https://github.com/llvm/llvm-project/pull/109263.diff
5 Files Affected:
- (modified) clang/lib/Driver/ToolChains/Gnu.cpp (+2-1)
- (added) clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtbegin.o ()
- (added) clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtbeginT.o ()
- (added) clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtend.o ()
- (modified) clang/test/Driver/linux-ld.c (+31-14)
``````````diff
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 603d0468dd3f3c..f075ed0b35b6c5 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2470,7 +2470,8 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
// lists should shrink over time. Please don't add more elements to *Triples.
static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const AArch64Triples[] = {
- "aarch64-none-linux-gnu", "aarch64-redhat-linux", "aarch64-suse-linux"};
+ "aarch64-none-linux-gnu", "aarch64-redhat-linux", "aarch64-suse-linux",
+ "aarch64-amazon-linux"};
static const char *const AArch64beLibDirs[] = {"/lib"};
static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu"};
diff --git a/clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtbegin.o b/clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtbeginT.o b/clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtbeginT.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtend.o b/clang/test/Driver/Inputs/ami_linux_tree/usr/lib/gcc/aarch64-amazon-linux/7/crtend.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 28fb075a80dbbc..3f775cc7b1003b 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1705,23 +1705,40 @@
// CHECK-LD-RHEL7-DTS-NOT: /usr/bin/ld
// CHECK-LD-RHEL7-DTS: [[SYSROOT]]/usr/lib/gcc/x86_64-redhat-linux/7/../../../../bin/ld
-// Check whether gcc7 install works fine on Amazon Linux AMI
+// Check whether gcc7 install works fine on Amazon Linux AMI targeting x86_64
// RUN: %clang -### %s -Werror -no-pie 2>&1 \
// RUN: --target=x86_64-amazon-linux -rtlib=libgcc --unwindlib=platform \
// RUN: --sysroot=%S/Inputs/ami_linux_tree \
-// RUN: | FileCheck --check-prefix=CHECK-LD-AMI %s
-// CHECK-LD-AMI: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-LD-AMI: "--eh-frame-hdr"
-// CHECK-LD-AMI: "-m" "elf_x86_64"
-// CHECK-LD-AMI: "-dynamic-linker"
-// CHECK-LD-AMI: "{{.*}}/usr/lib/gcc/x86_64-amazon-linux/7{{/|\\\\}}crtbegin.o"
-// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7"
-// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7/../../../../lib64"
-// CHECK-LD-AMI: "-L[[SYSROOT]]/lib"
-// CHECK-LD-AMI: "-L[[SYSROOT]]/usr/lib"
-// CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
-// CHECK-LD-AMI: "-lc"
-// CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// RUN: | FileCheck --check-prefix=CHECK-LD-AMI-X86_64 %s
+// CHECK-LD-AMI-X86_64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-AMI-X86_64: "--eh-frame-hdr"
+// CHECK-LD-AMI-X86_64: "-m" "elf_x86_64"
+// CHECK-LD-AMI-X86_64: "-dynamic-linker"
+// CHECK-LD-AMI-X86_64: "{{.*}}/usr/lib/gcc/x86_64-amazon-linux/7{{/|\\\\}}crtbegin.o"
+// CHECK-LD-AMI-X86_64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7"
+// CHECK-LD-AMI-X86_64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-amazon-linux/7/../../../../lib64"
+// CHECK-LD-AMI-X86_64: "-L[[SYSROOT]]/lib"
+// CHECK-LD-AMI-X86_64: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-AMI-X86_64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-LD-AMI-X86_64: "-lc"
+// CHECK-LD-AMI-X86_64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+
+// Check whether gcc7 install works fine on Amazon Linux AMI targeting aarch64
+// RUN: %clang -### %s -Werror -no-pie 2>&1 \
+// RUN: --target=aarch64-amazon-linux -rtlib=libgcc --unwindlib=platform \
+// RUN: --sysroot=%S/Inputs/ami_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-LD-AMI-AARCH64 %s
+// CHECK-LD-AMI-AARCH64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-LD-AMI-AARCH64: "--eh-frame-hdr"
+// CHECK-LD-AMI-AARCH64: "-dynamic-linker"
+// CHECK-LD-AMI-AARCH64: "{{.*}}/usr/lib/gcc/aarch64-amazon-linux/7{{/|\\\\}}crtbegin.o"
+// CHECK-LD-AMI-AARCH64: "-L[[SYSROOT]]/usr/lib/gcc/aarch64-amazon-linux/7"
+// CHECK-LD-AMI-AARCH64: "-L[[SYSROOT]]/usr/lib/gcc/aarch64-amazon-linux/7/../../../../lib64"
+// CHECK-LD-AMI-AARCH64: "-L[[SYSROOT]]/lib"
+// CHECK-LD-AMI-AARCH64: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-AMI-AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-LD-AMI-AARCH64: "-lc"
+// CHECK-LD-AMI-AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
// Check whether the OpenEmbedded ARM libs are added correctly.
// RUN: %clang -### %s -no-pie 2>&1 \
``````````
</details>
https://github.com/llvm/llvm-project/pull/109263
More information about the cfe-commits
mailing list