Merge pull request #6100 from apple/anoyes/fix-aarch64-build-including-m1

Fix aarch64 build including m1
This commit is contained in:
Andrew Noyes 2021-12-03 18:05:53 -08:00 committed by GitHub
commit 9954c6c0a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 36 additions and 28 deletions

View File

@ -62,11 +62,11 @@ def write_unix_asm(asmfile, functions, prefix):
if cpu != "aarch64":
asmfile.write(".intel_syntax noprefix\n")
if cpu == 'aarch64' or os == 'linux' or os == 'freebsd':
if os == 'linux' or os == 'freebsd':
asmfile.write("\n.data\n")
for f in functions:
asmfile.write("\t.extern fdb_api_ptr_%s\n" % f)
if os == 'linux' or os == 'freebsd':
asmfile.write("\n.text\n")
for f in functions:
@ -74,6 +74,8 @@ def write_unix_asm(asmfile, functions, prefix):
for f in functions:
asmfile.write("\n.globl %s%s\n" % (prefix, f))
if cpu == 'aarch64' and os == 'osx':
asmfile.write(".p2align\t2\n")
asmfile.write("%s%s:\n" % (prefix, f))
# These assembly implementations of versioned fdb c api functions must have the following properties.
@ -105,16 +107,16 @@ def write_unix_asm(asmfile, functions, prefix):
# .size g, .-g
# .ident "GCC: (GNU) 8.3.1 20190311 (Red Hat 8.3.1-3)"
p = ''
if os == 'osx':
p = '_'
if cpu == "aarch64":
asmfile.write("\tldr x16, =%sfdb_api_ptr_%s\n" % (p, f))
if os == 'osx':
asmfile.write("\tldr x16, [x16]\n")
else:
asmfile.write("\tadrp x8, _fdb_api_ptr_%s@GOTPAGE\n" % (f))
asmfile.write("\tldr x8, [x8, _fdb_api_ptr_%s@GOTPAGEOFF]\n" % (f))
elif os == 'linux':
asmfile.write("\tadrp x8, :got:fdb_api_ptr_%s\n" % (f))
asmfile.write("\tldr x8, [x8, #:got_lo12:fdb_api_ptr_%s]\n" % (f))
asmfile.write("\tldr x8, [x8]\n")
else:
assert False, '{} not supported for Arm yet'.format(os)
asmfile.write("\tldr x8, [x8]\n")
asmfile.write("\tbr x8\n")
else:
asmfile.write(

View File

@ -218,7 +218,11 @@ if(NOT OPEN_FOR_IDE)
if(WIN32)
set(lib_destination "windows/amd64")
elseif(APPLE)
set(lib_destination "osx/x86_64")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
set(lib_destination "osx/aarch64")
else()
set(lib_destination "osx/x86_64")
endif()
else()
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
set(lib_destination "linux/aarch64")

View File

@ -87,22 +87,24 @@ if(COMPILE_EIO)
target_link_libraries(fdbrpc_sampling PRIVATE eio)
endif()
set(CORO_SRCS libcoroutine/Common.c libcoroutine/Coro.c)
if(APPLE)
list(APPEND CORO_SRCS libcoroutine/asm.S)
if(${COROUTINE_IMPL} STREQUAL libcoro)
set(CORO_SRCS libcoroutine/Common.c libcoroutine/Coro.c)
if(APPLE)
list(APPEND CORO_SRCS libcoroutine/asm.S)
endif()
if(NOT WIN32)
list(APPEND CORO_SRCS libcoroutine/context.c)
endif()
add_library(coro STATIC ${CORO_SRCS})
if(WIN32)
target_compile_definitions(coro PRIVATE USE_FIBERS)
else()
target_compile_definitions(coro PRIVATE USE_UCONTEXT)
target_compile_options(coro BEFORE PRIVATE -w) # disable warnings for third party
endif()
if(USE_VALGRIND)
target_link_libraries(coro PUBLIC Valgrind)
endif()
target_link_libraries(fdbrpc PRIVATE coro)
target_link_libraries(fdbrpc_sampling PRIVATE coro)
endif()
if(NOT WIN32)
list(APPEND CORO_SRCS libcoroutine/context.c)
endif()
add_library(coro STATIC ${CORO_SRCS})
if(WIN32)
target_compile_definitions(coro PRIVATE USE_FIBERS)
else()
target_compile_definitions(coro PRIVATE USE_UCONTEXT)
target_compile_options(coro BEFORE PRIVATE -w) # disable warnings for third party
endif()
if(USE_VALGRIND)
target_link_libraries(coro PUBLIC Valgrind)
endif()
target_link_libraries(fdbrpc PRIVATE coro)
target_link_libraries(fdbrpc_sampling PRIVATE coro)