Bug 1437482 - gcc 8 has no-sanitize but not the {un,}signed-integer-overflow option r=Waldo
authorSylvestre Ledru <sledru@mozilla.com>
Mon, 12 Feb 2018 12:07:52 +0100
changeset 404202 24117c13a4043ea2ec4e56d55569e8d643446e82
parent 404132 6ba349d419dd67074dcfffc56ed8fa38337511da
child 404203 e78ab9a72984a252764331675cf1afed7347020c
push id99968
push userrgurzau@mozilla.com
push dateFri, 16 Feb 2018 22:14:56 +0000
treeherdermozilla-inbound@2e16779c96cc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1437482
milestone60.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1437482 - gcc 8 has no-sanitize but not the {un,}signed-integer-overflow option r=Waldo MozReview-Commit-ID: EfRYhaISZfL
mfbt/Attributes.h
--- a/mfbt/Attributes.h
+++ b/mfbt/Attributes.h
@@ -233,16 +233,23 @@
 #endif
 
 #if defined(__has_attribute)
 #  if __has_attribute(no_sanitize)
 #    define MOZ_HAVE_NO_SANITIZE_ATTR
 #  endif
 #endif
 
+#ifdef __clang__
+#  ifdef MOZ_HAVE_NO_SANITIZE_ATTR
+#    define MOZ_HAVE_UNSIGNED_OVERFLOW_SANITIZE_ATTR
+#    define MOZ_HAVE_SIGNED_OVERFLOW_SANITIZE_ATTR
+#  endif
+#endif
+
 /*
  * MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW disables *un*signed integer overflow
  * checking on the function it annotates, in builds configured to perform it.
  * (Currently this is only Clang using -fsanitize=unsigned-integer-overflow, or
  * via --enable-unsigned-overflow-sanitizer in Mozilla's build system.)  It has
  * no effect in other builds.
  *
  * Place this attribute at the very beginning of a function declaration.
@@ -266,17 +273,17 @@
  * The compiler instrumentation to detect unsigned integer overflow has costs
  * both at compile time and at runtime.  Functions that are repeatedly inlined
  * at compile time will also implicitly inline the necessary instrumentation,
  * increasing compile time.  Similarly, frequently-executed functions that
  * require large amounts of instrumentation will also notice significant runtime
  * slowdown to execute that instrumentation.  Use this attribute to eliminate
  * those costs -- but only after carefully verifying that no overflow can occur.
  */
-#if defined(MOZ_HAVE_NO_SANITIZE_ATTR)
+#ifdef MOZ_HAVE_UNSIGNED_OVERFLOW_SANITIZE_ATTR
 #  define MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW __attribute__((no_sanitize("unsigned-integer-overflow")))
 #else
 #  define MOZ_NO_SANITIZE_UNSIGNED_OVERFLOW /* nothing */
 #endif
 
 /*
  * MOZ_NO_SANITIZE_SIGNED_OVERFLOW disables *signed* integer overflow checking
  * on the function it annotates, in builds configured to perform it.  (Currently
@@ -294,17 +301,17 @@
  * The compiler instrumentation to detect signed integer overflow has costs both
  * at compile time and at runtime.  Functions that are repeatedly inlined at
  * compile time will also implicitly inline the necessary instrumentation,
  * increasing compile time.  Similarly, frequently-executed functions that
  * require large amounts of instrumentation will also notice significant runtime
  * slowdown to execute that instrumentation.  Use this attribute to eliminate
  * those costs -- but only after carefully verifying that no overflow can occur.
  */
-#if defined(MOZ_HAVE_NO_SANITIZE_ATTR)
+#ifdef MOZ_HAVE_SIGNED_OVERFLOW_SANITIZE_ATTR
 #  define MOZ_NO_SANITIZE_SIGNED_OVERFLOW __attribute__((no_sanitize("signed-integer-overflow")))
 #else
 #  define MOZ_NO_SANITIZE_SIGNED_OVERFLOW /* nothing */
 #endif
 
 #undef MOZ_HAVE_NO_SANITIZE_ATTR