https://github.com/jeremyd2019 updated https://github.com/llvm/llvm-project/pull/138587
>From 0c380bb4f2f41679ef32db2b9358cf127257d1fb Mon Sep 17 00:00:00 2001 From: Jeremy Drake <git...@jdrake.com> Date: Tue, 6 May 2025 16:54:24 -0700 Subject: [PATCH 1/2] [Clang][CMake] use CMakePushCheckState The previous approach of using list(REMOVE ...) would remove *all* occurences of the given item, not just the one appended above. --- clang/CMakeLists.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index c3f30e2a8e9c0..f12712f55fb96 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -183,18 +183,17 @@ check_include_file(sys/resource.h CLANG_HAVE_RLIMITS) # This check requires _GNU_SOURCE on linux check_include_file(dlfcn.h CLANG_HAVE_DLFCN_H) if( CLANG_HAVE_DLFCN_H ) + include(CMakePushCheckState) include(CheckLibraryExists) include(CheckSymbolExists) check_library_exists(dl dlopen "" HAVE_LIBDL) + cmake_push_check_state() if( HAVE_LIBDL ) list(APPEND CMAKE_REQUIRED_LIBRARIES dl) endif() list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) check_symbol_exists(dladdr dlfcn.h CLANG_HAVE_DLADDR) - list(REMOVE_ITEM CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) - if( HAVE_LIBDL ) - list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES dl) - endif() + cmake_pop_check_state() endif() set(CLANG_RESOURCE_DIR "" CACHE STRING >From b145528362ea4a8ecc0e50bd6c140cbf39f663a0 Mon Sep 17 00:00:00 2001 From: Jeremy Drake <git...@jdrake.com> Date: Mon, 5 May 2025 14:11:44 -0700 Subject: [PATCH 2/2] [CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS In #138329, _GNU_SOURCE was added for Cygwin, but when building Clang standalone against an installed LLVM this definition was not picked up, resulting in undefined strnlen. Follow the documentation in https://llvm.org/docs/CMake.html#developing-llvm-passes-out-of-source and add the LLVM_DEFINITIONS in standalone projects' cmakes. --- clang/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f12712f55fb96..ab2ac9bc6b9ad 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -68,6 +68,10 @@ if(CLANG_BUILT_STANDALONE) option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF) option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON) + separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS}) + add_definitions(${LLVM_DEFINITIONS_LIST}) + list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST}) + include(AddLLVM) include(TableGen) include(HandleLLVMOptions) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits