https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494
From b7a5fab29b810f72f2ffa65fb0945abd302c2411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <o...@mateuszmikula.dev> Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cygwin types sometimes do not match Linux exactly. Like in this case: ``` In file included from /h/projects/llvm-project/llvm/include/llvm/Support/Error.h:23, from /h/projects/llvm-project/llvm/include/llvm/Support/FileSystem.h:34, from /h/projects/llvm-project/llvm/lib/Support/Signals.cpp:22: /h/projects/llvm-project/llvm/include/llvm/Support/Format.h: In instantiation of ‘llvm::format_object<Ts>::format_object(const char*, const Ts& ...) [with Ts = {int, char [4096]}]’: /h/projects/llvm-project/llvm/include/llvm/Support/Format.h:126:10: required from ‘llvm::format_object<Ts ...> llvm::format(const char*, const Ts& ...) [with Ts = {int, char [4096]}]’ /h/projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:850:19: required from here /h/projects/llvm-project/llvm/include/llvm/Support/Format.h:106:34: error: no matching function for call to ‘std::tuple<int, char [4096]>::tuple(const int&, const char [4096])’ 106 | : format_object_base(fmt), Vals(vals...) { | ^~~~~~~~~~~~~ ``` Casting here is safe and solves the issue. --- llvm/lib/Support/Unix/Signals.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 30e5f40193974..691e1014f18e8 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -847,7 +847,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) - OS << format(" %-*s", width, dlinfo.dli_fname); + OS << format(" %-*s", width, static_cast<const char *>(dlinfo.dli_fname)); else OS << format(" %-*s", width, name + 1); From a04d045f298970e9d8a391100071125a97264196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <o...@mateuszmikula.dev> Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently building for Cygwin hits this error: ``` In file included from /h/projects/llvm-project/clang/lib/Basic/Attributes.cpp:17: /h/projects/llvm-project/clang/include/clang/Basic/ParsedAttrInfo.h:180:73: error: invalid declarator before ‘;’ token 180 | extern template class CLANG_TEMPLATE_ABI Registry<clang::ParsedAttrInfo>; ``` That's because `CLANG_TEMPLATE_ABI` ends up not being defined. The solution here is to follow MinGW case. --- clang/include/clang/Support/Compiler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/include/clang/Support/Compiler.h b/clang/include/clang/Support/Compiler.h index 5a74f8e3b6723..e1ae3eda4ccc2 100644 --- a/clang/include/clang/Support/Compiler.h +++ b/clang/include/clang/Support/Compiler.h @@ -50,7 +50,7 @@ #define CLANG_EXPORT_TEMPLATE #endif #elif defined(__ELF__) || defined(__MINGW32__) || defined(_AIX) || \ - defined(__MVS__) + defined(__MVS__) || defined(__CYGWIN__) #define CLANG_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT #define CLANG_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT #define CLANG_EXPORT_TEMPLATE From 94ec9d3f52024c671915ad0a1988c5dd6778eb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <o...@mateuszmikula.dev> Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default This change follows MinGW decisions, otherwise build with GCC fail with: ``` FAILED: bin/msys-clang-cpp-21.0git.dll lib/libclang-cpp.dll.a ... /usr/lib/gcc/x86_64-pc-msys/13.3.0/../../../../x86_64-pc-msys/bin/ld: error: export ordinal too large: 92250 ``` Co-authored-by: jeremyd2019 <git...@jdrake.com> --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index 9634eb12080c8..50e3d694236ac 100644 --- a/clang/tools/CMakeLists.txt +++ b/clang/tools/CMakeLists.txt @@ -26,9 +26,10 @@ endif() add_clang_subdirectory(c-index-test) add_clang_subdirectory(clang-refactor) -# For MinGW we only enable shared library if LLVM_LINK_LLVM_DYLIB=ON. +# For MinGW/Cygwin we only enable shared library if LLVM_LINK_LLVM_DYLIB=ON. # Without that option resulting library is too close to 2^16 DLL exports limit. -if(UNIX OR (MSVC AND LLVM_BUILD_LLVM_DYLIB_VIS) OR (MINGW AND LLVM_LINK_LLVM_DYLIB)) +if((UNIX AND NOT CYGWIN) OR (MSVC AND LLVM_BUILD_LLVM_DYLIB_VIS) OR + ((MINGW OR CYGWIN) AND LLVM_LINK_LLVM_DYLIB)) add_clang_subdirectory(clang-shlib) endif() diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 299c14660f3d4..37a939ffcada7 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,8 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if((NOT (WIN32 OR CYGWIN) AND LLVM_ENABLE_PIC) OR + ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From 062ad30eeab499f4229003acc1fedf8dd5574f6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= <o...@mateuszmikula.dev> Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous _WIN32 define and clean up Cygwin code With this define present and building with Clang the build fails: ``` In file included from /h/projects/llvm-project/clang/tools/libclang/CIndexer.cpp:36: In file included from /usr/include/w32api/windows.h:69: In file included from /usr/include/w32api/windef.h:9: In file included from /usr/include/w32api/minwindef.h:163: In file included from /usr/include/w32api/winnt.h:1658: In file included from /usr/lib/clang/20/include/x86intrin.h:15: In file included from /usr/lib/clang/20/include/immintrin.h:24: In file included from /usr/lib/clang/20/include/xmmintrin.h:31: /usr/lib/clang/20/include/mm_malloc.h:45:22: error: use of undeclared identifier '_aligned_malloc'; did you mean 'aligned_alloc'? 45 | __mallocedMemory = _aligned_malloc(__size, __align); | ^ ``` Removing it allows the build with Clang to succeed and doesn't break build with GCC. Co-authored-by: Jeremy Drake <git...@jdrake.com> --- clang/tools/libclang/CIndexer.cpp | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..11d9312b64849 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -26,12 +26,6 @@ #include <cstdio> #include <mutex> -#ifdef __CYGWIN__ -#include <cygwin/version.h> -#include <sys/cygwin.h> -#define _WIN32 1 -#endif - #ifdef _WIN32 #include <windows.h> #elif defined(_AIX) @@ -112,16 +106,6 @@ const std::string &CIndexer::getClangResourcesPath() { sizeof(mbi)); GetModuleFileNameA((HINSTANCE)mbi.AllocationBase, path, MAX_PATH); -#ifdef __CYGWIN__ - char w32path[MAX_PATH]; - strcpy(w32path, path); -#if CYGWIN_VERSION_API_MAJOR > 0 || CYGWIN_VERSION_API_MINOR >= 181 - cygwin_conv_path(CCP_WIN_A_TO_POSIX, w32path, path, MAX_PATH); -#else - cygwin_conv_to_full_posix_path(w32path, path); -#endif -#endif - LibClangPath += path; #elif defined(_AIX) getClangResourcesPathImplAIX(LibClangPath); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits