Index: CMakeLists.txt =================================================================== --- CMakeLists.txt +++ CMakeLists.txt @@ -49,6 +49,14 @@ # in Clang cmake files, instead of copying the rules here. string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION ${PACKAGE_VERSION}) + + # Compute the version identifier that will be used in a symbol name to prevent version mismatches. + set(DEFAULT_COMPILER_RT_VERSION_STRING "llvm-${PACKAGE_VERSION}") + set(COMPILER_RT_VERSION_STRING ${DEFAULT_COMPILER_RT_VERSION_STRING} CACHE STRING + "Version identifier for the compiler-rt libraries.") + string(REGEX REPLACE "[^a-zA-Z0-9]" "_" COMPILER_RT_VERSION_STRING ${COMPILER_RT_VERSION_STRING}) + list(APPEND SANITIZER_COMMON_CFLAGS -DCOMPILER_RT_VERSION_STRING=${COMPILER_RT_VERSION_STRING}) + # Setup the paths where compiler-rt runtimes and headers should be stored. set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}) set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) Index: lib/asan/asan_init_version.h =================================================================== --- lib/asan/asan_init_version.h +++ lib/asan/asan_init_version.h @@ -27,8 +27,15 @@ // v3=>v4: added '__asan_global_source_location' to __asan_global. // v4=>v5: changed the semantics and format of __asan_stack_malloc_ and // __asan_stack_free_ functions. - #define __asan_init __asan_init_v5 - #define __asan_init_name "__asan_init_v5" + // v5=>v6: changed versioning scheme to include LLVM release number + + #define ABI_VERSION v6 + + #define CONCAT(x, y) CONCAT2(x, y) + #define CONCAT2(x, y) __asan_version_mismatch_check__abi_ ## x ## __ ## y + #define __asan_version_mismatch_check CONCAT(ABI_VERSION, COMPILER_RT_VERSION_STRING) + + SANITIZER_INTERFACE_ATTRIBUTE void __asan_version_mismatch_check(); } #endif // ASAN_INIT_VERSION_H Index: lib/asan/asan_rtl.cc =================================================================== --- lib/asan/asan_rtl.cc +++ lib/asan/asan_rtl.cc @@ -578,3 +578,7 @@ AsanActivate(); AsanInitInternal(); } + +void __asan_version_mismatch_check() { + // Do nothing. +}