This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 5/7] Libsanitizer merge from upstream r249633.
- From: Maxim Ostapenko <m dot ostapenko at partner dot samsung dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Kostya Serebryany <kcc at google dot com>, Dmitry Vyukov <dvyukov at google dot com>, Marek Polacek <polacek at redhat dot com>, Yury Gribov <y dot gribov at samsung dot com>, Slava Garbuzov <v dot garbuzov at samsung dot com>, Vyacheslav Barinov <v dot barinov at samsung dot com>
- Date: Wed, 14 Oct 2015 19:23:09 +0300
- Subject: Re: [PATCH 5/7] Libsanitizer merge from upstream r249633.
- Authentication-results: sourceware.org; auth=none
- References: <561CE769 dot 6050800 at partner dot samsung dot com> <561CE8E6 dot 6080002 at partner dot samsung dot com> <20151014073702 dot GR478 at tucnak dot redhat dot com>
On 14/10/15 10:37, Jakub Jelinek wrote:
On Tue, Oct 13, 2015 at 02:20:06PM +0300, Maxim Ostapenko wrote:
This patch removes UBSan stubs from ASan and TSan code. We don't embed UBSan
to ASan and UBSan because that would lead to undefined references to C++
stuff when linking with -static-libasan. AFAIK, sanitizer developers use
different libraries for C and CXX runtimes, but I think this is out of scope
of this merge.
Where is CAN_SANITIZE_UB defined? I don't see it anywhere in the current
libsanitizer and in the patch only:
grep CAN_SANITIZE_UB libsanitizer-249633-2.diff
+#if CAN_SANITIZE_UB
+# define TSAN_CONTAINS_UBSAN (CAN_SANITIZE_UB && !defined(SANITIZER_GO))
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
+#if CAN_SANITIZE_UB
+#endif // CAN_SANITIZE_UB
Hm, this is strange, perhaps the patch was malformed.
So, unless I'm missing something, it would be best to arrange for
-DCAN_SANITIZE_UB=1 to be in CXXFLAGS for ubsan/ source files and
-DCAN_SANITIZE_UB=0 to be in CXXFLAGS for {a,t}san/ source files?
CAN_SANITIZE_UB definition is hardcoded into new ubsan/ubsan_platform.h
file. To use DCAN_SANITIZE_UB from CXXFLAGS, we still need some changes
in libsanitizer against upstream:
Index: libsanitizer/ubsan/ubsan_platform.h
===================================================================
--- libsanitizer/ubsan/ubsan_platform.h (revision 250295)
+++ libsanitizer/ubsan/ubsan_platform.h (working copy)
@@ -13,6 +13,7 @@
#ifndef UBSAN_PLATFORM_H
#define UBSAN_PLATFORM_H
+#ifndef CAN_SANITIZE_UB
// Other platforms should be easy to add, and probably work as-is.
#if (defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__))
&& \
(defined(__x86_64__) || defined(__i386__) || defined(__arm__) || \
@@ -23,5 +24,6 @@
#else
# define CAN_SANITIZE_UB 0
#endif
+#endif // CAN_SANITIZE_UB
#endif
Are there any other defines that are supposedly set from cmake or wherever
upstream and are left undefined?
There is ASAN_DYNAMIC macro, but I see it into current libsanitizer too
and it's not touched in any Makefile. Same for
ASAN_DYNAMIC_RUNTIME_THUNK, that is used for Windows build and
ASAN_LOW_MEMORY, that set explicitly only for Android. Do we need to
touch them?
Also, ASAN_FLEXIBLE_MAPPING_AND_OFFSET was bumped upstream, so we don't
need it anymore.
I'm applying the patch mentioned above, redefining CAN_SANITIZE_UB in
corresponding Makefiles, dropping ASAN_FLEXIBLE_MAPPING_AND_OFFSET and
resending libsanitizer-249633-2.diff in corresponding thread.
2015-10-13 Maxim Ostapenko <m.ostapenko@partner.samsung.com>
* tsan/tsan_defs.h: Define TSAN_CONTAINS_UBSAN to 0.
* asan/asan_flags.cc (InitializeFlags): Do not initialize UBSan flags.
* asan/asan_rtl.cc (AsanInitInternal): Do not init UBSan.
Jakub