From 9b9ef9cde818495a863860c66a0c07e8d6bddec7 Mon Sep 17 00:00:00 2001 From: Thomas A Date: Fri, 17 Apr 2020 17:10:41 -0700 Subject: [PATCH] cctools/ld64: Add ARM64 support --- cctools/ld64/src/CMakeLists.txt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/cctools/ld64/src/CMakeLists.txt b/cctools/ld64/src/CMakeLists.txt index 436c2555..a1a32ec3 100644 --- a/cctools/ld64/src/CMakeLists.txt +++ b/cctools/ld64/src/CMakeLists.txt @@ -1,5 +1,9 @@ project(ld64) +if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64") + add_compile_definitions(__arm64__) +endif() + add_definitions(-DHAVE_BCMP=1 -DHAVE_BZERO=1 -DHAVE_BCOPY=1 -DHAVE_INDEX=1 -DHAVE_RINDEX=1) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fblocks -std=c++11 -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value") @@ -15,8 +19,6 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/abstraction) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-U__APPLE__ - -DEMULATED_HOST_CPU_TYPE=16777223 - -DEMULATED_HOST_CPU_SUBTYPE=3 -D__STDC_LIMIT_MACROS=1 -D__STDC_CONSTANT_MACROS=1 -DHAVE_EXECINFO_H=1 @@ -25,6 +27,19 @@ add_definitions(-U__APPLE__ -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -Du_short=uint16_t) +# i386 has a different CPU type/subtype, but Darling only supports x86_64 +if (TARGET_x86_64 OR TARGET_i386) + add_definitions( + -DEMULATED_HOST_CPU_TYPE=16777223 + -DEMULATED_HOST_CPU_SUBTYPE=3 + ) +elseif (TARGET_ARM64) + add_definitions( + -DEMULATED_HOST_CPU_TYPE=16777228 + -DEMULATED_HOST_CPU_SUBTYPE=0 + ) +endif(TARGET_x86_64 OR TARGET_i386) + set(ld64_sources ./ld/InputFiles.cpp ./ld/OutputFile.cpp