[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
# The CompilerRT build system requires CMake version 2.8.8 or higher in order
|
|
|
|
# to use its support for building convenience "libraries" as a collection of
|
|
|
|
# .o files. This is particularly useful in producing larger, more complex
|
|
|
|
# runtime libraries.
|
|
|
|
|
|
|
|
include(CheckIncludeFile)
|
2017-08-22 07:25:50 +08:00
|
|
|
include(CheckCXXSourceCompiles)
|
2020-05-19 02:36:43 +08:00
|
|
|
include(TestBigEndian)
|
2017-08-22 07:25:50 +08:00
|
|
|
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
check_include_file(unwind.h HAVE_UNWIND_H)
|
|
|
|
|
2019-01-15 03:18:34 +08:00
|
|
|
# Used by sanitizer_common and tests.
|
|
|
|
check_include_file(rpc/xdr.h HAVE_RPC_XDR_H)
|
|
|
|
if (NOT HAVE_RPC_XDR_H)
|
|
|
|
set(HAVE_RPC_XDR_H 0)
|
|
|
|
endif()
|
|
|
|
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
# Top level target used to build all compiler-rt libraries.
|
|
|
|
add_custom_target(compiler-rt ALL)
|
2016-08-20 06:17:46 +08:00
|
|
|
add_custom_target(install-compiler-rt)
|
2017-12-02 03:06:29 +08:00
|
|
|
add_custom_target(install-compiler-rt-stripped)
|
2018-06-27 20:56:34 +08:00
|
|
|
set_property(
|
|
|
|
TARGET
|
|
|
|
compiler-rt
|
|
|
|
install-compiler-rt
|
|
|
|
install-compiler-rt-stripped
|
|
|
|
PROPERTY
|
|
|
|
FOLDER "Compiler-RT Misc"
|
|
|
|
)
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
|
2016-06-04 07:15:04 +08:00
|
|
|
# Setting these variables from an LLVM build is sufficient that compiler-rt can
|
|
|
|
# construct the output paths, so it can behave as if it were in-tree here.
|
|
|
|
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
|
|
|
|
set(LLVM_TREE_AVAILABLE On)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LLVM_TREE_AVAILABLE)
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
# Compute the Clang version from the LLVM version.
|
|
|
|
# FIXME: We should be able to reuse CLANG_VERSION variable calculated
|
|
|
|
# in Clang cmake files, instead of copying the rules here.
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
|
|
|
|
${PACKAGE_VERSION})
|
|
|
|
# Setup the paths where compiler-rt runtimes and headers should be stored.
|
|
|
|
set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
|
|
|
|
set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
|
|
|
|
set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
|
|
|
|
option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."
|
|
|
|
${LLVM_INCLUDE_TESTS})
|
|
|
|
option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered"
|
|
|
|
${LLVM_ENABLE_WERROR})
|
2019-09-13 02:44:47 +08:00
|
|
|
|
[InstrProf] Implement static profdata registration
Summary:
The motivating use case is eliminating duplicate profile data registered
for the same inline function in two object files. Before this change,
users would observe multiple symbol definition errors with VC link, but
links with LLD would succeed.
Users (Mozilla) have reported that PGO works well with clang-cl and LLD,
but when using LLD without this static registration, we would get into a
"relocation against a discarded section" situation. I'm not sure what
happens in that situation, but I suspect that duplicate, unused profile
information was retained. If so, this change will reduce the size of
such binaries with LLD.
Now, Windows uses static registration and is in line with all the other
platforms.
Reviewers: davidxl, wmi, inglorion, void, calixte
Subscribers: mgorny, krytarowski, eraman, fedor.sergeev, hiraditya, #sanitizers, dmajor, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D57929
llvm-svn: 353547
2019-02-09 03:03:50 +08:00
|
|
|
# Use just-built Clang to compile/link tests on all platforms.
|
2019-09-13 02:44:47 +08:00
|
|
|
if (CMAKE_CROSSCOMPILING)
|
|
|
|
if (CMAKE_HOST_WIN32)
|
|
|
|
set(_host_executable_suffix ".exe")
|
|
|
|
else()
|
|
|
|
set(_host_executable_suffix "")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(_host_executable_suffix ${CMAKE_EXECUTABLE_SUFFIX})
|
|
|
|
endif()
|
[InstrProf] Implement static profdata registration
Summary:
The motivating use case is eliminating duplicate profile data registered
for the same inline function in two object files. Before this change,
users would observe multiple symbol definition errors with VC link, but
links with LLD would succeed.
Users (Mozilla) have reported that PGO works well with clang-cl and LLD,
but when using LLD without this static registration, we would get into a
"relocation against a discarded section" situation. I'm not sure what
happens in that situation, but I suspect that duplicate, unused profile
information was retained. If so, this change will reduce the size of
such binaries with LLD.
Now, Windows uses static registration and is in line with all the other
platforms.
Reviewers: davidxl, wmi, inglorion, void, calixte
Subscribers: mgorny, krytarowski, eraman, fedor.sergeev, hiraditya, #sanitizers, dmajor, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D57929
llvm-svn: 353547
2019-02-09 03:03:50 +08:00
|
|
|
set(COMPILER_RT_TEST_COMPILER
|
2019-09-13 02:44:47 +08:00
|
|
|
${LLVM_RUNTIME_OUTPUT_INTDIR}/clang${_host_executable_suffix})
|
[InstrProf] Implement static profdata registration
Summary:
The motivating use case is eliminating duplicate profile data registered
for the same inline function in two object files. Before this change,
users would observe multiple symbol definition errors with VC link, but
links with LLD would succeed.
Users (Mozilla) have reported that PGO works well with clang-cl and LLD,
but when using LLD without this static registration, we would get into a
"relocation against a discarded section" situation. I'm not sure what
happens in that situation, but I suspect that duplicate, unused profile
information was retained. If so, this change will reduce the size of
such binaries with LLD.
Now, Windows uses static registration and is in line with all the other
platforms.
Reviewers: davidxl, wmi, inglorion, void, calixte
Subscribers: mgorny, krytarowski, eraman, fedor.sergeev, hiraditya, #sanitizers, dmajor, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D57929
llvm-svn: 353547
2019-02-09 03:03:50 +08:00
|
|
|
set(COMPILER_RT_TEST_CXX_COMPILER
|
2019-09-13 02:44:47 +08:00
|
|
|
${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++${_host_executable_suffix})
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
else()
|
|
|
|
# Take output dir and install path from the user.
|
|
|
|
set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH
|
|
|
|
"Path where built compiler-rt libraries should be stored.")
|
|
|
|
set(COMPILER_RT_EXEC_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/bin CACHE PATH
|
|
|
|
"Path where built compiler-rt executables should be stored.")
|
|
|
|
set(COMPILER_RT_INSTALL_PATH ${CMAKE_INSTALL_PREFIX} CACHE PATH
|
|
|
|
"Path where built compiler-rt libraries should be installed.")
|
|
|
|
option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests." OFF)
|
|
|
|
option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" OFF)
|
|
|
|
# Use a host compiler to compile/link tests.
|
|
|
|
set(COMPILER_RT_TEST_COMPILER ${CMAKE_C_COMPILER} CACHE PATH "Compiler to use for testing")
|
|
|
|
set(COMPILER_RT_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER} CACHE PATH "C++ Compiler to use for testing")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang[+]*$")
|
|
|
|
set(COMPILER_RT_TEST_COMPILER_ID Clang)
|
|
|
|
elseif("${COMPILER_RT_TEST_COMPILER}" MATCHES "clang.*.exe$")
|
|
|
|
set(COMPILER_RT_TEST_COMPILER_ID Clang)
|
|
|
|
else()
|
|
|
|
set(COMPILER_RT_TEST_COMPILER_ID GNU)
|
|
|
|
endif()
|
|
|
|
|
2017-05-25 06:41:49 +08:00
|
|
|
if(NOT DEFINED COMPILER_RT_OS_DIR)
|
|
|
|
string(TOLOWER ${CMAKE_SYSTEM_NAME} COMPILER_RT_OS_DIR)
|
|
|
|
endif()
|
2018-06-28 11:11:52 +08:00
|
|
|
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
|
|
|
|
set(COMPILER_RT_LIBRARY_OUTPUT_DIR
|
|
|
|
${COMPILER_RT_OUTPUT_DIR})
|
|
|
|
set(COMPILER_RT_LIBRARY_INSTALL_DIR
|
|
|
|
${COMPILER_RT_INSTALL_PATH})
|
|
|
|
else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
|
|
|
|
set(COMPILER_RT_LIBRARY_OUTPUT_DIR
|
|
|
|
${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
|
|
|
|
set(COMPILER_RT_LIBRARY_INSTALL_DIR
|
|
|
|
${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
|
|
|
|
endif()
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
|
|
|
|
if(APPLE)
|
2019-07-27 20:30:15 +08:00
|
|
|
# On Darwin if /usr/include/c++ doesn't exist, the user probably has Xcode but
|
|
|
|
# not the command line tools (or is using macOS 10.14 or newer). If this is
|
|
|
|
# the case, we need to find the OS X sysroot to pass to clang.
|
|
|
|
if(NOT EXISTS /usr/include/c++)
|
|
|
|
execute_process(COMMAND xcrun -sdk macosx --show-sdk-path
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
OUTPUT_VARIABLE OSX_SYSROOT
|
|
|
|
ERROR_QUIET
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2019-07-27 20:30:15 +08:00
|
|
|
if (NOT OSX_SYSROOT OR NOT EXISTS ${OSX_SYSROOT})
|
|
|
|
message(WARNING "Detected OSX_SYSROOT ${OSX_SYSROOT} does not exist")
|
|
|
|
else()
|
|
|
|
message(STATUS "Found OSX_SYSROOT: ${OSX_SYSROOT}")
|
|
|
|
set(OSX_SYSROOT_FLAG "-isysroot${OSX_SYSROOT}")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(OSX_SYSROOT_FLAG "")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
endif()
|
|
|
|
|
2016-10-06 04:45:36 +08:00
|
|
|
option(COMPILER_RT_ENABLE_IOS "Enable building for iOS" On)
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
option(COMPILER_RT_ENABLE_WATCHOS "Enable building for watchOS - Experimental" Off)
|
|
|
|
option(COMPILER_RT_ENABLE_TVOS "Enable building for tvOS - Experimental" Off)
|
2017-08-22 07:25:50 +08:00
|
|
|
|
2016-12-13 07:14:02 +08:00
|
|
|
else()
|
|
|
|
option(COMPILER_RT_DEFAULT_TARGET_ONLY "Build builtins only for the default target" Off)
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
endif()
|
|
|
|
|
2016-09-08 04:32:48 +08:00
|
|
|
if(WIN32 AND NOT MINGW AND NOT CYGWIN)
|
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX_C "")
|
|
|
|
set(CMAKE_SHARED_LIBRARY_PREFIX_CXX "")
|
|
|
|
set(CMAKE_STATIC_LIBRARY_PREFIX_C "")
|
|
|
|
set(CMAKE_STATIC_LIBRARY_PREFIX_CXX "")
|
|
|
|
set(CMAKE_STATIC_LIBRARY_SUFFIX_C ".lib")
|
|
|
|
set(CMAKE_STATIC_LIBRARY_SUFFIX_CXX ".lib")
|
|
|
|
endif()
|
|
|
|
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
macro(test_targets)
|
|
|
|
# Find and run MSVC (not clang-cl) and get its version. This will tell clang-cl
|
|
|
|
# what version of MSVC to pretend to be so that the STL works.
|
|
|
|
set(MSVC_VERSION_FLAG "")
|
|
|
|
if (MSVC)
|
|
|
|
execute_process(COMMAND "$ENV{VSINSTALLDIR}/VC/bin/cl.exe"
|
|
|
|
OUTPUT_QUIET
|
|
|
|
ERROR_VARIABLE MSVC_COMPAT_VERSION
|
|
|
|
)
|
|
|
|
string(REGEX REPLACE "^.*Compiler Version ([0-9.]+) for .*$" "\\1"
|
|
|
|
MSVC_COMPAT_VERSION "${MSVC_COMPAT_VERSION}")
|
|
|
|
if (MSVC_COMPAT_VERSION MATCHES "^[0-9].+$")
|
|
|
|
set(MSVC_VERSION_FLAG "-fms-compatibility-version=${MSVC_COMPAT_VERSION}")
|
|
|
|
# Add this flag into the host build if this is clang-cl.
|
|
|
|
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
append("${MSVC_VERSION_FLAG}" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
|
2016-06-18 01:48:52 +08:00
|
|
|
elseif (COMPILER_RT_TEST_COMPILER_ID MATCHES "Clang")
|
2016-06-21 22:32:52 +08:00
|
|
|
# Add this flag to test compiles to suppress clang's auto-detection
|
|
|
|
# logic.
|
|
|
|
append("${MSVC_VERSION_FLAG}" COMPILER_RT_TEST_COMPILER_CFLAGS)
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Generate the COMPILER_RT_SUPPORTED_ARCH list.
|
|
|
|
if(ANDROID)
|
|
|
|
# Examine compiler output to determine target architecture.
|
|
|
|
detect_target_arch()
|
2016-06-29 00:30:23 +08:00
|
|
|
set(COMPILER_RT_OS_SUFFIX "-android")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
elseif(NOT APPLE) # Supported archs for Apple platforms are generated later
|
2016-12-13 07:14:02 +08:00
|
|
|
if(COMPILER_RT_DEFAULT_TARGET_ONLY)
|
|
|
|
add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH})
|
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
if(NOT MSVC)
|
2018-03-03 19:48:54 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD")
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
|
|
|
test_target_arch(i386 __i386__ "-m32")
|
|
|
|
else()
|
|
|
|
test_target_arch(x86_64 "" "-m64")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
test_target_arch(x86_64 "" "-m64")
|
|
|
|
test_target_arch(i386 __i386__ "-m32")
|
|
|
|
endif()
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
else()
|
|
|
|
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
2016-06-21 22:32:52 +08:00
|
|
|
test_target_arch(i386 "" "")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
else()
|
2016-06-21 22:32:52 +08:00
|
|
|
test_target_arch(x86_64 "" "")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
|
2017-09-29 21:32:39 +08:00
|
|
|
# Strip out -nodefaultlibs when calling TEST_BIG_ENDIAN. Configuration
|
|
|
|
# will fail with this option when building with a sanitizer.
|
|
|
|
cmake_push_check_state()
|
2020-05-19 02:36:43 +08:00
|
|
|
string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
|
2017-09-29 21:32:39 +08:00
|
|
|
cmake_pop_check_state()
|
|
|
|
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
if(HOST_IS_BIG_ENDIAN)
|
|
|
|
test_target_arch(powerpc64 "" "-m64")
|
|
|
|
else()
|
|
|
|
test_target_arch(powerpc64le "" "-m64")
|
|
|
|
endif()
|
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "s390x")
|
|
|
|
test_target_arch(s390x "" "")
|
2019-07-12 16:30:17 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "sparc")
|
|
|
|
test_target_arch(sparc "" "-m32")
|
|
|
|
test_target_arch(sparcv9 "" "-m64")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mipsel|mips64el")
|
|
|
|
# Gcc doesn't accept -m32/-m64 so we do the next best thing and use
|
|
|
|
# -mips32r2/-mips64r2. We don't use -mips1/-mips3 because we want to match
|
|
|
|
# clang's default CPU's. In the 64-bit case, we must also specify the ABI
|
|
|
|
# since the default ABI differs between gcc and clang.
|
|
|
|
# FIXME: Ideally, we would build the N32 library too.
|
2019-05-16 06:27:19 +08:00
|
|
|
test_target_arch(mipsel "" "-mips32r2" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
2018-09-27 15:17:00 +08:00
|
|
|
test_target_arch(mips64el "" "-mips64r2" "-mabi=64")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "mips")
|
2019-05-16 06:27:19 +08:00
|
|
|
test_target_arch(mips "" "-mips32r2" "-mabi=32" "-D_LARGEFILE_SOURCE" "-D_FILE_OFFSET_BITS=64")
|
2018-09-27 15:17:00 +08:00
|
|
|
test_target_arch(mips64 "" "-mips64r2" "-mabi=64")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "arm")
|
2016-08-06 00:53:05 +08:00
|
|
|
if(WIN32)
|
|
|
|
test_target_arch(arm "" "" "")
|
|
|
|
else()
|
|
|
|
test_target_arch(arm "" "-march=armv7-a" "-mfloat-abi=soft")
|
|
|
|
test_target_arch(armhf "" "-march=armv7-a" "-mfloat-abi=hard")
|
2017-01-20 02:46:11 +08:00
|
|
|
test_target_arch(armv6m "" "-march=armv6m" "-mfloat-abi=soft")
|
2016-08-06 00:53:05 +08:00
|
|
|
endif()
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "aarch32")
|
|
|
|
test_target_arch(aarch32 "" "-march=armv8-a")
|
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "aarch64")
|
|
|
|
test_target_arch(aarch64 "" "-march=armv8-a")
|
2018-03-01 15:47:27 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "riscv32")
|
|
|
|
test_target_arch(riscv32 "" "")
|
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "riscv64")
|
|
|
|
test_target_arch(riscv64 "" "")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "wasm32")
|
|
|
|
test_target_arch(wasm32 "" "--target=wasm32-unknown-unknown")
|
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "wasm64")
|
|
|
|
test_target_arch(wasm64 "" "--target=wasm64-unknown-unknown")
|
2020-05-27 15:39:39 +08:00
|
|
|
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "ve")
|
|
|
|
test_target_arch(ve "__ve__" "--target=ve-unknown-none")
|
[CMake] Support platform building builtins without a full toolchain
Summary:
This patch adds support for building lib/builtins without a fully functioning toolchain. It allows you to bootstrap a cross-compiler, which previously couldn't be done with CMake.
This patch contains the following specific changes:
* Split builtin-specific code out of config-ix.cmake into builtin-config-ix.cmake
* Split some common CMake functionality needed by both builtins and sanitizers into base-config-ix.cmake
* Made lib/builtins/CMakeLists.txt able to be a top-level CMake configuration
I have tested this on Darwin targeting embedded Darwin, and on FreeBSD x86_64 targeting FreeBSD AArch64.
This patch depends on http://reviews.llvm.org/D19692, and is the last part of http://reviews.llvm.org/D16653.
Reviewers: samsonov, iains, jroelofs
Subscribers: compnerd, aemerson, tberghammer, danalbert, srhines, emaste, llvm-commits
Differential Revision: http://reviews.llvm.org/D19742
llvm-svn: 268977
2016-05-10 05:45:52 +08:00
|
|
|
endif()
|
|
|
|
set(COMPILER_RT_OS_SUFFIX "")
|
|
|
|
endif()
|
|
|
|
endmacro()
|