Commit Graph

340 Commits

Author SHA1 Message Date
Saleem Abdulrasool b939a7fde8 build: profile is not a sanitizer
There was an invalid entry in the sanitizer list, remove it.  This has no effect
on the building, just removes the definition of a cached variable.

llvm-svn: 280378
2016-09-01 15:05:36 +00:00
Chris Bieneman 21395f9839 [CMake] Connect Compiler-RT targets to LLVM Runtimes directory
This patch builds on LLVM r279776.

In this patch I've done some cleanup and abstracted three common steps runtime components have in their CMakeLists files, and added a fourth.

The three steps I abstract are:

(1) Add a top-level target (i.e asan, msan, ...)
(2) Set the target properties for sorting files in IDE generators
(3) Make the compiler-rt target depend on the top-level target

The new step is to check if a command named "runtime_register_component" is defined, and to call it with the component name.

The runtime_register_component command is defined in llvm/runtimes/CMakeLists.txt, and presently just adds the component to a list of sub-components, which later gets used to generate target mappings.

With this patch a new workflow for runtimes builds is supported. The new workflow when building runtimes from the LLVM runtimes directory is:

> cmake [...]
> ninja runtimes-configure
> ninja asan

The "runtimes-configure" target builds all the dependencies for configuring the runtimes projects, and runs CMake on the runtimes projects. Running the runtimes CMake generates a list of targets to bind into the top-level CMake so subsequent build invocations will have access to some of Compiler-RT's targets through the top-level build.

Note: This patch does exclude some top-level targets from compiler-rt libraries because they either don't install files (sanitizer_common), or don't have a cooresponding `check` target (stats).
llvm-svn: 279863
2016-08-26 20:52:22 +00:00
Francis Ricci 341b1fea7c [builtins] Make sure builtin compile tests respect CMAKE_C_COMPILER_TARGET
Summary:
Since we generate the compiler invocation on our own, we need to
manually add -target if CMAKE_C_COMPILER_TARGET has been specified.

Reviewers: compnerd, beanz

Subscribers: llvm-commits

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

llvm-svn: 279747
2016-08-25 16:15:45 +00:00
Francis Ricci 0f488dc215 [compiler-rt] Use flags found when configuring builtins during compilation
Summary: This fixes the omission of -fPIC when building the builtins.

Reviewers: compnerd, beanz

Subscribers: dberris, llvm-commits

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

llvm-svn: 279469
2016-08-22 20:33:47 +00:00
Filipe Cabecinhas e5914d82d2 [cmake] Fix append_rtti_flag macro and bad var name
llvm-svn: 279450
2016-08-22 18:30:37 +00:00
Chris Bieneman 9b818ac5d9 [CMake] Support building on OS X without Xcode installation
This should resolve PR23162. This patch has two parts.

First we need to check the error code from xcodebuild when querying for SDKs, second if the OS X SDK is not discovered, we ensure that /usr/include exists and use / as the OS X sysroot.

llvm-svn: 279336
2016-08-19 22:22:35 +00:00
Chris Bieneman 83877ee6cc [CMake] Add top-level install-compiler-rt target
This is a wrapper target of all the component install targets. This wrapper target will be used by the new LLVM runtimes directory to connect top-level targets to the runtime project target.

llvm-svn: 279333
2016-08-19 22:17:46 +00:00
Saleem Abdulrasool b6ced621e8 build: allow building a specific set of sanitizers
Introduce a new CMake option `COMPILER_RT_SANITIZERS_TO_BUILD` which takes
either a special token `all` (default) which will preserve the current behaviour
or a CMake list of sanitizers to build.  It will still perform the normal checks
if the sanitizer is requested.  It only permits a further means to exclude a
particular sanitizer.  This gives finer grained control than
`COMPILER_RT_BUILD_SANITIZERS` which only gives an all or nothing control.

llvm-svn: 279253
2016-08-19 15:13:21 +00:00
Chris Bieneman a8105c607b [CMake] Stop building eprintf library on Darwin
In r278988 clang stopped using the eprintf library, so we should stop generating it too.

llvm-svn: 279090
2016-08-18 17:10:55 +00:00
Chris Bieneman 86412e56fb [CMake] Renaming test variable to be consistent
Based on post-commit review by compnerd.

llvm-svn: 278728
2016-08-15 20:12:43 +00:00
Chris Bieneman 98ee3de514 [CMake] If the compiler supports _Atomic include atomic.c in builtins libraries
This fixes a long-standing TODO by implementing a compiler check for supporting the _Atomic keyword. If the _Atomic keyword is supported by the compiler we should include it in the builtin library sources.

llvm-svn: 278454
2016-08-12 01:29:26 +00:00
Saleem Abdulrasool 1313ae306a builtins: windows has only one flavour on ARM
Windows on ARM is a hard-float only environment.  Don't try to build two copies
of the same library.

llvm-svn: 277834
2016-08-05 16:53:05 +00:00
Jonas Hahnfeld 8ad6cc1c26 Revert "[CMake] Pass -nostdlib if supported"
This reverts commit r277419.

llvm-svn: 277420
2016-08-02 06:01:05 +00:00
Jonas Hahnfeld 55933dfb32 [CMake] Pass -nostdlib if supported
The sanitizers use C++ but don't require linking with the library.

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

llvm-svn: 277419
2016-08-02 05:51:09 +00:00
Jonas Hahnfeld 9b2c3ab620 [CMake] Load LLVMConfig for standalone build of builtins
Therefore move some code into reusable macros.

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

llvm-svn: 277418
2016-08-02 05:51:05 +00:00
Chris Bieneman 178cdfbf66 [CMake] Don't trust compiler error code, also check for errors
Summary: rnk reported that MSVC ignores unknown flags and still returns 0. This should cause unknown flags to be an error during the compiler check.

Reviewers: rnk

Subscribers: brad.king, llvm-commits

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

llvm-svn: 277377
2016-08-01 20:18:18 +00:00
Daniel Sanders aea8b553e3 [compiler-rt][cmake] Don't reset CAN_TARGET_${arch} on every cmake invocation.
Allowing this variable to be cached makes it possible to repair the MIPS
buildbots in lieu of either fixing the mips64 sanitizer issues or fixing the
detection of mips64 support (which I think was changed by r268977 but didn't
take effect on this buildbot until the last couple days) so that it returns to
not being built on these buildbots.

llvm-svn: 276402
2016-07-22 10:15:09 +00:00
Daniel Sanders 8390d50e9c Revert r276256 - Attempt to fix clang-cmake-mips after r268977.
It didn't fix the problem on the buildbot. CAN_TARGET_mips64 is still true.

llvm-svn: 276258
2016-07-21 09:52:33 +00:00
Daniel Sanders 14086eae46 Attempt to fix clang-cmake-mips after r268977.
I think it's wiped out the build area and fully-reconfigured for the first time
since r268977. This seems to have caused Mips64 to become enabled when it wasn't
before because compiling with -mabi=64 succeeds but linking with -mabi=64 fails.

llvm-svn: 276256
2016-07-21 09:28:09 +00:00
Dean Michael Berris 938c5031ab [compiler-rt][XRay] re-submitting r276117, with fixes for build breakage due to extraneous and missing dependencies and attempts to build on unsupported OSes
Summary:
This is a fixed-up version of D21612, to address failure identified post-commit.

Original commit description:

This patch implements the initialisation and patching routines for the XRay runtime, along with the necessary trampolines for function entry/exit handling. For now we only define the basic hooks for allowing an implementation to define a handler that gets run on function entry/exit. We expose a minimal API for controlling the behaviour of the runtime (patching, cleanup, and setting the handler to invoke when instrumenting).

Fixes include:
- Gating XRay build to only Linux x86_64 and with the right dependencies in case it is the only library being built
- Including <cstddef> to fix std::size_t issue

Reviewers: kcc, rnk, echristo

Subscribers: mehdi_amini, llvm-commits

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

llvm-svn: 276251
2016-07-21 07:39:55 +00:00
Hans Wennborg ae4e6fe990 Revert r276117 "[XRay] Basic initialization and flag definition for XRay runtime"
and also the follow-up "[xray] Only build xray on Linux for now"

Two build errors were reported on the llvm-commits list:

	[ 88%] Building CXX object lib/xray/CMakeFiles/clang_rt.xray-x86_64.dir/xray_flags.cc.o
	/mnt/b/sanitizer-buildbot1/sanitizer-x86_64-linux/build/llvm/projects/compiler-rt/lib/xray/xray_init.cc:23:10: fatal error: 'llvm/Support/ELF.h' file not found
  #include "llvm/Support/ELF.h"
					 ^

and

	In file included from /w/src/llvm.org/projects/compiler-rt/lib/xray/xray_interface.cc:16:
	/w/src/llvm.org/projects/compiler-rt/lib/xray/xray_interface_internal.h:36:8: error:
				no type named 'size_t' in namespace 'std'
		std::size_t Entries;
		~~~~~^

llvm-svn: 276186
2016-07-20 21:37:38 +00:00
Francis Ricci ba2405cc5b [compiler-rt] Don't require c++ headers when configuring compiler-rt builds
Summary:
A sysroot without c++ headers is able to build compiler-rt, don't
require them when configuring available architectures from cmake.

Reviewers: samsonov, beanz, compnerd

Subscribers: llvm-commits

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

llvm-svn: 276151
2016-07-20 18:25:46 +00:00
Francis Ricci b04a721830 [compiler-rt] Fix target architecture matching
Summary:
Use stricter comparisons for architecture. This prevents cmake from failing
for sysroots which can only compile armhf and not arm, since
arm MATCHES armhf is true, while arm STREQUAL armhf is false.

Reviewers: beanz, compnerd

Subscribers: aemerson, llvm-commits

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

llvm-svn: 276148
2016-07-20 18:06:31 +00:00
Reid Kleckner 8367634c7a [xray] Only build xray on Linux for now
Should fix the Windows buildbots, and maybe some other non-Linux Unix
bots too.

XRay currently depends on sanitizer_common, so associate it with the
"build sanitizers" option and remove the option for separately
controlling the XRay build.

llvm-svn: 276124
2016-07-20 14:58:07 +00:00
Dean Michael Berris e1c81d10d7 [compiler-rt] [XRay] Basic initialization and flag definition for XRay runtime
Summary:
This patch implements the initialisation and patching routines for the XRay runtime, along with the necessary trampolines for function entry/exit handling. For now we only define the basic hooks for allowing an implementation to define a handler that gets run on function entry/exit. We expose a minimal API for controlling the behaviour of the runtime (patching, cleanup, and setting the handler to invoke when instrumenting).

Depends on D19904

Reviewers: echristo, kcc, rnk

Subscribers: rnk, mehdi_amini, llvm-commits

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

llvm-svn: 276117
2016-07-20 14:14:50 +00:00
Mohit K. Bhakkad d7ae23b563 [Compiler-rt][MIPS] Fix simple test failure when using gcc
Reviewers: dsanders

Subscribers: slthakur, jaydeep, llvm-commits, Sanitizers

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

llvm-svn: 275780
2016-07-18 09:23:23 +00:00
Etienne Bergeron ab42f4ddba [compiler-rt] Fix VisualStudio virtual folders layout
Summary:
This patch is a refactoring of the way cmake 'targets' are grouped.
It won't affect non-UI cmake-generators.

Clang/LLVM are using a structured way to group targets which ease
navigation through Visual Studio UI. The Compiler-RT projects
differ from the way Clang/LLVM are grouping targets.

This patch doesn't contain behavior changes.

Reviewers: kubabrecka, rnk

Subscribers: wang0109, llvm-commits, kubabrecka, chrisha

Differential Revision: http://reviews.llvm.org/D21952

llvm-svn: 275111
2016-07-11 21:51:56 +00:00
Chris Bieneman 42e22dcbb5 [CMake] In r273957, I deleted a line that shouldn't have been removed.
llvm-svn: 274030
2016-06-28 16:30:23 +00:00
Chris Bieneman 990ff38786 [CMake] Check for androidabi in CMakeLists.txt not base-config-ix.cmake
COMPILER_RT_DEFAULT_TARGET_ABI is not set in base-config-ix.cmake, so we need to move this check into CMakeLists.txt.

llvm-svn: 273957
2016-06-27 22:52:05 +00:00
Chris Bieneman 90b46fba3d Revert "Parse the triple in base-config-ix to propagate ANDROID variable correctly"
This reverts commit r273914.

This commit broke bots building compiler-rt using LLVM_BUILD_EXTERNAL_COMPILER_RT. See:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/22221/console

llvm-svn: 273956
2016-06-27 22:52:03 +00:00
Sumanth Gundapaneni f0fa61ffcf Parse the triple in base-config-ix to propagate ANDROID variable correctly
The triple must be parsed in base-config-ix.cmake.
Otherwise, the cmake variable ANDROID won't be set and this
will confuse cmake to build unsupported targets targeted for
android.

Diferential revision: http://reviews.llvm.org/D21474

llvm-svn: 273914
2016-06-27 19:46:50 +00:00
Chris Bieneman 38adadfe2a [CMake] Converting darwin_test_archs simple source to C
Using C instead of CXX here removes a configuration-time dependency on libcxx for the sanitizers. This should be NFC.

llvm-svn: 273505
2016-06-22 23:02:49 +00:00
Etienne Bergeron 7e2fc3b702 [compiler-rt] Split cflags and link flags to avoid warnings
Summary:
The MSVC compiler is complaining about invalid flags. The CFLAGS are passed
to the linker (i.e. /Gy-, ...).

Reviewers: rnk

Subscribers: llvm-commits, kubabrecka, chrisha

Differential Revision: http://reviews.llvm.org/D21554

llvm-svn: 273265
2016-06-21 14:46:32 +00:00
Etienne Bergeron b2f17d1719 trimming whitespaces
llvm-svn: 273263
2016-06-21 14:32:52 +00:00
Marcin Koscielnicki d731820f1e Revert "Revert "[MSan] Enable on PowerPC64.""
This reverts commit r269532.

The failures triggered by the first attempt should be fixed by r273250.

llvm-svn: 273251
2016-06-21 07:13:24 +00:00
Reid Kleckner 44e6e36299 Turn off -Wunused-parameter when building compiler-rt with clang on Windows, it is very noisy
It is turned on as part of "clang-cl /W4", which enables -Wextra.

llvm-svn: 273028
2016-06-17 18:30:37 +00:00
Reid Kleckner 652d70f3e1 Fix most MSVC warnings in compiler-rt profiling library
Here's the warnings and how they were fixed:

- InstrProfilingUtil.c(110): warning C4013: '_open_osfhandle' undefined; assuming extern returning int

Include io.h to get the prototype.

- warning C4005: 'FILE_MAP_EXECUTE': macro redefinition

Stop trying to support pre-XP versions of Windows, don't attempt to
define this macro.

- InstrProfilingWriter.c(271): warning C4221: nonstandard extension used: 'Data': cannot be initialized using address of automatic variable 'Header'
- InstrProfilingWriter.c(275): warning C4221: nonstandard extension used: 'Data': cannot be initialized using address of automatic variable 'Zeroes'

Turn this warning off. This is definitely legal in C++, all compilers
accept it, and I only have room for half of one language standard in my
brain.

- InstrProfilingValue.c(320): warning C4113: 'uint32_t (__cdecl *)()' differs in parameter lists from 'uint32_t (__cdecl *)(void)'

Fix this with an explicit (void) in the prototype.

- InstrProfilingMerge.c.obj : warning LNK4006: _VPMergeHook already defined in InstrProfilingMergeFile.c.obj; second definition ignored

Last remaining warning. This is from linking a selectany definition with
a strong definition. We need to sort out weak symbols in compiler-rt in
general, though.

llvm-svn: 273026
2016-06-17 18:12:50 +00:00
Reid Kleckner d0680ad717 Fix some warnings in the MSVC build
- Fixes warnings about the ignored -fms-compatibility-version flag.
- Fixes warnings about overriding /W4 with /W3 and back.
- Fixes a warning where PREFETCH() expanded to nothing in a braceless if
  block.

llvm-svn: 273021
2016-06-17 17:48:52 +00:00
Chris Bieneman d31a728d76 [CMake] Cleanup CMake version checking
CMAKE_VERSION is always greater than 3.0 now. No reason not to remove the extra compatibility code.

llvm-svn: 272315
2016-06-09 21:35:37 +00:00
Kostya Serebryany 712fc9803a [sanitizer] Initial implementation of a Hardened Allocator
Summary:
This is an initial implementation of a Hardened Allocator based on Sanitizer Common's CombinedAllocator.
It aims at mitigating heap based vulnerabilities by adding several features to the base allocator, while staying relatively fast.
The following were implemented:
- additional consistency checks on the allocation function parameters and on the heap chunks;
- use of checksum protected chunk header, to detect corruption;
- randomness to the allocator base;
- delayed freelist (quarantine), to mitigate use after free and overall determinism.
Additional mitigations are in the works.

