File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -263,6 +263,17 @@ endif()
263
263
264
264
set (CMAKE_C_VISIBILITY_PRESET hidden )
265
265
266
+ set (print_msan_notice )
267
+ if (SECP256K1_BUILD_CTIME_TESTS )
268
+ include (CheckMemorySanitizer )
269
+ check_memory_sanitizer (msan_enabled )
270
+ if (msan_enabled )
271
+ try_append_c_flags (-fno-sanitize-memory-param-retval )
272
+ set (print_msan_notice YES )
273
+ endif ()
274
+ unset (msan_enabled )
275
+ endif ()
276
+
266
277
# Ask CTest to create a "check" target (e.g., make check) as alias for the "test" target.
267
278
# CTEST_TEST_TARGET_ALIAS is not documented but supposed to be user-facing.
268
279
# See: https://gitlab.kitware.com/cmake/cmake/-/commit/816c9d1aa1f2b42d40c81a991b68c96eb12b6d2
@@ -358,7 +369,14 @@ endif()
358
369
if (SECP256K1_LATE_CFLAGS )
359
370
message ("SECP256K1_LATE_CFLAGS ................. ${SECP256K1_LATE_CFLAGS} " )
360
371
endif ()
361
- message ("\n " )
372
+ message ("" )
373
+ if (print_msan_notice )
374
+ message (
375
+ "Note:\n "
376
+ " MemorySanitizer detected, tried to add -fno-sanitize-memory-param-retval to compile options\n "
377
+ " to avoid false positives in ctime_tests. Pass -DSECP256K1_BUILD_CTIME_TESTS=OFF to avoid this.\n "
378
+ )
379
+ endif ()
362
380
if (SECP256K1_EXPERIMENTAL )
363
381
message (
364
382
" ******\n "
Original file line number Diff line number Diff line change
1
+ include_guard (GLOBAL )
2
+ include (CheckCSourceCompiles )
3
+
4
+ function (check_memory_sanitizer output )
5
+ set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
6
+ check_c_source_compiles ("
7
+ #if defined(__has_feature)
8
+ # if __has_feature(memory_sanitizer)
9
+ /* MemorySanitizer is enabled. */
10
+ # elif
11
+ # error \" MemorySanitizer is disabled.\"
12
+ # endif
13
+ #else
14
+ # error \" __has_feature is not defined.\"
15
+ #endif
16
+ " HAVE_MSAN )
17
+ set (${output} ${HAVE_MSAN} PARENT_SCOPE )
18
+ endfunction ()
You can’t perform that action at this time.
0 commit comments