Hi CMake Mailing List,

I am using the CHECK_CXX_COMPILER_FLAG directive in a CMake file to detect 
whether the compiler uses the "-fsanitize=address" compiler flag. I'm using the 
g++ 7.3.0 compiler which supports this flag but the CHECK_CXX_COMPILER_FLAG 
directive incorrectly determines that this flag is not supported.


To test this I tried compiling the following program:

int main() {};


This compiled with the following commands:

> g++ -fsanitize=address -c test.cpp
> g++ -fsanitize=address test.o -o test.exe

And fails with the same error message as CHECK_CXX_COMPILER_FLAG when I compile 
with:
> g++ -fsanitize=address -c test.cpp
> g++ test.o -o test.exe

producing the following message:

Undefined symbols for architecture x86_64:
  "___asan_init", referenced from:
      __GLOBAL__sub_I_00099_0_test.cpp in test.o
  "___asan_version_mismatch_check_v8", referenced from:
      __GLOBAL__sub_I_00099_0_test.cpp in test.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

It seems that CHECK_CXX_COMPILER_FLAG doesn't add the flag to the linking 
command when it tests compilation. Is this a bug with CHECK_CXX_COMPILER_FLAG 
or is there something I'm missing?

Many thanks
Adrian Turner


-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to