r286898 - [sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET when building compiler-rt from clang/runtime/CMakeLists.txt

2016-11-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Mon Nov 14 16:38:57 2016
New Revision: 286898

URL: http://llvm.org/viewvc/llvm-project?rev=286898=rev
Log:
[sanitizer] Passthrough CMAKE_OSX_DEPLOYMENT_TARGET when building compiler-rt 
from clang/runtime/CMakeLists.txt

This breaks some Swift builds, because Swift's build scripts explicitly set 
CMAKE_OSX_DEPLOYMENT_TARGET. This however isn't propagated to the compiler-rt 
build, causing build errors.

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


Modified:
cfe/trunk/runtime/CMakeLists.txt

Modified: cfe/trunk/runtime/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/runtime/CMakeLists.txt?rev=286898=286897=286898=diff
==
--- cfe/trunk/runtime/CMakeLists.txt (original)
+++ cfe/trunk/runtime/CMakeLists.txt Mon Nov 14 16:38:57 2016
@@ -77,6 +77,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND E
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}
${COMPILER_RT_PASSTHROUGH_VARIABLES}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-11-07 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

This passes TSan tests on Darwin. LGTM.


https://reviews.llvm.org/D24991



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-11-02 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

In https://reviews.llvm.org/D24991#586219, @sebpop wrote:

> I just ran ninja check-all with and without this patch and there are no 
> regressions in compiler-rt on an x86_64-linux machine.


The TSan interceptors (and testcases) are Darwin-only at this point.  I'll run 
the tests on my machine.


https://reviews.llvm.org/D24991



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D24991: Inline hot functions in libcxx shared_ptr implementation.

2016-10-31 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

Just a question:  TSan intercepts on the dylib functions, namely 
`__release_shared`, to track the atomic accesses.  Can you make sure this 
doesn't break?  There's a few testcases for this in compiler-rt.


https://reviews.llvm.org/D24991



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25857: [tsan][clang] Introduce a function attribute to disable TSan checking at run time

2016-10-26 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

Does this also disable checking for the compiler generated `.cxx_destruct` 
Obj-C methods?  Can we add a testcase both here and into compiler-rt?


https://reviews.llvm.org/D25857



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r281603 - [libcxx] Allow sanitizing libcxx with ASan+UBSan simultaneously

2016-09-15 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Thu Sep 15 06:04:53 2016
New Revision: 281603

URL: http://llvm.org/viewvc/llvm-project?rev=281603=rev
Log:
[libcxx] Allow sanitizing libcxx with ASan+UBSan simultaneously

Allow building with LLVM_USE_SANITIZER=“Address;Undefined” (and 
“Undefined;Address”).

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


Modified:
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/test/libcxx/test/config.py

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=281603=281602=281603=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Thu Sep 15 06:04:53 2016
@@ -38,7 +38,9 @@ add_library_flags("${LIBCXX_CXX_ABI_LIBR
 add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" 
"-Wl,--no-whole-archive")
 
 if (APPLE AND LLVM_USE_SANITIZER)
-  if ("${LLVM_USE_SANITIZER}" STREQUAL "Address")
+  if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR
+  ("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR
+  ("${LLVM_USE_SANITIZER}" STREQUAL "Undefined;Address"))
 set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
   elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
 set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")

Modified: libcxx/trunk/test/libcxx/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/config.py?rev=281603=281602=281603=diff
==
--- libcxx/trunk/test/libcxx/test/config.py (original)
+++ libcxx/trunk/test/libcxx/test/config.py Thu Sep 15 06:04:53 2016
@@ -610,9 +610,17 @@ class Configuration(object):
 os.pathsep + symbolizer_search_paths)
 llvm_symbolizer = lit.util.which('llvm-symbolizer',
  symbolizer_search_paths)
+
+def add_ubsan():
+self.cxx.flags += ['-fsanitize=undefined',
+   
'-fno-sanitize=vptr,function,float-divide-by-zero',
+   '-fno-sanitize-recover=all']
+self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1'
+self.config.available_features.add('ubsan')
+
 # Setup the sanitizer compile flags
 self.cxx.flags += ['-g', '-fno-omit-frame-pointer']
-if san == 'Address':
+if san == 'Address' or san == 'Address;Undefined' or san == 
'Undefined;Address':
 self.cxx.flags += ['-fsanitize=address']
 if llvm_symbolizer is not None:
 self.env['ASAN_SYMBOLIZER_PATH'] = llvm_symbolizer
@@ -622,6 +630,8 @@ class Configuration(object):
 self.config.available_features.add('asan')
 self.config.available_features.add('sanitizer-new-delete')
 self.cxx.compile_flags += ['-O1']
+if san == 'Address;Undefined' or san == 'Undefined;Address':
+add_ubsan()
 elif san == 'Memory' or san == 'MemoryWithOrigins':
 self.cxx.flags += ['-fsanitize=memory']
 if san == 'MemoryWithOrigins':
@@ -633,12 +643,8 @@ class Configuration(object):
 self.config.available_features.add('sanitizer-new-delete')
 self.cxx.compile_flags += ['-O1']
 elif san == 'Undefined':
-self.cxx.flags += ['-fsanitize=undefined',
-   
'-fno-sanitize=vptr,function,float-divide-by-zero',
-   '-fno-sanitize-recover=all']
+add_ubsan()
 self.cxx.compile_flags += ['-O2']
-self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1'
-self.config.available_features.add('ubsan')
 elif san == 'Thread':
 self.cxx.flags += ['-fsanitize=thread']
 self.config.available_features.add('tsan')


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r281477 - [libcxx] Add a TSan regression test for a data race in call_once

2016-09-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Wed Sep 14 09:15:42 2016
New Revision: 281477

URL: http://llvm.org/viewvc/llvm-project?rev=281477=rev
Log:
[libcxx] Add a TSan regression test for a data race in call_once

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


Added:

libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp

Added: 
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp?rev=281477=auto
==
--- 
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
 (added)
+++ 
libcxx/trunk/test/std/thread/thread.mutex/thread.once/thread.once.callonce/race.pass.cpp
 Wed Sep 14 09:15:42 2016
@@ -0,0 +1,48 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: libcpp-has-no-threads
+
+// 
+
+// struct once_flag;
+
+// template
+//   void call_once(once_flag& flag, Callable&& func, Args&&... args);
+
+// This test is supposed to be run with ThreadSanitizer and verifies that
+// call_once properly synchronizes user state, a data race that was fixed
+// in r280621.
+
+#include 
+#include 
+#include 
+
+std::once_flag flg0;
+long global = 0;
+
+void init0()
+{
+++global;
+}
+
+void f0()
+{
+std::call_once(flg0, init0);
+assert(global == 1);
+}
+
+int main()
+{
+std::thread t0(f0);
+std::thread t1(f0);
+t0.join();
+t1.join();
+assert(global == 1);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r281476 - [libcxx] Fix a typo in test/libcxx/test/target_info.py that prevents running tests on Darwin with sanitizers

2016-09-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Wed Sep 14 09:13:50 2016
New Revision: 281476

URL: http://llvm.org/viewvc/llvm-project?rev=281476=rev
Log:
[libcxx] Fix a typo in test/libcxx/test/target_info.py that prevents running 
tests on Darwin with sanitizers

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


Modified:
libcxx/trunk/test/libcxx/test/target_info.py

Modified: libcxx/trunk/test/libcxx/test/target_info.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/test/target_info.py?rev=281476=281475=281476=diff
==
--- libcxx/trunk/test/libcxx/test/target_info.py (original)
+++ libcxx/trunk/test/libcxx/test/target_info.py Wed Sep 14 09:13:50 2016
@@ -115,7 +115,7 @@ class DarwinLocalTI(DefaultTargetInfo):
 return False
 
 def add_sanitizer_features(self, sanitizer_type, features):
-if san == 'Undefined':
+if sanitizer_type == 'Undefined':
 features.add('sanitizer-new-delete')
 
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r281475 - [libcxx] Enable building and testing of libcxx with ThreadSanitizer on OS X

2016-09-14 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Wed Sep 14 09:12:50 2016
New Revision: 281475

URL: http://llvm.org/viewvc/llvm-project?rev=281475=rev
Log:
[libcxx] Enable building and testing of libcxx with ThreadSanitizer on OS X

This patch enables building and testing libcxx under ThreadSanitizer on OS X. 
CMake builds that have -DLLVM_USE_SANITIZER=Thread will automatically build 
libcxx with -fsanitize=thread and testing via lit then runs under TSan.

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


Modified:
libcxx/trunk/lib/CMakeLists.txt

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=281475=281474=281475=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Wed Sep 14 09:12:50 2016
@@ -42,6 +42,8 @@ if (APPLE AND LLVM_USE_SANITIZER)
 set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib")
   elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined")
 set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib")
+  elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread")
+set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib")
   else()
 message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported 
on OS X")
   endif()


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24048: [Driver] [Darwin] Add sanitizer libraries even if -nodefaultlibs is passed

2016-09-08 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

Anyone who uses `-nostdlib` or `-nodefaultlibs` has to be aware that his 
program will be linked with less stuff than usual and has to expect linker 
error.  If such a user doesn’t know that ASan and TSan require a dylib on 
macOS, he should be able to figure this out from the error/warning.

That being said, I am in favor for the current patch (don’t link sanitizer 
runtime automatically with -nostdlib, but do so with an explicit 
-flink-sanitizer-runtimes), plus an explicit warning when using `-nostdlib` and 
`-fsanitize=...` together without `-flink-sanitizer-runtimes`, which should 
suggest to use the new option.

Could we consider renaming `-flink-sanitizer-runtimes` to something that starts 
with `-fsanitize`?  All current sanitizer flags start with `-fsanitize`, they 
never use the word sanitize/sanitizer in the middle.  We also already have 
`-fsanitize-link-c++-runtime`.


https://reviews.llvm.org/D24048



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r280621 - [libcxx] Fix a data race in call_once

2016-09-04 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Sun Sep  4 04:55:12 2016
New Revision: 280621

URL: http://llvm.org/viewvc/llvm-project?rev=280621=rev
Log:
[libcxx] Fix a data race in call_once

call_once is using relaxed atomic load to perform double-checked locking, which 
contains a data race. The fast-path load has to be an acquire atomic load.

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


Modified:
libcxx/trunk/include/memory
libcxx/trunk/include/mutex
libcxx/trunk/src/mutex.cpp

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=280621=280620=280621=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Sun Sep  4 04:55:12 2016
@@ -663,6 +663,18 @@ _ValueType __libcpp_relaxed_load(_ValueT
 #endif
 }
 
+template 
+inline _LIBCPP_ALWAYS_INLINE
+_ValueType __libcpp_acquire_load(_ValueType const* __value) {
+#if !defined(_LIBCPP_HAS_NO_THREADS) && \
+defined(__ATOMIC_ACQUIRE) &&\
+(__has_builtin(__atomic_load_n) || _GNUC_VER >= 407)
+return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
+#else
+return *__value;
+#endif
+}
+
 // addressof moved to <__functional_base>
 
 template  class allocator;

Modified: libcxx/trunk/include/mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/mutex?rev=280621=280620=280621=diff
==
--- libcxx/trunk/include/mutex (original)
+++ libcxx/trunk/include/mutex Sun Sep  4 04:55:12 2016
@@ -574,7 +574,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
 {
-if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
+if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
 {
 typedef tuple<_Callable&&, _Args&&...> _Gp;
 _Gp __f(_VSTD::forward<_Callable>(__func), 
_VSTD::forward<_Args>(__args)...);
@@ -590,7 +590,7 @@ inline _LIBCPP_INLINE_VISIBILITY
 void
 call_once(once_flag& __flag, _Callable& __func)
 {
-if (__libcpp_relaxed_load(&__flag.__state_) != ~0ul)
+if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
 {
 __call_once_param<_Callable> __p(__func);
 __call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);

Modified: libcxx/trunk/src/mutex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/mutex.cpp?rev=280621=280620=280621=diff
==
--- libcxx/trunk/src/mutex.cpp (original)
+++ libcxx/trunk/src/mutex.cpp Sun Sep  4 04:55:12 2016
@@ -199,9 +199,6 @@ static __libcpp_mutex_t mut = _LIBCPP_MU
 static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
 #endif
 
-/// NOTE: Changes to flag are done via relaxed atomic stores
-///   even though the accesses are protected by a mutex because threads
-///   just entering 'call_once` concurrently read from flag.
 void
 __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))
 {
@@ -238,7 +235,7 @@ __call_once(volatile unsigned long& flag
 __libcpp_mutex_unlock();
 func(arg);
 __libcpp_mutex_lock();
-__libcpp_relaxed_store(, ~0ul);
+__libcpp_atomic_store(, ~0ul, _AO_Release);
 __libcpp_mutex_unlock();
 __libcpp_condvar_broadcast();
 #ifndef _LIBCPP_NO_EXCEPTIONS


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21082: Do not assume that -fsanitize=address is valid option in clang tests

2016-06-07 Thread Kuba Brecka via cfe-commits
kubabrecka added a subscriber: kubabrecka.
kubabrecka added a comment.

This doesn’t make sense to me, Clang is able to produce ASanified code even 
when the compiler itself isn’t ASanified (that’s what LLVM_USE_SANITIZER does). 
 Where exactly is this test failing?


Repository:
  rL LLVM

http://reviews.llvm.org/D21082



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18280: [tsan] Allow -fsanitize=thread for iOS-style simulator targets

2016-03-18 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

LGTM after adding a check for a simulator.


http://reviews.llvm.org/D18280



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2016-01-25 Thread Kuba Brecka via cfe-commits
kubabrecka added inline comments.


Comment at: test/Driver/fsanitize.c:221
@@ +220,3 @@
+// RUN: %clang -target x86_64-apple-darwin10 
-resource-dir=%S/Inputs/resource_dir -fsanitize=memory -fsanitize=thread,memory 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-TSAN-MSAN-DARWIN1
+// CHECK-MSAN-TSAN-MSAN-DARWIN1: unsupported option '-fsanitize=thread,memory' 
for target 'x86_64-apple-darwin10'
+// CHECK-MSAN-TSAN-MSAN-DARWIN1-NOT: unsupported option

ygribov wrote:
> samsonov wrote:
> > beanz wrote:
> > > kubabrecka wrote:
> > > > samsonov wrote:
> > > > > Again, I feel like we're lying to users here: `-fsanitize=thread` 
> > > > > *is* supported for this target, it just requires building a runtime.
> > > > I'd like to see this from the point-of-view of a binary distribution.  
> > > > If the binary distribution (e.g. the one from llvm.org or Apple's Clang 
> > > > in Xcode) doesn't contain a runtime library, then the sanitizer is 
> > > > *not* supported in that distribution.  Also, see 
> > > > http://reviews.llvm.org/D14846, we'd like to have CMake options to 
> > > > select which runtimes will be built.  If you deliberately choose not to 
> > > > build ThreadSanitizer, then that sanitizer is *not* supported in your 
> > > > version of Clang.  If you're experimenting and porting a runtime to a 
> > > > new platform, then this sanitizer *is* supported in your version of 
> > > > Clang.
> > > Maybe the point is we should have a different error message for cases 
> > > where the runtime is just missing. Something like "runtime components for 
> > > '-fsanitize=thread' not available"
> > I see, so essentially you want to use a different approach for determining 
> > sanitizer availability (on OS X for now): if the library is present, then 
> > we support sanitizer, otherwise we don't: i.e. the binary distribution is 
> > the source of truth, not the list of sanitizers hardcoded into Clang driver 
> > source code. I'm fine with that, and see why it would make sense.
> > 
> > It's just that error message looks misleading: the problem is not TSan is 
> > unsupported for target, it's just unavailable in this distribution for one 
> > reason or another.
> > the binary distribution is the source of truth, not the list of sanitizers 
> > hardcoded into Clang driver source code.
> 
> This will not work for cross-compilers. It _may_ be ok for OSX but not for 
> other platforms.
Why not?  On Linux, there are statically-linked sanitizers, if you want to 
cross-compile, you need to have the runtime libraries for the target.  And 
dynamic libraries are a similar story – they're version-tied to the compiler 
and your compiler should really have the libraries of the sanitizers that it 
supports.


http://reviews.llvm.org/D15225



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2015-12-07 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

> The one thing I'm not sure about on this is, do we really want this to be 
> darwin-only? I kinda think it might be nice if we unified this behavior 
> across all platforms.

>  ... I wonder if this can't be better abstracted.

>  I'd really like to see all operating systems have the same behavior for 
> this, so I think much of the code can be shared.

>  If the runtime library exists for a sanitizer (any sanitizer) I don't see 
> any reason clang shouldn't then support the flags.


On Darwin, the situation is easier, because all the supported sanitizers are 
dylibs.  The code to link the runtimes is very different on every platform 
(Darwin, Linux, FreeBSD, Windows).  Alexey, can you comment on this?  Does this 
change make sense for Linux as well?


http://reviews.llvm.org/D15225



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2015-12-07 Thread Kuba Brecka via cfe-commits
kubabrecka updated this revision to Diff 42041.
kubabrecka added a comment.

Applying clang-format.


http://reviews.llvm.org/D15225

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Driver/ToolChain.h
  lib/Driver/SanitizerArgs.cpp
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains.cpp
  lib/Driver/ToolChains.h
  
test/Driver/Inputs/resource_dir_darwin_sanitizers/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
  
test/Driver/Inputs/resource_dir_darwin_sanitizers/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
  
test/Driver/Inputs/resource_dir_darwin_sanitizers/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib
  
test/Driver/Inputs/resource_dir_darwin_sanitizers/lib/darwin/libclang_rt.ubsan_iossim_dynamic.dylib
  
test/Driver/Inputs/resource_dir_darwin_sanitizers/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib
  test/Driver/darwin-asan-nofortify.c
  test/Driver/darwin-sanitizer-ld.c
  test/Driver/fsanitize.c
  test/Driver/sanitizer-ld.c

Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -295,6 +295,7 @@
 // RUN: -mmacosx-version-min=10.6 \
 // RUN: -target x86_64-apple-darwin13.4.0 \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: -resource-dir=%S/Inputs/resource_dir_darwin_sanitizers \
 // RUN:   | FileCheck --check-prefix=CHECK-ASAN-DARWIN106-CXX %s
 // CHECK-ASAN-DARWIN106-CXX: "{{.*}}ld{{(.exe)?}}"
 // CHECK-ASAN-DARWIN106-CXX: libclang_rt.asan_osx_dynamic.dylib
Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -10,8 +10,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED
 // CHECK-UNDEFINED: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|vptr|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){19}"}}
 
-// RUN: %clang -target x86_64-apple-darwin10 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN
-// CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
+// RUN: %clang -target x86_64-apple-darwin10 -resource-dir=%S/Inputs/resource_dir -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN1
+// CHECK-UNDEFINED-DARWIN1: error: '-fsanitize-trap=undefined' required with '-fsanitize=undefined' option
+// RUN: %clang -target x86_64-apple-darwin10 -resource-dir=%S/Inputs/resource_dir_darwin_sanitizers -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN2
+// CHECK-UNDEFINED-DARWIN2: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
 
 // RUN: %clang -target i386-unknown-openbsd -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-OPENBSD
 // CHECK-UNDEFINED-OPENBSD: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|float-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|object-size|float-cast-overflow|array-bounds|enum|bool|returns-nonnull-attribute|nonnull-attribute),?){17}"}}
@@ -28,9 +30,15 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-INTEGER
 // CHECK-INTEGER: "-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent),?){5}"}}
 
-// RUN: %clang -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS
 // CHECK-BOUNDS: "-fsanitize={{((array-bounds|local-bounds),?){2}"}}
 
+// RUN: %clang -target x86_64-apple-darwin10 -resource-dir=%S/Inputs/resource_dir -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS-DARWIN1
+// CHECK-BOUNDS-DARWIN1: error: '-fsanitize-trap=undefined' required with '-fsanitize=bounds' option
+
+// RUN: %clang -target x86_64-apple-darwin10 -resource-dir=%S/Inputs/resource_dir_darwin_sanitizers -fsanitize=bounds -### -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix=CHECK-BOUNDS-DARWIN2
+// CHECK-BOUNDS-DARWIN2: "-fsanitize={{((array-bounds|local-bounds),?){2}"}}
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=all %s -### 2>&1 | FileCheck %s 

[PATCH] D14440: [tsan] Add Clang frontend support for TSan on OS X

2015-11-06 Thread Kuba Brecka via cfe-commits
kubabrecka created this revision.
kubabrecka added reviewers: dvyukov, samsonov, kcc, glider.
kubabrecka added subscribers: cfe-commits, zaks.anna, ismailp, jasonk, 
jevinskie.

We're currently in process of porting TSan to OS X, and quite a few of the 
initial support in the runtime library has already landed in trunk.  This patch 
actually enables "-fsanitize=thread" in the frontend.

http://reviews.llvm.org/D14440

Files:
  lib/Driver/ToolChains.cpp

Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


Index: lib/Driver/ToolChains.cpp
===
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -389,6 +389,8 @@
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252310 - [tsan] Add Clang frontend support for TSan on OS X

2015-11-06 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Fri Nov  6 09:09:20 2015
New Revision: 252310

URL: http://llvm.org/viewvc/llvm-project?rev=252310=rev
Log:
[tsan] Add Clang frontend support for TSan on OS X

We're currently in process of porting TSan to OS X, and quite a few of the 
initial support in the runtime library has already landed in trunk. This patch 
actually enables "-fsanitize=thread" in the frontend.

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


Modified:
cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=252310=252309=252310=diff
==
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Fri Nov  6 09:09:20 2015
@@ -389,6 +389,8 @@ void DarwinClang::AddLinkRuntimeLibArgs(
 AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
   if (Sanitize.needsUbsanRt())
 AddLinkSanitizerLibArgs(Args, CmdArgs, "ubsan");
+  if (Sanitize.needsTsanRt())
+AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan");
 
   // Otherwise link libSystem, then the dynamic runtime library, and finally 
any
   // target specific static runtime library.
@@ -1199,6 +1201,7 @@ SanitizerMask Darwin::getSupportedSaniti
 if (!isMacosxVersionLT(10, 9))
   Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
+Res |= SanitizerKind::Thread;
   }
   return Res;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r252311 - Followup test failure fix for r252310 ("[tsan] Add Clang frontend support for TSan on OS X").

2015-11-06 Thread Kuba Brecka via cfe-commits
Author: kuba.brecka
Date: Fri Nov  6 09:20:30 2015
New Revision: 252311

URL: http://llvm.org/viewvc/llvm-project?rev=252311=rev
Log:
Followup test failure fix for r252310 ("[tsan] Add Clang frontend support for 
TSan on OS X").


Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=252311=252310=252311=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Fri Nov  6 09:20:30 2015
@@ -207,12 +207,11 @@
 // CHECK-MSAN-NOMSAN-DARWIN-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=memory 
-fsanitize=thread,memory %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-MSAN-TSAN-MSAN-DARWIN
-// CHECK-MSAN-TSAN-MSAN-DARWIN: unsupported option '-fsanitize=thread,memory' 
for target 'x86_64-apple-darwin10'
+// CHECK-MSAN-TSAN-MSAN-DARWIN: unsupported option '-fsanitize=memory' for 
target 'x86_64-apple-darwin10'
 // CHECK-MSAN-TSAN-MSAN-DARWIN-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=thread,memory 
-fsanitize=memory %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-TSAN-MSAN-MSAN-DARWIN
 // CHECK-TSAN-MSAN-MSAN-DARWIN: unsupported option '-fsanitize=memory' for 
target 'x86_64-apple-darwin10'
-// CHECK-TSAN-MSAN-MSAN-DARWIN: unsupported option '-fsanitize=thread' for 
target 'x86_64-apple-darwin10'
 // CHECK-TSAN-MSAN-MSAN-DARWIN-NOT: unsupported option
 
 // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=function %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-FSAN-DARWIN


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12646: Add libc++ header path for DarwinClang builds

2015-09-08 Thread Kuba Brecka via cfe-commits
kubabrecka added a comment.

> > I first noticed it when I tried to run the version of clang-tidy I'd just 
> > built and found I had to pass the path for it to find iostream.

> 

> 

> I think it works if you a) check out libcxx into llvm/projects/libcxx b) run 
> `make install` and c) run the binary from your install directory.


I don't think b) and c) are necessary.  At least for CMake builds, if you 
checkout libcxx, the output directory will get the C++ headers in the right 
place.


http://reviews.llvm.org/D12646



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH][www] Mention that libcxx is necessary on OS X

2015-09-07 Thread Kuba Brecka via cfe-commits
I’m also curious what exact test failed for you with the "can't find iostream” 
error.  AFAIK, you should currently receive the explaining message instead.

But anyway, I’d also like to see libcxx[abi] mentioned in the Getting started 
page.

Kuba

> On 04 Sep 2015, at 23:07, Yuri Gribov  > wrote:
> 
> Oh, nice so this was actually done by Kuba to fix sanitizer unittests:
> 
>   "echo '#include ' | ${COMPILER_RT_TEST_COMPILER} -E -x c++ - 
> > /dev/null"
>   "if [ $? != 0 ] "
>   "  then echo"
>   "  echo 'Your just-built clang cannot find C++ headers, which are 
> needed to build and run compiler-rt tests.'"
>   "  echo 'You should copy or symlink your system C++ headers into 
> ${LLVM_BINARY_DIR}/include/c++'"
>   "  if [ -d $(dirname $(dirname $(xcrun -f clang)))/include/c++ ]"
>   "then echo 'e.g. with:'"
>   "echo '  cp -r' $(dirname $(dirname $(xcrun -f clang)))/include/c++ 
> '${LLVM_BINARY_DIR}/include/'"
>   "  elif [ -d $(dirname $(dirname $(xcrun -f clang)))/lib/c++ ]"
>   "then echo 'e.g. with:'"
>   "echo '  cp -r' $(dirname $(dirname $(xcrun -f clang)))/lib/c++ 
> '${LLVM_BINARY_DIR}/include/'"
>   "  fi"
>   "  echo 'This can also be fixed by checking out the libcxx project from 
> llvm.org  and installing the headers'"
>   "  echo 'into your build directory:'"
>   "  echo '  cd ${LLVM_SOURCE_DIR}/projects && svn co 
> http://llvm.org/svn/llvm-project/libcxx/trunk 
>  libcxx'"
>   "  echo '  cd ${LLVM_BINARY_DIR} && make -C 
> ${LLVM_SOURCE_DIR}/projects/libcxx installheaders 
> HEADER_DIR=${LLVM_BINARY_DIR}/include'"
>   "  echo"
>   "  false"
>   "fi"
> 
> What I mean is that we should either fix the tests, or describe precisely the 
> scenario in which libcxx+libcxxabi is needed because it's not always 
> needed. I suspect it's just needed when testing the sanitizers (but I might 
> be wrong).
> 
> What if I s/mandatory on OS X, optional otherwise/required to run tests on OS 
> X/ ?
> 
> -Y

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH][www] Mention that libcxx is necessary on OS X

2015-09-07 Thread Kuba Brecka via cfe-commits

> On 07 Sep 2015, at 17:21, Nico Weber  wrote:
> 
> libcxx is needed to run compiler-rt tests, but it shouldn't be needed to run 
> clang's tests. And to _use_ your self-built compiler, you need to add 
> `-isysroot $(xcrun -show-sdk-path)` to the compile flags to let the compiler 
> find C headers anyway, which also makes it find the libc++ headers.

No, it doesn’t:

   $ clang++ a.cpp  # System version.
   $ clang++ a.cpp -isysroot $(xcrun --show-sdk-path)  # System version.
   $ ./clang++ ~/test/cpp101.cpp  # Self-built version.
   a.cpp:1:10: fatal error: 'iostream' file not found
   $ ./clang++ a.cpp -isysroot $(xcrun --show-sdk-path)  # Self-built version.
   a.cpp:1:10: fatal error: 'iostream' file not found

Kuba

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits