Commit Graph

554 Commits

Author SHA1 Message Date
Petr Hosek 47e5fcba57 [profile] Support profiling runtime on Fuchsia
This ports the profiling runtime on Fuchsia and enables the
instrumentation. Unlike on other platforms, Fuchsia doesn't use
files to dump the instrumentation data since on Fuchsia, filesystem
may not be accessible to the instrumented process. We instead use
the data sink to pass the profiling data to the system the same
sanitizer runtimes do.

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

llvm-svn: 337881
2018-07-25 03:01:35 +00:00
Petr Hosek d533fae6ef [CMake] Change the flag to use compiler-rt builtins to boolean
This changes the name and the type to what it was prior to r333037
which matches the name of the flag used in other runtimes: libc++,
libc++abi and libunwind. We don't need the type to be a string since
there's only binary choice between libgcc and compiler-rt unlike in
the case of C++ library where there're multiple options.

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

llvm-svn: 337116
2018-07-15 03:05:20 +00:00
Dan Liew b1f95697c1 [CMake] Add compiler-rt header files to the list of sources for targets
when building with an IDE so that header files show up in the UI.
This massively improves the development workflow in IDEs.

To implement this a new function `compiler_rt_process_sources(...)` has
been added that adds header files to the list of sources when the
generator is an IDE. For non-IDE generators (e.g. Ninja/Makefile) no
changes are made to the list of source files.

The function can be passed a list of headers via the
`ADDITIONAL_HEADERS` argument. For each runtime library a list of
explicit header files has been added and passed via
`ADDITIONAL_HEADERS`. For `tsan` and `sanitizer_common` a list of
headers was already present but it was stale and has been updated
to reflect the current state of the source tree.

The original version of this patch used file globbing (`*.{h,inc,def}`)
to find the headers but the approach was changed due to this being a
CMake anti-pattern (if the list of headers changes CMake won't
automatically re-generate if globbing is used).

The LLVM repo contains a similar function named `llvm_process_sources()`
but we don't use it here for several reasons:

* It depends on the `LLVM_ENABLE_OPTION` cache variable which is
  not set in standalone compiler-rt builds.
* We would have to `include(LLVMProcessSources)` which I'd like to
  avoid because it would include a bunch of stuff we don't need.

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

llvm-svn: 336663
2018-07-10 13:00:17 +00:00
Kostya Kortchinsky 02827792b5 [scudo] Enable Scudo on PPC64
Summary:
In conjunction with the clang side change D48833, this will enable Scudo on
PPC64. I tested `check-scudo` on a powerpc64le box and everything passes.

Reviewers: eugenis, alekseyshl

Reviewed By: alekseyshl

Subscribers: mgorny, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 336213
2018-07-03 16:09:18 +00:00
Kuba Mracek df93fe46e5 Skip building TSan on platforms where there are no 64-bit architectures.
llvm-svn: 335873
2018-06-28 16:43:43 +00:00
Petr Hosek 887f26d470 Support for multiarch runtimes layout
This change adds a support for multiarch style runtimes layout, so in
addition to the existing layout where runtimes get installed to:

lib/clang/$version/lib/$os

Clang now allows runtimes to be installed to:

lib/clang/$version/$target/lib

This also includes libc++, libc++abi and libunwind; today those are
assumed to be in Clang library directory built for host, with the
new layout it is possible to install libc++, libc++abi and libunwind
into the runtime directory built for different targets.

The use of new layout is enabled by setting the
LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both
projects and runtimes layouts. The runtimes CMake build has been further
modified to use the new layout when building runtimes for multiple
targets.

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

llvm-svn: 335809
2018-06-28 03:11:52 +00:00
Dan Liew bb78eef6b6 [CMake] Tidy up the organisation of compiler-rt when configured as a standalone
build with an IDE (e.g. Xcode) as the generator.

Previously the global `USE_FOLDERS` property wasn't set in standalone
builds leading to existing settings of FOLDER not being respected.

In addition to this there were several targets that appeared at the top
level that were not interesting and clustered up the view. These have
been changed to be displayed in "Compiler-RT Misc".

Now when an Xcode project is generated from a standalone compiler-rt
build the project navigator is much less cluttered. The interesting
libraries should appear in "Compiler-RT Libraries" in the IDE.

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

llvm-svn: 335728
2018-06-27 12:56:34 +00:00
David Carlier 7a0bf90dcf [UBsan] Enable ubsan minimal unit tests on OpenBSD
OpenBSD needs lld linker for sanitisers.
Disabling lint checking as some symbols cannot be defined and block the proper unit tests launch.

Reviewers: lebedev.ri, vitalybuka

Reviewed By: vitalybuka

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

llvm-svn: 335524
2018-06-25 21:10:25 +00:00
Jonas Hahnfeld 71befacd6c Revert "[CMake] Use a different source depending on C++ support"
This reverts commit r332924 and followup r332936 silencing a warning.

The change breaks the build on x86 if there is no 32-bit version of the
C++ libraries, see discussion in https://reviews.llvm.org/D47169.

llvm-svn: 334903
2018-06-17 09:51:33 +00:00
George Karpenkov d1e0365ce3 [libFuzzer] [NFC] Support multi-arch and multi-OS building and testing
Differential Revision: https://reviews.llvm.org/D47296

llvm-svn: 334768
2018-06-14 20:46:07 +00:00
Shoaib Meenai b682276f48 [compiler-rt] Use CMAKE_LINKER instead of hardcoding ld
Respect a custom linker path provided by the user if one is present
(otherwise CMAKE_LINKER will have been set to the right value by CMake).

llvm-svn: 334654
2018-06-13 20:48:30 +00:00
Petr Hosek 7252e2a8bd [XRay] Set an explicit dependency on libc++ when needed
When XRay is being built as part of the just built compiler together
with libc++ as part of the runtimes build, we need an explicit
dependency from XRay to libc++ to make sure that the library is
available by the time we start building XRay.

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

llvm-svn: 334575
2018-06-13 07:08:28 +00:00
Petr Hosek 22f8825dca Reland "Passthrough additional flags to custom libcxx CMake build"
This is needed when we're cross-compiling compiler-rt.

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

llvm-svn: 334570
2018-06-13 05:32:22 +00:00
Matt Morehouse e3300d2ff3 Revert r334458, r334220, r334212, r334139.
Reverts changes to AddCompilerRT.cmake due to breakage of
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/.

llvm-svn: 334528
2018-06-12 19:43:40 +00:00
Matt Morehouse a4374ab222 [CMake] Remove -Wno-maybe-uninitialized from passthrough vars.
Fixes http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/
buildbot.

llvm-svn: 334458
2018-06-12 00:37:06 +00:00
Eric Fiselier 84be761332 [CMake] Fix Libc++ Modules build.
When building the dylib, the C++ headers are fundamentally non-module.
They require special versions of the headers in order to provide C++03 and
legacy ABI definitions. This causes ODR issues when modules are enabled
during both the build and the usage of the libc++ headers.

This patch fixes the build error by disabling modules when building the
libc++ sources.

llvm-svn: 334220
2018-06-07 19:57:43 +00:00
Petr Hosek 6367bca339 [CMake] Filter out -z,defs when building custom libc++
-z,defs is incompatible with sanitizers so we need to filter it out
from the linker flags before passing them to the libc++ build.

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

llvm-svn: 334212
2018-06-07 18:27:27 +00:00
Petr Hosek 3cf6db2d56 [CMake] Passthrough additional flags to custom libcxx CMake build
This is needed when we're cross-compiling compiler-rt.

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

llvm-svn: 334139
2018-06-06 22:10:12 +00:00
George Karpenkov e7e3fc26ee [libFuzzer] Fix a typo in CMake configuration.
NFC now when libFuzzer supports only one architecture,
will stop being NFC after multiple architectures are supported.

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

llvm-svn: 333239
2018-05-24 23:55:51 +00:00
Azharuddin Mohammed 06e0fd3bc1 Revert "[cmake] [ARM] Check if VFP is supported before including any VFP builtins"
This reverts commit 2a10f5da5acb1b51d0a2ecf13dca0bf1de859db2.

