Support AArch64 and PPC64 in third party dependencies

PiperOrigin-RevId: 338992825
Change-Id: I2f77ea8379e55007a22ad0461efc98f41a01ad44
This commit is contained in:
Christian Blichmann 2020-10-26 01:21:58 -07:00 committed by Copybara-Service
parent 28bb32add6
commit 19a8e38a51
4 changed files with 131 additions and 43 deletions

View File

@ -87,10 +87,9 @@ if(UNIX)
-Wno-psabi)
check_cxx_compiler_flag(${flag} _sapi_has_flag)
if(_sapi_has_flag)
target_compile_options(sapi_base INTERFACE
${flag}
)
target_compile_options(sapi_base INTERFACE ${flag})
endif()
unset(_sapi_has_flag)
endforeach()
endif()

View File

@ -36,6 +36,39 @@ set(_ffi_src "${CMAKE_BINARY_DIR}/libffi-src")
set(libffi_INCLUDE_DIR ${_ffi_src}/libffi/include)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
list(APPEND _ffi_platform_srcs
${_ffi_src}/src/x86/asmnames.h
${_ffi_src}/src/x86/ffi.c
${_ffi_src}/src/x86/ffi64.c
${_ffi_src}/src/x86/ffiw64.c
${_ffi_src}/src/x86/internal.h
${_ffi_src}/src/x86/internal64.h
${_ffi_src}/src/x86/sysv.S
${_ffi_src}/src/x86/unix64.S
${_ffi_src}/src/x86/win64.S
)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64")
list(APPEND _ffi_platform_srcs
${_ffi_src}/src/powerpc/ffi.c
${_ffi_src}/src/powerpc/ffi_linux64.c
${_ffi_src}/src/powerpc/ffi_sysv.c
${_ffi_src}/src/powerpc/linux64.S
${_ffi_src}/src/powerpc/linux64_closure.S
${_ffi_src}/src/powerpc/ppc_closure.S
${_ffi_src}/src/powerpc/sysv.S
# Textual headers
${_ffi_src}/src/powerpc/ffi_powerpc.h
${_ffi_src}/src/powerpc/asm.h
)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
list(APPEND _ffi_platform_srcs
${_ffi_src}/src/aarch64/ffi.c
${_ffi_src}/src/aarch64/internal.h
${_ffi_src}/src/aarch64/sysv.S
)
endif()
add_library(ffi STATIC
${_ffi_src}/fficonfig.h
${_ffi_src}/include/ffi.h
@ -48,15 +81,7 @@ add_library(ffi STATIC
${_ffi_src}/src/prep_cif.c
${_ffi_src}/src/raw_api.c
${_ffi_src}/src/types.c
${_ffi_src}/src/x86/asmnames.h
${_ffi_src}/src/x86/ffi.c
${_ffi_src}/src/x86/ffi64.c
${_ffi_src}/src/x86/ffiw64.c
${_ffi_src}/src/x86/internal.h
${_ffi_src}/src/x86/internal64.h
${_ffi_src}/src/x86/sysv.S
${_ffi_src}/src/x86/unix64.S
${_ffi_src}/src/x86/win64.S
${_ffi_platform_srcs}
)
add_library(libffi::libffi ALIAS ffi)
target_include_directories(ffi PUBLIC

View File

@ -33,6 +33,58 @@ if(error)
endif()
set(_unwind_src "${CMAKE_BINARY_DIR}/libunwind-src")
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(_unwind_cpu "x86_64")
list(APPEND _unwind_platform_srcs
${_unwind_src}/src/x86_64/Gcreate_addr_space.c
${_unwind_src}/src/x86_64/Gglobal.c
${_unwind_src}/src/x86_64/Ginit.c
${_unwind_src}/src/x86_64/Gos-linux.c
${_unwind_src}/src/x86_64/Gregs.c
${_unwind_src}/src/x86_64/Gresume.c
${_unwind_src}/src/x86_64/Gstash_frame.c
${_unwind_src}/src/x86_64/Gstep.c
${_unwind_src}/src/x86_64/is_fpreg.c
${_unwind_src}/src/x86_64/setcontext.S
)
list(APPEND _unwind_ptrace_srcs
${_unwind_src}/src/x86_64/Ginit_remote.c
)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64")
set(_unwind_cpu "ppc64")
list(APPEND _unwind_platform_srcs
${_unwind_src}/src/ppc/Gis_signal_frame.c
${_unwind_src}/src/ppc64/Gcreate_addr_space.c
${_unwind_src}/src/ppc64/Gglobal.c
${_unwind_src}/src/ppc64/Ginit.c
${_unwind_src}/src/ppc64/Gregs.c
${_unwind_src}/src/ppc64/Gresume.c
${_unwind_src}/src/ppc64/Gstep.c
${_unwind_src}/src/ppc64/get_func_addr.c
${_unwind_src}/src/ppc64/is_fpreg.c
)
list(APPEND _unwind_ptrace_srcs
${_unwind_src}/src/ppc/Ginit_remote.c
)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
set(_unwind_cpu "aarch64")
list(APPEND _unwind_platform_srcs
${_unwind_src}/src/aarch64/Gcreate_addr_space.c
${_unwind_src}/src/aarch64/Gglobal.c
${_unwind_src}/src/aarch64/Ginit.c
${_unwind_src}/src/aarch64/Gis_signal_frame.c
${_unwind_src}/src/aarch64/Gregs.c
${_unwind_src}/src/aarch64/Gresume.c
${_unwind_src}/src/aarch64/Gstash_frame.c
${_unwind_src}/src/aarch64/Gstep.c
${_unwind_src}/src/aarch64/is_fpreg.c
)
list(APPEND _unwind_ptrace_srcs
${_unwind_src}/src/aarch64/Ginit_remote.c
)
endif()
add_library(unwind_ptrace_wrapped STATIC
# internal_headers
${_unwind_src}/include/compiler.h
@ -86,16 +138,7 @@ add_library(unwind_ptrace_wrapped STATIC
${_unwind_src}/src/mi/init.c
${_unwind_src}/src/mi/mempool.c
${_unwind_src}/src/os-linux.c
${_unwind_src}/src/x86_64/Gcreate_addr_space.c
${_unwind_src}/src/x86_64/Gglobal.c
${_unwind_src}/src/x86_64/Ginit.c
${_unwind_src}/src/x86_64/Gos-linux.c
${_unwind_src}/src/x86_64/Gregs.c
${_unwind_src}/src/x86_64/Gresume.c
${_unwind_src}/src/x86_64/Gstash_frame.c
${_unwind_src}/src/x86_64/Gstep.c
${_unwind_src}/src/x86_64/is_fpreg.c
${_unwind_src}/src/x86_64/setcontext.S
${_unwind_platform_srcs}
# srcs
${_unwind_src}/src/mi/Gdyn-remote.c
${_unwind_src}/src/ptrace/_UPT_access_fpreg.c
@ -116,7 +159,7 @@ add_library(unwind_ptrace_wrapped STATIC
${_unwind_src}/include/config.h
${_unwind_src}/include/libunwind.h
# source_ptrace
${_unwind_src}/src/x86_64/Ginit_remote.c
${_unwind_ptrace_srcs}
)
add_library(unwind::unwind_ptrace_wrapped ALIAS unwind_ptrace_wrapped)
target_include_directories(unwind_ptrace_wrapped PUBLIC
@ -135,12 +178,14 @@ target_compile_definitions(unwind_ptrace_wrapped
PUBLIC -D_UPT_accessors=_UPT_accessors_wrapped
-D_UPT_create=_UPT_create_wrapped
-D_UPT_destroy=_UPT_destroy_wrapped
-D_Ux86_64_create_addr_space=_Ux86_64_create_addr_space_wrapped
-D_Ux86_64_destroy_addr_space=_Ux86_64_destroy_addr_space_wrapped
-D_Ux86_64_get_proc_name=_Ux86_64_get_proc_name_wrapped
-D_Ux86_64_get_reg=_Ux86_64_get_reg_wrapped
-D_Ux86_64_init_remote=_Ux86_64_init_remote_wrapped
-D_Ux86_64_step=_Ux86_64_step_wrapped
-D_U${_unwind_cpu}_create_addr_space=_U${_unwind_cpu}_create_addr_space_wrapped
-D_U${_unwind_cpu}_destroy_addr_space=_U${_unwind_cpu}_destroy_addr_space_wrapped
-D_U${_unwind_cpu}_get_proc_name=_U${_unwind_cpu}_get_proc_name_wrapped
-D_U${_unwind_cpu}_get_reg=_U${_unwind_cpu}_get_reg_wrapped
-D_U${_unwind_cpu}_init_remote=_U${_unwind_cpu}_init_remote_wrapped
-D_U${_unwind_cpu}_step=_U${_unwind_cpu}_step_wrapped
-Dptrace=ptrace_wrapped
)
target_link_libraries(unwind_ptrace_wrapped PRIVATE

View File

@ -15,17 +15,14 @@
cc_library(
name = "libffi",
srcs = [
"configure-bazel-gen/fficonfig.h",
"configure-bazel-gen/include/ffi.h",
"configure-bazel-gen/include/ffitarget.h",
"include/ffi_cfi.h",
"include/ffi_common.h",
"src/closures.c",
"src/debug.c",
"src/java_raw_api.c",
"src/prep_cif.c",
"src/raw_api.c",
"src/types.c",
] + select({
"@bazel_tools//src/conditions:linux_x86_64": [
"src/x86/asmnames.h",
"src/x86/ffi.c",
"src/x86/ffi64.c",
@ -36,6 +33,28 @@ cc_library(
"src/x86/unix64.S",
"src/x86/win64.S",
],
"@bazel_tools//src/conditions:linux_ppc": [
"src/powerpc/ffi.c",
"src/powerpc/ffi_linux64.c",
"src/powerpc/ffi_sysv.c",
"src/powerpc/linux64.S",
"src/powerpc/linux64_closure.S",
"src/powerpc/ppc_closure.S",
"src/powerpc/sysv.S",
],
"@bazel_tools//src/conditions:linux_aarch64": [
"src/aarch64/ffi.c",
"src/aarch64/internal.h",
"src/aarch64/sysv.S",
],
}),
hdrs = [
"configure-bazel-gen/fficonfig.h",
"configure-bazel-gen/include/ffi.h",
"configure-bazel-gen/include/ffitarget.h",
"include/ffi_cfi.h",
"include/ffi_common.h",
],
copts = [
# libffi-3.3-rc0 uses variable length arrays for closures on all
# platforms.