[clang] [clang] [MinGW] Don't look for a GCC in path if the install base has a proper mingw sysroot (PR #76949)
https://github.com/mati865 approved this pull request. Thank you https://github.com/llvm/llvm-project/pull/76949 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
mati865 wrote: I'd be fine with closing this PR and #10148 if that is the preferred solution. https://github.com/llvm/llvm-project/pull/121442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
mati865 wrote: Guess this is not happening. https://github.com/llvm/llvm-project/pull/121442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
https://github.com/mati865 closed https://github.com/llvm/llvm-project/pull/121442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/121442 From b4a5daabac693aa3021c81180a9d25ac34177f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 1 Jan 2025 21:38:49 +0100 Subject: [PATCH] [Clang][Driver] Declare win32 threads on Windows Fixes https://github.com/llvm/llvm-project/issues/101 --- clang/lib/Driver/ToolChain.cpp| 2 +- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/lib/Driver/ToolChains/MSVC.h| 2 ++ clang/lib/Driver/ToolChains/MinGW.h | 2 ++ clang/test/Driver/thread-model.c | 6 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 9f174fbda398b5..aef5b7e2d15d4e 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -1082,7 +1082,7 @@ bool ToolChain::isThreadModelSupported(const StringRef Model) const { Triple.getArch() == llvm::Triple::armeb || Triple.getArch() == llvm::Triple::thumb || Triple.getArch() == llvm::Triple::thumbeb || Triple.isWasm(); - } else if (Model == "posix") + } else if (Model == "posix" || (Model == "win32" && Triple.isOSWindows())) return true; return false; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index a020e00cd17392..bc181dfddc6398 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5792,7 +5792,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Model = A->getValue(); } else Model = TC.getThreadModel(); -if (Model != "posix") { +if (Model != "posix" && Model != "win32") { CmdArgs.push_back("-mthread-model"); CmdArgs.push_back(Args.MakeArgString(Model)); } diff --git a/clang/lib/Driver/ToolChains/MSVC.h b/clang/lib/Driver/ToolChains/MSVC.h index 3950a8ed38e8b4..4962f8d70def21 100644 --- a/clang/lib/Driver/ToolChains/MSVC.h +++ b/clang/lib/Driver/ToolChains/MSVC.h @@ -51,6 +51,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain { TranslateArgs(const llvm::opt::DerivedArgList &Args, StringRef BoundArch, Action::OffloadKind DeviceOffloadKind) const override; + std::string getThreadModel() const override { return "win32"; } + UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h index a9963d8d06c29d..a99b6ad3b1b577 100644 --- a/clang/lib/Driver/ToolChains/MinGW.h +++ b/clang/lib/Driver/ToolChains/MinGW.h @@ -66,6 +66,8 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain { bool HasNativeLLVMSupport() const override; + std::string getThreadModel() const override { return "win32"; } + UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override; bool isPICDefault() const override; diff --git a/clang/test/Driver/thread-model.c b/clang/test/Driver/thread-model.c index 9abe5f11d9aab9..ce9e7bbc8f5b9e 100644 --- a/clang/test/Driver/thread-model.c +++ b/clang/test/Driver/thread-model.c @@ -8,9 +8,15 @@ // SINGLE: Thread model: single // SINGLE: "-mthread-model" "single" // INVALID: error: invalid thread model 'silly' in '-mthread-model silly' for this target +// WIN32: Thread model: win32 // RUN: %clang -### -target wasm32-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s // RUN: %clang -### -target wasm32-unknown-linux-gnu -c %s -v -mthread-model single 2>&1 | FileCheck --check-prefix=SINGLE %s // RUN: %clang -### -target wasm32-unknown-linux-gnu -c %s -v -mthread-model posix 2>&1 | FileCheck %s // RUN: not %clang -### --target=wasm32-unknown-linux-gnu -c %s -v -mthread-model silly 2>&1 | FileCheck --check-prefix=INVALID %s // RUN: %clang -### -target wasm64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s + +// RUN: %clang -### -target x86_64-pc-windows-gnu -c %s -v 2>&1 | FileCheck --check-prefix=WIN32 %s +// RUN: %clang -### -target x86_64-pc-windows-gnu -c %s -v -mthread-model posix 2>&1 | FileCheck %s +// RUN: %clang -### -target x86_64-pc-windows-gnu -c %s -v -mthread-model win32 2>&1 | FileCheck --check-prefix=WIN32 %s +// RUN: %clang -### -target x86_64-pc-windows-msvc -c %s -v 2>&1 | FileCheck --check-prefix=WIN32 %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
@@ -619,7 +619,13 @@ class ToolChain { virtual bool SupportsEmbeddedBitcode() const { return false; } /// getThreadModel() - Which thread model does this target use? - virtual std::string getThreadModel() const { return "posix"; } + virtual std::string getThreadModel() const { +#ifdef _WIN32 +return "win32"; mati865 wrote: Oh, you are right. This change as is is pretty dumb right now. https://github.com/llvm/llvm-project/pull/121442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
https://github.com/mati865 converted_to_draft https://github.com/llvm/llvm-project/pull/121442 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Driver] Declare win32 threads on Windows (PR #121442)
https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/121442 Fixes https://github.com/llvm/llvm-project/issues/10148 Recently I saw a user confused by it and thought Clang was using `winpthreads`. Note: this does not change structures like https://github.com/llvm/llvm-project/blob/0cbe28df7100bf4384f84542d602f90cb783a2d4/clang/include/clang/Basic/LangOptions.h#L360 which still yield `posix`. From cc7708f2646326c5065c4853a8a2971db48e3718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Wed, 1 Jan 2025 21:38:49 +0100 Subject: [PATCH] [Clang][Driver] Declare win32 threads on Windows Fixes https://github.com/llvm/llvm-project/issues/10148 --- clang/include/clang/Driver/ToolChain.h | 8 +++- clang/lib/Driver/ToolChains/Clang.cpp | 2 +- clang/test/Driver/thread-model.c | 10 +++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 5347e29be91439..9db12486d4d833 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -619,7 +619,13 @@ class ToolChain { virtual bool SupportsEmbeddedBitcode() const { return false; } /// getThreadModel() - Which thread model does this target use? - virtual std::string getThreadModel() const { return "posix"; } + virtual std::string getThreadModel() const { +#ifdef _WIN32 +return "win32"; +#else +return "posix"; +#endif + } /// isThreadModelSupported() - Does this target support a thread model? virtual bool isThreadModelSupported(const StringRef Model) const; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index a020e00cd17392..bc181dfddc6398 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -5792,7 +5792,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Model = A->getValue(); } else Model = TC.getThreadModel(); -if (Model != "posix") { +if (Model != "posix" && Model != "win32") { CmdArgs.push_back("-mthread-model"); CmdArgs.push_back(Args.MakeArgString(Model)); } diff --git a/clang/test/Driver/thread-model.c b/clang/test/Driver/thread-model.c index 9abe5f11d9aab9..a07f8913630a35 100644 --- a/clang/test/Driver/thread-model.c +++ b/clang/test/Driver/thread-model.c @@ -1,5 +1,6 @@ // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -mthread-model posix -v 2>&1 | FileCheck %s -// RUN: %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s +// RUN: %if !system-windows %{ %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s %} +// RUN: %if system-windows %{ %clang -### -target arm-unknown-linux-gnu -c %s -v 2>&1 | FileCheck --check-prefix=WIN32 %s %} // RUN: %clang -### -target arm-unknown-linux-gnu -c %s -mthread-model single -v 2>&1 | FileCheck --check-prefix=SINGLE %s // RUN: not %clang -target arm-unknown-linux-gnu -c %s -mthread-model silly -v 2>&1 | FileCheck --check-prefix=INVALID %s @@ -8,9 +9,12 @@ // SINGLE: Thread model: single // SINGLE: "-mthread-model" "single" // INVALID: error: invalid thread model 'silly' in '-mthread-model silly' for this target +// WIN32: Thread model: win32 -// RUN: %clang -### -target wasm32-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s +// RUN: %if !system-windows %{ %clang -### -target wasm32-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s %} +// RUN: %if system-windows %{ %clang -### -target wasm32-unknown-linux-gnu -c %s -v 2>&1 | FileCheck --check-prefix=WIN32 %s %} // RUN: %clang -### -target wasm32-unknown-linux-gnu -c %s -v -mthread-model single 2>&1 | FileCheck --check-prefix=SINGLE %s // RUN: %clang -### -target wasm32-unknown-linux-gnu -c %s -v -mthread-model posix 2>&1 | FileCheck %s // RUN: not %clang -### --target=wasm32-unknown-linux-gnu -c %s -v -mthread-model silly 2>&1 | FileCheck --check-prefix=INVALID %s -// RUN: %clang -### -target wasm64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s +// RUN: %if !system-windows %{ %clang -### -target wasm64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck %s %} +// RUN: %if system-windows %{ %clang -### -target wasm64-unknown-linux-gnu -c %s -v 2>&1 | FileCheck --check-prefix=WIN32 %s %} ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134458 From adbcc7f650edfb4f2f86d1146b8116794a9de6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 01:13:06 +0100 Subject: [PATCH 1/4] [Clang][Cygwin] Enable few conditions that are shared with MinGW --- clang/lib/AST/ItaniumCXXABI.cpp | 3 +-- clang/lib/AST/RecordLayoutBuilder.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 7 ++- clang/lib/CodeGen/Targets/X86.cpp | 2 +- clang/lib/Driver/ToolChain.cpp| 4 +--- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/lib/Sema/SemaDeclCXX.cpp| 4 ++-- clang/lib/Sema/SemaTemplate.cpp | 9 - 9 files changed, 14 insertions(+), 21 deletions(-) diff --git a/clang/lib/AST/ItaniumCXXABI.cpp b/clang/lib/AST/ItaniumCXXABI.cpp index a1b2551419f5e..11d8bbe8b24ba 100644 --- a/clang/lib/AST/ItaniumCXXABI.cpp +++ b/clang/lib/AST/ItaniumCXXABI.cpp @@ -236,8 +236,7 @@ class ItaniumCXXABI : public CXXABI { CallingConv getDefaultMethodCallConv(bool isVariadic) const override { const llvm::Triple &T = Context.getTargetInfo().getTriple(); -if (!isVariadic && T.isWindowsGNUEnvironment() && -T.getArch() == llvm::Triple::x86) +if (!isVariadic && T.isOSCygMing() && T.getArch() == llvm::Triple::x86) return CC_X86ThisCall; return Context.getTargetInfo().getDefaultCallingConv(); } diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 3e756ab9b9bfe..43b54850598af 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1950,7 +1950,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, // silently there. For other targets that have ms_struct enabled // (most probably via a pragma or attribute), trigger a diagnostic // that defaults to an error. - if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) + if (!Context.getTargetInfo().getTriple().isOSCygMing()) Diag(D->getLocation(), diag::warn_npot_ms_struct); } if (TypeSize > FieldAlign && diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8f9cf965af2b9..f4cf4f8ae7c0d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1680,7 +1680,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, const llvm::Triple &TT = CGM.getTriple(); const auto &CGOpts = CGM.getCodeGenOpts(); - if (TT.isWindowsGNUEnvironment()) { + if (TT.isOSCygMing()) { // In MinGW, variables without DLLImport can still be automatically // imported from a DLL by the linker; don't mark variables that // potentially could come from another DLL as DSO local. diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 2822d526a54b0..153bafc45740a 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3757,7 +3757,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM, bool IsDLLImport = RD->hasAttr(); // Don't import the RTTI but emit it locally. -if (CGM.getTriple().isWindowsGNUEnvironment()) +if (CGM.getTriple().isOSCygMing()) return false; if (CGM.getVTables().isVTableExternal(RD)) { @@ -4044,10 +4044,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM, return llvm::GlobalValue::ExternalLinkage; // MinGW always uses LinkOnceODRLinkage for type info. if (RD->isDynamicClass() && - !CGM.getContext() - .getTargetInfo() - .getTriple() - .isWindowsGNUEnvironment()) + !CGM.getContext().getTargetInfo().getTriple().isOSCygMing()) return CGM.getVTableLinkage(RD); } diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp index b36a6e1396653..cb09c52856744 100644 --- a/clang/lib/CodeGen/Targets/X86.cpp +++ b/clang/lib/CodeGen/Targets/X86.cpp @@ -1391,7 +1391,7 @@ class WinX86_64ABIInfo : public ABIInfo { public: WinX86_64ABIInfo(CodeGen::CodeGenTypes &CGT, X86AVXABILevel AVXLevel) : ABIInfo(CGT), AVXLevel(AVXLevel), -IsMingw64(getTarget().getTriple().isWindowsGNUEnvironment()) {} +IsMingw64(getTarget().getTriple().isOSCygMing()) {} void computeInfo(CGFunctionInfo &FI) const override; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 36d0ae34dec86..37e1e65310fbb 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -744,9 +744,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args, Suffix = IsITANMSVCWindows ? ".lib" : ".a"; break; case ToolChain::FT_Shared: -Suffix = TT.isOSWindows() - ? (
[clang] [llvm] Fix Singals compatibility with Cygwin API (PR #134494)
https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/134494 With these changes, LLVM and Clang become buildable for Cygwin. GCC config (using MSYS2 GCC): `CFLAGS="-D_GNU_SOURCE=1" CXXFLAGS="-D_GNU_SOURCE=1" CPPFLAGS="-D_GNU_SOURCE=1" cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-cygwin -DLLVM_HOST_TRIPLE=x86_64-pc-cygwin -DLLVM_TARGETS_TO_BUILD="AArch64;X86" -DLIBCLANG_BUILD_STATIC=ON ../llvm` Clang config (using https://github.com/msys2/MSYS2-packages/pull/5308): `CC=clang CXX=clang++ cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;lld" -DLLVM_DEFAULT_TARGET_TRIPLE=x86_64-pc-cygwin -DLLVM_HOST_TRIPLE=x86_64-pc-cygwin -DLLVM_TARGETS_TO_BUILD="AArch64;X86" -DLIBCLANG_BUILD_STATIC=ON ../llvm` Split out from https://github.com/llvm/llvm-project/pull/134458 From 17cbb1f99d281adfc83c7c7a250de31fd341db7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Singals compatibility with Cygwin API --- llvm/lib/Support/Unix/Signals.inc | 6 ++ 1 file changed, 6 insertions(+) diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 30e5f40193974..68a0e2d218e68 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, &dlinfo.dli_fname); +#else OS << format(" %-*s", width, dlinfo.dli_fname); +#endif else OS << format(" %-*s", width, name + 1); @@ -884,6 +888,8 @@ void llvm::sys::DisableSystemDialogsOnCrash() {} /// When an error signal (such as SIGABRT or SIGSEGV) is delivered to the /// process, print a stack trace and then exit. void llvm::sys::PrintStackTraceOnErrorSignal(StringRef Argv0, + + bool DisableCrashReporting) { ::Argv0 = Argv0; From cd536e2c11fbbe68333569cf3a425eb546c99b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition --- 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 59dd21b97cc324be1eb4c28b4cdc0e4374df9463 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index e3557c1328d53..0f4949f8d37a5 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From ef352adb9035d61333674d4418e682f31c4e342b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From e3efa736cf6c95d536c58e5dbf5bc3916aeef58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Singals compatibility with Cygwin API --- llvm/lib/Support/Unix/Signals.inc | 4 1 file changed, 4 insertions(+) diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 30e5f40193974..e0c04198befcf 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, &dlinfo.dli_fname); +#else OS << format(" %-*s", width, dlinfo.dli_fname); +#endif else OS << format(" %-*s", width, name + 1); From 00b20584b574fe68a943d5f626137397c20f1f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition --- 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 398fcdf90220bee6eac065988fc84096c7f77ab7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index e3557c1328d53..0f4949f8d37a5 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From 164b90e805a4fd28d98fcb7f8881d100a20275ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..1b9d58bc439ad 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -29,7 +29,6 @@ #ifdef __CYGWIN__ #include #include -#define _WIN32 1 #endif #ifdef _WIN32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
@@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, &dlinfo.dli_fname); mati865 wrote: Good point, somehow my brain switched to Rust mode when working on this problem. Can we even trust Cygwin's `dli_fname` to always be null terminated? Maybe the best solution would be to create std::string and then just call `.c_str()`? https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)
https://github.com/mati865 converted_to_draft https://github.com/llvm/llvm-project/pull/134458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)
https://github.com/mati865 closed https://github.com/llvm/llvm-project/pull/134458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)
mati865 wrote: Sure, I'll split this in the upcoming days. https://github.com/llvm/llvm-project/pull/134458 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
@@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) mati865 wrote: Oof, I missed that (I knew about PIC, just didn't connect these two) and needlessly rebuilt LLVM from scratch a couple of times when preparing the package for MSYS2. This might warrant a separate PR though. https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From ee496adcd21933ce9c8f0304c27b8a070d2b83f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/5] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API --- 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..230763e729520 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, (const char *)dlinfo.dli_fname); else OS << format(" %-*s", width, name + 1); From c069b9b68ac1d571af82e5779dc05560de0aa369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/5] [Clang][Cygwin] Fix symbol visibility definition --- 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 595cce46dfe348c430faebf253bfbd48d3700206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/5] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From 07f6ee70efe14bc9e1bc09a6c316f0ac5576d7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/5] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..1b9d58bc439ad 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -29,7 +29,6 @@ #ifdef __CYGWIN__ #include #include -#define _WIN32 1 #endif #ifdef _WIN32 From 7e3c5be835881949431170f2dea177f9c040ac68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 8 Apr 2025 21:48:17 +0200 Subject: [PATCH 5/5] [Clang][Cygwin] Avoid unwanted shared libclang builds Co-authored-by: jeremyd2019 --- clang/tools/libclang/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index ac7a9a8db37c0..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 OR CYGWIN) 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_SHAR
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 ready_for_review https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From 80edab2cb3114b327d6debc904f77bfb790f7e14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Singals compatibility with Cygwin API --- llvm/lib/Support/Unix/Signals.inc | 4 1 file changed, 4 insertions(+) diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 30e5f40193974..e0c04198befcf 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, &dlinfo.dli_fname); +#else OS << format(" %-*s", width, dlinfo.dli_fname); +#endif else OS << format(" %-*s", width, name + 1); From 8d5783a48b36675864e10017319169a1265479bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition --- 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 3c94435b22427d16b03e39f18c3f99fba0fb1777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From a4e7abd74627bdba311b51c6237ef2e904468431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..1b9d58bc439ad 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -29,7 +29,6 @@ #ifdef __CYGWIN__ #include #include -#define _WIN32 1 #endif #ifdef _WIN32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From 0b1b897e988e38d22735d8768e9421f2c42d517b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API --- 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..2527a0d27 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, (char *)dlinfo.dli_fname); else OS << format(" %-*s", width, name + 1); From 189e1385b8ed9529a6bc9682a6978066c644cfef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition --- 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 ba6f73af2c40698305b1acad3adf8295ec3f46b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From a55831f96ac32b2038d1903cfdea7eba4e469cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..1b9d58bc439ad 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -29,7 +29,6 @@ #ifdef __CYGWIN__ #include #include -#define _WIN32 1 #endif #ifdef _WIN32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From cf2678bbd9052e125dc056a07d8eaa6a55d734d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API --- llvm/lib/Support/Unix/Signals.inc | 4 1 file changed, 4 insertions(+) diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc index 30e5f40193974..5346ab25bfb52 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, (char *)dlinfo.dli_fname); +#else OS << format(" %-*s", width, dlinfo.dli_fname); +#endif else OS << format(" %-*s", width, name + 1); From c493bbfc465c29f8f853bbf72cb05f14b4dfa786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition --- 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 b84f9818287809c7f332c57e72ae61395247c7e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From ededfae6ae42ea4ecd50e980dfd322ba6a6b4ce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..1b9d58bc439ad 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -29,7 +29,6 @@ #ifdef __CYGWIN__ #include #include -#define _WIN32 1 #endif #ifdef _WIN32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
@@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, &dlinfo.dli_fname); mati865 wrote: Simple cast results in a warning on Linux: ``` /home/mateusz/Projects/llvm-project/llvm/lib/Support/Unix/Signals.inc:850:36: warning: cast from type ‘const char*’ to type ‘char*’ casts away qualifiers [-Wcast-qual] 850 | OS << format(" %-*s", width, (char *)dlinfo.dli_fname); |^~~~ ``` I'll restore ifdef version. https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From ee496adcd21933ce9c8f0304c27b8a070d2b83f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/4] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API --- 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..230763e729520 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, (const char *)dlinfo.dli_fname); else OS << format(" %-*s", width, name + 1); From c069b9b68ac1d571af82e5779dc05560de0aa369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/4] [Clang][Cygwin] Fix symbol visibility definition --- 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 595cce46dfe348c430faebf253bfbd48d3700206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/4] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From 07f6ee70efe14bc9e1bc09a6c316f0ac5576d7e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/4] [Clang][Cygwin] Remove erroneous define --- clang/tools/libclang/CIndexer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp index 12d9d418dea51..1b9d58bc439ad 100644 --- a/clang/tools/libclang/CIndexer.cpp +++ b/clang/tools/libclang/CIndexer.cpp @@ -29,7 +29,6 @@ #ifdef __CYGWIN__ #include #include -#define _WIN32 1 #endif #ifdef _WIN32 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
mati865 wrote: > These changes mostly look good to me, but it all feels a bit unclear to me > still. So I'd appreciate e.g. one or a few sentences in the commit message on > each of these commits, to explain a bit about the why/how and how things work > in other preexisting environments. Sure, I'll do that within the next few days. > Is this for building LLVM/Clang with GCC, or for building LLVM/Clang with > Clang? Both, initially I started with GCC and then added fixes for building with Clang. > Then secondly, LLVM only allows "squash and merge" merging of PRs - so all > these nicely split changes (with individual explanations soon, I'd hope!) > would end up all mushed together. So unfortunately, to preserve the info > about each of them, they'd need to be filed in separate individual PRs. I think the descriptions would be preserved if I combined them all into PR description. I've split the commits only to make the review easier. > Luckily most of these changes don't build on top of each other (even if you > might not be able to build things properly unless you have all of them > applied at once?), so it should be fairly straightforward to file all those > PRs in parallel. Yeah, this won't build at all without all commits (or most of in case of GCC). So, it's not like there is anything to lose. https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
@@ -847,7 +847,11 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { const char *name = strrchr(dlinfo.dli_fname, '/'); if (!name) +#ifdef __CYGWIN__ + OS << format(" %-*s", width, &dlinfo.dli_fname); mati865 wrote: Right, I doubted my C knowledge too much at this point. https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Disable shared libs on Cygwin by default (PR #138119)
https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/138119 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 ``` Split out from https://github.com/llvm/llvm-project/pull/134494 From dddb263950fd745d859db3456b1944d64a43d05b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH] [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 --- 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() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Remove erroneous _WIN32 define and clean up Cygwin code (PR #138120)
https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/138120 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. Split out from https://github.com/llvm/llvm-project/pull/134494 From 3dc4b18cc6ecb734fb3ab7fff68f2802149b5007 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH] [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 --- 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 #include -#ifdef __CYGWIN__ -#include -#include -#define _WIN32 1 -#endif - #ifdef _WIN32 #include #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
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
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?= 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::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 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::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(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?= 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; ``` 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?= 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 --- 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
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 converted_to_draft https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Fix symbol visibility definition (PR #138118)
https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/138118 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; ``` That's because `CLANG_TEMPLATE_ABI` ends up not being defined. The solution here is to follow MinGW case. Split out from https://github.com/llvm/llvm-project/pull/134494 From 41a22fcdb5d1c62ca47825039230c3dc03ccaf5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH] [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; ``` 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 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Disable shared libs on Cygwin by default (PR #138119)
@@ -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)) mati865 wrote: Indeed, that's unfortunate and has always been a problem. `LLVM_ENABLE_PIC` defaults to ON on Windows, so that condition never worked unless you explicitly disabled `LLVM_ENABLE_PIC` as found out by @jeremyd2019. https://github.com/llvm/llvm-project/pull/138119 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [Driver] add a Cygwin ToolChain (PR #135691)
@@ -0,0 +1,77 @@ +// RUN: %clang -### %s --target=i686-pc-windows-cygnus --sysroot=%S/Inputs/basic_cygwin_tree \ +// RUN: -resource-dir=%S/Inputs/resource_dir \ +// RUN: --stdlib=platform 2>&1 | FileCheck --check-prefix=CHECK %s +// CHECK: "-cc1" +// CHECK-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]" +// CHECK-SAME: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-pc-cygwin/10/../../../../include/c++/10" +// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-pc-cygwin/10/../../../../include/i686-pc-cygwin/c++/10" +// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-pc-cygwin/10/../../../../include/c++/10/backward" +// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/local/include" +// CHECK-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]{{(/|)}}include" +// CHECK-SAME: {{^}} "-internal-isystem" "[[SYSROOT]]/usr/lib/gcc/i686-pc-cygwin/10/../../../../i686-pc-cygwin/include" +// CHECK-SAME: "-internal-externc-isystem" "[[SYSROOT]]/include" +// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include" +// CHECK-SAME: {{^}} "-internal-externc-isystem" "[[SYSROOT]]/usr/include/w32api" +// CHECK-SAME: "-femulated-tls" +// CHECK-SAME: "-exception-model=dwarf" +// CHECK: "{{.*}}gcc{{(\.exe)?}}" +// CHECK-SAME: "-m32" + +// RUN: %clang -### %s --target=i686-pc-cygwin --sysroot=%S/Inputs/basic_cygwin_tree \ +// RUN: --stdlib=platform -static 2>&1 | FileCheck --check-prefix=CHECK-STATIC %s +// CHECK-STATIC: "-cc1" "-triple" "i686-pc-windows-cygnus" +// CHECK-STATIC-SAME: "-static-define" +// CHECK-STATIC: "{{.*}}gcc{{(\.exe)?}}" mati865 wrote: Agree with Jeremy, let's not spread oneself too thinly. Adding a dedicated driver is already a bit deal and solves a lot of problems. https://github.com/llvm/llvm-project/pull/135691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
mati865 wrote: Okay, you were right. Keeping this in a single description hurts readability a lot. So I have opened a series of smaller PRs: https://github.com/llvm/llvm-project/pull/138117 https://github.com/llvm/llvm-project/pull/138118 https://github.com/llvm/llvm-project/pull/138119 https://github.com/llvm/llvm-project/pull/138120 This branch is equal to the other ones (once they are merged together), so we can go either way. I think you can publish them from drafts once you are happy with them. You can also mention me on GH, so I get the notification instantly and publish them. https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Remove erroneous _WIN32 define and clean up Cygwin code (PR #138120)
mati865 wrote: > Defining `_WIN32` in cygwin mode compilations, and including w32api headers > from there, feels brittle; I'm not familiar enough with cygwin to know if > this is something that one usually can do, or whether it is commonly done, or > what caveats that involves (doesn't e.g. cygwin have an incompatible > definition of the type `long`?) - so getting rid of that probably is good in > itself. The rule of thumb is to avoid using Win32 APIs unless absolutely necessary, but I'm not familiar with the reasons. > Was this an issue only when building Clang with Clang - did this succeed if > building Clang with GCC? Indeed, it builds fine with GCC. I think the difference here is Clang being a cross-compiler, has more robust headers that cover all targets. GCC can drop bits irrelevant to its target at the build time. If I grep through `/usr` for `_aligned_malloc` there are no matches for GCC and Clang guards it based on `_WIN32`: ``` $ grep -R _aligned_malloc /usr -C2 /usr/lib/clang/20/include/mm_malloc.h- void *__mallocedMemory; /usr/lib/clang/20/include/mm_malloc.h-#if defined(__MINGW32__) /usr/lib/clang/20/include/mm_malloc.h: __mallocedMemory = __mingw_aligned_malloc(__size, __align); /usr/lib/clang/20/include/mm_malloc.h-#elif defined(_WIN32) /usr/lib/clang/20/include/mm_malloc.h: __mallocedMemory = _aligned_malloc(__size, __align); /usr/lib/clang/20/include/mm_malloc.h-#else /usr/lib/clang/20/include/mm_malloc.h- if (posix_memalign(&__mallocedMemory, __align, __size)) -- /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/c++config.h-/* #undef _GLIBCXX_HAVE__ACOSL */ /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/c++config.h- /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/c++config.h:/* Define to 1 if you have the `_aligned_malloc' function. */ /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/c++config.h-/* #undef _GLIBCXX_HAVE__ALIGNED_MALLOC */ /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/c++config.h- -- /usr/share/aclocal/ax_check_page_aligned_malloc.m4-# = /usr/share/aclocal/ax_check_page_aligned_malloc.m4:# https://www.gnu.org/software/autoconf-archive/ax_check_page_aligned_malloc.html /usr/share/aclocal/ax_check_page_aligned_malloc.m4-# = /usr/share/aclocal/ax_check_page_aligned_malloc.m4-# ``` GCC has some `_WIN32` checks with special `__CYGWIN__` condition, but I think these code paths (except `fs_path.h`) are not that relevant: ``` $ grep -R _WIN32 /usr/lib/gcc /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/bits/fs_path.h:#if defined(_WIN32) && !defined(__CYGWIN__) /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/experimental/bits/fs_path.h:#if defined(_WIN32) && !defined(__CYGWIN__) /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/experimental/internet:#if defined _WIN32 && __has_include() /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/parallel/compatibility.h:#if !defined(_WIN32) || defined (__CYGWIN__) /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/parallel/compatibility.h:#if defined (_WIN32) && !defined (__CYGWIN__) /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/c++config.h:/* #undef _GLIBCXX_USE_WIN32_SLEEP */ /usr/lib/gcc/x86_64-pc-msys/13.3.0/include/c++/x86_64-pc-msys/bits/os_defines.h:#define _GLIBCXX_THREAD_ATEXIT_WIN32 1 ``` It would be possible to apply similar `&& !defined(__CYGWIN__)` here, but I don't know how many other places would hit the same problem. While using Win32 APIs is sometimes necessary, I think defining `_WIN32` is a red flag, although I don't have that much experience with Cygwin. > I presume that the removed codepaths did serve some purpose at some point > initially. Can we dig up that purpose from the git history and recheck > whether it's needed/relevant still at this point. It was introduced by https://github.com/llvm/llvm-project/commit/aa63fdf3b57ab5701e951b4bf20a9dca3d8da419 I'd expect Cygwin API missing the required bits back then, these days it can use the same code as Linux in this file. @jeremyd2019 pointed that out in: https://github.com/llvm/llvm-project/pull/134494#discussion_r2035957416 > While building may be broken right now, the individual issue of missing > `_aligned_malloc()` probably is fixable as well, so I'd like to know a bit > more about the reasoning for why this cygwin specific codepath should be > removed. There is another error for `_aligned_free` but I didn't include it to shorten the message. https://github.com/llvm/llvm-project/pull/138120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] [Driver] add a Cygwin ToolChain (PR #135691)
https://github.com/mati865 edited https://github.com/llvm/llvm-project/pull/135691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From ede237421177b81181900b915eeda7fc5ee6ae12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/5] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API --- 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..230763e729520 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, (const char *)dlinfo.dli_fname); else OS << format(" %-*s", width, name + 1); From 3e279783e6ed4537f0dbe04a4549a6a0cdbe58b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/5] [Clang][Cygwin] Fix symbol visibility definition --- 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 106d5d3d208c943dc1431cc04fcea180d1630a34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/5] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From 400ec11792a9c1cc4370556203a1a215d2519265 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/5] [Clang][Cygwin] Remove erroneous define and clean it up Co-authored-by: Jeremy Drake --- 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 #include -#ifdef __CYGWIN__ -#include -#include -#define _WIN32 1 -#endif - #ifdef _WIN32 #include #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); From 60c7a44e1241bf674492ea9e5cb90e7936243a5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 8 Apr 2025 21:48:17 +0200 Subject: [PATCH 5/5] [Clang][Cygwin] Avoid unwanted shared libcla
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134494 From ee496adcd21933ce9c8f0304c27b8a070d2b83f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 5 Apr 2025 13:18:35 +0200 Subject: [PATCH 1/5] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API --- 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..230763e729520 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, (const char *)dlinfo.dli_fname); else OS << format(" %-*s", width, name + 1); From c069b9b68ac1d571af82e5779dc05560de0aa369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 13:57:49 +0100 Subject: [PATCH 2/5] [Clang][Cygwin] Fix symbol visibility definition --- 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 595cce46dfe348c430faebf253bfbd48d3700206 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 15:08:18 +0200 Subject: [PATCH 3/5] [Clang][Cygwin] Disable shared libs on Cygwin by default --- clang/tools/CMakeLists.txt | 5 +++-- clang/tools/libclang/CMakeLists.txt | 2 +- 2 files changed, 4 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..ac7a9a8db37c0 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) set(ENABLE_SHARED SHARED) endif() From b6605cf83324cffe362b1cea72f17d1e4edab79d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 21:41:50 +0200 Subject: [PATCH 4/5] [Clang][Cygwin] Remove erroneous define and clean it up Co-authored-by: Jeremy Drake --- 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 #include -#ifdef __CYGWIN__ -#include -#include -#define _WIN32 1 -#endif - #ifdef _WIN32 #include #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); From b81759aa5391af76a4cc3900e4a3f83322b7d842 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Tue, 8 Apr 2025 21:48:17 +0200 Subject: [PATCH 5/5] [Clang][Cygwin] Avoid unwanted shared libcla
[clang] [Clang] [Driver] add a Cygwin ToolChain (PR #135691)
mati865 wrote: So this is basically `hack: dynamically resolve G++ include dir` and `hack: add system search paths` from https://github.com/mati865/llvm-project/commits/cygwin-more-fixes/ but done the proper way. It will take a few more changes to get everything working, but this is a good start. LGTM https://github.com/llvm/llvm-project/pull/135691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
@@ -106,7 +106,7 @@ if (LLVM_EXPORTED_SYMBOL_FILE) DEPENDS ${LIBCLANG_VERSION_SCRIPT_FILE}) endif() -if(LLVM_ENABLE_PIC OR (WIN32 AND NOT LIBCLANG_BUILD_STATIC)) +if(LLVM_ENABLE_PIC OR ((WIN32 OR CYGWIN) AND NOT LIBCLANG_BUILD_STATIC)) mati865 wrote: I'd prefer to avoid unrelated changes here. https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] attempt to fix building shared libclang. (PR #138351)
mati865 wrote: > But people build mingw clang with gcc, right? Dunno. > It seems like having explicit dllexport annotations as libclang does should > turn off auto-export. I didn't see `--export-all-symbols` in the command line > anyway. Yes, linker exports all the symbols by default, but explicit export disable that. https://github.com/llvm/llvm-project/pull/138351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
mati865 wrote: Thank you for taking care of it! https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix building Clang for Cygwin (PR #134494)
https://github.com/mati865 closed https://github.com/llvm/llvm-project/pull/134494 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Remove erroneous _WIN32 define and clean up Cygwin code (PR #138120)
mati865 wrote: Looks good, thanks. https://github.com/llvm/llvm-project/pull/138120 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] attempt to fix building shared libclang. (PR #138351)
mati865 wrote: I think it works when you build with Clang rather than GCC. Clang will not export symbols with hidden visibility. https://github.com/llvm/llvm-project/pull/138351 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)
https://github.com/mati865 created https://github.com/llvm/llvm-project/pull/134458 This is part of the fixes from https://github.com/mati865/llvm-project/commits/cygwin-more-fixes/ that I consider good enough to upstream. The other branch with hacky changes even goes as far as making Clang successfully build LLVM+LLD+itself (although it still calls GCC for linking), but it would take a lot more work that I'm not planning to do. From 7f22b8f408e25fcdb239343043d157dcfe05d270 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 01:13:06 +0100 Subject: [PATCH 1/5] [Clang][Cygwin] Enable few conditions that are shared with MinGW --- clang/lib/AST/ItaniumCXXABI.cpp | 2 +- clang/lib/AST/RecordLayoutBuilder.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 4 ++-- clang/lib/CodeGen/Targets/X86.cpp | 2 +- clang/lib/Driver/ToolChain.cpp| 2 +- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/lib/Sema/SemaDeclCXX.cpp| 4 ++-- clang/lib/Sema/SemaTemplate.cpp | 8 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/clang/lib/AST/ItaniumCXXABI.cpp b/clang/lib/AST/ItaniumCXXABI.cpp index a1b2551419f5e..d866f6023e146 100644 --- a/clang/lib/AST/ItaniumCXXABI.cpp +++ b/clang/lib/AST/ItaniumCXXABI.cpp @@ -236,7 +236,7 @@ class ItaniumCXXABI : public CXXABI { CallingConv getDefaultMethodCallConv(bool isVariadic) const override { const llvm::Triple &T = Context.getTargetInfo().getTriple(); -if (!isVariadic && T.isWindowsGNUEnvironment() && +if (!isVariadic && T.isOSCygMing() && T.getArch() == llvm::Triple::x86) return CC_X86ThisCall; return Context.getTargetInfo().getDefaultCallingConv(); diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 3e756ab9b9bfe..43b54850598af 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1950,7 +1950,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, // silently there. For other targets that have ms_struct enabled // (most probably via a pragma or attribute), trigger a diagnostic // that defaults to an error. - if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) + if (!Context.getTargetInfo().getTriple().isOSCygMing()) Diag(D->getLocation(), diag::warn_npot_ms_struct); } if (TypeSize > FieldAlign && diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8f9cf965af2b9..f4cf4f8ae7c0d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1680,7 +1680,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, const llvm::Triple &TT = CGM.getTriple(); const auto &CGOpts = CGM.getCodeGenOpts(); - if (TT.isWindowsGNUEnvironment()) { + if (TT.isOSCygMing()) { // In MinGW, variables without DLLImport can still be automatically // imported from a DLL by the linker; don't mark variables that // potentially could come from another DLL as DSO local. diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 2822d526a54b0..f8c63d185a24a 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3757,7 +3757,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM, bool IsDLLImport = RD->hasAttr(); // Don't import the RTTI but emit it locally. -if (CGM.getTriple().isWindowsGNUEnvironment()) +if (CGM.getTriple().isOSCygMing()) return false; if (CGM.getVTables().isVTableExternal(RD)) { @@ -4047,7 +4047,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM, !CGM.getContext() .getTargetInfo() .getTriple() - .isWindowsGNUEnvironment()) + .isOSCygMing()) return CGM.getVTableLinkage(RD); } diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp index b36a6e1396653..cb09c52856744 100644 --- a/clang/lib/CodeGen/Targets/X86.cpp +++ b/clang/lib/CodeGen/Targets/X86.cpp @@ -1391,7 +1391,7 @@ class WinX86_64ABIInfo : public ABIInfo { public: WinX86_64ABIInfo(CodeGen::CodeGenTypes &CGT, X86AVXABILevel AVXLevel) : ABIInfo(CGT), AVXLevel(AVXLevel), -IsMingw64(getTarget().getTriple().isWindowsGNUEnvironment()) {} +IsMingw64(getTarget().getTriple().isOSCygMing()) {} void computeInfo(CGFunctionInfo &FI) const override; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 36d0ae34dec86..26d7311227327 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -745,7 +745,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args, break; case ToolCh
[clang] [llvm] [LLVM][Clang][Cygwin] Fix Cygwin builds (PR #134458)
https://github.com/mati865 updated https://github.com/llvm/llvm-project/pull/134458 From adbcc7f650edfb4f2f86d1146b8116794a9de6df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 01:13:06 +0100 Subject: [PATCH 1/5] [Clang][Cygwin] Enable few conditions that are shared with MinGW --- clang/lib/AST/ItaniumCXXABI.cpp | 3 +-- clang/lib/AST/RecordLayoutBuilder.cpp | 2 +- clang/lib/CodeGen/CodeGenModule.cpp | 2 +- clang/lib/CodeGen/ItaniumCXXABI.cpp | 7 ++- clang/lib/CodeGen/Targets/X86.cpp | 2 +- clang/lib/Driver/ToolChain.cpp| 4 +--- clang/lib/Sema/SemaDecl.cpp | 2 +- clang/lib/Sema/SemaDeclCXX.cpp| 4 ++-- clang/lib/Sema/SemaTemplate.cpp | 9 - 9 files changed, 14 insertions(+), 21 deletions(-) diff --git a/clang/lib/AST/ItaniumCXXABI.cpp b/clang/lib/AST/ItaniumCXXABI.cpp index a1b2551419f5e..11d8bbe8b24ba 100644 --- a/clang/lib/AST/ItaniumCXXABI.cpp +++ b/clang/lib/AST/ItaniumCXXABI.cpp @@ -236,8 +236,7 @@ class ItaniumCXXABI : public CXXABI { CallingConv getDefaultMethodCallConv(bool isVariadic) const override { const llvm::Triple &T = Context.getTargetInfo().getTriple(); -if (!isVariadic && T.isWindowsGNUEnvironment() && -T.getArch() == llvm::Triple::x86) +if (!isVariadic && T.isOSCygMing() && T.getArch() == llvm::Triple::x86) return CC_X86ThisCall; return Context.getTargetInfo().getDefaultCallingConv(); } diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp index 3e756ab9b9bfe..43b54850598af 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1950,7 +1950,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, // silently there. For other targets that have ms_struct enabled // (most probably via a pragma or attribute), trigger a diagnostic // that defaults to an error. - if (!Context.getTargetInfo().getTriple().isWindowsGNUEnvironment()) + if (!Context.getTargetInfo().getTriple().isOSCygMing()) Diag(D->getLocation(), diag::warn_npot_ms_struct); } if (TypeSize > FieldAlign && diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 8f9cf965af2b9..f4cf4f8ae7c0d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1680,7 +1680,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, const llvm::Triple &TT = CGM.getTriple(); const auto &CGOpts = CGM.getCodeGenOpts(); - if (TT.isWindowsGNUEnvironment()) { + if (TT.isOSCygMing()) { // In MinGW, variables without DLLImport can still be automatically // imported from a DLL by the linker; don't mark variables that // potentially could come from another DLL as DSO local. diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 2822d526a54b0..153bafc45740a 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3757,7 +3757,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM, bool IsDLLImport = RD->hasAttr(); // Don't import the RTTI but emit it locally. -if (CGM.getTriple().isWindowsGNUEnvironment()) +if (CGM.getTriple().isOSCygMing()) return false; if (CGM.getVTables().isVTableExternal(RD)) { @@ -4044,10 +4044,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(CodeGenModule &CGM, return llvm::GlobalValue::ExternalLinkage; // MinGW always uses LinkOnceODRLinkage for type info. if (RD->isDynamicClass() && - !CGM.getContext() - .getTargetInfo() - .getTriple() - .isWindowsGNUEnvironment()) + !CGM.getContext().getTargetInfo().getTriple().isOSCygMing()) return CGM.getVTableLinkage(RD); } diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp index b36a6e1396653..cb09c52856744 100644 --- a/clang/lib/CodeGen/Targets/X86.cpp +++ b/clang/lib/CodeGen/Targets/X86.cpp @@ -1391,7 +1391,7 @@ class WinX86_64ABIInfo : public ABIInfo { public: WinX86_64ABIInfo(CodeGen::CodeGenTypes &CGT, X86AVXABILevel AVXLevel) : ABIInfo(CGT), AVXLevel(AVXLevel), -IsMingw64(getTarget().getTriple().isWindowsGNUEnvironment()) {} +IsMingw64(getTarget().getTriple().isOSCygMing()) {} void computeInfo(CGFunctionInfo &FI) const override; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 36d0ae34dec86..37e1e65310fbb 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -744,9 +744,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args, Suffix = IsITANMSVCWindows ? ".lib" : ".a"; break; case ToolChain::FT_Shared: -Suffix = TT.isOSWindows() - ? (
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -314,6 +308,11 @@ function(add_link_opts target_name) set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-brtl") endif() + + if (NOT MINGW) +llvm_check_linker_flag(CXX "-Wl,-Bsymbolic-functions" + LINKER_SUPPORTS_B_SYMBOLIC_FUNCTIONS) + endif() mati865 wrote: This `if` is unnecessary thanks to this PR. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [CMake] Add a linker test for -Bsymbolic-functions to AddLLVM (PR #79539)
@@ -355,6 +349,9 @@ function(add_link_opts target_name) set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-brtl") endif() + + check_linker_flag(CXX "-Wl,-Bsymbolic-functions" mati865 wrote: I'd argue it's much faster than autotools for other large projects. It would be nice if the configuration phase could be parallelized, at least to some degree, but even with a single thread, it's a matter of seconds. https://github.com/llvm/llvm-project/pull/79539 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang][Cygwin] Enable few conditions that are shared with MinGW (PR #149637)
mati865 wrote: Thanks for taking care of it; I had thought these changes were already done by somebody. https://github.com/llvm/llvm-project/pull/149637 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits