From e15f28cfcac344cd7d86a281f499d24ee7ae87bc Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Mon, 28 Jan 2019 04:12:54 +0000 Subject: [PATCH] [CMake] Use __libc_start_main rather than fopen when checking for C library The check_library_exists CMake uses a custom symbol definition. This is a problem when checking for C library symbols because Clang recognizes many of them as builtins, and returns the -Wbuiltin-requires-header (or -Wincompatible-library-redeclaration) error. When building with -Werror which is the default, this causes the check_library_exists check fail making the build think that C library isn't available. To avoid this issue, we should use a symbol that isn't recognized by Clang and wouldn't cause the same issue. __libc_start_main seems like reasonable choice that fits the bill. Differential Revision: https://reviews.llvm.org/D57142 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@352341 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/config-ix.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 730ee7e16..657b036dc 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -7,7 +7,7 @@ if(WIN32 AND NOT MINGW) # let the default linking take care of that. set(LIBCXX_HAS_C_LIB NO) else() - check_library_exists(c fopen "" LIBCXX_HAS_C_LIB) + check_library_exists(c __libc_start_main "" LIBCXX_HAS_C_LIB) endif() if (NOT LIBCXX_USE_COMPILER_RT)