소스 검색

Features: Use the features symbol in the feature-test compile.

Clang discards the entire string if it is not used, removing
the ability to read the features from the compiled binary. That
is prevented by using the symbol.

GNU with -O3 also discards the string, so use the string in a
way which is determined by a runtime value (argc) to prevent
it being discarded.
Stephen Kelly 11 년 전
부모
커밋
f6f1095413
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      Modules/Internal/FeatureTesting.cmake

+ 1 - 1
Modules/Internal/FeatureTesting.cmake

@@ -20,7 +20,7 @@ macro(record_compiler_features lang compile_flags feature_list)
     endif()
   endforeach()
   file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}"
-    "\n};\n\nint main() { return 0; }\n")
+    "\n};\n\nint main(int argc, char** argv) { (void)argv; return features[argc]; }\n")
 
   try_compile(CMAKE_${lang}_FEATURE_TEST
     ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}"