llvm-svn: 333232
2018-05-24 21:36:27 +00:00
Azharuddin Mohammed 80968a9aba [cmake] [ARM] Check if VFP is supported before including any VFP builtins
Summary:
rL325492 disables FPU features when using soft floating point
(-mfloat-abi=soft), which is used internally when building for armv7. This
causes errors with builtins that utililize VFP instructions. With this change
we first check if VFP is enabled (by checking if the preprocessor macro
__VFP_FP__ is defined) before including such builtins.

Reviewers: rengolin, samsonov, compnerd, smeenai, javed.absar, peter.smith

Reviewed By: peter.smith

Subscribers: peter.smith, mgorny, kristof.beyls, chrib, llvm-commits

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

llvm-svn: 333216
2018-05-24 18:53:16 +00:00
Petr Hosek aa6d13e501 [CMake] Support builtins as Clang default rtlib in compiler-rt
Use compiler-rt builtins when selected as default Clang rtlib and avoid
explicitly passing -rtlib= flag to avoid the "argument unused during
compilation" warning.

This is a partial alternative to D47094 that does not rely on compiler
runtime checks.

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

llvm-svn: 333037
2018-05-22 22:58:48 +00:00
Petr Hosek 1ffaa48d4a [CMake] Support libc++ as Clang default stdlib in compiler-rt
Use libc++ when selected as default Clang stdlib and avoid checking
C++ compiler when using the in-tree version of libc++.

This is a partial alternative to D47094 that does not rely on compiler
runtime checks.

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

llvm-svn: 333010
2018-05-22 18:33:27 +00:00
Petr Hosek 4ca5af0721 [CMake] Silence unused variable warning in compiler check
This is breaking the compiler check.

llvm-svn: 332936
2018-05-22 02:53:32 +00:00
Petr Hosek f6dda7cb44 [CMake] Use a different source depending on C++ support
When using system C++ library, assume we have a working C++ compiler and
try to compile a complete C++ program. When using in tree C++ library,
only check the C compiler since the C++ library likely won't have been
built yet at time of running the check.

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

llvm-svn: 332924
2018-05-22 01:01:56 +00:00
Petr Hosek 702d073642 Revert "[CMake] Reland "Make simple source used for CMake checks a C file""
This reverts commit rCRT332679 which doesn't quite work and will be
replaced by D47100 and D47115 which is a cleaner solution.

llvm-svn: 332871
2018-05-21 19:32:43 +00:00
Reid Kleckner 4f9516d617 Revert r332683 & r332684 relating to compiler runtime checks
r332683 passes flags to the compiler without first checking if they are
supported.

llvm-svn: 332754
2018-05-18 18:44:37 +00:00
Petr Hosek 83061cc4aa [CMake] Use <UNIX|WINDOWS>_COMMAND with separate_arguments
NATIVE_COMMAND is only available since CMake 3.9.

llvm-svn: 332684
2018-05-18 01:20:47 +00:00
Petr Hosek 8b5fe57d3e [CMake] Detect the compiler runtime and standard library
Rather then requiring the user to specify runtime the compiler
runtime and C++ standard library, or trying to guess them which is
error-prone, use auto-detection by parsing the compiler link output.

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

llvm-svn: 332683
2018-05-18 01:10:09 +00:00
Petr Hosek 3eb71831e5 [CMake] Reland "Make simple source used for CMake checks a C file"
The source being compiled is plain C, but using .cc extension forces it
to be compiled as C++ which requires a working C++ compiler including
C++ library which may not be the case when we're building compiler-rt
together with libcxx as part of runtimes build.

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

llvm-svn: 332679
2018-05-17 23:50:35 +00:00
Petr Hosek 5a668a054b [CMake] Cleanup find_compiler_rt_library function [NFC]
Rename the output variable and remove the unnecessary set call.

llvm-svn: 332661
2018-05-17 20:35:55 +00:00
Sid Manning ed3065f7a1 Add basic compiler-rt builtins support for hexagon.
Differential Revision: https://reviews.llvm.org/D46364

llvm-svn: 331881
2018-05-09 14:44:54 +00:00
Petr Hosek 5d3df3cf44 Revert "[CMake] Make simple source used for CMake checks a C file"
This reverts commit r331003 which breaks sanitizer bots because of
missing 32-bit libstdc++ library.

llvm-svn: 331009
2018-04-27 01:25:32 +00:00
Petr Hosek 887fbc61d4 [CMake] Make simple source used for CMake checks a C file
The source being compiled is plain C, but using .cc extension forces it
to be compiled as C++ which requires a working C++ compiler including
C++ library which may not be the case when we're building compiler-rt
together with libcxx as part of runtimes build.

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

llvm-svn: 331003
2018-04-26 23:35:13 +00:00
Aaron Smith 56e6e0d352 Revert "[cmake] Remove duplicate command line options from build"
The Android sanitizer buildbot is failing with this change and it
looks like an additional change to cmake is necessary to fix the 
build. Reverting this change for now.

llvm-svn: 329828
2018-04-11 17:31:18 +00:00
Aaron Smith 112d6760a8 [cmake] Remove duplicate command line options from build
CMAKE_CXX_FLAGS was added twice to the command line. This causes the command 
line options to be doubled which works until it doesn't as not all options 
can be specified twice. 

For example,

clang-cl foo.c /GS- /GS- -mllvm -small-loop-cost=1 -mllvm -small-loop-cost=1
clang (LLVM option parsing): for the -small-loop-cost option: may only occur zero or one times!

llvm-svn: 329817
2018-04-11 14:56:35 +00:00
Vitaly Buka 9802089e13 libFuzzer, OpenBSD support
Summary:
- Enabling libfuzzer on OpenBSD
- OpenBSD can t support asan, msan ... the tests can t be run.

Patch by David CARLIER

Reviewers: eugenis, phosek, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, mgorny, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 329631
2018-04-09 22:38:26 +00:00
Peter Collingbourne 6662e9890b shadowcallstack: Make runtime tests compatible with aarch64.
Differential Revision: https://reviews.llvm.org/D45303

llvm-svn: 329614
2018-04-09 20:18:10 +00:00
Dean Michael Berris fe79b04a74 [XRay][compiler-rt] Build XRay runtime for OpenBSD
Summary:
This is D45125; the patch enables the build of XRay on OpenBSD. We also
introduce some OpenBSD specific changes to the runtime implementation,
involving how we get the TSC rate through the syscall interface specific
to OpenBSD.

Reviewers: dberris

Authored by: devnexen

Subscribers: dberris, mgorny, krytarowski, llvm-commits

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

llvm-svn: 329189
2018-04-04 13:04:15 +00:00
Alex Shlyapnikov 5cd35ed4fe [HWASan] Port HWASan to Linux x86-64 (compiler-rt)
Summary:
Porting HWASan to Linux x86-64, first of the three patches, compiler-rt part.

The approach is similar to ARM case, trap signal is used to communicate
memory tag check failure. int3 instruction is used to generate a signal,
access parameters are stored in nop [eax + offset] instruction immediately
following the int3 one