Reviewers: eugenis, aizatsky, pcc, krasin, vitalybuka, glider, dvyukov, kcc

Subscribers: kubabrecka, filcab, llvm-commits

Differential Revision: http://reviews.llvm.org/D20084

llvm-svn: 271968
2016-06-07 01:20:26 +00:00
Chris Bieneman c0d89826a7 [CMake] Support constructing output paths from LLVM variables
This tweak to constructing output paths allows compiler-rt to use LLVM
output variables if they are set regardless of whether or not the build
is in-tree.

llvm-svn: 271749
2016-06-03 23:15:04 +00:00
Chris Bieneman 648d3bc8c7 [CMake] detect_target_arch needs to be moved to Utils
This macro is called from the base config, so it can't live in config-ix, it needs to be in the utils. I suspect the only reason this hasn't caused problems is that nobody is building the Android builtins from the builtins subdirectory.

llvm-svn: 271693
2016-06-03 17:34:02 +00:00
Etienne Bergeron 00f3f6e296 This patch is activating the build of Asan on Windows 64-bits.
It's fixing compilation errors. The runtime is not yet working.

Missing features:

OverrideFunction for x64
an equiv function for inline asm (atomic_compare_exchange_strong)
shadow memory offset needs to be adjusted
RoundUpToInstrBoundary for x64
They will be implemented by subsequent patches.

Patch by Wei Wang.

Differential revision: http://reviews.llvm.org/D20455

llvm-svn: 271049
2016-05-27 21:29:31 +00:00
Kuba Brecka 6d8873b8bc [sanitizer] Fix a typo in config-ix.cmake causing all Darwin embedded platforms to be built with the 'iossim' SDK.
llvm-svn: 270840
2016-05-26 11:18:22 +00:00
Etienne Bergeron 3df2879232 [compiler-rt] Fix multi-configuration output paths
Summary:
When using a multi-configuration build (i.e. MSVC) the output path where
libraries are dropped is incorrect.

Example:
```
C:\src\llvm\examples>d:\src\llvm\build\Release\bin\clang-cl.exe -fsanitize=address test.cc
LINK : fatal error LNK1181: cannot open input file 'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\clang_rt.asan-i386.lib'
```

The dropped executable path contains the configuration 'Release':
```
'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\Release\clang_rt.asan-i386.lib'
```


The variable 'RUNTIME_OUTPUT_DIRECTORY' is used to specify the output directory.
But CMAKE is appending the current configuration (i.e. Debug, Release).

see: https://cmake.org/cmake/help/v3.0/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html
```
"Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory."
```

To avoid this problem, the configuration specific variable must be set:
'RUNTIME_OUTPUT_DIRECTORY_DEBUG', 'RUNTIME_OUTPUT_DIRECTORY_RELEASE', and so on.

Reviewers: ddunbar, chapuni, rnk

Subscribers: kubabrecka, llvm-commits

Differential Revision: http://reviews.llvm.org/D20261

llvm-svn: 269658
2016-05-16 14:58:07 +00:00
Marcin Koscielnicki bcbba8caed Revert "[MSan] Enable on PowerPC64."
This reverts commit r269522.

This broke dtls_test.c on ppc64le buildbots.

llvm-svn: 269532
2016-05-14 02:17:38 +00:00
Marcin Koscielnicki c4743ff313 [MSan] Enable on PowerPC64.
Differential Revision: http://reviews.llvm.org/D20001

llvm-svn: 269522
2016-05-14 00:18:02 +00:00
Chris Bieneman 1455de2171 [CMake] Cache check results and avoid duplicate checks
This caches the result of builtin_check_c_compiler_flag, and removes a duplicate check for C99 flag support.

llvm-svn: 269230
2016-05-11 20:37:43 +00:00
Chris Bieneman c49e5e336b [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
Chris Bieneman aa3d2c13bf [CMake] NFC. Add support for testing the compiler without testing the linker
Summary:
One of the big limitations we have in the compiler-rt build system today is that we cannot bootstrap building the builtins because you need a fully functional toolchain to pass CMake's tests.

This change adds support for compile only tests.

It is NFC because nothing is using the compile-only tests yet.

I believe this is the last separable part of D16653.

Reviewers: samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D19692

llvm-svn: 268427
2016-05-03 19:48:11 +00:00