Skip to content

[LLVM][Clang][Cygwin] Fix building Clang for Cygwin #134494

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/Support/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions clang/tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
16 changes: 0 additions & 16 deletions clang/tools/libclang/CIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion clang/tools/libclang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/Unix/Signals.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Loading