ruby-changes:53342
From: shyouhei <ko1@a...>
Date: Tue, 6 Nov 2018 11:57:33 +0900 (JST)
Subject: [ruby-changes:53342] shyouhei:r65558 (trunk): gc.c: move ASAN check to configure
shyouhei 2018-11-06 11:57:28 +0900 (Tue, 06 Nov 2018) New Revision: 65558 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65558 Log: gc.c: move ASAN check to configure Availability of attributes are checked in configure these days, rather than compiler macros. Also __attribute__((no_address_safety_analysis)) is considered deprecated in both GCC and Clang. Use the current best practice if available. See also: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html https://clang.llvm.org/docs/AddressSanitizer.html Modified files: trunk/configure.ac trunk/gc.c trunk/internal.h trunk/tool/m4/ruby_decl_attribute.m4 Index: configure.ac =================================================================== --- configure.ac (revision 65557) +++ configure.ac (revision 65558) @@ -1352,6 +1352,9 @@ RUBY_FUNC_ATTRIBUTE(__deprecated__("by " https://github.com/ruby/ruby/blob/trunk/configure.ac#L1352 RUBY_TYPE_ATTRIBUTE(__deprecated__ mesg, DEPRECATED_TYPE(mesg,x), rb_cv_type_deprecated) RUBY_FUNC_ATTRIBUTE(__noinline__, NOINLINE) RUBY_FUNC_ATTRIBUTE(__always_inline__, ALWAYS_INLINE) +RUBY_FUNC_ATTRIBUTE(__no_sanitize__(san), NO_SANITIZE(san, x), rb_cv_func_no_sanitize) +RUBY_FUNC_ATTRIBUTE(__no_sanitize_address__, NO_SANITIZE_ADDRESS) +RUBY_FUNC_ATTRIBUTE(__no_address_safety_analysis__, NO_ADDRESS_SAFETY_ANALYSIS) RUBY_FUNC_ATTRIBUTE(__warn_unused_result__, WARN_UNUSED_RESULT) RUBY_FUNC_ATTRIBUTE(__unused__, MAYBE_UNUSED) RUBY_FUNC_ATTRIBUTE(__error__ mesg, ERRORFUNC(mesg,x), rb_cv_func___error__) Index: gc.c =================================================================== --- gc.c (revision 65557) +++ gc.c (revision 65558) @@ -61,16 +61,6 @@ https://github.com/ruby/ruby/blob/trunk/gc.c#L61 # endif #endif -#if /* is ASAN enabled? */ \ - __has_feature(address_sanitizer) /* Clang */ || \ - defined(__SANITIZE_ADDRESS__) /* GCC 4.8.x */ - #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS \ - __attribute__((no_address_safety_analysis)) \ - __attribute__((noinline)) -#else - #define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS -#endif - #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -4158,8 +4148,10 @@ ruby_stack_check(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L4148 } ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS +( static void mark_locations_array(rb_objspace_t *objspace, register const VALUE *x, register long n) +) { VALUE v; while (n--) { Index: internal.h =================================================================== --- internal.h (revision 65557) +++ internal.h (revision 65558) @@ -54,6 +54,20 @@ extern "C" { https://github.com/ruby/ruby/blob/trunk/internal.h#L54 # define WARN_UNUSED_RESULT(x) x #endif +#if 0 +#elif defined(NO_SANITIZE) +# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \ + NO_SANITIZE("address", NOINLINE(x)) +#elif defined(NO_SANITIZE_ADDRESS) +# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \ + NO_SANITIZE_ADDRESS(NOINLINE(x)) +#elif defined(NO_ADDRESS_SAFETY_ANALYSIS) +# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS(x) \ + NO_ADDRESS_SAFETY_ANALYSIS(NOINLINE(x)) +#else +# define ATTRIBUTE_NO_ADDRESS_SAFETY_ANALYSIS +#endif + #ifdef HAVE_VALGRIND_MEMCHECK_H # include <valgrind/memcheck.h> # ifndef VALGRIND_MAKE_MEM_DEFINED Index: tool/m4/ruby_decl_attribute.m4 =================================================================== --- tool/m4/ruby_decl_attribute.m4 (revision 65557) +++ tool/m4/ruby_decl_attribute.m4 (revision 65558) @@ -29,6 +29,7 @@ ${rbcv_cond+[@%:@define ]attrib[](attrib https://github.com/ruby/ruby/blob/trunk/tool/m4/ruby_decl_attribute.m4#L29 ${rbcv_cond+[@%:@endif]}) $6 @%:@define mesg ("") +@%:@define san "address" attrib[](attrib_params)[;], [], [rbcv="$mac"; break]) done -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/