2014-02-14 09:20:33 +00:00
|
|
|
# This directory contains a large amount of C code which provides
|
|
|
|
# generic implementations of the core runtime library along with optimized
|
|
|
|
# architecture-specific code in various subdirectories.
|
|
|
|
|
[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-09 21:45:52 +00:00
|
|
|
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
Reland "[CMake] Bumps minimum version to 3.20.0.
This reverts commit d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6.
Adds the patch by @hans from
https://github.com/llvm/llvm-project/issues/62719
This patch fixes the Windows build.
d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 reverted the reviews
D144509 [CMake] Bumps minimum version to 3.20.0.
This partly undoes D137724.
This change has been discussed on discourse
https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193
Note this does not remove work-arounds for older CMake versions, that
will be done in followup patches.
D150532 [OpenMP] Compile assembly files as ASM, not C
Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent)
when compiling a file which has been set as having the language
C. This behaviour change only takes place if "cmake_minimum_required"
is set to 3.20 or newer, or if the policy CMP0119 is set to new.
Attempting to compile assembly files with "-x c" fails, however
this is workarounded in many cases, as OpenMP overrides this with
"-x assembler-with-cpp", however this is only added for non-Windows
targets.
Thus, after increasing cmake_minimum_required to 3.20, this breaks
compiling the GNU assembly for Windows targets; the GNU assembly is
used for ARM and AArch64 Windows targets when building with Clang.
This patch unbreaks that.
D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump
The build uses other mechanism to select the runtime.
Fixes #62719
Reviewed By: #libc, Mordante
Differential Revision: https://reviews.llvm.org/D151344
2023-05-24 18:12:32 +02:00
|
|
|
cmake_minimum_required(VERSION 3.20.0)
|
[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-09 21:45:52 +00:00
|
|
|
|
2024-01-24 12:38:09 -08:00
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
[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-09 21:45:52 +00:00
|
|
|
project(CompilerRTBuiltins C ASM)
|
|
|
|
set(COMPILER_RT_STANDALONE_BUILD TRUE)
|
|
|
|
set(COMPILER_RT_BUILTINS_STANDALONE_BUILD TRUE)
|
2022-01-01 07:03:31 +00:00
|
|
|
|
|
|
|
set(COMPILER_RT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
|
|
|
|
|
|
|
set(LLVM_COMMON_CMAKE_UTILS "${COMPILER_RT_SOURCE_DIR}/../cmake")
|
|
|
|
|
|
|
|
# Add path for custom modules
|
[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-09 21:45:52 +00:00
|
|
|
list(INSERT CMAKE_MODULE_PATH 0
|
2022-01-01 07:03:31 +00:00
|
|
|
"${COMPILER_RT_SOURCE_DIR}/cmake"
|
|
|
|
"${COMPILER_RT_SOURCE_DIR}/cmake/Modules"
|
|
|
|
"${LLVM_COMMON_CMAKE_UTILS}"
|
|
|
|
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
|
|
|
|
)
|
|
|
|
|
[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-09 21:45:52 +00:00
|
|
|
include(base-config-ix)
|
|
|
|
include(CompilerRTUtils)
|
2016-08-02 05:51:05 +00:00
|
|
|
|
2022-11-11 22:50:14 +00:00
|
|
|
if (NOT LLVM_RUNTIMES_BUILD)
|
|
|
|
load_llvm_config()
|
|
|
|
endif()
|
2016-08-02 05:51:05 +00:00
|
|
|
construct_compiler_rt_default_triple()
|
|
|
|
|
2021-12-07 11:53:38 -08:00
|
|
|
include(SetPlatformToolchainTools)
|
[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-09 21:45:52 +00:00
|
|
|
if(APPLE)
|
|
|
|
include(CompilerRTDarwinUtils)
|
|
|
|
endif()
|
2020-08-21 13:03:13 -07:00
|
|
|
if(APPLE)
|
2019-06-04 02:38:15 +00:00
|
|
|
include(UseLibtool)
|
|
|
|
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-09 21:45:52 +00:00
|
|
|
include(AddCompilerRT)
|
2023-12-07 13:25:24 +02:00
|
|
|
|
|
|
|
if(MINGW)
|
|
|
|
# Simplified version of what's set in cmake/config-ix.cmake; not including
|
|
|
|
# builtins, which are linked separately.
|
|
|
|
set(MINGW_LIBRARIES mingw32 moldname mingwex msvcrt advapi32 shell32
|
|
|
|
user32 kernel32 mingw32 moldname mingwex msvcrt)
|
|
|
|
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-09 21:45:52 +00:00
|
|
|
endif()
|
|
|
|
|
2020-01-31 15:57:18 -08:00
|
|
|
if (COMPILER_RT_STANDALONE_BUILD)
|
|
|
|
# When compiler-rt is being built standalone, possibly as a cross-compilation
|
|
|
|
# target, the target may or may not want position independent code. This
|
|
|
|
# option provides an avenue through which the flag may be controlled when an
|
|
|
|
# LLVM configuration is not being utilized.
|
|
|
|
option(COMPILER_RT_BUILTINS_ENABLE_PIC
|
|
|
|
"Turns on or off -fPIC for the builtin library source"
|
|
|
|
ON)
|
|
|
|
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-09 21:45:52 +00:00
|
|
|
include(builtin-config-ix)
|
2023-06-28 07:14:00 +00:00
|
|
|
include(CMakeDependentOption)
|
2023-03-03 13:54:08 +00:00
|
|
|
include(CMakePushCheckState)
|
[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-09 21:45:52 +00:00
|
|
|
|
[builtins] Add COMPILER_RT_BUILTINS_HIDE_SYMBOLS
On Android, when the builtins are linked into a binary, they are
typically linked using -Wl,--exclude-libs so that the symbols aren't
reexported. For the NDK, compiler-rt's default behavior (build the
builtins archive with -fvisibility=hidden) is better so that builtins
are hidden even without -Wl,--exclude-libs.
Android needs the builtins with non-hidden symbols only for a special
case: for backwards compatibility with old binaries, the libc.so and
libm.so DSOs in the platform need to export some builtins for arm32 and
32-bit x86. See D56977.
Control the behavior with a new flag,
`COMPILER_RT_BUILTINS_HIDE_SYMBOLS`, that behaves similarly to the
`*_HERMETIC_STATIC_LIBRARY` in libunwind/libcxx/libcxxabi, so that
Android can build a special builtins variant for libc.so/libm.so.
Unlike the hermetic flags for other projects, this new flag is enabled
by default.
Reviewed By: compnerd, MaskRay
Differential Revision: https://reviews.llvm.org/D93431
2021-01-07 17:49:29 -08:00
|
|
|
option(COMPILER_RT_BUILTINS_HIDE_SYMBOLS
|
|
|
|
"Do not export any symbols from the static library." ON)
|
|
|
|
|
2015-11-12 19:17:05 +00:00
|
|
|
# TODO: Need to add a mechanism for logging errors when builtin source files are
|
|
|
|
# added to a sub-directory and not this CMakeLists file.
|
2014-02-14 09:20:33 +00:00
|
|
|
set(GENERIC_SOURCES
|
|
|
|
absvdi2.c
|
|
|
|
absvsi2.c
|
|
|
|
absvti2.c
|
|
|
|
adddf3.c
|
|
|
|
addsf3.c
|
|
|
|
addvdi3.c
|
|
|
|
addvsi3.c
|
|
|
|
addvti3.c
|
|
|
|
apple_versioning.c
|
|
|
|
ashldi3.c
|
|
|
|
ashlti3.c
|
|
|
|
ashrdi3.c
|
|
|
|
ashrti3.c
|
Add generic __bswap[ds]i2 implementations
Summary:
In FreeBSD we needed to add generic implementations for `__bswapdi2` and
`__bswapsi2`, since gcc 6.x for mips is emitting calls to these. See:
https://reviews.freebsd.org/D10838 and https://reviews.freebsd.org/rS318601
The actual mips code generated for these generic C versions is pretty
OK, as can be seen in the (FreeBSD) review.
I checked over gcc sources, and it seems that it can emit these calls on
more architectures, so maybe it's best to simply always add them to the
compiler-rt builtins library.
Reviewers: howard.hinnant, compnerd, petarj, emaste
Reviewed By: compnerd, emaste
Subscribers: mgorny, llvm-commits, arichardson
Differential Revision: https://reviews.llvm.org/D33516
llvm-svn: 303866
2017-05-25 14:52:14 +00:00
|
|
|
bswapdi2.c
|
|
|
|
bswapsi2.c
|
2014-02-14 09:20:33 +00:00
|
|
|
clzdi2.c
|
|
|
|
clzsi2.c
|
|
|
|
clzti2.c
|
|
|
|
cmpdi2.c
|
|
|
|
cmpti2.c
|
|
|
|
comparedf2.c
|
|
|
|
comparesf2.c
|
|
|
|
ctzdi2.c
|
|
|
|
ctzsi2.c
|
|
|
|
ctzti2.c
|
|
|
|
divdc3.c
|
|
|
|
divdf3.c
|
|
|
|
divdi3.c
|
|
|
|
divmoddi4.c
|
|
|
|
divmodsi4.c
|
2020-09-16 21:56:01 -07:00
|
|
|
divmodti4.c
|
2014-02-14 09:20:33 +00:00
|
|
|
divsc3.c
|
|
|
|
divsf3.c
|
|
|
|
divsi3.c
|
|
|
|
divti3.c
|
|
|
|
extendsfdf2.c
|
2015-05-12 18:33:42 +00:00
|
|
|
extendhfsf2.c
|
2014-02-14 09:20:33 +00:00
|
|
|
ffsdi2.c
|
2017-04-06 18:12:02 +00:00
|
|
|
ffssi2.c
|
2014-02-14 09:20:33 +00:00
|
|
|
ffsti2.c
|
|
|
|
fixdfdi.c
|
|
|
|
fixdfsi.c
|
|
|
|
fixdfti.c
|
|
|
|
fixsfdi.c
|
|
|
|
fixsfsi.c
|
|
|
|
fixsfti.c
|
|
|
|
fixunsdfdi.c
|
|
|
|
fixunsdfsi.c
|
|
|
|
fixunsdfti.c
|
|
|
|
fixunssfdi.c
|
|
|
|
fixunssfsi.c
|
|
|
|
fixunssfti.c
|
|
|
|
floatdidf.c
|
|
|
|
floatdisf.c
|
|
|
|
floatsidf.c
|
|
|
|
floatsisf.c
|
|
|
|
floattidf.c
|
|
|
|
floattisf.c
|
|
|
|
floatundidf.c
|
|
|
|
floatundisf.c
|
|
|
|
floatunsidf.c
|
|
|
|
floatunsisf.c
|
|
|
|
floatuntidf.c
|
|
|
|
floatuntisf.c
|
2019-09-05 01:05:05 +00:00
|
|
|
fp_mode.c
|
2014-02-14 09:20:33 +00:00
|
|
|
int_util.c
|
|
|
|
lshrdi3.c
|
|
|
|
lshrti3.c
|
|
|
|
moddi3.c
|
|
|
|
modsi3.c
|
|
|
|
modti3.c
|
|
|
|
muldc3.c
|
|
|
|
muldf3.c
|
|
|
|
muldi3.c
|
|
|
|
mulodi4.c
|
|
|
|
mulosi4.c
|
|
|
|
muloti4.c
|
|
|
|
mulsc3.c
|
|
|
|
mulsf3.c
|
|
|
|
multi3.c
|
|
|
|
mulvdi3.c
|
|
|
|
mulvsi3.c
|
|
|
|
mulvti3.c
|
|
|
|
negdf2.c
|
|
|
|
negdi2.c
|
|
|
|
negsf2.c
|
|
|
|
negti2.c
|
|
|
|
negvdi2.c
|
|
|
|
negvsi2.c
|
|
|
|
negvti2.c
|
2017-03-09 17:02:16 +00:00
|
|
|
os_version_check.c
|
2014-02-14 09:20:33 +00:00
|
|
|
paritydi2.c
|
|
|
|
paritysi2.c
|
|
|
|
parityti2.c
|
|
|
|
popcountdi2.c
|
|
|
|
popcountsi2.c
|
|
|
|
popcountti2.c
|
|
|
|
powidf2.c
|
|
|
|
powisf2.c
|
|
|
|
subdf3.c
|
|
|
|
subsf3.c
|
|
|
|
subvdi3.c
|
|
|
|
subvsi3.c
|
|
|
|
subvti3.c
|
|
|
|
trampoline_setup.c
|
2015-05-12 18:33:42 +00:00
|
|
|
truncdfhf2.c
|
2014-02-14 09:20:33 +00:00
|
|
|
truncdfsf2.c
|
2015-05-12 18:33:42 +00:00
|
|
|
truncsfhf2.c
|
2014-02-14 09:20:33 +00:00
|
|
|
ucmpdi2.c
|
|
|
|
ucmpti2.c
|
|
|
|
udivdi3.c
|
|
|
|
udivmoddi4.c
|
|
|
|
udivmodsi4.c
|
|
|
|
udivmodti4.c
|
|
|
|
udivsi3.c
|
|
|
|
udivti3.c
|
|
|
|
umoddi3.c
|
|
|
|
umodsi3.c
|
2019-04-05 21:30:40 +00:00
|
|
|
umodti3.c
|
|
|
|
)
|
2014-02-14 09:20:33 +00:00
|
|
|
|
2023-03-03 13:54:08 +00:00
|
|
|
# We only build BF16 files when "__bf16" is available.
|
|
|
|
set(BF16_SOURCES
|
2024-03-04 00:01:50 -05:00
|
|
|
extendbfsf2.c
|
2023-01-23 11:21:28 +01:00
|
|
|
truncdfbf2.c
|
2024-09-19 15:39:07 +08:00
|
|
|
truncxfbf2.c
|
2023-01-23 11:21:28 +01:00
|
|
|
truncsfbf2.c
|
2024-11-12 15:54:09 +08:00
|
|
|
trunctfbf2.c
|
2023-03-03 13:54:08 +00:00
|
|
|
)
|
2022-08-10 09:13:27 +08:00
|
|
|
|
2017-05-04 13:34:17 +00:00
|
|
|
set(GENERIC_TF_SOURCES
|
2020-06-25 22:32:41 +03:00
|
|
|
addtf3.c
|
2017-05-04 13:34:17 +00:00
|
|
|
comparetf2.c
|
2020-06-25 22:32:41 +03:00
|
|
|
divtc3.c
|
|
|
|
divtf3.c
|
2017-05-04 13:34:17 +00:00
|
|
|
extenddftf2.c
|
2020-12-08 10:26:18 -03:00
|
|
|
extendhftf2.c
|
2017-05-04 13:34:17 +00:00
|
|
|
extendsftf2.c
|
|
|
|
fixtfdi.c
|
|
|
|
fixtfsi.c
|
|
|
|
fixtfti.c
|
|
|
|
fixunstfdi.c
|
|
|
|
fixunstfsi.c
|
|
|
|
fixunstfti.c
|
|
|
|
floatditf.c
|
|
|
|
floatsitf.c
|
|
|
|
floattitf.c
|
|
|
|
floatunditf.c
|
|
|
|
floatunsitf.c
|
|
|
|
floatuntitf.c
|
|
|
|
multc3.c
|
2020-06-25 22:32:41 +03:00
|
|
|
multf3.c
|
|
|
|
powitf2.c
|
|
|
|
subtf3.c
|
2017-05-04 13:34:17 +00:00
|
|
|
trunctfdf2.c
|
2020-12-08 10:26:18 -03:00
|
|
|
trunctfhf2.c
|
2019-04-05 21:30:40 +00:00
|
|
|
trunctfsf2.c
|
|
|
|
)
|
2017-05-04 13:34:17 +00:00
|
|
|
|
2016-09-01 21:05:49 +00:00
|
|
|
option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
|
2018-06-14 23:22:53 +00:00
|
|
|
"Skip the atomic builtin (these should normally be provided by a shared library)"
|
|
|
|
On)
|
2016-09-01 21:05:49 +00:00
|
|
|
|
2024-07-10 15:07:11 -05:00
|
|
|
if(NOT FUCHSIA AND NOT COMPILER_RT_BAREMETAL_BUILD AND NOT COMPILER_RT_GPU_BUILD)
|
2017-05-10 15:34:25 +00:00
|
|
|
set(GENERIC_SOURCES
|
|
|
|
${GENERIC_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
emutls.c
|
2017-07-12 19:33:30 +00:00
|
|
|
enable_execute_stack.c
|
2019-04-05 21:30:40 +00:00
|
|
|
eprintf.c
|
|
|
|
)
|
2017-05-10 15:34:25 +00:00
|
|
|
endif()
|
|
|
|
|
2024-06-13 10:03:15 -07:00
|
|
|
option(COMPILER_RT_LIBATOMIC_USE_PTHREAD
|
|
|
|
"Whether libatomic should use pthreads if available."
|
|
|
|
Off)
|
|
|
|
|
|
|
|
if(COMPILER_RT_LIBATOMIC_USE_PTHREAD)
|
|
|
|
add_compile_definitions(_LIBATOMIC_USE_PTHREAD)
|
|
|
|
endif()
|
|
|
|
|
2016-09-01 21:05:49 +00:00
|
|
|
if(COMPILER_RT_HAS_ATOMIC_KEYWORD AND NOT COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN)
|
2016-08-12 01:29:26 +00:00
|
|
|
set(GENERIC_SOURCES
|
|
|
|
${GENERIC_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
atomic.c
|
|
|
|
)
|
2016-08-12 01:29:26 +00:00
|
|
|
endif()
|
|
|
|
|
2015-09-23 15:28:44 +00:00
|
|
|
if(APPLE)
|
|
|
|
set(GENERIC_SOURCES
|
|
|
|
${GENERIC_SOURCES}
|
|
|
|
atomic_flag_clear.c
|
|
|
|
atomic_flag_clear_explicit.c
|
|
|
|
atomic_flag_test_and_set.c
|
|
|
|
atomic_flag_test_and_set_explicit.c
|
|
|
|
atomic_signal_fence.c
|
2019-04-05 21:30:40 +00:00
|
|
|
atomic_thread_fence.c
|
|
|
|
)
|
2015-09-23 15:28:44 +00:00
|
|
|
endif()
|
|
|
|
|
2015-01-14 15:55:17 +00:00
|
|
|
if (HAVE_UNWIND_H)
|
|
|
|
set(GENERIC_SOURCES
|
2019-04-05 21:30:40 +00:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
gcc_personality_v0.c
|
|
|
|
)
|
2015-01-14 15:55:17 +00:00
|
|
|
endif ()
|
|
|
|
|
2017-07-12 19:33:30 +00:00
|
|
|
if (NOT FUCHSIA)
|
|
|
|
set(GENERIC_SOURCES
|
|
|
|
${GENERIC_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
clear_cache.c
|
|
|
|
)
|
2017-07-12 19:33:30 +00:00
|
|
|
endif()
|
|
|
|
|
2020-07-16 15:10:22 -07:00
|
|
|
# These files are used on 32-bit and 64-bit x86.
|
2020-07-16 18:29:48 -04:00
|
|
|
set(x86_ARCH_SOURCES
|
2023-12-19 11:09:50 -07:00
|
|
|
cpu_model/x86.c
|
2020-07-16 18:29:48 -04:00
|
|
|
)
|
2020-07-16 15:10:22 -07:00
|
|
|
|
|
|
|
if (NOT MSVC)
|
|
|
|
set(x86_ARCH_SOURCES
|
|
|
|
${x86_ARCH_SOURCES}
|
|
|
|
i386/fp_mode.c
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
# Implement extended-precision builtins, assuming long double is 80 bits.
|
|
|
|
# long double is not 80 bits on Android or MSVC.
|
|
|
|
set(x86_80_BIT_SOURCES
|
2017-11-30 19:39:33 +00:00
|
|
|
divxc3.c
|
2024-11-25 23:49:27 +05:30
|
|
|
extendhfxf2.c
|
2023-10-16 16:12:33 -07:00
|
|
|
extendxftf2.c
|
2017-11-30 19:39:33 +00:00
|
|
|
fixxfdi.c
|
|
|
|
fixxfti.c
|
|
|
|
fixunsxfdi.c
|
|
|
|
fixunsxfsi.c
|
|
|
|
fixunsxfti.c
|
|
|
|
floatdixf.c
|
|
|
|
floattixf.c
|
|
|
|
floatundixf.c
|
|
|
|
floatuntixf.c
|
|
|
|
mulxc3.c
|
|
|
|
powixf2.c
|
2023-10-16 16:12:33 -07:00
|
|
|
trunctfxf2.c
|
2024-12-31 03:44:43 +05:30
|
|
|
truncxfhf2.c
|
2017-11-30 19:39:33 +00:00
|
|
|
)
|
|
|
|
|
2015-10-15 02:47:19 +00:00
|
|
|
if (NOT MSVC)
|
2015-07-17 16:23:05 +00:00
|
|
|
set(x86_64_SOURCES
|
2020-06-18 23:59:36 -07:00
|
|
|
${GENERIC_SOURCES}
|
2019-04-18 19:29:03 +00:00
|
|
|
${GENERIC_TF_SOURCES}
|
2020-06-18 23:59:36 -07:00
|
|
|
${x86_ARCH_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
x86_64/floatdidf.c
|
|
|
|
x86_64/floatdisf.c
|
|
|
|
)
|
2023-04-06 07:51:35 +00:00
|
|
|
if (NOT WIN32)
|
|
|
|
set(x86_64_SOURCES
|
|
|
|
${x86_64_SOURCES}
|
|
|
|
x86_64/floatundidf.S
|
|
|
|
x86_64/floatundisf.S
|
|
|
|
)
|
|
|
|
endif()
|
2020-06-18 23:59:36 -07:00
|
|
|
|
2020-07-16 15:10:22 -07:00
|
|
|
if (NOT ANDROID)
|
|
|
|
set(x86_64_SOURCES
|
|
|
|
${x86_64_SOURCES}
|
|
|
|
${x86_80_BIT_SOURCES}
|
|
|
|
x86_64/floatdixf.c
|
|
|
|
)
|
2023-04-06 07:51:35 +00:00
|
|
|
if (NOT WIN32)
|
|
|
|
set(x86_64_SOURCES
|
|
|
|
${x86_64_SOURCES}
|
|
|
|
x86_64/floatundixf.S
|
|
|
|
)
|
|
|
|
endif()
|
2020-07-16 15:10:22 -07:00
|
|
|
endif()
|
|
|
|
|
2020-06-18 23:59:36 -07:00
|
|
|
# Darwin x86_64 Haswell
|
2015-10-15 02:47:19 +00:00
|
|
|
set(x86_64h_SOURCES ${x86_64_SOURCES})
|
2015-07-17 16:23:05 +00:00
|
|
|
|
2015-10-15 02:47:19 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(x86_64_SOURCES
|
2019-04-05 21:30:40 +00:00
|
|
|
${x86_64_SOURCES}
|
|
|
|
x86_64/chkstk.S
|
|
|
|
)
|
2015-10-15 02:47:19 +00:00
|
|
|
endif()
|
2014-02-14 09:20:33 +00:00
|
|
|
|
2015-07-17 16:23:05 +00:00
|
|
|
set(i386_SOURCES
|
2020-06-18 23:59:36 -07:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
${x86_ARCH_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
i386/ashldi3.S
|
|
|
|
i386/ashrdi3.S
|
|
|
|
i386/divdi3.S
|
|
|
|
i386/floatdidf.S
|
|
|
|
i386/floatdisf.S
|
|
|
|
i386/floatundidf.S
|
|
|
|
i386/floatundisf.S
|
|
|
|
i386/lshrdi3.S
|
|
|
|
i386/moddi3.S
|
|
|
|
i386/muldi3.S
|
|
|
|
i386/udivdi3.S
|
|
|
|
i386/umoddi3.S
|
|
|
|
)
|
2015-07-17 16:23:05 +00:00
|
|
|
|
2020-07-16 15:10:22 -07:00
|
|
|
if (NOT ANDROID)
|
|
|
|
set(i386_SOURCES
|
|
|
|
${i386_SOURCES}
|
|
|
|
${x86_80_BIT_SOURCES}
|
|
|
|
i386/floatdixf.S
|
|
|
|
i386/floatundixf.S
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2015-10-15 02:47:19 +00:00
|
|
|
if (WIN32)
|
|
|
|
set(i386_SOURCES
|
2019-04-05 21:30:40 +00:00
|
|
|
${i386_SOURCES}
|
2023-08-30 00:05:06 +03:00
|
|
|
i386/chkstk.S
|
2019-04-05 21:30:40 +00:00
|
|
|
)
|
2015-10-15 02:47:19 +00:00
|
|
|
endif()
|
|
|
|
else () # MSVC
|
|
|
|
# Use C versions of functions when building on MSVC
|
2016-02-20 12:56:04 +00:00
|
|
|
# MSVC's assembler takes Intel syntax, not AT&T syntax.
|
|
|
|
# Also use only MSVC compilable builtin implementations.
|
2015-10-15 02:47:19 +00:00
|
|
|
set(x86_64_SOURCES
|
2020-06-18 23:59:36 -07:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
${x86_ARCH_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
x86_64/floatdidf.c
|
|
|
|
x86_64/floatdisf.c
|
|
|
|
)
|
2020-06-18 23:59:36 -07:00
|
|
|
set(i386_SOURCES ${GENERIC_SOURCES} ${x86_ARCH_SOURCES})
|
2015-10-15 02:47:19 +00:00
|
|
|
endif () # if (NOT MSVC)
|
2014-10-01 12:55:06 +00:00
|
|
|
|
2022-12-01 20:52:18 +00:00
|
|
|
|
|
|
|
# builtin support for Targets that have Arm state or have Thumb2
|
|
|
|
set(arm_or_thumb2_base_SOURCES
|
2019-09-05 01:05:05 +00:00
|
|
|
arm/fp_mode.c
|
2016-08-04 21:58:39 +00:00
|
|
|
arm/bswapdi2.S
|
|
|
|
arm/bswapsi2.S
|
|
|
|
arm/clzdi2.S
|
|
|
|
arm/clzsi2.S
|
|
|
|
arm/comparesf2.S
|
|
|
|
arm/divmodsi4.S
|
|
|
|
arm/divsi3.S
|
|
|
|
arm/modsi3.S
|
2022-12-01 20:52:18 +00:00
|
|
|
arm/udivmodsi4.S
|
|
|
|
arm/udivsi3.S
|
|
|
|
arm/umodsi3.S
|
|
|
|
${GENERIC_SOURCES}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(arm_sync_SOURCES
|
2016-08-04 21:58:39 +00:00
|
|
|
arm/sync_fetch_and_add_4.S
|
|
|
|
arm/sync_fetch_and_add_8.S
|
|
|
|
arm/sync_fetch_and_and_4.S
|
|
|
|
arm/sync_fetch_and_and_8.S
|
|
|
|
arm/sync_fetch_and_max_4.S
|
|
|
|
arm/sync_fetch_and_max_8.S
|
|
|
|
arm/sync_fetch_and_min_4.S
|
|
|
|
arm/sync_fetch_and_min_8.S
|
|
|
|
arm/sync_fetch_and_nand_4.S
|
|
|
|
arm/sync_fetch_and_nand_8.S
|
|
|
|
arm/sync_fetch_and_or_4.S
|
|
|
|
arm/sync_fetch_and_or_8.S
|
|
|
|
arm/sync_fetch_and_sub_4.S
|
|
|
|
arm/sync_fetch_and_sub_8.S
|
|
|
|
arm/sync_fetch_and_umax_4.S
|
|
|
|
arm/sync_fetch_and_umax_8.S
|
|
|
|
arm/sync_fetch_and_umin_4.S
|
|
|
|
arm/sync_fetch_and_umin_8.S
|
|
|
|
arm/sync_fetch_and_xor_4.S
|
|
|
|
arm/sync_fetch_and_xor_8.S
|
2019-04-05 21:30:40 +00:00
|
|
|
)
|
2016-08-04 21:58:39 +00:00
|
|
|
|
2022-12-01 20:52:18 +00:00
|
|
|
# builtin support for Thumb-only targets with very limited Thumb2 technology,
|
|
|
|
# such as v6-m and v8-m.baseline
|
|
|
|
set(thumb1_base_SOURCES
|
2017-01-19 18:46:11 +00:00
|
|
|
arm/divsi3.S
|
|
|
|
arm/udivsi3.S
|
|
|
|
arm/comparesf2.S
|
2017-02-06 06:04:10 +00:00
|
|
|
arm/addsf3.S
|
2019-04-05 21:30:40 +00:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
)
|
2017-01-19 18:46:11 +00:00
|
|
|
|
2016-08-04 21:58:39 +00:00
|
|
|
set(arm_EABI_SOURCES
|
2015-08-21 00:25:37 +00:00
|
|
|
arm/aeabi_cdcmp.S
|
|
|
|
arm/aeabi_cdcmpeq_check_nan.c
|
|
|
|
arm/aeabi_cfcmp.S
|
|
|
|
arm/aeabi_cfcmpeq_check_nan.c
|
2014-02-14 09:20:33 +00:00
|
|
|
arm/aeabi_dcmp.S
|
2014-09-06 21:34:02 +00:00
|
|
|
arm/aeabi_div0.c
|
2015-08-18 18:10:33 +00:00
|
|
|
arm/aeabi_drsub.c
|
2014-02-14 09:20:33 +00:00
|
|
|
arm/aeabi_fcmp.S
|
2015-08-18 18:10:33 +00:00
|
|
|
arm/aeabi_frsub.c
|
2014-02-14 09:20:33 +00:00
|
|
|
arm/aeabi_idivmod.S
|
|
|
|
arm/aeabi_ldivmod.S
|
|
|
|
arm/aeabi_memcmp.S
|
|
|
|
arm/aeabi_memcpy.S
|
|
|
|
arm/aeabi_memmove.S
|
|
|
|
arm/aeabi_memset.S
|
|
|
|
arm/aeabi_uidivmod.S
|
2019-04-05 21:30:40 +00:00
|
|
|
arm/aeabi_uldivmod.S
|
|
|
|
)
|
2017-01-19 18:46:11 +00:00
|
|
|
|
2016-08-05 16:24:56 +00:00
|
|
|
set(arm_Thumb1_JT_SOURCES
|
|
|
|
arm/switch16.S
|
|
|
|
arm/switch32.S
|
|
|
|
arm/switch8.S
|
2019-04-05 21:30:40 +00:00
|
|
|
arm/switchu8.S
|
|
|
|
)
|
2016-08-05 16:24:56 +00:00
|
|
|
set(arm_Thumb1_SjLj_EH_SOURCES
|
|
|
|
arm/restore_vfp_d8_d15_regs.S
|
2019-04-05 21:30:40 +00:00
|
|
|
arm/save_vfp_d8_d15_regs.S
|
|
|
|
)
|
2020-11-12 14:44:54 +00:00
|
|
|
set(arm_Thumb1_VFPv2_DP_SOURCES
|
2016-08-04 21:58:39 +00:00
|
|
|
arm/adddf3vfp.S
|
2014-02-14 09:20:33 +00:00
|
|
|
arm/divdf3vfp.S
|
|
|
|
arm/eqdf2vfp.S
|
|
|
|
arm/extendsfdf2vfp.S
|
|
|
|
arm/fixdfsivfp.S
|
|
|
|
arm/fixunsdfsivfp.S
|
|
|
|
arm/floatsidfvfp.S
|
|
|
|
arm/floatunssidfvfp.S
|
|
|
|
arm/gedf2vfp.S
|
|
|
|
arm/gtdf2vfp.S
|
|
|
|
arm/ledf2vfp.S
|
|
|
|
arm/ltdf2vfp.S
|
|
|
|
arm/muldf3vfp.S
|
|
|
|
arm/nedf2vfp.S
|
|
|
|
arm/negdf2vfp.S
|
|
|
|
arm/subdf3vfp.S
|
|
|
|
arm/truncdfsf2vfp.S
|
|
|
|
arm/unorddf2vfp.S
|
2020-11-12 14:44:54 +00:00
|
|
|
)
|
|
|
|
set(arm_Thumb1_VFPv2_SP_SOURCES
|
|
|
|
arm/addsf3vfp.S
|
|
|
|
arm/divsf3vfp.S
|
|
|
|
arm/eqsf2vfp.S
|
|
|
|
arm/fixsfsivfp.S
|
|
|
|
arm/fixunssfsivfp.S
|
|
|
|
arm/floatsisfvfp.S
|
|
|
|
arm/floatunssisfvfp.S
|
|
|
|
arm/gesf2vfp.S
|
|
|
|
arm/gtsf2vfp.S
|
|
|
|
arm/lesf2vfp.S
|
|
|
|
arm/ltsf2vfp.S
|
|
|
|
arm/mulsf3vfp.S
|
|
|
|
arm/negsf2vfp.S
|
|
|
|
arm/nesf2vfp.S
|
|
|
|
arm/subsf3vfp.S
|
2019-04-05 21:30:40 +00:00
|
|
|
arm/unordsf2vfp.S
|
|
|
|
)
|
2016-08-05 16:24:56 +00:00
|
|
|
set(arm_Thumb1_icache_SOURCES
|
2019-04-05 21:30:40 +00:00
|
|
|
arm/sync_synchronize.S
|
|
|
|
)
|
2022-12-01 20:52:18 +00:00
|
|
|
|
|
|
|
# thumb1 calling into Arm to cover support
|
2018-05-24 21:36:27 +00:00
|
|
|
set(arm_Thumb1_SOURCES
|
|
|
|
${arm_Thumb1_JT_SOURCES}
|
|
|
|
${arm_Thumb1_SjLj_EH_SOURCES}
|
2020-11-12 14:44:54 +00:00
|
|
|
${arm_Thumb1_VFPv2_DP_SOURCES}
|
|
|
|
${arm_Thumb1_VFPv2_SP_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
${arm_Thumb1_icache_SOURCES}
|
|
|
|
)
|
2016-08-04 21:58:39 +00:00
|
|
|
|
2022-12-01 20:52:18 +00:00
|
|
|
# base functionality for Arm Targets prior to Arm v7-a and Armv6-m such as v6,
|
|
|
|
# v5t, v4t
|
|
|
|
set(arm_min_SOURCES
|
|
|
|
${arm_or_thumb2_base_SOURCES}
|
|
|
|
${arm_EABI_SOURCES}
|
|
|
|
)
|
|
|
|
|
2016-11-19 21:22:38 +00:00
|
|
|
if(MINGW)
|
|
|
|
set(arm_SOURCES
|
2019-04-05 21:30:40 +00:00
|
|
|
arm/aeabi_idivmod.S
|
|
|
|
arm/aeabi_ldivmod.S
|
|
|
|
arm/aeabi_uidivmod.S
|
|
|
|
arm/aeabi_uldivmod.S
|
|
|
|
arm/chkstk.S
|
2022-12-01 20:52:18 +00:00
|
|
|
${arm_or_thumb2_base_SOURCES}
|
|
|
|
${arm_sync_SOURCES}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(thumb1_SOURCES
|
|
|
|
${thumb1_base_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
)
|
2016-12-01 22:00:54 +00:00
|
|
|
elseif(NOT WIN32)
|
2016-08-05 16:24:56 +00:00
|
|
|
# TODO the EABI sources should only be added to EABI targets
|
2016-08-04 21:58:39 +00:00
|
|
|
set(arm_SOURCES
|
2022-12-01 20:52:18 +00:00
|
|
|
${arm_or_thumb2_base_SOURCES}
|
|
|
|
${arm_sync_SOURCES}
|
2016-08-04 21:58:39 +00:00
|
|
|
${arm_EABI_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
${arm_Thumb1_SOURCES}
|
|
|
|
)
|
2017-01-19 18:46:11 +00:00
|
|
|
|
|
|
|
set(thumb1_SOURCES
|
2022-12-01 20:52:18 +00:00
|
|
|
${thumb1_base_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
${arm_EABI_SOURCES}
|
|
|
|
)
|
2016-08-04 21:58:39 +00:00
|
|
|
endif()
|
2014-02-14 09:20:33 +00:00
|
|
|
|
[compiler-rt] Add AArch64 to CMake configuration and several missing builtins
Summary:
Currently CMake doesn't build builtins for AArch64 and if one does this anyway
it's likely that at least `__multc3`, `__floatditf` and `__floatunditf` will be
missing. There is actually more builtins to add, but these come from
different libc implementations, thus providing them makes compiler-rt for
AArch64 good enough at least for basic usage.
Builtins implementation were originally taken from FreeBSD project:
* [[ https://reviews.freebsd.org/D2173 | __multc3 ]]
* [[ https://reviews.freebsd.org/D2174 | __floatditf and __floatunditf ]]
Until they have been tested to find mistakes in `__float*` functions.
`__floatditf` was based on `__floatsitf`, which had the same mistakes
(fixed it in r243746).
Version of the builtins in this patch are fixed and complemented with basic
tests. Additionally they were tested via GCC's torture (this is what revealed
these issues).
P.S. Ed (author of FreeBSD patches) asked for feedback on the list some time ago (here [[ http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-March/084064.html | here ]])
and got no response, but it seems to be worth adding these builtins as is and
extracting common part later.
Reviewers: howard.hinnant, t.p.northover, jmolloy, enefaim, rengolin, zatrazz
Subscribers: asl, emaste, samsonov, aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D11679
llvm-svn: 245296
2015-08-18 13:43:37 +00:00
|
|
|
set(aarch64_SOURCES
|
2017-05-04 13:34:17 +00:00
|
|
|
${GENERIC_TF_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
${GENERIC_SOURCES}
|
2023-12-19 11:09:50 -07:00
|
|
|
cpu_model/aarch64.c
|
2019-09-05 01:05:05 +00:00
|
|
|
aarch64/fp_mode.c
|
2019-04-05 21:30:40 +00:00
|
|
|
)
|
[compiler-rt] Add AArch64 to CMake configuration and several missing builtins
Summary:
Currently CMake doesn't build builtins for AArch64 and if one does this anyway
it's likely that at least `__multc3`, `__floatditf` and `__floatunditf` will be
missing. There is actually more builtins to add, but these come from
different libc implementations, thus providing them makes compiler-rt for
AArch64 good enough at least for basic usage.
Builtins implementation were originally taken from FreeBSD project:
* [[ https://reviews.freebsd.org/D2173 | __multc3 ]]
* [[ https://reviews.freebsd.org/D2174 | __floatditf and __floatunditf ]]
Until they have been tested to find mistakes in `__float*` functions.
`__floatditf` was based on `__floatsitf`, which had the same mistakes
(fixed it in r243746).
Version of the builtins in this patch are fixed and complemented with basic
tests. Additionally they were tested via GCC's torture (this is what revealed
these issues).
P.S. Ed (author of FreeBSD patches) asked for feedback on the list some time ago (here [[ http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-March/084064.html | here ]])
and got no response, but it seems to be worth adding these builtins as is and
extracting common part later.
Reviewers: howard.hinnant, t.p.northover, jmolloy, enefaim, rengolin, zatrazz
Subscribers: asl, emaste, samsonov, aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D11679
llvm-svn: 245296
2015-08-18 13:43:37 +00:00
|
|
|
|
2024-12-12 15:59:48 +00:00
|
|
|
set(COMPILER_RT_AARCH64_FMV_USES_GLOBAL_CONSTRUCTOR NOT(FUCHSIA OR APPLE))
|
|
|
|
|
2024-06-12 09:35:57 +01:00
|
|
|
if (COMPILER_RT_HAS_AARCH64_SME)
|
2025-01-03 22:07:27 -08:00
|
|
|
if (APPLE)
|
|
|
|
list(APPEND aarch64_SOURCES aarch64/arm_apple_sme_abi.s)
|
|
|
|
set_source_files_properties(aarch64/arm_apple_sme_abi.s PROPERTIES COMPILE_FLAGS -march=armv8a+sme)
|
|
|
|
message(STATUS "AArch64 Apple SME ABI routines enabled")
|
|
|
|
elseif (NOT COMPILER_RT_DISABLE_AARCH64_FMV AND COMPILER_RT_HAS_FNO_BUILTIN_FLAG AND COMPILER_RT_AARCH64_FMV_USES_GLOBAL_CONSTRUCTOR)
|
2024-12-11 15:53:17 +00:00
|
|
|
list(APPEND aarch64_SOURCES aarch64/sme-abi.S aarch64/sme-libc-mem-routines.S aarch64/sme-abi-assert.c aarch64/sme-libc-routines.c)
|
2024-06-12 09:35:57 +01:00
|
|
|
message(STATUS "AArch64 SME ABI routines enabled")
|
|
|
|
set_source_files_properties(aarch64/sme-libc-routines.c PROPERTIES COMPILE_FLAGS "-fno-builtin")
|
|
|
|
else()
|
|
|
|
if(COMPILER_RT_DISABLE_AARCH64_FMV)
|
|
|
|
message(WARNING "AArch64 SME ABI routines require function multiversioning support.")
|
|
|
|
endif()
|
|
|
|
if(NOT COMPILER_RT_HAS_FNO_BUILTIN_FLAG)
|
|
|
|
message(WARNING "AArch64 SME ABI routines require '-fno-builtin'")
|
|
|
|
endif()
|
|
|
|
if(NOT (COMPILER_RT_HAS_AUXV OR COMPILER_RT_BAREMETAL_BUILD))
|
|
|
|
message(WARNING "AArch64 SME ABI routines requires sys/auxv.h or COMPILER_RT_BAREMETAL_BUILD flag")
|
|
|
|
endif()
|
|
|
|
message(STATUS "AArch64 SME ABI routines disabled")
|
|
|
|
endif()
|
2023-10-14 16:35:03 +01:00
|
|
|
endif()
|
|
|
|
|
2020-11-20 15:02:57 +00:00
|
|
|
# Generate outline atomics helpers from lse.S base
|
2020-12-05 20:45:22 +00:00
|
|
|
set(OA_HELPERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/outline_atomic_helpers.dir")
|
2020-12-15 08:15:58 +02:00
|
|
|
file(MAKE_DIRECTORY "${OA_HELPERS_DIR}")
|
2020-11-20 15:02:57 +00:00
|
|
|
|
2021-03-06 11:45:57 +02:00
|
|
|
if(CMAKE_HOST_UNIX)
|
|
|
|
set(COMPILER_RT_LINK_OR_COPY create_symlink)
|
|
|
|
else()
|
|
|
|
set(COMPILER_RT_LINK_OR_COPY copy)
|
|
|
|
endif()
|
|
|
|
|
2020-11-20 15:02:57 +00:00
|
|
|
foreach(pat cas swp ldadd ldclr ldeor ldset)
|
|
|
|
foreach(size 1 2 4 8 16)
|
2023-09-04 01:46:00 +01:00
|
|
|
foreach(model 1 2 3 4 5)
|
2020-11-20 15:02:57 +00:00
|
|
|
if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
|
2023-09-21 11:57:18 -07:00
|
|
|
set(source_asm "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S")
|
2020-12-15 08:15:58 +02:00
|
|
|
set(helper_asm "${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S")
|
2023-09-21 11:57:18 -07:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${helper_asm}"
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${source_asm}" "${helper_asm}"
|
|
|
|
DEPENDS "${source_asm}"
|
|
|
|
)
|
2020-12-15 08:15:58 +02:00
|
|
|
set_source_files_properties("${helper_asm}"
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_DEFINITIONS "L_${pat};SIZE=${size};MODEL=${model}"
|
|
|
|
INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
|
2020-11-20 15:02:57 +00:00
|
|
|
)
|
2020-12-15 08:15:58 +02:00
|
|
|
list(APPEND aarch64_SOURCES "${helper_asm}")
|
2020-11-20 15:02:57 +00:00
|
|
|
endif()
|
|
|
|
endforeach(model)
|
|
|
|
endforeach(size)
|
|
|
|
endforeach(pat)
|
|
|
|
|
2017-12-20 06:52:52 +00:00
|
|
|
if (MINGW)
|
|
|
|
set(aarch64_SOURCES
|
2019-04-05 21:30:40 +00:00
|
|
|
${aarch64_SOURCES}
|
|
|
|
aarch64/chkstk.S
|
|
|
|
)
|
2017-12-20 06:52:52 +00:00
|
|
|
endif()
|
|
|
|
|
2024-07-10 15:07:11 -05:00
|
|
|
set(amdgcn_SOURCES ${GENERIC_SOURCES})
|
|
|
|
|
2022-12-01 20:52:18 +00:00
|
|
|
set(armv4t_SOURCES ${arm_min_SOURCES})
|
2023-01-11 10:00:02 +00:00
|
|
|
set(armv5te_SOURCES ${arm_min_SOURCES})
|
|
|
|
set(armv6_SOURCES ${arm_min_SOURCES})
|
2015-09-26 03:26:01 +00:00
|
|
|
set(armhf_SOURCES ${arm_SOURCES})
|
2015-08-31 21:24:50 +00:00
|
|
|
set(armv7_SOURCES ${arm_SOURCES})
|
|
|
|
set(armv7s_SOURCES ${arm_SOURCES})
|
2016-02-02 02:01:17 +00:00
|
|
|
set(armv7k_SOURCES ${arm_SOURCES})
|
2015-08-31 21:24:50 +00:00
|
|
|
set(arm64_SOURCES ${aarch64_SOURCES})
|
2020-03-11 19:58:15 -07:00
|
|
|
set(arm64e_SOURCES ${aarch64_SOURCES})
|
2021-04-01 17:15:56 -07:00
|
|
|
set(arm64_32_SOURCES ${aarch64_SOURCES})
|
2015-08-31 21:24:50 +00:00
|
|
|
|
2015-09-29 23:13:45 +00:00
|
|
|
# macho_embedded archs
|
2017-01-19 18:46:11 +00:00
|
|
|
set(armv6m_SOURCES ${thumb1_SOURCES})
|
2015-09-29 23:13:45 +00:00
|
|
|
set(armv7m_SOURCES ${arm_SOURCES})
|
|
|
|
set(armv7em_SOURCES ${arm_SOURCES})
|
2023-03-14 17:20:54 -07:00
|
|
|
set(armv8m.base_SOURCES ${thumb1_SOURCES})
|
2021-03-30 16:57:50 +01:00
|
|
|
set(armv8m.main_SOURCES ${arm_SOURCES})
|
|
|
|
set(armv8.1m.main_SOURCES ${arm_SOURCES})
|
2015-09-29 23:13:45 +00:00
|
|
|
|
2022-04-06 10:45:50 +00:00
|
|
|
# 8-bit AVR MCU
|
|
|
|
set(avr_SOURCES
|
|
|
|
avr/mulqi3.S
|
|
|
|
avr/mulhi3.S
|
|
|
|
avr/exit.S
|
2022-05-05 07:35:09 +00:00
|
|
|
avr/divmodhi4.S
|
|
|
|
avr/udivmodhi4.S
|
|
|
|
avr/divmodqi4.S
|
|
|
|
avr/udivmodqi4.S
|
2022-05-05 00:46:27 +02:00
|
|
|
${GENERIC_SOURCES}
|
2022-04-06 10:45:50 +00:00
|
|
|
)
|
|
|
|
|
2018-05-09 14:44:54 +00:00
|
|
|
# hexagon arch
|
|
|
|
set(hexagon_SOURCES
|
|
|
|
hexagon/common_entry_exit_abi1.S
|
|
|
|
hexagon/common_entry_exit_abi2.S
|
|
|
|
hexagon/common_entry_exit_legacy.S
|
|
|
|
hexagon/dfaddsub.S
|
|
|
|
hexagon/dfdiv.S
|
|
|
|
hexagon/dffma.S
|
|
|
|
hexagon/dfminmax.S
|
|
|
|
hexagon/dfmul.S
|
|
|
|
hexagon/dfsqrt.S
|
|
|
|
hexagon/divdi3.S
|
|
|
|
hexagon/divsi3.S
|
|
|
|
hexagon/fastmath2_dlib_asm.S
|
|
|
|
hexagon/fastmath2_ldlib_asm.S
|
|
|
|
hexagon/fastmath_dlib_asm.S
|
|
|
|
hexagon/memcpy_forward_vp4cp4n2.S
|
|
|
|
hexagon/memcpy_likely_aligned.S
|
|
|
|
hexagon/moddi3.S
|
|
|
|
hexagon/modsi3.S
|
|
|
|
hexagon/sfdiv_opt.S
|
|
|
|
hexagon/sfsqrt_opt.S
|
|
|
|
hexagon/udivdi3.S
|
|
|
|
hexagon/udivmoddi4.S
|
|
|
|
hexagon/udivmodsi4.S
|
|
|
|
hexagon/udivsi3.S
|
|
|
|
hexagon/umoddi3.S
|
2019-04-05 21:30:40 +00:00
|
|
|
hexagon/umodsi3.S
|
2020-02-21 13:41:22 -06:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
${GENERIC_TF_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
)
|
2018-05-09 14:44:54 +00:00
|
|
|
|
2022-11-01 20:08:06 +08:00
|
|
|
set(loongarch_SOURCES
|
|
|
|
loongarch/fp_mode.c
|
|
|
|
${GENERIC_SOURCES}
|
|
|
|
${GENERIC_TF_SOURCES}
|
|
|
|
)
|
|
|
|
set(loongarch64_SOURCES
|
|
|
|
${loongarch_SOURCES}
|
|
|
|
)
|
2018-05-09 14:44:54 +00:00
|
|
|
|
2015-10-06 09:02:38 +00:00
|
|
|
set(mips_SOURCES ${GENERIC_SOURCES})
|
|
|
|
set(mipsel_SOURCES ${mips_SOURCES})
|
2017-05-04 13:34:17 +00:00
|
|
|
set(mips64_SOURCES ${GENERIC_TF_SOURCES}
|
|
|
|
${mips_SOURCES})
|
|
|
|
set(mips64el_SOURCES ${GENERIC_TF_SOURCES}
|
|
|
|
${mips_SOURCES})
|
2015-10-06 09:02:38 +00:00
|
|
|
|
2024-07-10 15:07:11 -05:00
|
|
|
set(nvptx64_SOURCES ${GENERIC_SOURCES})
|
|
|
|
|
2022-08-02 15:34:42 +02:00
|
|
|
set(powerpc_SOURCES ${GENERIC_SOURCES})
|
|
|
|
|
2021-11-26 13:29:06 -08:00
|
|
|
set(powerpcspe_SOURCES ${GENERIC_SOURCES})
|
|
|
|
|
2022-08-02 15:34:42 +02:00
|
|
|
set(powerpc64_SOURCES
|
2017-11-30 21:04:11 +00:00
|
|
|
ppc/divtc3.c
|
|
|
|
ppc/fixtfdi.c
|
|
|
|
ppc/fixunstfdi.c
|
|
|
|
ppc/floatditf.c
|
|
|
|
ppc/floatunditf.c
|
|
|
|
ppc/gcc_qadd.c
|
|
|
|
ppc/gcc_qdiv.c
|
|
|
|
ppc/gcc_qmul.c
|
|
|
|
ppc/gcc_qsub.c
|
|
|
|
ppc/multc3.c
|
2019-04-05 21:30:40 +00:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
)
|
2020-08-25 11:30:17 -04:00
|
|
|
# These routines require __int128, which isn't supported on AIX.
|
2023-06-28 07:14:00 +00:00
|
|
|
if (NOT OS_NAME MATCHES "AIX")
|
2022-08-02 15:34:42 +02:00
|
|
|
set(powerpc64_SOURCES
|
2020-08-25 11:30:17 -04:00
|
|
|
ppc/floattitf.c
|
|
|
|
ppc/fixtfti.c
|
|
|
|
ppc/fixunstfti.c
|
2022-08-02 15:34:42 +02:00
|
|
|
${powerpc64_SOURCES}
|
2020-08-25 11:30:17 -04:00
|
|
|
)
|
|
|
|
endif()
|
2022-08-02 15:34:42 +02:00
|
|
|
set(powerpc64le_SOURCES ${powerpc64_SOURCES})
|
2017-11-30 21:04:11 +00:00
|
|
|
|
2020-11-12 16:33:03 +00:00
|
|
|
set(riscv_SOURCES
|
2024-07-24 07:52:08 +08:00
|
|
|
cpu_model/riscv.c
|
2022-08-08 09:57:43 +08:00
|
|
|
riscv/fp_mode.c
|
2020-11-12 16:33:03 +00:00
|
|
|
riscv/save.S
|
|
|
|
riscv/restore.S
|
|
|
|
${GENERIC_SOURCES}
|
|
|
|
${GENERIC_TF_SOURCES}
|
|
|
|
)
|
2018-03-01 07:47:27 +00:00
|
|
|
set(riscv32_SOURCES
|
|
|
|
riscv/mulsi3.S
|
2019-04-05 21:30:40 +00:00
|
|
|
${riscv_SOURCES}
|
|
|
|
)
|
2020-08-21 13:04:25 +01:00
|
|
|
set(riscv64_SOURCES
|
|
|
|
riscv/muldi3.S
|
|
|
|
${riscv_SOURCES}
|
|
|
|
)
|
2018-03-01 07:47:27 +00:00
|
|
|
|
2019-07-12 08:30:17 +00:00
|
|
|
set(sparc_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
|
|
|
|
set(sparcv9_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
|
|
|
|
|
2017-11-07 19:03:11 +00:00
|
|
|
set(wasm32_SOURCES
|
|
|
|
${GENERIC_TF_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
)
|
2017-11-07 19:03:11 +00:00
|
|
|
set(wasm64_SOURCES
|
|
|
|
${GENERIC_TF_SOURCES}
|
2019-04-05 21:30:40 +00:00
|
|
|
${GENERIC_SOURCES}
|
|
|
|
)
|
2016-01-13 16:56:15 +00:00
|
|
|
|
2020-05-27 09:39:39 +02:00
|
|
|
set(ve_SOURCES
|
|
|
|
ve/grow_stack.S
|
|
|
|
ve/grow_stack_align.S
|
|
|
|
${GENERIC_TF_SOURCES}
|
|
|
|
${GENERIC_SOURCES})
|
|
|
|
|
2014-02-18 09:33:45 +00:00
|
|
|
add_custom_target(builtins)
|
2024-06-04 09:26:45 +02:00
|
|
|
set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT/Metatargets")
|
2014-02-18 09:33:45 +00:00
|
|
|
|
2023-02-28 13:13:45 -08:00
|
|
|
option(COMPILER_RT_ENABLE_SOFTWARE_INT128
|
|
|
|
"Enable the int128 builtin routines for all targets."
|
|
|
|
OFF)
|
|
|
|
|
2015-08-31 21:24:50 +00:00
|
|
|
if (APPLE)
|
2015-09-29 23:21:07 +00:00
|
|
|
add_subdirectory(Darwin-excludes)
|
|
|
|
add_subdirectory(macho_embedded)
|
2015-09-23 15:18:17 +00:00
|
|
|
darwin_add_builtin_libraries(${BUILTIN_SUPPORTED_OS})
|
2016-02-20 12:56:04 +00:00
|
|
|
else ()
|
2016-08-22 20:33:47 +00:00
|
|
|
set(BUILTIN_CFLAGS "")
|
2022-08-25 21:34:09 -07:00
|
|
|
add_security_warnings(BUILTIN_CFLAGS 0)
|
2016-10-28 23:19:03 +00:00
|
|
|
|
2022-01-10 09:23:28 +08:00
|
|
|
if (COMPILER_RT_HAS_FCF_PROTECTION_FLAG)
|
|
|
|
append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full BUILTIN_CFLAGS)
|
|
|
|
endif()
|
|
|
|
|
2022-04-27 00:19:14 +03:00
|
|
|
append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 BUILTIN_CFLAGS)
|
2023-06-26 12:24:39 -07:00
|
|
|
append_list_if(COMPILER_RT_HAS_WBUILTIN_DECLARATION_MISMATCH_FLAG -Werror=builtin-declaration-mismatch BUILTIN_CFLAGS)
|
2022-04-27 00:19:14 +03:00
|
|
|
|
2023-10-31 12:51:38 +00:00
|
|
|
# Don't embed directives for picking any specific CRT
|
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
|
|
|
|
append_list_if(COMPILER_RT_HAS_ZL_FLAG /Zl BUILTIN_CFLAGS)
|
|
|
|
endif()
|
|
|
|
|
2016-08-22 20:33:47 +00:00
|
|
|
# These flags would normally be added to CMAKE_C_FLAGS by the llvm
|
|
|
|
# cmake step. Add them manually if this is a standalone build.
|
|
|
|
if(COMPILER_RT_STANDALONE_BUILD)
|
2020-01-31 15:57:18 -08:00
|
|
|
if(COMPILER_RT_BUILTINS_ENABLE_PIC)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC BUILTIN_CFLAGS)
|
|
|
|
endif()
|
2016-08-22 20:33:47 +00:00
|
|
|
append_list_if(COMPILER_RT_HAS_FNO_BUILTIN_FLAG -fno-builtin BUILTIN_CFLAGS)
|
[builtins] Add COMPILER_RT_BUILTINS_HIDE_SYMBOLS
On Android, when the builtins are linked into a binary, they are
typically linked using -Wl,--exclude-libs so that the symbols aren't
reexported. For the NDK, compiler-rt's default behavior (build the
builtins archive with -fvisibility=hidden) is better so that builtins
are hidden even without -Wl,--exclude-libs.
Android needs the builtins with non-hidden symbols only for a special
case: for backwards compatibility with old binaries, the libc.so and
libm.so DSOs in the platform need to export some builtins for arm32 and
32-bit x86. See D56977.
Control the behavior with a new flag,
`COMPILER_RT_BUILTINS_HIDE_SYMBOLS`, that behaves similarly to the
`*_HERMETIC_STATIC_LIBRARY` in libunwind/libcxx/libcxxabi, so that
Android can build a special builtins variant for libc.so/libm.so.
Unlike the hermetic flags for other projects, this new flag is enabled
by default.
Reviewed By: compnerd, MaskRay
Differential Revision: https://reviews.llvm.org/D93431
2021-01-07 17:49:29 -08:00
|
|
|
if(COMPILER_RT_BUILTINS_HIDE_SYMBOLS)
|
2019-01-23 01:59:35 +00:00
|
|
|
append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG -fvisibility=hidden BUILTIN_CFLAGS)
|
|
|
|
endif()
|
2016-08-22 20:33:47 +00:00
|
|
|
if(NOT COMPILER_RT_DEBUG)
|
|
|
|
append_list_if(COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG -fomit-frame-pointer BUILTIN_CFLAGS)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-11-20 03:37:12 +00:00
|
|
|
|
2024-07-10 15:07:11 -05:00
|
|
|
# Directly targeting the GPU requires a few extra flags.
|
|
|
|
if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn|nvptx")
|
|
|
|
append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding BUILTIN_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_NOGPULIB_FLAG -nogpulib BUILTIN_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FLTO_FLAG -flto BUILTIN_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FCONVERGENT_FUNCTIONS_FLAG
|
|
|
|
-fconvergent-functions BUILTIN_CFLAGS)
|
2025-04-10 11:31:21 -05:00
|
|
|
|
|
|
|
# AMDGPU targets want to use a generic ABI.
|
|
|
|
if("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "amdgcn")
|
|
|
|
append_list_if(COMPILER_RT_HAS_CODE_OBJECT_VERSION_FLAG
|
|
|
|
"SHELL:-Xclang -mcode-object-version=none" BUILTIN_CFLAGS)
|
|
|
|
endif()
|
2024-07-10 15:07:11 -05:00
|
|
|
endif()
|
|
|
|
|
2016-10-28 23:19:03 +00:00
|
|
|
set(BUILTIN_DEFS "")
|
|
|
|
|
[builtins] Add COMPILER_RT_BUILTINS_HIDE_SYMBOLS
On Android, when the builtins are linked into a binary, they are
typically linked using -Wl,--exclude-libs so that the symbols aren't
reexported. For the NDK, compiler-rt's default behavior (build the
builtins archive with -fvisibility=hidden) is better so that builtins
are hidden even without -Wl,--exclude-libs.
Android needs the builtins with non-hidden symbols only for a special
case: for backwards compatibility with old binaries, the libc.so and
libm.so DSOs in the platform need to export some builtins for arm32 and
32-bit x86. See D56977.
Control the behavior with a new flag,
`COMPILER_RT_BUILTINS_HIDE_SYMBOLS`, that behaves similarly to the
`*_HERMETIC_STATIC_LIBRARY` in libunwind/libcxx/libcxxabi, so that
Android can build a special builtins variant for libc.so/libm.so.
Unlike the hermetic flags for other projects, this new flag is enabled
by default.
Reviewed By: compnerd, MaskRay
Differential Revision: https://reviews.llvm.org/D93431
2021-01-07 17:49:29 -08:00
|
|
|
if(COMPILER_RT_BUILTINS_HIDE_SYMBOLS)
|
2019-01-23 01:59:35 +00:00
|
|
|
append_list_if(COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG VISIBILITY_HIDDEN BUILTIN_DEFS)
|
|
|
|
endif()
|
2016-10-28 23:19:03 +00:00
|
|
|
|
2022-12-30 13:34:45 +00:00
|
|
|
if(COMPILER_RT_DISABLE_AARCH64_FMV)
|
|
|
|
list(APPEND BUILTIN_DEFS DISABLE_AARCH64_FMV)
|
2024-12-11 15:53:17 +00:00
|
|
|
elseif(COMPILER_RT_BAREMETAL_BUILD)
|
|
|
|
list(APPEND BUILTIN_DEFS ENABLE_BAREMETAL_AARCH64_FMV)
|
2022-12-30 13:34:45 +00:00
|
|
|
endif()
|
|
|
|
|
2020-12-15 08:15:58 +02:00
|
|
|
append_list_if(COMPILER_RT_HAS_ASM_LSE HAS_ASM_LSE BUILTIN_DEFS)
|
|
|
|
|
2015-08-31 21:24:50 +00:00
|
|
|
foreach (arch ${BUILTIN_SUPPORTED_ARCH})
|
2014-07-26 23:44:22 +00:00
|
|
|
if (CAN_TARGET_${arch})
|
2023-03-03 13:54:08 +00:00
|
|
|
cmake_push_check_state()
|
|
|
|
# TODO: we should probably make most of the checks in builtin-config depend on the target flags.
|
2021-06-01 15:26:51 +03:00
|
|
|
set(BUILTIN_CFLAGS_${arch} ${BUILTIN_CFLAGS})
|
2025-04-04 09:02:24 -07:00
|
|
|
# CMAKE_REQUIRED_FLAGS must be a space separated string
|
|
|
|
# Join BUILTIN_CFLAGS_${arch} and TARGET_${arch}_CFLAGS as a
|
|
|
|
# space-separated string.
|
|
|
|
list(APPEND CMAKE_REQUIRED_FLAGS
|
|
|
|
${BUILTIN_CFLAGS_${arch}}
|
|
|
|
${TARGET_${arch}_CFLAGS})
|
|
|
|
list(JOIN CMAKE_REQUIRED_FLAGS " " CMAKE_REQUIRED_FLAGS)
|
2024-11-28 10:42:47 -08:00
|
|
|
message(STATUS "Performing additional configure checks with target flags: ${CMAKE_REQUIRED_FLAGS}")
|
[cmake] [ARM] Exclude any VFP builtins if VFP is not supported
Summary:
rL325492 disables FPU features when using soft floating point
(-mfloat-abi=soft), which is used internally when building for arm. This causes
errors with builtins that utililize VFP instructions.
With this change we check if VFP is enabled (by checking if the preprocessor
macro __VFP_FP__ is defined), and exclude such builtins if it is not enabled.
Reviewers: rengolin, samsonov, compnerd, smeenai, javed.absar, peter.smith
Reviewed By: peter.smith
Subscribers: delcypher, peter.smith, mgorny, kristof.beyls, chrib, llvm-commits
Differential Revision: https://reviews.llvm.org/D47217
llvm-svn: 338284
2018-07-30 18:18:59 +00:00
|
|
|
# For ARM archs, exclude any VFP builtins if VFP is not supported
|
2021-03-30 16:57:50 +01:00
|
|
|
if (${arch} MATCHES "^(arm|armhf|armv7|armv7s|armv7k|armv7m|armv7em|armv8m.main|armv8.1m.main)$")
|
2025-04-04 09:02:24 -07:00
|
|
|
check_compile_definition(__ARM_FP "${CMAKE_C_FLAGS}" COMPILER_RT_HAS_${arch}_VFP)
|
[cmake] [ARM] Exclude any VFP builtins if VFP is not supported
Summary:
rL325492 disables FPU features when using soft floating point
(-mfloat-abi=soft), which is used internally when building for arm. This causes
errors with builtins that utililize VFP instructions.
With this change we check if VFP is enabled (by checking if the preprocessor
macro __VFP_FP__ is defined), and exclude such builtins if it is not enabled.
Reviewers: rengolin, samsonov, compnerd, smeenai, javed.absar, peter.smith
Reviewed By: peter.smith
Subscribers: delcypher, peter.smith, mgorny, kristof.beyls, chrib, llvm-commits
Differential Revision: https://reviews.llvm.org/D47217
llvm-svn: 338284
2018-07-30 18:18:59 +00:00
|
|
|
if(NOT COMPILER_RT_HAS_${arch}_VFP)
|
2020-11-12 14:44:54 +00:00
|
|
|
list(REMOVE_ITEM ${arch}_SOURCES ${arm_Thumb1_VFPv2_DP_SOURCES} ${arm_Thumb1_VFPv2_SP_SOURCES} ${arm_Thumb1_SjLj_EH_SOURCES})
|
|
|
|
else()
|
|
|
|
# Exclude any double-precision builtins if VFP is single-precision-only
|
2021-03-11 22:14:45 +02:00
|
|
|
try_compile_only(COMPILER_RT_HAS_${arch}_VFP_DP
|
|
|
|
SOURCE "#if !(__ARM_FP & 0x8)
|
2020-11-12 14:44:54 +00:00
|
|
|
#error No double-precision support!
|
|
|
|
#endif
|
2022-11-08 01:36:43 +00:00
|
|
|
int main(void) { return 0; }")
|
2020-11-12 14:44:54 +00:00
|
|
|
if(NOT COMPILER_RT_HAS_${arch}_VFP_DP)
|
|
|
|
list(REMOVE_ITEM ${arch}_SOURCES ${arm_Thumb1_VFPv2_DP_SOURCES})
|
|
|
|
endif()
|
[cmake] [ARM] Exclude any VFP builtins if VFP is not supported
Summary:
rL325492 disables FPU features when using soft floating point
(-mfloat-abi=soft), which is used internally when building for arm. This causes
errors with builtins that utililize VFP instructions.
With this change we check if VFP is enabled (by checking if the preprocessor
macro __VFP_FP__ is defined), and exclude such builtins if it is not enabled.
Reviewers: rengolin, samsonov, compnerd, smeenai, javed.absar, peter.smith
Reviewed By: peter.smith
Subscribers: delcypher, peter.smith, mgorny, kristof.beyls, chrib, llvm-commits
Differential Revision: https://reviews.llvm.org/D47217
llvm-svn: 338284
2018-07-30 18:18:59 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
[builtins] Fix missing main() function in float16/bfloat16 support checks (#104478)
The CMake docs state that `check_c_source_compiles()` checks whether the
supplied code "can be compiled as a C source file and linked as an
executable (so it must contain at least a `main()` function)."
https://cmake.org/cmake/help/v3.30/module/CheckCSourceCompiles.html
In practice, this command is a wrapper around `try_compile()`:
- https://gitlab.kitware.com/cmake/cmake/blob/2904ce00d2ed6ad5dac6d3459af62d8223e06ce0/Modules/CheckCSourceCompiles.cmake#L54
- https://gitlab.kitware.com/cmake/cmake/blob/2904ce00d2ed6ad5dac6d3459af62d8223e06ce0/Modules/Internal/CheckSourceCompiles.cmake#L101
When `CMAKE_SOURCE_DIR` is compiler-rt/lib/builtins/,
`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to `STATIC_LIBRARY`, so the
checks for `float16` and `bfloat16` support work as intended in a
Clang + compiler-rt runtime build for example, as it runs CMake
recursively from that directory.
However, when using llvm/ or compiler-rt/ as CMake source directory, as
`CMAKE_TRY_COMPILE_TARGET_TYPE` defaults to `EXECUTABLE`, these checks
will indeed fail if the code doesn't have a `main()` function. This
results in LLVM using x86 SIMD registers when generating calls to
builtins that, with Arch Linux's compiler-rt package for example,
actually use a GPR for their argument or return value as they use
`uint16_t` instead of `_Float16`.
This had been caught in post-commit review:
https://reviews.llvm.org/D145237#4521152. Use of the internal
`CMAKE_C_COMPILER_WORKS` variable is not what hides the issue, however.
PR #69842 tried to fix this by unconditionally setting
`CMAKE_TRY_COMPILE_TARGET_TYPE` to `STATIC_LIBRARY`, but it apparently
caused other issues, so it was reverted. This PR just adds a `main()`
function in the checks, as per the CMake docs.
2024-08-30 12:59:05 +02:00
|
|
|
check_c_source_compiles("_Float16 foo(_Float16 x) { return x; }
|
|
|
|
int main(void) { return 0; }"
|
2023-03-03 13:54:08 +00:00
|
|
|
COMPILER_RT_HAS_${arch}_FLOAT16)
|
|
|
|
append_list_if(COMPILER_RT_HAS_${arch}_FLOAT16 -DCOMPILER_RT_HAS_FLOAT16 BUILTIN_CFLAGS_${arch})
|
[builtins] Fix missing main() function in float16/bfloat16 support checks (#104478)
The CMake docs state that `check_c_source_compiles()` checks whether the
supplied code "can be compiled as a C source file and linked as an
executable (so it must contain at least a `main()` function)."
https://cmake.org/cmake/help/v3.30/module/CheckCSourceCompiles.html
In practice, this command is a wrapper around `try_compile()`:
- https://gitlab.kitware.com/cmake/cmake/blob/2904ce00d2ed6ad5dac6d3459af62d8223e06ce0/Modules/CheckCSourceCompiles.cmake#L54
- https://gitlab.kitware.com/cmake/cmake/blob/2904ce00d2ed6ad5dac6d3459af62d8223e06ce0/Modules/Internal/CheckSourceCompiles.cmake#L101
When `CMAKE_SOURCE_DIR` is compiler-rt/lib/builtins/,
`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to `STATIC_LIBRARY`, so the
checks for `float16` and `bfloat16` support work as intended in a
Clang + compiler-rt runtime build for example, as it runs CMake
recursively from that directory.
However, when using llvm/ or compiler-rt/ as CMake source directory, as
`CMAKE_TRY_COMPILE_TARGET_TYPE` defaults to `EXECUTABLE`, these checks
will indeed fail if the code doesn't have a `main()` function. This
results in LLVM using x86 SIMD registers when generating calls to
builtins that, with Arch Linux's compiler-rt package for example,
actually use a GPR for their argument or return value as they use
`uint16_t` instead of `_Float16`.
This had been caught in post-commit review:
https://reviews.llvm.org/D145237#4521152. Use of the internal
`CMAKE_C_COMPILER_WORKS` variable is not what hides the issue, however.
PR #69842 tried to fix this by unconditionally setting
`CMAKE_TRY_COMPILE_TARGET_TYPE` to `STATIC_LIBRARY`, but it apparently
caused other issues, so it was reverted. This PR just adds a `main()`
function in the checks, as per the CMake docs.
2024-08-30 12:59:05 +02:00
|
|
|
check_c_source_compiles("__bf16 foo(__bf16 x) { return x; }
|
|
|
|
int main(void) { return 0; }"
|
2023-03-03 13:54:08 +00:00
|
|
|
COMPILER_RT_HAS_${arch}_BFLOAT16)
|
|
|
|
# Build BF16 files only when "__bf16" is available.
|
|
|
|
if(COMPILER_RT_HAS_${arch}_BFLOAT16)
|
|
|
|
list(APPEND ${arch}_SOURCES ${BF16_SOURCES})
|
|
|
|
endif()
|
[cmake] [ARM] Exclude any VFP builtins if VFP is not supported
Summary:
rL325492 disables FPU features when using soft floating point
(-mfloat-abi=soft), which is used internally when building for arm. This causes
errors with builtins that utililize VFP instructions.
With this change we check if VFP is enabled (by checking if the preprocessor
macro __VFP_FP__ is defined), and exclude such builtins if it is not enabled.
Reviewers: rengolin, samsonov, compnerd, smeenai, javed.absar, peter.smith
Reviewed By: peter.smith
Subscribers: delcypher, peter.smith, mgorny, kristof.beyls, chrib, llvm-commits
Differential Revision: https://reviews.llvm.org/D47217
llvm-svn: 338284
2018-07-30 18:18:59 +00:00
|
|
|
|
2020-06-18 23:59:36 -07:00
|
|
|
# Remove a generic C builtin when an arch-specific builtin is specified.
|
|
|
|
filter_builtin_sources(${arch}_SOURCES ${arch})
|
2014-07-26 23:44:22 +00:00
|
|
|
|
2016-10-26 15:20:33 +00:00
|
|
|
# Needed for clear_cache on debug mode, due to r7's usage in inline asm.
|
|
|
|
# Release mode already sets it via -O2/3, Debug mode doesn't.
|
|
|
|
if (${arch} STREQUAL "armhf")
|
2021-06-01 15:26:51 +03:00
|
|
|
list(APPEND BUILTIN_CFLAGS_${arch} -fomit-frame-pointer -DCOMPILER_RT_ARMHF_TARGET)
|
2016-10-26 15:20:33 +00:00
|
|
|
endif()
|
|
|
|
|
2022-08-02 15:34:42 +02:00
|
|
|
# For RISCV32, we must force enable int128 for compiling long
|
|
|
|
# double routines.
|
2023-02-28 13:13:45 -08:00
|
|
|
if(COMPILER_RT_ENABLE_SOFTWARE_INT128 OR "${arch}" STREQUAL "riscv32")
|
2021-06-01 15:26:51 +03:00
|
|
|
list(APPEND BUILTIN_CFLAGS_${arch} -fforce-enable-int128)
|
[RISCV] Force enable int128 for compiling long double routines
Summary:
For RISCV32, we must force enable int128 for compiling long double routines using the flag -fforce-enable-int128.
Related clang patch: https://reviews.llvm.org/D43105
Reviewers: asb, kito-cheng, apazos, compnerd, howard.hinnant
Reviewed By: kito-cheng
Subscribers: shiva0217, efriedma, mgorny, hintonda, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D43106
llvm-svn: 326346
2018-02-28 18:24:09 +00:00
|
|
|
endif()
|
|
|
|
|
2015-08-25 19:53:09 +00:00
|
|
|
add_compiler_rt_runtime(clang_rt.builtins
|
|
|
|
STATIC
|
2015-08-31 21:24:50 +00:00
|
|
|
ARCHS ${arch}
|
2021-07-21 20:38:24 +03:00
|
|
|
DEPS ${deps_${arch}}
|
2014-07-26 23:44:22 +00:00
|
|
|
SOURCES ${${arch}_SOURCES}
|
2016-10-28 23:19:03 +00:00
|
|
|
DEFS ${BUILTIN_DEFS}
|
2021-06-01 15:26:51 +03:00
|
|
|
CFLAGS ${BUILTIN_CFLAGS_${arch}}
|
2015-08-25 19:53:09 +00:00
|
|
|
PARENT_TARGET builtins)
|
2023-03-03 13:54:08 +00:00
|
|
|
cmake_pop_check_state()
|
2014-07-26 23:44:22 +00:00
|
|
|
endif ()
|
|
|
|
endforeach ()
|
|
|
|
endif ()
|
2014-02-18 09:33:45 +00:00
|
|
|
|
2023-06-28 07:14:00 +00:00
|
|
|
add_dependencies(compiler-rt builtins)
|
|
|
|
|
2021-05-16 05:03:10 +00:00
|
|
|
option(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC
|
|
|
|
"Build standalone shared atomic library."
|
|
|
|
OFF)
|
|
|
|
|
|
|
|
if(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC)
|
|
|
|
add_custom_target(builtins-standalone-atomic)
|
2021-06-11 23:21:40 +00:00
|
|
|
set(BUILTIN_TYPE SHARED)
|
2023-06-28 07:14:00 +00:00
|
|
|
if(OS_NAME MATCHES "AIX")
|
|
|
|
include(CompilerRTAIXUtils)
|
2021-05-16 05:03:10 +00:00
|
|
|
if(NOT COMPILER_RT_LIBATOMIC_LINK_FLAGS)
|
|
|
|
get_aix_libatomic_default_link_flags(COMPILER_RT_LIBATOMIC_LINK_FLAGS
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/ppc/atomic.exp")
|
|
|
|
endif()
|
2021-06-11 23:21:40 +00:00
|
|
|
# For different versions of cmake, SHARED behaves differently. For some
|
|
|
|
# versions, we might need MODULE rather than SHARED.
|
|
|
|
get_aix_libatomic_type(BUILTIN_TYPE)
|
2023-05-30 18:19:00 +00:00
|
|
|
else()
|
|
|
|
list(APPEND COMPILER_RT_LIBATOMIC_LINK_FLAGS -nodefaultlibs)
|
2021-05-16 05:03:10 +00:00
|
|
|
endif()
|
|
|
|
foreach (arch ${BUILTIN_SUPPORTED_ARCH})
|
|
|
|
if(CAN_TARGET_${arch})
|
2023-12-07 13:25:24 +02:00
|
|
|
list(APPEND COMPILER_RT_LIBATOMIC_LINK_LIBS_${arch} clang_rt.builtins-${arch})
|
|
|
|
append_list_if(MINGW "${MINGW_LIBRARIES}" COMPILER_RT_LIBATOMIC_LINK_LIBS_${arch})
|
2021-05-16 05:03:10 +00:00
|
|
|
add_compiler_rt_runtime(clang_rt.atomic
|
2021-06-11 23:21:40 +00:00
|
|
|
${BUILTIN_TYPE}
|
2021-05-16 05:03:10 +00:00
|
|
|
ARCHS ${arch}
|
|
|
|
SOURCES atomic.c
|
|
|
|
LINK_FLAGS ${COMPILER_RT_LIBATOMIC_LINK_FLAGS}
|
2023-12-07 13:25:24 +02:00
|
|
|
LINK_LIBS ${COMPILER_RT_LIBATOMIC_LINK_LIBS_${arch}}
|
2021-05-16 05:03:10 +00:00
|
|
|
PARENT_TARGET builtins-standalone-atomic)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
# FIXME: On AIX, we have to archive built shared libraries into a static
|
|
|
|
# archive, i.e., libatomic.a. Once cmake adds support of such usage for AIX,
|
|
|
|
# this ad-hoc part can be removed.
|
2023-06-28 07:14:00 +00:00
|
|
|
if(OS_NAME MATCHES "AIX")
|
2022-02-28 02:27:26 +00:00
|
|
|
archive_aix_libatomic(clang_rt.atomic libatomic
|
2021-05-16 05:03:10 +00:00
|
|
|
ARCHS ${BUILTIN_SUPPORTED_ARCH}
|
|
|
|
PARENT_TARGET builtins-standalone-atomic)
|
|
|
|
endif()
|
|
|
|
add_dependencies(compiler-rt builtins-standalone-atomic)
|
|
|
|
endif()
|
|
|
|
|
2023-06-28 07:14:00 +00:00
|
|
|
cmake_dependent_option(COMPILER_RT_BUILD_CRT "Build crtbegin.o/crtend.o" ON "COMPILER_RT_HAS_CRT" OFF)
|
|
|
|
|
2023-07-12 17:41:16 +00:00
|
|
|
if (COMPILER_RT_BUILD_CRT)
|
2023-06-28 07:14:00 +00:00
|
|
|
add_compiler_rt_component(crt)
|
|
|
|
|
2024-03-08 15:13:20 -08:00
|
|
|
option(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY "Use eh_frame in crtbegin.o/crtend.o" ON)
|
2023-06-28 07:14:00 +00:00
|
|
|
|
|
|
|
include(CheckSectionExists)
|
|
|
|
check_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY
|
|
|
|
SOURCE "volatile int x;\n__attribute__((constructor)) void f(void) {x = 0;}\nint main(void) { return 0; }\n")
|
|
|
|
|
|
|
|
append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 CRT_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_CRT_USE_EH_FRAME_REGISTRY -DEH_USE_FRAME_REGISTRY CRT_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC CRT_CFLAGS)
|
|
|
|
append_list_if(COMPILER_RT_HAS_WNO_PEDANTIC -Wno-pedantic CRT_CFLAGS)
|
|
|
|
if (COMPILER_RT_HAS_FCF_PROTECTION_FLAG)
|
|
|
|
append_list_if(COMPILER_RT_ENABLE_CET -fcf-protection=full CRT_CFLAGS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(arch ${BUILTIN_SUPPORTED_ARCH})
|
|
|
|
add_compiler_rt_runtime(clang_rt.crtbegin
|
|
|
|
OBJECT
|
|
|
|
ARCHS ${arch}
|
|
|
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtbegin.c
|
|
|
|
CFLAGS ${CRT_CFLAGS}
|
|
|
|
PARENT_TARGET crt)
|
|
|
|
add_compiler_rt_runtime(clang_rt.crtend
|
|
|
|
OBJECT
|
|
|
|
ARCHS ${arch}
|
|
|
|
SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/crtend.c
|
|
|
|
CFLAGS ${CRT_CFLAGS}
|
|
|
|
PARENT_TARGET crt)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
add_dependencies(compiler-rt crt)
|
|
|
|
endif()
|