Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation fails on Amazon Linux 2023 aarch64 #8227

Open
sebsto opened this issue Feb 17, 2024 · 1 comment
Open

Compilation fails on Amazon Linux 2023 aarch64 #8227

sebsto opened this issue Feb 17, 2024 · 1 comment

Comments

@sebsto
Copy link

sebsto commented Feb 17, 2024

Trying to compile llvm-project on Amazon Linux 2023 aarch64 (Amazon Graviton CPUs) fails with

-- Check for working C compiler: /home/ec2-user/swift-project/build/buildbot_linux/llvm-linux-aarch64/./bin/clang - broken
CMake Error at /usr/share/cmake/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/home/ec2-user/swift-project/build/buildbot_linux/llvm-linux-aarch64/./bin/clang"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/ec2-user/swift-project/build/buildbot_linux/llvm-linux-aarch64/tools/clang/runtime/compiler-rt-bins/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/home/ec2-user/swift-project/build/buildbot_linux/ninja-build/ninja cmTC_a5c7b && [1/2][ 50%][0.033s] Building C object CMakeFiles/cmTC_a5c7b.dir/testCCompiler.c.o
    [2/2][100%][0.106s] Linking C executable cmTC_a5c7b
    FAILED: cmTC_a5c7b 
    : && /home/ec2-user/swift-project/build/buildbot_linux/llvm-linux-aarch64/./bin/clang   CMakeFiles/cmTC_a5c7b.dir/testCCompiler.c.o -o cmTC_a5c7b   && :
    /usr/bin/ld: cannot find crtbeginS.o: No such file or directory
    /usr/bin/ld: cannot find -lgcc: No such file or directory
    /usr/bin/ld: cannot find -lgcc_s: No such file or directory
    clang-13: error: linker command failed with exit code 1 (use -v to see invocation)
    ninja: build stopped: subcommand failed.
   
  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:10 (project)


-- Configuring incomplete, errors occurred!

This is because Amazon defined a new triplet to identify the platform : aarch64-amazon-linux

Solution seems to add the triplet in Gnu.cpp like this (diff generated from next branch):

diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index a2526a2b9039..3aa870d4c423 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2456,7 +2456,7 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes(
   static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
   static const char *const AArch64Triples[] = {
       "aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-redhat-linux",
-      "aarch64-suse-linux"};
+      "aarch64-suse-linux", "aarch64-amazon-linux"};
   static const char *const AArch64beLibDirs[] = {"/lib"};
   static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
                                                  "aarch64_be-linux-gnu"};
@sebsto
Copy link
Author

sebsto commented Feb 17, 2024

Created a PR #8228

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant