Commit Graph

436 Commits

Author SHA1 Message Date
John Ericson 7017e6c9cf [cmake] Partially deduplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm
We previously had a few varied definitions of this floating around.

I had tried to make the one installed with LLVM handle all the cases, and then made the others use it, but this ran into issues with `HandleOutOfTreeLLVM` not working for compiler-rt, and also `CMAKE_EXE_LINKER_FLAGS` not working right without `CMP0056` set to the new behavior.

 My compromise solution is this:

 - No not completely deduplicate: the runtime libs will instead use a version that still exists as part of the internal and not installed common shared CMake utilities. This avoids `HandleOutOfTreeLLVM` or a workaround for compiler-rt.

- Continue to use `CMAKE_REQUIRED_FLAGS`, which effects compilation and linking. Maybe this is unnecessary, but it's safer to leave that as a future change. Also means we can avoid `CMP0056` for now, to try out later, which is good incrementality too.

- Call it `llvm_check_compiler_linker_flag` since it, in fact is about both per its implementation (before and after this patch), so there is no name collision.

In the future, we might still enable CMP0056 and make compiler-rt work with HandleOutOfTreeLLVM, which case we delete `llvm_check_compiler_flag` and go back to the old way (as these are, in fact, linking related flags), but that I leave for someone else as future work.

The original issue was reported to me in https://reviews.llvm.org/D116521#3248117 as
D116521 made clang and LLVM use the common cmake utils.

Reviewed By: sebastian-ne, phosek, #libunwind, #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D117537
2022-01-29 06:07:24 +00:00
Petr Hosek 10e5c513b5 Revert "[cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm"
This reverts commit 4af11272f5.
2022-01-21 09:53:14 -08:00
John Ericson 4af11272f5 [cmake] Duplicate `{llvm,compiler_rt}_check_linker_flag` for runtime libs and llvm
We previously had a few varied definitions of this floating around. I made the one installed with LLVM handle all the cases, and then made the others use it.

This issue was reported to me in https://reviews.llvm.org/D116521#3248117 as
D116521 made clang and llvm use the common cmake utils.

Reviewed By: sebastian-ne, phosek, #libunwind, #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D117537
2022-01-20 21:18:42 +00:00
zijunzhao c0f9592daa add tsan shared library
Add tsan shared library on Android. Only build tsan when minSdkVersion is above 23.

Reviewed By: danalbert, vitalybuka

Differential Revision: https://reviews.llvm.org/D108394
2022-01-20 17:54:16 +00:00
Fangrui Song be622a47ff [CMake] Fix compiler-rt -Wl,-z,gnu-version-script-compat warnings on non-Solaris 2022-01-15 01:35:48 -08:00
Alexandre Ganea ae4c643bcd [compiler-rt] Silence warnings when building with MSVC
Differential Revision: https://reviews.llvm.org/D116872
2022-01-11 10:36:57 -05:00
jinge90 6fab274275 Control-flow Enforcement Technology (CET), published by Intel, introduces
indirect branch tracking(IBT) feature aiming to ensure the target address
of an indirect jump/call is not tampered.
When IBT is enabled, each function or target of any indirect jump/call will start
with an 'endbr32/64' instruction otherwise the program will crash during execution.
To build an application with CET enabled. we need to ensure:

  1. build the source code with "-fcf-protection=full"
  2. all the libraries linked with .o files must be CET enabled too

This patch aims to enable CET for compiler-rt builtins library, we add an option
"COMPILER_RT_ENABLE_CET" whose default value is OFF to enable CET for compiler-rt
in building time and when this option is "ON", "-fcf-protection=full" is added to
BUILTINS_CFLAG and the "endbr32/64" will be placed in the beginning of each assembly
function. We also enabled CET for crtbegin, crtend object files in this patch.

Reviewed by: MaskRay, compnerd, manojgupta, efriedma
Differential Revision: https://reviews.llvm.org/D109811

Signed-off-by: jinge90 <ge.jin@intel.com>
2022-01-10 11:01:11 +08:00
ZijunZhao d2b43605c9 add tsan shared lib
Change-Id: Ic83ff1ec86d6a7d61b07fa3df7e0cb2790b5ebc7
2021-11-16 00:42:30 +00:00
Emily Shi 919ca9fc04 [compiler-rt] separate lsan, ubsan, stats configuration from SANITIZER_COMMON_SUPPORTED_OS
Currently, SANITIZER_COMMON_SUPPORTED_OS is being used to enable many libraries.
Unfortunately this makes it impossible to selectively disable a library based on the OS.
This patch removes this limitation by adding a separate list of supported OSs for the lsan, ubsan, ubsan_minimal, and stats libraries.

Reviewed By: delcypher

Differential Revision: https://reviews.llvm.org/D113444
2021-11-10 19:16:20 -08:00
zijunzhao 45d28e3a30 Revert "add tsan shared lib"
This reverts commit 92c9b340be.
2021-11-09 16:36:06 +00:00
Djordje Todorovic 2ca1cd7e37 [cmake] By default do not instrument compiler-rt if LLVM_BUILD_INSTRUMENTED_COVERAGE is ON
Applying the same rules as for LLVM_BUILD_INSTRUMENTED build in the cmake files.
By having this patch, we are able to disable/enable instrument+coverage build
of the compiler-rt project when building instrumented LLVM.

Differential Revision: https://reviews.llvm.org/D108127
2021-11-09 10:59:25 +01:00
ZijunZhao 92c9b340be add tsan shared lib
Change-Id: Ic83ff1ec86d6a7d61b07fa3df7e0cb2790b5ebc7
2021-11-09 02:34:37 +00:00
Petr Hosek 22acda48ff [CMake] Cache the compiler-rt library search results
There's a lot of duplicated calls to find various compiler-rt libraries
from build of runtime libraries like libunwind, libc++, libc++abi and
compiler-rt. The compiler-rt helper module already implemented caching
for results avoid repeated Clang invocations.

This change moves the compiler-rt implementation into a shared location
and reuses it from other runtimes to reduce duplication and speed up
the build.

Differential Revision: https://reviews.llvm.org/D88458
2021-10-27 17:53:03 -07:00
Petr Hosek ba4920e98e Revert "[CMake] Cache the compiler-rt library search results"
This reverts commit 0eed292fba, there
are compiler-rt build failures that appear to have been introduced
by this change.
2021-10-21 10:32:01 -07:00
Ben Langmuir b8da594750 Reapply [ORC-RT] Configure the ORC runtime for more architectures and platforms
Reapply 5692ed0cce, but with the ORC runtime disabled explicitly on
CrossWinToARMLinux to match the other compiler-rt runtime libraries.

Differential Revision: https://reviews.llvm.org/D112229

---

Enable building the ORC runtime for 64-bit and 32-bit ARM architectures,
and for all Darwin embedded platforms (iOS, tvOS, and watchOS). This
covers building the cross-platform code, but does not add TLV runtime
support for the new architectures, which can be added independently.

Incidentally, stop building the Mach-O TLS support file unnecessarily on
other platforms.

Differential Revision: https://reviews.llvm.org/D112111
2021-10-21 09:00:18 -07:00
Ben Langmuir f3671de550 Revert "[ORC-RT] Configure the ORC runtime for more architectures and platforms"
Broke on aarch64-linux. Reverting while I investigate.

This reverts commit 5692ed0cce.
2021-10-20 15:32:06 -07:00
Ben Langmuir 5692ed0cce [ORC-RT] Configure the ORC runtime for more architectures and platforms
Enable building the ORC runtime for 64-bit and 32-bit ARM architectures,
and for all Darwin embedded platforms (iOS, tvOS, and watchOS). This
covers building the cross-platform code, but does not add TLV runtime
support for the new architectures, which can be added independently.

Incidentally, stop building the Mach-O TLS support file unnecessarily on
other platforms.

Differential Revision: https://reviews.llvm.org/D112111
2021-10-20 11:21:18 -07:00
Petr Hosek 0eed292fba [CMake] Cache the compiler-rt library search results
There's a lot of duplicated calls to find various compiler-rt libraries
from build of runtime libraries like libunwind, libc++, libc++abi and
compiler-rt. The compiler-rt helper module already implemented caching
for results avoid repeated Clang invocations.

This change moves the compiler-rt implementation into a shared location
and reuses it from other runtimes to reduce duplication and speed up
the build.

Differential Revision: https://reviews.llvm.org/D88458
2021-10-18 14:44:07 -07:00
ZijunZhao 0e8862901c revert tsan part for investigation 2021-10-01 18:52:36 +00:00
ZijunZhao 91bfccf837 add tsan shared library 2021-10-01 00:19:35 +00:00
Dan Liew f4382d4b09 [Compiler-RT] For arm64e test suites use the SDK version as the minimum deployment target.
Previously we used the minimum deployment target used for the platform
(e.g. iOS is 9.0). Unfortunately this leads to ABI incompatibilities with
arm64e devices running newer OSs. In particular the following TSan test
cases that used libcxx would fail due to the ABI mismatch.

* Darwin/libcxx-shared-ptr-recursive.mm
* Darwin/libcxx-shared-ptr-stress.mm
* Darwin/libcxx-shared-ptr.mm
* libcxx/std_shared_ptr.cpp

Given that arm64e is not ABI stable we should ideally match the
deployment target for sanitizer runtimes and their tests cases to the
device when building for arm64e. Unfortunately having a mixed deployment
target (based on architecture) isn't currently supported by the build system
and is non-trivial to implement.

As a stop-gap measure this patch changes the sanitizer test suites (but not the
sanitizer runtimes themselves) to use a newer deployment target when
targetting arm64e.

The deployment target used for arm64e is the SDK version because this
"should" match the OS version running on the target device (it is a
configuration error to not match them).

rdar://83080611
2021-09-15 14:22:25 -07:00
Michał Górny 210d72e9d6 [compiler-rt] Move -fno-omit-frame-pointer check to common config-ix
9ee64c3746 has started using
COMPILER_RT_HAS_OMIT_FRAME_POINTER_FLAG inside scudo.  However,
the relevant CMake check was performed in builtin-config-ix.cmake,
so the definition was missing when builtins were not built.  Move
the check to config-ix.cmake, so that it runs unconditionally of
the components being built.

Fixes PR#51847

Differential Revision: https://reviews.llvm.org/D109812
2021-09-15 18:32:33 +02:00
Nico Weber 8cfab5de13 [Windows build] Use "DIA SDK" in sysroot
This updates llvm/utils/sysroot.py to include the "DIA SDK" folder in the
sysroot.

It also updates the build to look for the DIA SDK there if a sysroot is set.

This requires moving LLVM_WINSYSROOT to config-ix.cmake.

For the GN build, I chose to pass a qualified path to diaguids in libs instead
of pushing a config with a `/libpath:` flag. The former requires a GN with
https://gn-review.googlesource.com/c/gn/+/12200, the latter requires D109624.
The former is more like the cmake build, arguably a bit simpler, and it's
easier to check for the wrong GN revision and easier to update GN.

Differential Revision: https://reviews.llvm.org/D109708
2021-09-14 08:59:28 -04:00
Kazuaki Ishizaki a1e7e401d2 [compiler-rt] NFC: Fix trivial typo
Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D77457
2021-09-04 14:12:58 +05:30
Vitaly Buka 3d4d1b9b29 [scudo] Don't build SCUDO for Android
Android 11 uses scudo_standalone as default
allocator making difficult to test legacy scudo.
2021-08-18 18:32:54 -07:00
Dmitry Vyukov 9c8f888f5f sanitizer_common: prepare for enabling format string checking
The __attribute__((format)) was added somewhere in 2012,
the lost during refactoring, then re-added in 2014 but
to te source files, which is a no-op.
Move it back to header files so that it actually takes effect.
But over the past 7 years we've accumulated whole lot of
format string bugs of different types, so disable the warning
with -Wno-format for now for incremental clean up.

Among the bugs that it warns about are all kinds of bad things:
 - wrong sizes of arguments
 - missing/excessive arguments
 - printing wrong things (e.g. *ptr instead of ptr)
 - completely messed up format strings
 - security issues where external string is used as format

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D107977
2021-08-13 13:43:57 +02:00
Petr Hosek f59f659879 [CMake] Check the builtins library value first
When the builtins library isn't found, find_compiler_rt_library
returns NOTFOUND so we'll end up linking against -lNOTFOUND. We need
to check the return value before adding it to the list.

Differential Revision: https://reviews.llvm.org/D107627
2021-08-06 10:59:24 -07:00
Michael Jones 6ed60fb8a2 [libc] add integration tests for scudo in libc
This change adds tests to make sure that SCUDO is being properly
included with llvm libc. This change also adds the toggles to properly
use SCUDO, as GWP-ASan is enabled by default and must be included for
SCUDO to function.

Reviewed By: sivachandra, hctim

Differential Revision: https://reviews.llvm.org/D106919
2021-08-04 20:06:09 +00:00
Leonard Chan 606ca48d79 [compiler-rt][Fuchsia] Support HWASan on Fuchsia
This allows for hwasan to be built targetting fuchsia.

Differential Revision: https://reviews.llvm.org/D103543
2021-07-30 11:43:03 -07:00
Ilya Leoshkevich e34078f121 [TSan] Enable SystemZ support
Enable building the runtime and enable -fsanitize=thread in clang.

Reviewed By: dvyukov

Differential Revision: https://reviews.llvm.org/D105629
2021-07-15 12:18:48 +02:00
Vitaly Buka 00f474e9b1 [GWP_ASAN] Enable ARM tests
Reviewed By: hctim

Differential Revision: https://reviews.llvm.org/D105233
2021-06-30 20:43:33 -07:00
Mitch Phillips 2dba40561a Revert "[scudo] Build scudo_standalone on Android and Fuchsia."
This reverts commit 2fe987e6ba.

Broke the Android buildbots. Turns out a couple more tweaks are
necessary to turn them back on.
2021-05-26 16:52:13 -07:00
Mitch Phillips 2fe987e6ba [scudo] Build scudo_standalone on Android and Fuchsia.
This should be fine now, and is necessary for D102543.

Reviewed By: cryptoad

Differential Revision: https://reviews.llvm.org/D103200
2021-05-26 15:29:28 -07:00
Mitch Phillips f4ccbaf310 [scudo] Add supported architectures.
Adds extra supported architectures that were available for vanilla
scudo, in preparation for D102543. Hopefully the dust has settled and
7d0a81ca38 is no longer an issue.

Reviewed By: cryptoad, vitalybuka

Differential Revision: https://reviews.llvm.org/D102648
2021-05-20 11:22:51 -07:00
David Spickett 7d0a81ca38 Revert "[scudo] Enable arm32 arch"
This reverts commit b1a77e465e.

Which has a failing test on our armv7 bots:
https://lab.llvm.org/buildbot/#/builders/59/builds/1812
2021-05-12 13:12:28 +01:00
Lang Hames e0b6c99288 Re-apply "[ORC-RT] Add unit test infrastructure, extensible_rtti..."
This reapplies 6d263b6f1c (which was reverted in 1c7c6f2b10) with a fix for a
CMake issue.
2021-05-11 10:28:33 -07:00
Lang Hames 1c7c6f2b10 Revert "[ORC-RT] Add unit test infrastructure, extensible_rtti..."
This reverts commit 6d263b6f1c while I investigate the CMake failures that it
causes in some configurations.
2021-05-11 09:51:12 -07:00
Lang Hames 6d263b6f1c [ORC-RT] Add unit test infrastructure, extensible_rtti implementation, unit test
Add unit test infrastructure for the ORC runtime, plus a cut-down
extensible_rtti system and extensible_rtti unit test.

Removes the placeholder.cpp source file.

Differential Revision: https://reviews.llvm.org/D102080
2021-05-10 17:15:59 -07:00
Steven Wu 7259394b32 [CMake][compiler-rt] avoid conflict with builtin check_linker_flag
Rename `check_linker_flag` in compiler_rt to avoid conflict. Follow up
as the fix in D100901.

Patched by radford.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D101581
2021-04-29 19:32:39 -07:00
Vitaly Buka b1a77e465e [scudo] Enable arm32 arch 2021-04-27 18:35:45 -07:00
Vitaly Buka 98a7563261 [scudo] Mark ARM64 as supported platform 2021-04-25 15:47:28 -07:00
Lang Hames 5e537ea1d7 [ORC-RT] Re-apply "Initial ORC Runtime directories and build..." with fixes.
This reapplies 1e1d75b190, which was reverted in ce1a4d5323 due to build
failures.

The unconditional dependencies on clang and llvm-jitlink in
compiler-rt/test/orc/CMakeLists.txt have been removed -- they don't appear to
be necessary, and I suspect they're the cause of the build failures seen
earlier.
2021-04-24 16:00:20 -07:00
Lang Hames ce1a4d5323 Revert "[ORC-RT] Initial ORC Runtime directories and build system files."
Some builders failed with a missing clang dependency. E.g.

CMake Error at /Users/buildslave/jenkins/workspace/clang-stage1-RA/clang-build \
  /lib/cmake/llvm/AddLLVM.cmake:1786 (add_dependencies):
The dependency target "clang" of target "check-compiler-rt" does not exist.

Reverting while I investigate.

This reverts commit 1e1d75b190.
2021-04-23 20:36:59 -07:00
Lang Hames 1e1d75b190 [ORC-RT] Initial ORC Runtime directories and build system files.
This patch contains initial directories and build files for the ORC runtime.

Differential Revision: https://reviews.llvm.org/D100711
2021-04-23 20:21:22 -07:00
Luís Marques 3203c96842 [CMake][compiler-rt][RISCV] Support RISC-V cross-compilation
This seems to be a safe way to ensure that the Compiler-RT test compiler
flags are properly set in all cross-compilation scenarios. Without this
when `BUILTINS_TEST_TARGET_CFLAGS` is set in
`compiler-rt/test/builtins/CMakeLists.txt` the other flags are cleared.

Differential Revision: https://reviews.llvm.org/D92124
2021-01-31 23:52:57 +00:00
Luís Marques 2de4f19ecd [LSan][RISCV] Enable LSan for RISCV64
Fixes the broken RISCV64 implementation of `internal_clone` and
adds RISCV64 support for LSan.

Differential Revision: https://reviews.llvm.org/D92403
2021-01-31 21:53:25 +00:00
Kazushi (Jam) Marukawa 70474dfebc [VE][compiler-rt] Add VE as a target of crt
SX Aurora VE is an experimental target.  We upstreamed many part of
ported llvm and clang.  In order to continue this move, we need to
support libraries next, then we need to show the ability of llvm for
VE through test cases.  As a first step for that, we need to use
crt in compiler-rt.  VE has it's own crt but they are a part of
proprietary compiler.  So, we want to use crt in compiler-rt as an
alternative.

This patch enables VE as a candidate of crt in compiler-rt.

Reviewed By: phosek, compnerd

Differential Revision: https://reviews.llvm.org/D92748
2021-01-12 10:20:21 +09:00
Vy Nguyen 484ec6be30 Reland [lsan] Enable LSAN for Android
Reland: a2291a58bf.

New fixes for the breakages reported in D85927 include:
 - declare a weak decl for `dl_iterate_phdr`, because it does not exist on older  APIs
 - Do not enable leak-sanitizer if api_level is less than 29, because of  `ld.lld: error: undefined symbol: __aeabi_read_tp` for armv7, API level 16.
 - Put back the interceptor for `memalign` but still opt out intercepting `__libc_memalign` and `cfree` because both of these don't exist in Bionic.

Reviewed By: srhines, vitalybuka

Differential Revision: https://reviews.llvm.org/D89251
2020-11-04 18:00:25 -08:00
etiotto e1af54296c [compiler-rt][profile][AIX]: Enable compiler-rt profile build on AIX
This patch adds support for building the compiler-rt profile library on AIX.

Reviewed by: phosek

Differential Revision: https://reviews.llvm.org/D90619
2020-11-03 11:46:21 -05:00
Petr Hosek 59d5031591 [CMake] Add -fno-rtti into tsan unittests
And some other NFC parts of D88922
2020-10-30 20:03:38 -07:00