[PATCH] Forbid -DENABLE_ASAN=ON with GCC explicitly

Alexander Turenko alexander.turenko at tarantool.org
Sun Dec 23 05:00:50 MSK 2018


The build time error is confusing for users. The patch makes the error
explicit and moves it to the cmake stage.

Follow up of #3070.
---

It is simple fixup to bring a user's attention to the configuration
error and push (s)he to do full cleanup and use clang.

To be honest, I don't know why luajit cannot be compiled with
-fsanitize=address with GCC. It is smth with always inline attribute,
there is the example in [1].

https://github.com/tarantool/tarantool/tree/Totktonada/gh-3070-forbid-asan-on-gcc
https://github.com/tarantool/tarantool/issues/3070#issuecomment-449327136

Please, push to 2.1 and 1.10 branches.

[1]: https://github.com/tarantool/tarantool/issues/3070#issuecomment-449297693

 cmake/profile.cmake | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/cmake/profile.cmake b/cmake/profile.cmake
index 3e8f1499b..0ba31fa2c 100644
--- a/cmake/profile.cmake
+++ b/cmake/profile.cmake
@@ -44,7 +44,14 @@ endif()
 
 option(ENABLE_ASAN "Enable AddressSanitizer, a fast memory error detector based on compiler instrumentation" OFF)
 if (ENABLE_ASAN)
-    add_compile_flags("C;CXX" -fsanitize=address)
+    if (CMAKE_COMPILER_IS_GNUCC)
+        message(FATAL_ERROR
+            "\n"
+            " Tarantool does not support GCC's AddressSanitizer. Use clang:\n"
+            " $ git clean -xfd; git submodule foreach --recursive git clean -xfd\n"
+            " $ CC=clang CXX=clang++ cmake . <...> -DENABLE_ASAN=ON && make -j\n"
+            "\n")
+    endif()
 
     set(CMAKE_REQUIRED_FLAGS "-fsanitize=address")
     check_c_source_compiles("int main(void) {
@@ -68,4 +75,6 @@ if (ENABLE_ASAN)
     else()
         message(FATAL_ERROR "Cannot enable AddressSanitizer")
     endif()
+
+    add_compile_flags("C;CXX" -fsanitize=address)
 endif()
-- 
2.20.0




More information about the Tarantool-patches mailing list