mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
Handles libffi on the CMake build.
Patch by arrowdodger! llvm-svn: 123976
This commit is contained in:
parent
2f96371a7a
commit
da69ba084d
@ -114,6 +114,10 @@ if(LLVM_ENABLE_TIMESTAMPS)
|
|||||||
set(ENABLE_TIMESTAMPS 1)
|
set(ENABLE_TIMESTAMPS 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF)
|
||||||
|
set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
|
||||||
|
set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h")
|
||||||
|
|
||||||
set(C_INCLUDE_DIRS "" CACHE STRING
|
set(C_INCLUDE_DIRS "" CACHE STRING
|
||||||
"Colon separated list of directories clang will search for headers.")
|
"Colon separated list of directories clang will search for headers.")
|
||||||
|
|
||||||
|
@ -190,6 +190,35 @@ llvm_find_program(fdp)
|
|||||||
llvm_find_program(dot)
|
llvm_find_program(dot)
|
||||||
llvm_find_program(dotty)
|
llvm_find_program(dotty)
|
||||||
|
|
||||||
|
if( LLVM_ENABLE_FFI )
|
||||||
|
find_path(FFI_INCLUDE_PATH ffi.h PATHS ${FFI_INCLUDE_DIR})
|
||||||
|
if( FFI_INCLUDE_PATH )
|
||||||
|
set(FFI_HEADER ffi.h CACHE INTERNAL "")
|
||||||
|
set(HAVE_FFI_H 1 CACHE INTERNAL "")
|
||||||
|
else()
|
||||||
|
find_path(FFI_INCLUDE_PATH ffi/ffi.h PATHS ${FFI_INCLUDE_DIR})
|
||||||
|
if( FFI_INCLUDE_PATH )
|
||||||
|
set(FFI_HEADER ffi/ffi.h CACHE INTERNAL "")
|
||||||
|
set(HAVE_FFI_FFI_H 1 CACHE INTERNAL "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if( NOT FFI_HEADER )
|
||||||
|
message(FATAL_ERROR "libffi includes are not found.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
find_library(FFI_LIBRARY_PATH ffi PATHS ${FFI_LIBRARY_DIR})
|
||||||
|
if( NOT FFI_LIBRARY_PATH )
|
||||||
|
message(FATAL_ERROR "libffi is not found.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
|
||||||
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
|
||||||
|
check_symbol_exists(ffi_call ${FFI_HEADER} HAVE_FFI_CALL)
|
||||||
|
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES ${FFI_INCLUDE_PATH})
|
||||||
|
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES ${FFI_LIBRARY_PATH})
|
||||||
|
endif( LLVM_ENABLE_FFI )
|
||||||
|
|
||||||
# Define LLVM_MULTITHREADED if gcc atomic builtins exists.
|
# Define LLVM_MULTITHREADED if gcc atomic builtins exists.
|
||||||
include(CheckAtomic)
|
include(CheckAtomic)
|
||||||
|
|
||||||
|
@ -338,6 +338,12 @@
|
|||||||
By default, <tt>"-sv --no-progress-bar"</tt>
|
By default, <tt>"-sv --no-progress-bar"</tt>
|
||||||
on Visual C++ and Xcode,
|
on Visual C++ and Xcode,
|
||||||
<tt>"-sv"</tt> on others.</dd>
|
<tt>"-sv"</tt> on others.</dd>
|
||||||
|
|
||||||
|
<dt><b>LLVM_ENABLE_FFI</b>:BOOL</dt>
|
||||||
|
<dd>Indicates whether LLVM Interpreter will be linked with Foreign
|
||||||
|
Function Interface library. If the library or its headers are
|
||||||
|
installed on a custom location, you can set the variables
|
||||||
|
FFI_INCLUDE_DIR and FFI_LIBRARY_DIR. Defaults to OFF.</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@ -130,13 +130,13 @@
|
|||||||
#cmakedefine HAVE_FENV_H ${HAVE_FENV_H}
|
#cmakedefine HAVE_FENV_H ${HAVE_FENV_H}
|
||||||
|
|
||||||
/* Define if libffi is available on this platform. */
|
/* Define if libffi is available on this platform. */
|
||||||
#undef HAVE_FFI_CALL
|
#cmakedefine HAVE_FFI_CALL ${HAVE_FFI_CALL}
|
||||||
|
|
||||||
/* Define to 1 if you have the <ffi/ffi.h> header file. */
|
/* Define to 1 if you have the <ffi/ffi.h> header file. */
|
||||||
#undef HAVE_FFI_FFI_H
|
#cmakedefine HAVE_FFI_FFI_H ${HAVE_FFI_FFI_H}
|
||||||
|
|
||||||
/* Define to 1 if you have the <ffi.h> header file. */
|
/* Define to 1 if you have the <ffi.h> header file. */
|
||||||
#undef HAVE_FFI_H
|
#cmakedefine HAVE_FFI_H ${HAVE_FFI_H}
|
||||||
|
|
||||||
/* Set to 1 if the finite function is found in <ieeefp.h> */
|
/* Set to 1 if the finite function is found in <ieeefp.h> */
|
||||||
#cmakedefine HAVE_FINITE_IN_IEEEFP_H ${HAVE_FINITE_IN_IEEEFP_H}
|
#cmakedefine HAVE_FINITE_IN_IEEEFP_H ${HAVE_FINITE_IN_IEEEFP_H}
|
||||||
|
@ -1,5 +1,21 @@
|
|||||||
|
# If the user required a custom path for ffi headers, use it on its
|
||||||
|
# abolute form (see config-ix.cmake):
|
||||||
|
if( FFI_INCLUDE_DIR )
|
||||||
|
include_directories( ${FFI_INCLUDE_PATH} )
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# If the user required a custom path for libffi, use it on its abolute
|
||||||
|
# form (see config-ix.cmake):
|
||||||
|
if( FFI_LIBRARY_DIR )
|
||||||
|
link_directories( ${FFI_LIBRARY_PATH} )
|
||||||
|
endif()
|
||||||
|
|
||||||
add_llvm_library(LLVMInterpreter
|
add_llvm_library(LLVMInterpreter
|
||||||
Execution.cpp
|
Execution.cpp
|
||||||
ExternalFunctions.cpp
|
ExternalFunctions.cpp
|
||||||
Interpreter.cpp
|
Interpreter.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if( LLVM_ENABLE_FFI )
|
||||||
|
target_link_libraries( LLVMInterpreter ffi )
|
||||||
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user