[libunwind] r352341 - [CMake] Use __libc_start_main rather than fopen when checking for C library

Petr Hosek via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 27 20:12:54 PST 2019


Author: phosek
Date: Sun Jan 27 20:12:54 2019
New Revision: 352341

URL: http://llvm.org/viewvc/llvm-project?rev=352341&view=rev
Log:
[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

Modified:
    libunwind/trunk/cmake/config-ix.cmake

Modified: libunwind/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/libunwind/trunk/cmake/config-ix.cmake?rev=352341&r1=352340&r2=352341&view=diff
==============================================================================
--- libunwind/trunk/cmake/config-ix.cmake (original)
+++ libunwind/trunk/cmake/config-ix.cmake Sun Jan 27 20:12:54 2019
@@ -3,7 +3,7 @@ include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(CheckLibraryExists)
 
-check_library_exists(c fopen "" LIBUNWIND_HAS_C_LIB)
+check_library_exists(c __libc_start_main "" LIBUNWIND_HAS_C_LIB)
 
 if (NOT LIBUNWIND_USE_COMPILER_RT)
   check_library_exists(gcc_s __gcc_personality_v0 "" LIBUNWIND_HAS_GCC_S_LIB)




More information about the cfe-commits mailing list