Had to add HWASan init on malloc because, due to much less interceptors
defined (most other sanitizers intercept much more and get initalized
via one of those interceptors or don't care about malloc), HWASan was not
initialized yet when libstdc++ was trying to allocate memory for its own
fixed-size heap, which led to CHECK-fail in AllocateFromLocalPool.

Also added the CHECK() failure handler with more detailed message and
stack reporting.

Reviewers: eugenis

Subscribers: kubamracek, dberris, mgorny, kristof.beyls, delcypher, #sanitizers, llvm-commits

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

llvm-svn: 328385
2018-03-23 23:38:04 +00:00
Petr Hosek 2d19f9036e [Fuzzer] Avoid the unnecessary rebuild of the custom libc++
This changes the add_custom_libcxx macro to resemble the
llvm_ExternalProject_Add. The primary motivation is to avoid
unnecessary libFuzzer rebuilds that are being done on every
Ninja/Make invocation. The libc++ should be only rebuilt whenever
the libc++ source itself changes.

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

llvm-svn: 326921
2018-03-07 18:14:09 +00:00
Kamil Rytarowski 0d58e0f613 OpenBSD UBsan support, cmake part
Summary:
On OpenBSD no multi arch support
Enabling only UBsan and disabling Asan.

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka

Reviewed By: vitalybuka

Subscribers: srhines, mgorny, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 326646
2018-03-03 11:48:54 +00:00
Kamil Rytarowski 3d7fbb052f Adding Msan support to FreeBSD
Summary:
Enabling the memory sanitizer support for FreeBSD, most of unit tests are compatible.
- Adding fstat and stressor_r interceptors.
- Updating the struct link_map access since most likely the struct Obj_Entry had been updated since.
- Disabling few unit tests until further work is needed (or we can assume it can work in real world code).

Patch by: David CARLIER

Reviewers: vitalybuka, krytarowski

Reviewed By: vitalybuka

Subscribers: eugenis, dim, srhines, emaste, kubamracek, mgorny, fedor.sergeev, hintonda, llvm-commits, #sanitizers

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

llvm-svn: 326644
2018-03-03 11:43:11 +00:00
Shiva Chen 77f19a384c [PATCH] [compiler-rt, RISCV] Support builtins for RISC-V
Summary:
Support builtins for RISC-V, RV32 and RV64.

Reviewers: asb, apazos, mgrang

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

llvm-svn: 326420
2018-03-01 07:47:27 +00:00
Kamil Rytarowski bab5252789 Add initial XRay support for NetBSD
Summary:
Reuse the existing FreeBSD code as it is.

Sponsored by <The NetBSD Foundation>

Reviewers: dberris, rnk, vitalybuka

Reviewed By: dberris

Subscribers: mclow.lists, emaste, mgorny, llvm-commits, #sanitizers

Tags: #sanitizers

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

llvm-svn: 325345
2018-02-16 14:45:20 +00:00
Kamil Rytarowski 4d4ed0e288 Add Xray instrumentation support to FreeBSD
Summary:
- Enabling the build.
- Using assembly for the cpuid parts.
- Using thr_self FreeBSD call to get the thread id 

Patch by: David CARLIER

Reviewers: dberris, rnk, krytarowski

Reviewed By: dberris, krytarowski

Subscribers: emaste, stevecheckoway, nglevin, srhines, kubamracek, dberris, mgorny, krytarowski, llvm-commits, #sanitizers

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

llvm-svn: 325240
2018-02-15 14:17:15 +00:00
Petr Hosek b1eaa56704 [fuzzer] Update and enable libFuzzer on Fuchsia
This change updates the Fuchsia-specific code to use the C++ friendly
duration expressions and flips on the building of
libclang_rt.fuzzer-x86_64.a and similar for Fuchsia. Given that
compiler-rt doesn't build on Fuchsia, test have been run by explicitly
building the library and linking it against
lib/fuzzer/tests/FuzzerUnittest.cpp.

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

llvm-svn: 323828
2018-01-30 22:59:48 +00:00
Kostya Kortchinsky c15da10101 [scudo] Add support for Fuchsia OS.
Summary: Built & tested in Fuchsia's build system.

Reviewers: alekseyshl, cryptoad, aarongreen

Reviewed By: cryptoad

Subscribers: srhines, mgorny

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

llvm-svn: 323685
2018-01-29 20:17:29 +00:00
Don Hinton 23743f48fa Revert: [compiler-rt] r323626 - [cmake] [compiler-rt] Remove duplicate CMAKE_CXX_FLAGS.
Looks like it broke a bot: http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/7195
Reverting until I have a chance to investigate.

llvm-svn: 323629
2018-01-29 05:32:21 +00:00
Don Hinton 448ef74698 [cmake] [compiler-rt] Remove duplicate CMAKE_CXX_FLAGS.
`set_target_compile_flags()` ultimately sets COMPILE_FLAGS which is
added to CMAKE_CXX_FLAGS in the compile rule, so passing
CMAKE_CXX_FLAGS causes them to be duplicated.

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

llvm-svn: 323626
2018-01-29 05:07:20 +00:00