[libc-commits] [libc] [libc][cmake] pass -mthumb for thumb triples (PR #96550)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Mon Jun 24 13:26:59 PDT 2024
https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/96550
Allows cross compiling for 32b ARM in thumb mode via
`-DLIBC_TARGET_TRIPLE=thumbv7-linux-gnueabihf`. Strangely, setting that target
triple doesn't imply `-mthumb`, so set that when using a triple that starts
with "thumb". Android only cares about building llvm-libc for 32b ARM in thumb
mode, so we need to ensure this target builds (it doesn't, but with this change
we can at least configure then start working through the build issues) and is
continuously tested.
>From bca80ef6bd778f70ebdb9df8397f36269d388870 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Mon, 24 Jun 2024 13:24:05 -0700
Subject: [PATCH] [libc][cmake] pass -mthumb for thumb triples
Allows cross compiling for 32b ARM in thumb mode via
`-DLIBC_TARGET_TRIPLE=thumbv7-linux-gnueabihf`. Strangely, setting that target
triple doesn't imply `-mthumb`, so set that when using a triple that starts
with "thumb". Android only cares about building llvm-libc for 32b ARM in thumb
mode, so we need to ensure this target builds (it doesn't, but with this change
we can at least configure then start working through the build issues) and is
continuously tested.
---
libc/cmake/modules/LLVMLibCArchitectures.cmake | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index dacb4db75d337..5acc35569b5ed 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -33,7 +33,7 @@ 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 "^arm")
+ elseif(target_arch MATCHES "^arm" OR target_arch MATCHES "^thumb")
# TODO(lntue): Shall we separate `arm64`? It is currently recognized as
# `arm` here.
set(target_arch "arm")
@@ -203,6 +203,9 @@ if(explicit_target_triple AND
else()
list(APPEND
LIBC_COMPILE_OPTIONS_DEFAULT "--target=${explicit_target_triple}")
+ if (explicit_target_triple MATCHES "^thumb")
+ list(APPEND LIBC_COMPILE_OPTIONS_DEFAULT "-mthumb")
+ endif()
endif()
endif()
More information about the libc-commits
mailing list