Skip to content

[LibC] Refactor arm64 to aarch64 for darwin. #141509

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

Merged
merged 3 commits into from
May 30, 2025

Conversation

AlyElashram
Copy link
Contributor

Fixes #141505

The main intention behind this PR is to update the LibCTargetArchitecture for arm64 to use the implementation of aarch64 architecture and not arm32.

This is a historical issue , and is a blocker to issue #138407.

The intended fix is to set the LibCTargetArchitecture to aarch64 when it matches arm64 , this in turn would help us run darwin/aarch64 specific code on our MacOs pipeline in the git actions.

Methods used to search and find "darwin/arm" directories was

  1. "find . -type d -path "/libc//darwin/arm" in a linux terminal to check for arm specifically
  2. "find . -type d -path "/libc//darwin/*" to ensure there are no directories that are named "arm" where star is a wildcard for any character.

@llvmbot llvmbot added the libc label May 26, 2025
@llvmbot
Copy link
Member

llvmbot commented May 26, 2025

@llvm/pr-subscribers-libc

Author: Aly ElAshram (AlyElashram)

Changes

Fixes #141505

The main intention behind this PR is to update the LibCTargetArchitecture for arm64 to use the implementation of aarch64 architecture and not arm32.

This is a historical issue , and is a blocker to issue #138407.

The intended fix is to set the LibCTargetArchitecture to aarch64 when it matches arm64 , this in turn would help us run darwin/aarch64 specific code on our MacOs pipeline in the git actions.

Methods used to search and find "darwin/arm" directories was

  1. "find . -type d -path "/libc//darwin/arm" in a linux terminal to check for arm specifically
  2. "find . -type d -path "/libc//darwin/*" to ensure there are no directories that are named "arm" where star is a wildcard for any character.

Full diff: https://github.com/llvm/llvm-project/pull/141509.diff

6 Files Affected:

  • (modified) libc/cmake/modules/LLVMLibCArchitectures.cmake (+2-4)
  • (renamed) libc/config/darwin/aarch64/entrypoints.txt ()
  • (renamed) libc/config/darwin/aarch64/headers.txt ()
  • (renamed) libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt ()
  • (renamed) libc/src/__support/OSUtil/darwin/aarch64/syscall.h ()
  • (modified) libc/src/__support/OSUtil/darwin/syscall.h (+1-1)
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 62f3a2e3bdb59..c94a407d974df 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -33,12 +33,10 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
   # value.
   if(target_arch MATCHES "^mips")
     set(target_arch "mips")
+  elseif(target_arch MATCHES "^aarch64|^arm64")
+    set(target_arch "aarch64")
   elseif(target_arch MATCHES "^arm")
-    # TODO(lntue): Shall we separate `arm64`?  It is currently recognized as
-    # `arm` here.
     set(target_arch "arm")
-  elseif(target_arch MATCHES "^aarch64")
-    set(target_arch "aarch64")
   elseif(target_arch MATCHES "(x86_64)|(AMD64|amd64)")
     set(target_arch "x86_64")
   elseif(target_arch MATCHES "(^i.86$)")
diff --git a/libc/config/darwin/arm/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
similarity index 100%
rename from libc/config/darwin/arm/entrypoints.txt
rename to libc/config/darwin/aarch64/entrypoints.txt
diff --git a/libc/config/darwin/arm/headers.txt b/libc/config/darwin/aarch64/headers.txt
similarity index 100%
rename from libc/config/darwin/arm/headers.txt
rename to libc/config/darwin/aarch64/headers.txt
diff --git a/libc/src/__support/OSUtil/darwin/arm/CMakeLists.txt b/libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt
similarity index 100%
rename from libc/src/__support/OSUtil/darwin/arm/CMakeLists.txt
rename to libc/src/__support/OSUtil/darwin/aarch64/CMakeLists.txt
diff --git a/libc/src/__support/OSUtil/darwin/arm/syscall.h b/libc/src/__support/OSUtil/darwin/aarch64/syscall.h
similarity index 100%
rename from libc/src/__support/OSUtil/darwin/arm/syscall.h
rename to libc/src/__support/OSUtil/darwin/aarch64/syscall.h
diff --git a/libc/src/__support/OSUtil/darwin/syscall.h b/libc/src/__support/OSUtil/darwin/syscall.h
index eab96366a21a3..463407dbe19ef 100644
--- a/libc/src/__support/OSUtil/darwin/syscall.h
+++ b/libc/src/__support/OSUtil/darwin/syscall.h
@@ -15,7 +15,7 @@
 #include "src/__support/macros/properties/architectures.h"
 
 #ifdef LIBC_TARGET_ARCH_IS_ANY_ARM
-#include "arm/syscall.h"
+#include "aarch64/syscall.h"
 #else
 #error "Unsupported architecture"
 #endif

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, adding @lntue for visibility

@SchrodingerZhu
Copy link
Contributor

Thanks for doing this!

@lntue lntue merged commit bfd7024 into llvm:main May 30, 2025
18 checks passed
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Jun 3, 2025
Fixes [llvm#141505](llvm#141505)

The main intention behind this PR is to update the
LibCTargetArchitecture for arm64 to use the implementation of aarch64
architecture and not arm32.

This is a historical issue , and is a blocker to issue llvm#138407. 

The intended fix is to set the `LibCTargetArchitecture` to aarch64 when
it matches arm64 , this in turn would help us run darwin/aarch64
specific code on our MacOs pipeline in the git actions.

Methods used to search and find "darwin/arm" directories was  

1. "find . -type d -path "*/libc/*/darwin/arm" in a linux terminal to
check for arm specifically
2. "find . -type d -path "*/libc/*/darwin/*" to ensure there are no
directories that are named "*arm*" where star is a wildcard for any
character.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[LibC] Migrate arm64 to point to aarch64 and not arm32
5 participants