diff --git a/llvm/0001-LLVM-Cygwin-Fix-symbol-visibility-definition.patch b/llvm/0001-LLVM-Cygwin-Fix-symbol-visibility-definition.patch index 68c15252..d201c5fe 100644 --- a/llvm/0001-LLVM-Cygwin-Fix-symbol-visibility-definition.patch +++ b/llvm/0001-LLVM-Cygwin-Fix-symbol-visibility-definition.patch @@ -1,7 +1,7 @@ -From b29678bd48d4f0dfbd062943c6063358e1285a0d Mon Sep 17 00:00:00 2001 +From 4a8070f19bb9485f61804fd48c07f5667e18dc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 4 Apr 2025 20:12:21 +0200 -Subject: [PATCH 01/15] [LLVM][Cygwin] Fix symbol visibility definition +Subject: [PATCH] [LLVM][Cygwin] Fix symbol visibility definition --- llvm/cmake/modules/AddLLVM.cmake | 2 +- @@ -12,7 +12,7 @@ Subject: [PATCH 01/15] [LLVM][Cygwin] Fix symbol visibility definition 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake -index d3e9377c8..7e1449e1a 100644 +index d3e9377c8d..7e1449e1a8 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -666,7 +666,7 @@ function(llvm_add_library name) @@ -25,7 +25,7 @@ index d3e9377c8..7e1449e1a 100644 NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake -index 5db06ccda..93c970fdf 100644 +index 5db06ccdad..93c970fdf2 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -210,7 +210,7 @@ if( LLVM_REVERSE_ITERATION ) @@ -47,7 +47,7 @@ index 5db06ccda..93c970fdf 100644 # about use of the attributes. As long as we don't use the attributes (to # override the default) we shouldn't set the command line options either. diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index dc8b53890..6c1a9b7e7 100644 +index dc8b538906..6c1a9b7e70 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -129,7 +129,7 @@ @@ -69,7 +69,7 @@ index dc8b53890..6c1a9b7e7 100644 #define LLVM_TEMPLATE_ABI LLVM_ATTRIBUTE_VISIBILITY_DEFAULT #define LLVM_EXPORT_TEMPLATE diff --git a/llvm/lib/Target/CMakeLists.txt b/llvm/lib/Target/CMakeLists.txt -index 2739233f9..e2c86baff 100644 +index 2739233f9c..e2c86baffb 100644 --- a/llvm/lib/Target/CMakeLists.txt +++ b/llvm/lib/Target/CMakeLists.txt @@ -23,7 +23,7 @@ add_llvm_component_library(LLVMTarget @@ -82,7 +82,7 @@ index 2739233f9..e2c86baff 100644 NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET) # Set default visibility to hidden, so we don't export all the Target classes diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt -index ede3c5034..9ad6154ae 100644 +index ede3c5034e..9ad6154ae1 100644 --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt @@ -57,11 +57,11 @@ if(LLVM_BUILD_LLVM_DYLIB) diff --git a/llvm/0002-LLVM-Cygwin-Remove-special-case-for-CXX-extensions-o.patch b/llvm/0002-LLVM-Cygwin-Remove-special-case-for-CXX-extensions-o.patch new file mode 100644 index 00000000..067bed4d --- /dev/null +++ b/llvm/0002-LLVM-Cygwin-Remove-special-case-for-CXX-extensions-o.patch @@ -0,0 +1,38 @@ +From 4651dd2144c2ce03e22965a8c504527e361f4edd Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Sat, 3 May 2025 14:33:03 -0700 +Subject: [PATCH] [LLVM][Cygwin] Remove special case for CXX extensions on + Cygwin. (#138328) + +This is no longer necessary, and results in an inconvenient define of +`i386` on i386 Cygwin targets which breaks compiling +llvm/include/llvm/ExecutionEngine/JITLink/i386.h. + +Signed-off-by: Jeremy Drake +--- + llvm/CMakeLists.txt | 9 +-------- + 1 file changed, 1 insertion(+), 8 deletions(-) + +diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt +index f5293e8663..fea727943d 100644 +--- a/llvm/CMakeLists.txt ++++ b/llvm/CMakeLists.txt +@@ -77,14 +77,7 @@ endif() + + set(CMAKE_CXX_STANDARD ${LLVM_REQUIRED_CXX_STANDARD} CACHE STRING "C++ standard to conform to") + set(CMAKE_CXX_STANDARD_REQUIRED YES) +- +-if (CYGWIN) +- # Cygwin is a bit stricter and lack things like 'strdup', 'stricmp', etc in +- # c++xx mode. +- set(CMAKE_CXX_EXTENSIONS YES) +-else() +- set(CMAKE_CXX_EXTENSIONS NO) +-endif() ++set(CMAKE_CXX_EXTENSIONS NO) + + if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(FATAL_ERROR " +-- +2.49.0.windows.1 + diff --git a/llvm/0002-undef-i386.patch b/llvm/0002-undef-i386.patch deleted file mode 100644 index 9510ac4d..00000000 --- a/llvm/0002-undef-i386.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0f2dba27dc8b706c5985ef05ed7acb0c7d15cf6b Mon Sep 17 00:00:00 2001 -From: Jeremy Drake -Date: Sun, 13 Apr 2025 22:21:02 -0700 -Subject: [PATCH 02/15] undef i386 - -i686 cygwin gcc has a default define of i386 to 1, which conflicts with -a namespace of i386, so undef it. ---- - llvm/include/llvm/ExecutionEngine/JITLink/i386.h | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/llvm/include/llvm/ExecutionEngine/JITLink/i386.h b/llvm/include/llvm/ExecutionEngine/JITLink/i386.h -index efe818293..6e53aae99 100644 ---- a/llvm/include/llvm/ExecutionEngine/JITLink/i386.h -+++ b/llvm/include/llvm/ExecutionEngine/JITLink/i386.h -@@ -16,6 +16,8 @@ - #include "llvm/ExecutionEngine/JITLink/JITLink.h" - #include "llvm/ExecutionEngine/JITLink/TableManager.h" - -+#undef i386 -+ - namespace llvm::jitlink::i386 { - /// Represets i386 fixups - enum EdgeKind_i386 : Edge::Kind { --- -2.49.0.windows.1 - diff --git a/llvm/0003-LLVM-Cygwin-Fix-llvm-config-shared-library-names.patch b/llvm/0003-LLVM-Cygwin-Fix-shared-library-name-136599.patch similarity index 89% rename from llvm/0003-LLVM-Cygwin-Fix-llvm-config-shared-library-names.patch rename to llvm/0003-LLVM-Cygwin-Fix-shared-library-name-136599.patch index f28b9e78..4440c119 100644 --- a/llvm/0003-LLVM-Cygwin-Fix-llvm-config-shared-library-names.patch +++ b/llvm/0003-LLVM-Cygwin-Fix-shared-library-name-136599.patch @@ -1,7 +1,7 @@ -From 5cb3c0bc6beeb169ab08ffc7da8a78276f254c25 Mon Sep 17 00:00:00 2001 -From: Jeremy Drake -Date: Mon, 21 Apr 2025 10:37:40 -0700 -Subject: [PATCH 17/17] [LLVM][Cygwin] Fix llvm shared library name +From ea3ae57e80924447a31b164901c55d20e651554d Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Thu, 24 Apr 2025 13:51:34 -0700 +Subject: [PATCH] [LLVM][Cygwin] Fix shared library name (#136599) Treat Cygwin like WIN32 in llvm-shlib for naming the library. @@ -9,8 +9,9 @@ Don't create shlib symlinks on Cygwin, they don't help anything there, but teach llvm_install_library_symlink that Cygwin's shared libraries live in BINDIR like WIN32. -Add a new variable to BuildVariables to have CMake's shared library -prefix, to avoid having to patch between "cyg" and "msys-" on MSYS2. +Add a new variable to llvm-config's BuildVariables to have CMake's +shared library prefix, to avoid having to patch between "cyg" and +"msys-" on MSYS2. --- llvm/cmake/modules/AddLLVM.cmake | 4 ++-- llvm/tools/llvm-config/BuildVariables.inc.in | 1 + @@ -20,7 +21,7 @@ prefix, to avoid having to patch between "cyg" and "msys-" on MSYS2. 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake -index 7e1449e1a..93ce51e69 100644 +index 7e1449e1a8..93ce51e697 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -750,7 +750,7 @@ function(llvm_add_library name) @@ -42,7 +43,7 @@ index 7e1449e1a..93ce51e69 100644 endif() diff --git a/llvm/tools/llvm-config/BuildVariables.inc.in b/llvm/tools/llvm-config/BuildVariables.inc.in -index 370005cd8..e4e1d449b 100644 +index 370005cd8d..e4e1d449bf 100644 --- a/llvm/tools/llvm-config/BuildVariables.inc.in +++ b/llvm/tools/llvm-config/BuildVariables.inc.in @@ -35,3 +35,4 @@ @@ -51,7 +52,7 @@ index 370005cd8..e4e1d449b 100644 #define LLVM_TOOLS_INSTALL_DIR "@LLVM_TOOLS_INSTALL_DIR@" +#define LLVM_SHARED_LIBRARY_PREFIX "@LLVM_SHARED_LIBRARY_PREFIX@" diff --git a/llvm/tools/llvm-config/CMakeLists.txt b/llvm/tools/llvm-config/CMakeLists.txt -index 02c2532db..3a8f40b9c 100644 +index 02c2532dba..3a8f40b9c6 100644 --- a/llvm/tools/llvm-config/CMakeLists.txt +++ b/llvm/tools/llvm-config/CMakeLists.txt @@ -65,6 +65,7 @@ set(LLVM_CXXFLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION} ${L @@ -63,7 +64,7 @@ index 02c2532db..3a8f40b9c 100644 # Use the C++ link flags, since they should be a superset of C link flags. set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}") diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp -index d5b76b1bb..a54538bb5 100644 +index d5b76b1bb6..a54538bb53 100644 --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/llvm/tools/llvm-config/llvm-config.cpp @@ -390,7 +390,7 @@ int main(int argc, char **argv) { @@ -97,7 +98,7 @@ index d5b76b1bb..a54538bb5 100644 } } diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt -index 9ad6154ae..64492f9db 100644 +index 9ad6154ae1..64492f9db4 100644 --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt @@ -33,7 +33,7 @@ if(LLVM_BUILD_LLVM_DYLIB) diff --git a/llvm/0004-LLVM-Cygwin-Fix-Signals-compatibility-with-Cygwin-AP.patch b/llvm/0004-LLVM-Cygwin-Fix-Signals-compatibility-with-Cygwin-AP.patch index 3dce5d29..c3ac11ed 100644 --- a/llvm/0004-LLVM-Cygwin-Fix-Signals-compatibility-with-Cygwin-AP.patch +++ b/llvm/0004-LLVM-Cygwin-Fix-Signals-compatibility-with-Cygwin-AP.patch @@ -1,15 +1,31 @@ -From b6b6d01ec5c84ba11bc797e185e915e701699532 Mon Sep 17 00:00:00 2001 +From 132e91b6e97ae70d89cdabd6ef6948d338bdf3f8 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 17/17] [LLVM][Cygwin] Fix Signals compatibility with Cygwin - API +Date: Fri, 2 May 2025 10:02:51 +0200 +Subject: [PATCH] [LLVM][Cygwin] Fix Signals compatibility with Cygwin API + (#138117) +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 2e7b467a1..4f8010ca2 100644 +index 2e7b467a14..ac01d05ab6 100644 --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -842,7 +842,7 @@ void llvm::sys::PrintStackTrace(raw_ostream &OS, int Depth) { @@ -17,7 +33,7 @@ index 2e7b467a1..4f8010ca2 100644 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); ++ OS << format(" %-*s", width, static_cast(dlinfo.dli_fname)); else OS << format(" %-*s", width, name + 1); diff --git a/llvm/0005-LLVM-TargetParser-Handle-msys-targets-the-same-as-cy.patch b/llvm/0005-LLVM-TargetParser-Handle-msys-targets-the-same-as-cy.patch new file mode 100644 index 00000000..2ee91f19 --- /dev/null +++ b/llvm/0005-LLVM-TargetParser-Handle-msys-targets-the-same-as-cy.patch @@ -0,0 +1,66 @@ +From b8c0bfbafddce093d85448438fce0bc46ca510fb Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Thu, 24 Apr 2025 03:28:27 -0700 +Subject: [PATCH] [LLVM][TargetParser] Handle -msys targets the same as + -cygwin. (#136817) + +MSYS2 uses i686-pc-msys and x86_64-pc-msys as target, and is a fork of +Cygwin. There's an effort underway to try to switch as much as possible +to use -pc-cygwin targets, but the -msys target will be hanging around +for the forseeable future. +--- + llvm/lib/TargetParser/Triple.cpp | 5 +++-- + llvm/unittests/TargetParser/TripleTest.cpp | 7 +++++++ + 2 files changed, 10 insertions(+), 2 deletions(-) + +diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp +index e9e6f130f7..74363f8d71 100644 +--- a/llvm/lib/TargetParser/Triple.cpp ++++ b/llvm/lib/TargetParser/Triple.cpp +@@ -1150,7 +1150,8 @@ std::string Triple::normalize(StringRef Str, CanonicalForm Form) { + OSType OS = UnknownOS; + if (Components.size() > 2) { + OS = parseOS(Components[2]); +- IsCygwin = Components[2].starts_with("cygwin"); ++ IsCygwin = Components[2].starts_with("cygwin") || ++ Components[2].starts_with("msys"); + IsMinGW32 = Components[2].starts_with("mingw"); + } + EnvironmentType Environment = UnknownEnvironment; +@@ -1195,7 +1196,7 @@ std::string Triple::normalize(StringRef Str, CanonicalForm Form) { + break; + case 2: + OS = parseOS(Comp); +- IsCygwin = Comp.starts_with("cygwin"); ++ IsCygwin = Comp.starts_with("cygwin") || Comp.starts_with("msys"); + IsMinGW32 = Comp.starts_with("mingw"); + Valid = OS != UnknownOS || IsCygwin || IsMinGW32; + break; +diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp +index 61b3637bb4..e409a3b6a6 100644 +--- a/llvm/unittests/TargetParser/TripleTest.cpp ++++ b/llvm/unittests/TargetParser/TripleTest.cpp +@@ -2572,6 +2572,8 @@ TEST(TripleTest, NormalizeWindows) { + EXPECT_EQ("i686-unknown-windows-gnu", Triple::normalize("i686-mingw32-w64")); + EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-cygwin")); + EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-cygwin")); ++ EXPECT_EQ("i686-pc-windows-cygnus", Triple::normalize("i686-pc-msys")); ++ EXPECT_EQ("i686-unknown-windows-cygnus", Triple::normalize("i686-msys")); + + EXPECT_EQ("x86_64-pc-windows-msvc", Triple::normalize("x86_64-pc-win32")); + EXPECT_EQ("x86_64-unknown-windows-msvc", Triple::normalize("x86_64-win32")); +@@ -2581,6 +2583,11 @@ TEST(TripleTest, NormalizeWindows) { + Triple::normalize("x86_64-pc-mingw32-w64")); + EXPECT_EQ("x86_64-unknown-windows-gnu", + Triple::normalize("x86_64-mingw32-w64")); ++ EXPECT_EQ("x86_64-pc-windows-cygnus", Triple::normalize("x86_64-pc-cygwin")); ++ EXPECT_EQ("x86_64-unknown-windows-cygnus", ++ Triple::normalize("x86_64-cygwin")); ++ EXPECT_EQ("x86_64-pc-windows-cygnus", Triple::normalize("x86_64-pc-msys")); ++ EXPECT_EQ("x86_64-unknown-windows-cygnus", Triple::normalize("x86_64-msys")); + + EXPECT_EQ("i686-pc-windows-elf", Triple::normalize("i686-pc-win32-elf")); + EXPECT_EQ("i686-unknown-windows-elf", Triple::normalize("i686-win32-elf")); +-- +2.49.0.windows.1 + diff --git a/llvm/0006-LLVM-Cygwin-Define-_GNU_SOURCE-on-Cygwin-as-well.-13.patch b/llvm/0006-LLVM-Cygwin-Define-_GNU_SOURCE-on-Cygwin-as-well.-13.patch new file mode 100644 index 00000000..c7c383df --- /dev/null +++ b/llvm/0006-LLVM-Cygwin-Define-_GNU_SOURCE-on-Cygwin-as-well.-13.patch @@ -0,0 +1,43 @@ +From 13348c154d083fdb302734dd64565d4cfa0835ac Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Sat, 3 May 2025 14:32:44 -0700 +Subject: [PATCH] [LLVM][Cygwin] Define _GNU_SOURCE on Cygwin as well. + (#138329) + +Without it, certain functions such as dladdr are not make available by +the headers. + +Signed-off-by: Jeremy Drake +--- + llvm/cmake/config-ix.cmake | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake +index 767774812a..3d6ed8c795 100644 +--- a/llvm/cmake/config-ix.cmake ++++ b/llvm/cmake/config-ix.cmake +@@ -86,15 +86,15 @@ endif() + # Keep this at the top to make sure we don't add _GNU_SOURCE dependent checks + # before adding it. + check_symbol_exists(__GLIBC__ stdio.h LLVM_USING_GLIBC) +-if(LLVM_USING_GLIBC) ++if(LLVM_USING_GLIBC OR CYGWIN) + add_compile_definitions(_GNU_SOURCE) + list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE") ++endif() + +- # enable 64bit off_t on 32bit systems using glibc +- if(CMAKE_SIZEOF_VOID_P EQUAL 4) +- add_compile_definitions(_FILE_OFFSET_BITS=64) +- list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64") +- endif() ++# enable 64bit off_t on 32bit systems using glibc ++if(LLVM_USING_GLIBC AND CMAKE_SIZEOF_VOID_P EQUAL 4) ++ add_compile_definitions(_FILE_OFFSET_BITS=64) ++ list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D_FILE_OFFSET_BITS=64") + endif() + + # include checks +-- +2.49.0.windows.1 + diff --git a/llvm/0102-Clang-Cygwin-Enable-few-conditions-that-are-shared-w.patch b/llvm/0102-Clang-Cygwin-Enable-few-conditions-that-are-shared-w.patch index e1193370..4bf0c506 100644 --- a/llvm/0102-Clang-Cygwin-Enable-few-conditions-that-are-shared-w.patch +++ b/llvm/0102-Clang-Cygwin-Enable-few-conditions-that-are-shared-w.patch @@ -1,8 +1,8 @@ -From c7773978fb0c3d9d1f976d219543c4fa189939c0 Mon Sep 17 00:00:00 2001 +From 03c850993ecc5aa7e892bb14ac152bd209755a94 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 03/15] [Clang][Cygwin] Enable few conditions that are shared - with MinGW +Subject: [PATCH] [Clang][Cygwin] Enable few conditions that are shared with + MinGW --- clang/lib/AST/RecordLayoutBuilder.cpp | 2 +- @@ -16,7 +16,7 @@ Subject: [PATCH 03/15] [Clang][Cygwin] Enable few conditions that are shared 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/clang/lib/AST/RecordLayoutBuilder.cpp b/clang/lib/AST/RecordLayoutBuilder.cpp -index ae6d29902..b0a19ea55 100644 +index ae6d299024..b0a19ea55d 100644 --- a/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1946,7 +1946,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, @@ -29,7 +29,7 @@ index ae6d29902..b0a19ea55 100644 } if (TypeSize > FieldAlign && diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp -index eb8d3ceee..2dddfb31e 100644 +index eb8d3ceeeb..2dddfb31e4 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -1671,7 +1671,7 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, @@ -42,7 +42,7 @@ index eb8d3ceee..2dddfb31e 100644 // 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 7c463f51f..7e8369207 100644 +index 7c463f51f6..7e83692075 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3749,7 +3749,7 @@ static bool ShouldUseExternalRTTIDescriptor(CodeGenModule &CGM, @@ -64,7 +64,7 @@ index 7c463f51f..7e8369207 100644 } diff --git a/clang/lib/CodeGen/Targets/X86.cpp b/clang/lib/CodeGen/Targets/X86.cpp -index 5ee5179dd..c446add08 100644 +index 5ee5179dd0..c446add081 100644 --- a/clang/lib/CodeGen/Targets/X86.cpp +++ b/clang/lib/CodeGen/Targets/X86.cpp @@ -1374,7 +1374,7 @@ class WinX86_64ABIInfo : public ABIInfo { @@ -77,7 +77,7 @@ index 5ee5179dd..c446add08 100644 void computeInfo(CGFunctionInfo &FI) const override; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp -index acf9d264d..e9d1d3534 100644 +index acf9d264d6..e9d1d3534e 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -749,7 +749,7 @@ std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args, @@ -90,7 +90,7 @@ index acf9d264d..e9d1d3534 100644 break; } diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp -index 41d5f9f2f..8ee89e1fe 100644 +index 41d5f9f2f3..8ee89e1feb 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -12516,7 +12516,7 @@ static bool isDefaultStdCall(FunctionDecl *FD, Sema &S) { @@ -103,7 +103,7 @@ index 41d5f9f2f..8ee89e1fe 100644 // Default calling convention for WinMain, wWinMain and DllMain diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp -index 85de46c9a..899a34fe9 100644 +index 85de46c9ad..899a34fe9c 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -6163,7 +6163,7 @@ static void ReferenceDllExportedMembers(Sema &S, CXXRecordDecl *Class) { @@ -125,7 +125,7 @@ index 85de46c9a..899a34fe9 100644 return; } diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp -index 1c555b382..59a70e15f 100644 +index 1c555b3827..59a70e15f9 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -8936,7 +8936,7 @@ Sema::CheckSpecializationInstantiationRedecl(SourceLocation NewLoc, diff --git a/llvm/0103-Clang-Cygwin-Enable-TLS.patch b/llvm/0103-Clang-Cygwin-Enable-TLS.patch index 7fc70d7a..ba2bad8f 100644 --- a/llvm/0103-Clang-Cygwin-Enable-TLS.patch +++ b/llvm/0103-Clang-Cygwin-Enable-TLS.patch @@ -1,14 +1,14 @@ -From 968f83c4bca36abe454b3a0ee82dff3b6a505641 Mon Sep 17 00:00:00 2001 +From 75cb38667c46ab586fa947aafee9189232b701c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Sat, 8 Feb 2025 01:23:32 +0100 -Subject: [PATCH 04/15] [Clang][Cygwin] Enable TLS +Subject: [PATCH] [Clang][Cygwin] Enable TLS --- clang/lib/Basic/Targets/X86.h | 1 - 1 file changed, 1 deletion(-) diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h -index 8bd54e362..05c40d001 100644 +index 8bd54e3625..05c40d0014 100644 --- a/clang/lib/Basic/Targets/X86.h +++ b/clang/lib/Basic/Targets/X86.h @@ -948,7 +948,6 @@ public: diff --git a/llvm/0104-Clang-Cygwin-Fix-symbol-visibility-definition-138118.patch b/llvm/0104-Clang-Cygwin-Fix-symbol-visibility-definition-138118.patch new file mode 100644 index 00000000..ebf35207 --- /dev/null +++ b/llvm/0104-Clang-Cygwin-Fix-symbol-visibility-definition-138118.patch @@ -0,0 +1,36 @@ +From f087a8c88fd3a3e869224f93e92919e08217e35c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= +Date: Fri, 2 May 2025 10:01:37 +0200 +Subject: [PATCH] [Clang][Cygwin] Fix symbol visibility definition (#138118) +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 5a74f8e3b6..e1ae3eda4c 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 +-- +2.49.0.windows.1 + diff --git a/llvm/0104-Clang-Cygwin-Fix-symbol-visibility-definition.patch b/llvm/0104-Clang-Cygwin-Fix-symbol-visibility-definition.patch deleted file mode 100644 index 8597df5d..00000000 --- a/llvm/0104-Clang-Cygwin-Fix-symbol-visibility-definition.patch +++ /dev/null @@ -1,25 +0,0 @@ -From b939f9bd3edfaf513fcd5d90a5d02813408b6297 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 05/15] [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 5a74f8e3b..e1ae3eda4 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 --- -2.49.0.windows.1 - diff --git a/llvm/0106-disable-shared-libs-on-Cygwin-by-default.patch b/llvm/0106-Clang-Cygwin-Disable-shared-libs-on-Cygwin-by-defaul.patch similarity index 66% rename from llvm/0106-disable-shared-libs-on-Cygwin-by-default.patch rename to llvm/0106-Clang-Cygwin-Disable-shared-libs-on-Cygwin-by-defaul.patch index 0d8ecaad..a42d5596 100644 --- a/llvm/0106-disable-shared-libs-on-Cygwin-by-default.patch +++ b/llvm/0106-Clang-Cygwin-Disable-shared-libs-on-Cygwin-by-defaul.patch @@ -1,15 +1,24 @@ -From 9dd7a39cf803e4e2c3c09d9e84885041f621d4b4 Mon Sep 17 00:00:00 2001 +From b689d830aa9a662fe0fd565912b9783a36087b8d 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 07/15] disable shared libs on Cygwin by default +Date: Fri, 2 May 2025 10:02:11 +0200 +Subject: [PATCH] [Clang][Cygwin] Disable shared libs on Cygwin by default + (#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 +``` + +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 98c018e96..a12bb7443 100644 +index 98c018e968..0446853901 100644 --- a/clang/tools/CMakeLists.txt +++ b/clang/tools/CMakeLists.txt @@ -21,9 +21,10 @@ endif() @@ -17,16 +26,16 @@ index 98c018e96..a12bb7443 100644 add_clang_subdirectory(clang-refactor) -# For MinGW we only enable shared library if LLVM_LINK_LLVM_DYLIB=ON. -+# For Cygwin/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 -+ ((CYGWIN OR MINGW) AND LLVM_LINK_LLVM_DYLIB)) ++ ((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 00a1223c0..84ced23f1 100644 +index 00a1223c08..84ced23f17 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -111,7 +111,8 @@ if (LLVM_EXPORTED_SYMBOL_FILE) diff --git a/llvm/0107-Clang-Cygwin-Remove-erroneous-_WIN32-define-and-clea.patch b/llvm/0107-Clang-Cygwin-Remove-erroneous-_WIN32-define-and-clea.patch new file mode 100644 index 00000000..b8679ab6 --- /dev/null +++ b/llvm/0107-Clang-Cygwin-Remove-erroneous-_WIN32-define-and-clea.patch @@ -0,0 +1,75 @@ +From f41ed3315c708bb286babe790c9b7afc6bc47bf8 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= +Date: Fri, 2 May 2025 10:07:15 +0200 +Subject: [PATCH] [Clang][Cygwin] Remove erroneous _WIN32 define and clean up + Cygwin code (#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. + +The "#define _WIN32" was originally "#define LLVM_ON_WIN32", but this +was changed into a plain "#define _WIN32" (which not necessarily is +something that is supported to do) in +1865df49960e34cc90d0083b0e0cd4771c0feb35 as part of a larger +refactoring. + +This cygwin specific code isn't needed for converting paths anymore, as +dladdr takes care of it. (dladdr was added to cygwin in 2017, according +to the tags in version 2.8.0.) + +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 12d9d418de..11d9312b64 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); +-- +2.49.0.windows.1 + diff --git a/llvm/0107-Clang-Cygwin-Remove-erroneous-define.patch b/llvm/0107-Clang-Cygwin-Remove-erroneous-define.patch deleted file mode 100644 index aded1391..00000000 --- a/llvm/0107-Clang-Cygwin-Remove-erroneous-define.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 3c239ebd42bd85701da3e35b836695300c523f5a 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 08/15] [Clang][Cygwin] Remove erroneous define - ---- - clang/tools/libclang/CIndexer.cpp | 17 ----------------- - 1 file changed, 17 deletions(-) - -diff --git a/clang/tools/libclang/CIndexer.cpp b/clang/tools/libclang/CIndexer.cpp -index 12d9d418d..553545e80 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) -@@ -111,17 +105,6 @@ const std::string &CIndexer::getClangResourcesPath() { - VirtualQuery((void *)(uintptr_t)clang_createTranslationUnit, &mbi, - 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); --- -2.49.0.windows.1 - diff --git a/llvm/0108-Clang-Cygwin-dont-use-Bsymbolic-functions.patch b/llvm/0108-Clang-Cygwin-don-t-use-Bsymbolic-functions-138217.patch similarity index 66% rename from llvm/0108-Clang-Cygwin-dont-use-Bsymbolic-functions.patch rename to llvm/0108-Clang-Cygwin-don-t-use-Bsymbolic-functions-138217.patch index 43939f4d..42a72fd0 100644 --- a/llvm/0108-Clang-Cygwin-dont-use-Bsymbolic-functions.patch +++ b/llvm/0108-Clang-Cygwin-don-t-use-Bsymbolic-functions-138217.patch @@ -1,14 +1,16 @@ -From e2a425d684c80eab0570022d87f2d3bd5326a2b6 Mon Sep 17 00:00:00 2001 -From: Jeremy Drake -Date: Sun, 13 Apr 2025 22:38:38 -0700 -Subject: [PATCH 09/15] [Clang] [Cygwin] don't use -Bsymbolic-functions +From 780619aa01f26564fea84de1f4364213c2fd1149 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Sat, 3 May 2025 14:33:54 -0700 +Subject: [PATCH] [Clang][Cygwin] don't use -Bsymbolic-functions (#138217) +GNU ld seems to ignore this option, but LLD treats the presence of this +unknown option as an error. --- clang/tools/clang-shlib/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt -index 31484ec49..317964de4 100644 +index 31484ec49c..317964de4f 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -57,7 +57,7 @@ endif() diff --git a/llvm/0109-hack-cygwin-allow-multiple-definition-c-index-test.patch b/llvm/0109-hack-cygwin-allow-multiple-definition-c-index-test.patch index 7a7a7247..5efb811c 100644 --- a/llvm/0109-hack-cygwin-allow-multiple-definition-c-index-test.patch +++ b/llvm/0109-hack-cygwin-allow-multiple-definition-c-index-test.patch @@ -1,14 +1,14 @@ -From a30e4b23adb1f845980c3d4dcc573556780e23e8 Mon Sep 17 00:00:00 2001 +From afbbefc26eda92ef5ec0aee7cb7658d75cb15195 Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Sun, 13 Apr 2025 22:39:46 -0700 -Subject: [PATCH 10/15] hack: cygwin: allow multiple definition in c-index-test +Subject: [PATCH] hack: cygwin: allow multiple definition in c-index-test --- clang/tools/c-index-test/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/clang/tools/c-index-test/CMakeLists.txt b/clang/tools/c-index-test/CMakeLists.txt -index 24e7c9692..3858fe547 100644 +index 24e7c9692c..3858fe5478 100644 --- a/clang/tools/c-index-test/CMakeLists.txt +++ b/clang/tools/c-index-test/CMakeLists.txt @@ -31,6 +31,10 @@ else() diff --git a/llvm/0110-Clang-Driver-add-a-Cygwin-ToolChain.patch b/llvm/0110-Clang-Driver-add-a-Cygwin-ToolChain.patch index c2db9391..fc7983d0 100644 --- a/llvm/0110-Clang-Driver-add-a-Cygwin-ToolChain.patch +++ b/llvm/0110-Clang-Driver-add-a-Cygwin-ToolChain.patch @@ -1,7 +1,7 @@ -From 0d70b24e4a9054e9b3ee52a4b63a783b8890d732 Mon Sep 17 00:00:00 2001 +From 570f3059308bb24f5a6f8817e91ab3f8985cf576 Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Mon, 14 Apr 2025 10:37:59 -0700 -Subject: [PATCH 13/15] [Clang] [Driver] add a Cygwin ToolChain +Subject: [PATCH] [Clang] [Driver] add a Cygwin ToolChain Add a new Cygwin toolchain that just goes through the motions to initialize the Generic_GCC base properly. This allows removing some @@ -21,7 +21,7 @@ Signed-off-by: Jeremy Drake create mode 100644 clang/lib/Driver/ToolChains/Cygwin.h diff --git a/clang/lib/Driver/CMakeLists.txt b/clang/lib/Driver/CMakeLists.txt -index 5bdb66143..e72525e99 100644 +index 5bdb661438..e72525e99d 100644 --- a/clang/lib/Driver/CMakeLists.txt +++ b/clang/lib/Driver/CMakeLists.txt @@ -51,6 +51,7 @@ add_clang_library(clangDriver @@ -33,7 +33,7 @@ index 5bdb66143..e72525e99 100644 ToolChains/DragonFly.cpp ToolChains/Flang.cpp diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp -index 87855fdb7..c5c2af6eb 100644 +index 87855fdb79..c5c2af6eb2 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -17,6 +17,7 @@ @@ -56,7 +56,7 @@ index 87855fdb7..c5c2af6eb 100644 Args); diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp b/clang/lib/Driver/ToolChains/Cygwin.cpp new file mode 100644 -index 000000000..c310f096a +index 0000000000..c310f096a5 --- /dev/null +++ b/clang/lib/Driver/ToolChains/Cygwin.cpp @@ -0,0 +1,109 @@ @@ -171,7 +171,7 @@ index 000000000..c310f096a +} diff --git a/clang/lib/Driver/ToolChains/Cygwin.h b/clang/lib/Driver/ToolChains/Cygwin.h new file mode 100644 -index 000000000..a4c0ee86a +index 0000000000..a4c0ee86a3 --- /dev/null +++ b/clang/lib/Driver/ToolChains/Cygwin.h @@ -0,0 +1,36 @@ @@ -212,7 +212,7 @@ index 000000000..a4c0ee86a + +#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Cygwin_H diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp -index f56eeda3c..e9fdfeea2 100644 +index f56eeda3cb..e9fdfeea27 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -2630,6 +2630,27 @@ void Generic_GCC::GCCInstallationDetector::AddDefaultGCCPrefixes( @@ -244,7 +244,7 @@ index f56eeda3c..e9fdfeea2 100644 case llvm::Triple::aarch64: LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs)); diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp -index bb2a21356..45bca1834 100644 +index bb2a21356f..45bca1834e 100644 --- a/clang/lib/Lex/InitHeaderSearch.cpp +++ b/clang/lib/Lex/InitHeaderSearch.cpp @@ -74,20 +74,10 @@ public: diff --git a/llvm/0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.patch b/llvm/0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.-.patch similarity index 91% rename from llvm/0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.patch rename to llvm/0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.-.patch index d5526e4c..76c9a71e 100644 --- a/llvm/0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.patch +++ b/llvm/0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.-.patch @@ -1,20 +1,19 @@ -From a86450e05d96df7e1b33672319beff3e0fa0d81f Mon Sep 17 00:00:00 2001 -From: Jeremy Drake -Date: Mon, 14 Apr 2025 14:43:42 -0700 -Subject: [PATCH 15/15] [Clang] [Driver] use __cxa_atexit by default on Cygwin. +From 20d499bf8e25d8527c14ebc9fdf517a3e39ba3e6 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Tue, 22 Apr 2025 23:48:08 -0700 +Subject: [PATCH] [Clang] [Driver] use __cxa_atexit by default on Cygwin. + (#135701) GCC on Cygwin and MSYS2 are built with --enable-__cxa_atexit. Adjust test to expect this change. - -Signed-off-by: Jeremy Drake --- clang/lib/Driver/ToolChains/Clang.cpp | 4 +++- clang/test/Driver/cxa-atexit.cpp | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp -index 57b7d2bd4..f8b4267b9 100644 +index 57b7d2bd46..f8b4267b94 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7230,7 +7230,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, @@ -29,7 +28,7 @@ index 57b7d2bd4..f8b4267b9 100644 RawTriple.hasEnvironment())) || KernelOrKext) diff --git a/clang/test/Driver/cxa-atexit.cpp b/clang/test/Driver/cxa-atexit.cpp -index 537a11a35..8bfb938e8 100644 +index 537a11a35f..8bfb938e8e 100644 --- a/clang/test/Driver/cxa-atexit.cpp +++ b/clang/test/Driver/cxa-atexit.cpp @@ -1,15 +1,15 @@ diff --git a/llvm/0112-hack-cygwin-define-_GLIBCXX_USE_CXX11_ABI-to-1-if-no.patch b/llvm/0112-hack-cygwin-define-_GLIBCXX_USE_CXX11_ABI-to-1-if-no.patch index 2f63cf4d..e37653ae 100644 --- a/llvm/0112-hack-cygwin-define-_GLIBCXX_USE_CXX11_ABI-to-1-if-no.patch +++ b/llvm/0112-hack-cygwin-define-_GLIBCXX_USE_CXX11_ABI-to-1-if-no.patch @@ -1,7 +1,7 @@ -From 7dc5554735c44e61e0fb080c7e2ec91d6e540274 Mon Sep 17 00:00:00 2001 +From 75a3a36f652b5711e0748fcbd5df1e082190a484 Mon Sep 17 00:00:00 2001 From: Jeremy Drake Date: Wed, 16 Apr 2025 12:02:07 -0700 -Subject: [PATCH 15/15] hack: cygwin: define _GLIBCXX_USE_CXX11_ABI to 1 if not +Subject: [PATCH] hack: cygwin: define _GLIBCXX_USE_CXX11_ABI to 1 if not previously defined work around llvm/llvm-project#135910 @@ -12,7 +12,7 @@ see also msys2/MSYS2-packages#5329 2 files changed, 22 insertions(+) diff --git a/clang/lib/Driver/ToolChains/Cygwin.cpp b/clang/lib/Driver/ToolChains/Cygwin.cpp -index c310f096a..5a040be64 100644 +index c310f096a5..5a040be641 100644 --- a/clang/lib/Driver/ToolChains/Cygwin.cpp +++ b/clang/lib/Driver/ToolChains/Cygwin.cpp @@ -107,3 +107,20 @@ void Cygwin::AddClangSystemIncludeArgs(const ArgList &DriverArgs, @@ -37,7 +37,7 @@ index c310f096a..5a040be64 100644 + CC1Args.push_back("-D_GLIBCXX_USE_CXX11_ABI=1"); +} diff --git a/clang/lib/Driver/ToolChains/Cygwin.h b/clang/lib/Driver/ToolChains/Cygwin.h -index a4c0ee86a..1fa358c7c 100644 +index a4c0ee86a3..1fa358c7cc 100644 --- a/clang/lib/Driver/ToolChains/Cygwin.h +++ b/clang/lib/Driver/ToolChains/Cygwin.h @@ -27,6 +27,11 @@ public: diff --git a/llvm/0201-LLD-MinGW-Implement-dll-search-prefix-option.patch b/llvm/0201-LLD-MinGW-Implement-dll-search-prefix-option.patch index 95d4f93a..008e3587 100644 --- a/llvm/0201-LLD-MinGW-Implement-dll-search-prefix-option.patch +++ b/llvm/0201-LLD-MinGW-Implement-dll-search-prefix-option.patch @@ -1,7 +1,7 @@ -From b9a6840626dc9b5901848ed65cd80cc2b9c02655 Mon Sep 17 00:00:00 2001 +From 436fce72a0bd3715a0138f59ce13f37162ce977b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Miku=C5=82a?= Date: Fri, 7 Feb 2025 22:28:12 +0100 -Subject: [PATCH 11/15] [LLD][MinGW] Implement --dll-search-prefix option +Subject: [PATCH] [LLD][MinGW] Implement --dll-search-prefix option --- lld/MinGW/Driver.cpp | 17 ++++++++++++++--- @@ -9,7 +9,7 @@ Subject: [PATCH 11/15] [LLD][MinGW] Implement --dll-search-prefix option 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp -index a77d86b44..131bacdf1 100644 +index a77d86b443..131bacdf14 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -139,8 +139,9 @@ static std::optional findFile(StringRef path1, @@ -58,7 +58,7 @@ index a77d86b44..131bacdf1 100644 case OPT_whole_archive: prefix = "-wholearchive:"; diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td -index 01b019721..d3ee67922 100644 +index 01b0197211..d3ee679221 100644 --- a/lld/MinGW/Options.td +++ b/lld/MinGW/Options.td @@ -65,6 +65,8 @@ def disable_runtime_pseudo_reloc: F<"disable-runtime-pseudo-reloc">, diff --git a/llvm/0203-LLD-COFF-add-__-data-bss-_-start-end-__-symbols-for-.patch b/llvm/0203-LLD-COFF-add-__-data-bss-_-start-end-__-symbols-for-.patch index 7db17eb2..b05d4e74 100644 --- a/llvm/0203-LLD-COFF-add-__-data-bss-_-start-end-__-symbols-for-.patch +++ b/llvm/0203-LLD-COFF-add-__-data-bss-_-start-end-__-symbols-for-.patch @@ -1,21 +1,30 @@ -From 6a552fa2d904773ac0b9aa1f11ccf642b96f8dd2 Mon Sep 17 00:00:00 2001 -From: Jeremy Drake -Date: Sun, 13 Apr 2025 22:41:05 -0700 -Subject: [PATCH 11/15] [LLD][COFF] add __{data,bss}_{start,end}__ symbols for - Cygwin support +From fdd77991d204abd6a4a67132130e5e7256752dde Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Fri, 2 May 2025 00:58:14 -0700 +Subject: [PATCH] [LLD][COFF] add __{data,bss}_{start,end}__ symbols for Cygwin + support (#136180) Cygwin requires these symbols for its fork emulation to know what data -to copy into the child. GNU ld defines these symbols for MinGW targets +to copy into the child. GNU ld defines these symbols for MinGW targets also, so do the same here. +Cygwin also has the `.data_cygwin_nocopy` section, which is merged into +`.data` outside the `__data_start__` to `__data_end__` range. This +excludes it from fork's copying. AFAIK it's only used by the Cygwin DLL +itself (which requires a custom linker script to link, that's not +supported by LLD), but the section is included in GNU ld's default +linker script so handle it here too. + Signed-off-by: Jeremy Drake --- - lld/COFF/Driver.cpp | 5 +++++ - lld/COFF/Writer.cpp | 33 +++++++++++++++++++++++++++++++-- - 2 files changed, 36 insertions(+), 2 deletions(-) + lld/COFF/Driver.cpp | 5 ++ + lld/COFF/Writer.cpp | 33 +++++++++++- + lld/test/COFF/cygwin-symbols.s | 99 ++++++++++++++++++++++++++++++++++ + 3 files changed, 135 insertions(+), 2 deletions(-) + create mode 100644 lld/test/COFF/cygwin-symbols.s diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp -index ac3ac57bd..fa882f883 100644 +index ac3ac57bd1..fa882f883d 100644 --- a/lld/COFF/Driver.cpp +++ b/lld/COFF/Driver.cpp @@ -2018,6 +2018,7 @@ void LinkerDriver::linkerMain(ArrayRef argsArr) { @@ -38,10 +47,10 @@ index ac3ac57bd..fa882f883 100644 if (config->debug || config->buildIDHash != BuildIDHash::None) if (symtab.findUnderscore("__buildid")) diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp -index 2bdaeb58a..41973a245 100644 +index 28c10ad1f6..083d4e1ecc 100644 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp -@@ -239,6 +239,7 @@ private: +@@ -240,6 +240,7 @@ private: void createRuntimePseudoRelocs(); void createECChunks(); void insertCtorDtorSymbols(); @@ -49,7 +58,7 @@ index 2bdaeb58a..41973a245 100644 void markSymbolsWithRelocations(ObjFile *file, SymbolRVASet &usedSymbols); void createGuardCFTables(); void markSymbolsForRVATable(ObjFile *file, -@@ -314,6 +315,7 @@ private: +@@ -315,6 +316,7 @@ private: OutputSection *textSec; OutputSection *hexpthkSec; @@ -57,7 +66,7 @@ index 2bdaeb58a..41973a245 100644 OutputSection *rdataSec; OutputSection *buildidSec; OutputSection *dataSec; -@@ -1068,7 +1070,7 @@ void Writer::createSections() { +@@ -1069,7 +1071,7 @@ void Writer::createSections() { textSec = createSection(".text", code | r | x); if (isArm64EC(ctx.config.machine)) hexpthkSec = createSection(".hexpthk", code | r | x); @@ -66,7 +75,7 @@ index 2bdaeb58a..41973a245 100644 rdataSec = createSection(".rdata", data | r); buildidSec = createSection(".buildid", data | r); dataSec = createSection(".data", data | r | w); -@@ -1242,8 +1244,10 @@ void Writer::createMiscChunks() { +@@ -1243,8 +1245,10 @@ void Writer::createMiscChunks() { if (config->autoImport) createRuntimePseudoRelocs(); @@ -78,7 +87,7 @@ index 2bdaeb58a..41973a245 100644 } // Create .idata section for the DLL-imported symbol table. -@@ -2334,6 +2338,31 @@ void Writer::insertCtorDtorSymbols() { +@@ -2347,6 +2351,31 @@ void Writer::insertCtorDtorSymbols() { dtorListHead); } @@ -110,6 +119,111 @@ index 2bdaeb58a..41973a245 100644 // Handles /section options to allow users to overwrite // section attributes. void Writer::setSectionPermissions() { +diff --git a/lld/test/COFF/cygwin-symbols.s b/lld/test/COFF/cygwin-symbols.s +new file mode 100644 +index 0000000000..d1aec42784 +--- /dev/null ++++ b/lld/test/COFF/cygwin-symbols.s +@@ -0,0 +1,99 @@ ++# REQUIRES: x86 ++# RUN: split-file %s %t.dir && cd %t.dir ++ ++# RUN: llvm-mc -triple=x86_64-windows-cygnus -filetype=obj -o data-no-bss.obj data-no-bss.s ++# RUN: lld-link -lldmingw -entry:main data-no-bss.obj -out:data-no-bss.exe ++# RUN: llvm-objdump -s data-no-bss.exe | FileCheck --check-prefix=DATANOBSS %s ++ ++# RUN: llvm-mc -triple=x86_64-windows-cygnus -filetype=obj -o bss-no-data.obj bss-no-data.s ++# RUN: lld-link -lldmingw -entry:main bss-no-data.obj -out:bss-no-data.exe ++# RUN: llvm-objdump -s bss-no-data.exe | FileCheck --check-prefix=BSSNODATA %s ++ ++# RUN: llvm-mc -triple=x86_64-windows-cygnus -filetype=obj -o data-and-bss.obj data-and-bss.s ++# RUN: lld-link -lldmingw -entry:main data-and-bss.obj -out:data-and-bss.exe ++# RUN: llvm-objdump -s data-and-bss.exe | FileCheck --check-prefix=DATAANDBSS %s ++ ++#--- data-no-bss.s ++.globl main ++main: ++ nop ++ ++.data ++ .quad 1 ++ .byte 2 ++ ++.section .data_cygwin_nocopy, "w" ++ .align 4 ++ .quad 3 ++ .byte 4 ++ ++.section .test, "w" ++ .quad __data_start__ ++ .quad __data_end__ ++ .quad __bss_start__ ++ .quad __bss_end__ ++ ++#--- bss-no-data.s ++.globl main ++main: ++ nop ++ ++.bss ++ .zero 8192 ++ ++.section .test, "w" ++ .quad __data_start__ ++ .quad __data_end__ ++ .quad __bss_start__ ++ .quad __bss_end__ ++ ++#--- data-and-bss.s ++.globl main ++main: ++ nop ++ ++.data ++ .quad 1 ++ .byte 2 ++ ++.section .data_cygwin_nocopy, "w" ++ .align 4 ++ .quad 3 ++ .byte 4 ++ ++.bss ++ .zero 8192 ++ ++.section .test, "w" ++ .quad __data_start__ ++ .quad __data_end__ ++ .quad __bss_start__ ++ .quad __bss_end__ ++ ++# DATANOBSS: Contents of section .data: ++# DATANOBSS-NEXT: 140003000 01000000 00000000 02000000 03000000 ++# DATANOBSS-NEXT: 140003010 00000000 04 ++# __data_start__ pointing at 0x140003000 and ++# __data_end__ pointing at 0x140003009. ++# DATANOBSS-NEXT: Contents of section .test: ++# DATANOBSS-NEXT: 140004000 00300040 01000000 09300040 01000000 ++# DATANOBSS-NEXT: 140004010 18300040 01000000 18300040 01000000 ++ ++# __bss_start__ pointing at 0x140003000 and ++# __bss_end__ pointing at 0x140005000. ++# BSSNODATA-NOT: Contents of section .data: ++# BSSNODATA: Contents of section .test: ++# BSSNODATA-NEXT: 140005000 00300040 01000000 00300040 01000000 ++# BSSNODATA-NEXT: 140005010 00300040 01000000 00500040 01000000 ++ ++# DATAANDBSS: Contents of section .data: ++# DATAANDBSS-NEXT: 140003000 01000000 00000000 02000000 03000000 ++# DATAANDBSS-NEXT: 140003010 00000000 04000000 00000000 00000000 ++# __data_start__ pointing at 0x140003000 and ++# __data_end__ pointing at 0x140003009. ++# __bss_start__ pointing at 0x140003018 and ++# __bss_end__ pointing at 0x140005018. ++# DATAANDBSS: 1400031f0 00000000 00000000 00000000 00000000 ++# DATAANDBSS-NEXT: Contents of section .test: ++# DATAANDBSS-NEXT: 140006000 00300040 01000000 09300040 01000000 ++# DATAANDBSS-NEXT: 140006010 18300040 01000000 18500040 01000000 -- 2.49.0.windows.1 diff --git a/llvm/0204-LLD-MinGW-Fall-back-to-using-default-target-if-no-m-.patch b/llvm/0204-LLD-MinGW-Fall-back-to-using-default-target-if-no-m-.patch index a9a4dce5..25a1132d 100644 --- a/llvm/0204-LLD-MinGW-Fall-back-to-using-default-target-if-no-m-.patch +++ b/llvm/0204-LLD-MinGW-Fall-back-to-using-default-target-if-no-m-.patch @@ -1,11 +1,11 @@ -From 9c31a1121f6e9fb489acf707ff249a8e9156f6ae Mon Sep 17 00:00:00 2001 -From: Jeremy Drake -Date: Mon, 7 Apr 2025 11:07:04 -0700 -Subject: [PATCH 13/15] [LLD] [MinGW] Fall back to using default target if no - -m flag given. +From da6667ef9a087a8738867fac9a8f070c5bbda88d Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Thu, 10 Apr 2025 14:20:10 -0700 +Subject: [PATCH] [LLD] [MinGW] Fall back to using default target if no -m flag + given. (#134700) -On Cygwin at least, GCC is not pasing any -m flag to the linker, so fall -back to the default target triple to determine if we need to apply +On Cygwin at least, GCC is not passing any -m flag to the linker, so +fall back to the default target triple to determine if we need to apply i386-specific behaviors. Fixes #134558 @@ -14,7 +14,7 @@ Fixes #134558 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp -index 131bacdf1..76b5fdf0c 100644 +index 131bacdf14..76b5fdf0c3 100644 --- a/lld/MinGW/Driver.cpp +++ b/lld/MinGW/Driver.cpp @@ -177,6 +177,14 @@ static std::string searchLibrary(StringRef name, diff --git a/llvm/0205-LLD-COFF-Ensure-.bss-is-merged-at-the-end-of-a-secti.patch b/llvm/0205-LLD-COFF-Ensure-.bss-is-merged-at-the-end-of-a-secti.patch new file mode 100644 index 00000000..e5d547a0 --- /dev/null +++ b/llvm/0205-LLD-COFF-Ensure-.bss-is-merged-at-the-end-of-a-secti.patch @@ -0,0 +1,197 @@ +From bddcc28756f453ef0a6e3b334f0daa41a854f940 Mon Sep 17 00:00:00 2001 +From: jeremyd2019 +Date: Wed, 30 Apr 2025 02:09:20 -0700 +Subject: [PATCH] [LLD][COFF] Ensure .bss is merged at the end of a section. + (#137677) + +Because it is full of zeros, it is expected that as much of it as +possible is elided from the actual image, and that cannot happen if +there is initialized data in the section after it. +--- + lld/COFF/Writer.cpp | 55 +++++++++++------- + lld/test/COFF/merge-data-bss.test | 92 +++++++++++++++++++++++++++++++ + 2 files changed, 126 insertions(+), 21 deletions(-) + create mode 100644 lld/test/COFF/merge-data-bss.test + +diff --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp +index 2bdaeb58ab..28c10ad1f6 100644 +--- a/lld/COFF/Writer.cpp ++++ b/lld/COFF/Writer.cpp +@@ -215,6 +215,7 @@ private: + void appendImportThunks(); + void locateImportTables(); + void createExportTable(); ++ void mergeSection(const std::map::value_type &p); + void mergeSections(); + void sortECChunks(); + void appendECImportTables(); +@@ -1547,6 +1548,30 @@ void Writer::createSymbolAndStringTable() { + fileSize = alignTo(fileOff, ctx.config.fileAlign); + } + ++void Writer::mergeSection(const std::map::value_type &p) { ++ StringRef toName = p.second; ++ if (p.first == toName) ++ return; ++ StringSet<> names; ++ while (true) { ++ if (!names.insert(toName).second) ++ Fatal(ctx) << "/merge: cycle found for section '" << p.first << "'"; ++ auto i = ctx.config.merge.find(toName); ++ if (i == ctx.config.merge.end()) ++ break; ++ toName = i->second; ++ } ++ OutputSection *from = findSection(p.first); ++ OutputSection *to = findSection(toName); ++ if (!from) ++ return; ++ if (!to) { ++ from->name = toName; ++ return; ++ } ++ to->merge(from); ++} ++ + void Writer::mergeSections() { + llvm::TimeTraceScope timeScope("Merge sections"); + if (!pdataSec->chunks.empty()) { +@@ -1575,28 +1600,16 @@ void Writer::mergeSections() { + } + + for (auto &p : ctx.config.merge) { +- StringRef toName = p.second; +- if (p.first == toName) +- continue; +- StringSet<> names; +- while (true) { +- if (!names.insert(toName).second) +- Fatal(ctx) << "/merge: cycle found for section '" << p.first << "'"; +- auto i = ctx.config.merge.find(toName); +- if (i == ctx.config.merge.end()) +- break; +- toName = i->second; +- } +- OutputSection *from = findSection(p.first); +- OutputSection *to = findSection(toName); +- if (!from) +- continue; +- if (!to) { +- from->name = toName; +- continue; +- } +- to->merge(from); ++ if (p.first != ".bss") ++ mergeSection(p); + } ++ ++ // Because .bss contains all zeros, it should be merged at the end of ++ // whatever section it is being merged into (usually .data) so that the image ++ // need not actually contain all of the zeros. ++ auto it = ctx.config.merge.find(".bss"); ++ if (it != ctx.config.merge.end()) ++ mergeSection(*it); + } + + // EC targets may have chunks of various architectures mixed together at this +diff --git a/lld/test/COFF/merge-data-bss.test b/lld/test/COFF/merge-data-bss.test +new file mode 100644 +index 0000000000..a821f8d6e9 +--- /dev/null ++++ b/lld/test/COFF/merge-data-bss.test +@@ -0,0 +1,92 @@ ++# RUN: yaml2obj %s -o %t.obj ++# RUN: lld-link /out:%t.exe /entry:main /subsystem:console /force \ ++# RUN: /merge:.other=.data %t.obj /debug ++# RUN: llvm-readobj --sections %t.exe | FileCheck %s ++ ++# CHECK: Name: .data ++# CHECK-NEXT: VirtualSize: 0x2018 ++# CHECK-NEXT: VirtualAddress: 0x3000 ++# CHECK-NEXT: RawDataSize: 512 ++# CHECK-NOT: Name: .other ++ ++--- !COFF ++header: ++ Machine: IMAGE_FILE_MACHINE_AMD64 ++ Characteristics: [ ] ++sections: ++ - Name: .text ++ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] ++ Alignment: 4 ++ SectionData: '90' ++ SizeOfRawData: 1 ++ - Name: .data ++ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] ++ Alignment: 4 ++ SectionData: '010000000000000002' ++ SizeOfRawData: 9 ++ - Name: .bss ++ Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] ++ Alignment: 4 ++ SectionData: '' ++ SizeOfRawData: 8192 ++ - Name: .other ++ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] ++ Alignment: 4 ++ SectionData: '030000000000000004' ++ SizeOfRawData: 9 ++symbols: ++ - Name: .text ++ Value: 0 ++ SectionNumber: 1 ++ SimpleType: IMAGE_SYM_TYPE_NULL ++ ComplexType: IMAGE_SYM_DTYPE_NULL ++ StorageClass: IMAGE_SYM_CLASS_STATIC ++ SectionDefinition: ++ Length: 1 ++ NumberOfRelocations: 0 ++ NumberOfLinenumbers: 0 ++ CheckSum: 4027552580 ++ Number: 1 ++ - Name: .data ++ Value: 0 ++ SectionNumber: 2 ++ SimpleType: IMAGE_SYM_TYPE_NULL ++ ComplexType: IMAGE_SYM_DTYPE_NULL ++ StorageClass: IMAGE_SYM_CLASS_STATIC ++ SectionDefinition: ++ Length: 9 ++ NumberOfRelocations: 0 ++ NumberOfLinenumbers: 0 ++ CheckSum: 4185224559 ++ Number: 2 ++ - Name: .bss ++ Value: 0 ++ SectionNumber: 3 ++ SimpleType: IMAGE_SYM_TYPE_NULL ++ ComplexType: IMAGE_SYM_DTYPE_NULL ++ StorageClass: IMAGE_SYM_CLASS_STATIC ++ SectionDefinition: ++ Length: 8192 ++ NumberOfRelocations: 0 ++ NumberOfLinenumbers: 0 ++ CheckSum: 0 ++ Number: 3 ++ - Name: .other ++ Value: 0 ++ SectionNumber: 4 ++ SimpleType: IMAGE_SYM_TYPE_NULL ++ ComplexType: IMAGE_SYM_DTYPE_NULL ++ StorageClass: IMAGE_SYM_CLASS_STATIC ++ SectionDefinition: ++ Length: 9 ++ NumberOfRelocations: 0 ++ NumberOfLinenumbers: 0 ++ CheckSum: 1054931164 ++ Number: 4 ++ - Name: main ++ Value: 0 ++ SectionNumber: 1 ++ SimpleType: IMAGE_SYM_TYPE_NULL ++ ComplexType: IMAGE_SYM_DTYPE_NULL ++ StorageClass: IMAGE_SYM_CLASS_EXTERNAL ++... +-- +2.49.0.windows.1 + diff --git a/llvm/PKGBUILD b/llvm/PKGBUILD index d066ddcb..b321f8c3 100644 --- a/llvm/PKGBUILD +++ b/llvm/PKGBUILD @@ -12,7 +12,7 @@ _version=20.1.3 _rc="" _tag=llvmorg-${_version}${_rc} pkgver=${_version}${_rc/-/} -pkgrel=2 +pkgrel=3 pkgdesc="C language family frontend for LLVM" arch=('i686' 'x86_64') url="https://llvm.org/" @@ -38,22 +38,25 @@ source=("${_url}/llvm-${pkgver}.src.tar.xz"{,.sig} "${_url}/libunwind-${pkgver}.src.tar.xz"{,.sig} "${_url}/runtimes-${pkgver}.src.tar.xz"{,.sig} "0001-LLVM-Cygwin-Fix-symbol-visibility-definition.patch" - "0002-undef-i386.patch" - "0003-LLVM-Cygwin-Fix-llvm-config-shared-library-names.patch" + "0002-LLVM-Cygwin-Remove-special-case-for-CXX-extensions-o.patch" + "0003-LLVM-Cygwin-Fix-shared-library-name-136599.patch" "0004-LLVM-Cygwin-Fix-Signals-compatibility-with-Cygwin-AP.patch" + "0005-LLVM-TargetParser-Handle-msys-targets-the-same-as-cy.patch" + "0006-LLVM-Cygwin-Define-_GNU_SOURCE-on-Cygwin-as-well.-13.patch" "0102-Clang-Cygwin-Enable-few-conditions-that-are-shared-w.patch" "0103-Clang-Cygwin-Enable-TLS.patch" - "0104-Clang-Cygwin-Fix-symbol-visibility-definition.patch" - "0106-disable-shared-libs-on-Cygwin-by-default.patch" - "0107-Clang-Cygwin-Remove-erroneous-define.patch" - "0108-Clang-Cygwin-dont-use-Bsymbolic-functions.patch" + "0104-Clang-Cygwin-Fix-symbol-visibility-definition-138118.patch" + "0106-Clang-Cygwin-Disable-shared-libs-on-Cygwin-by-defaul.patch" + "0107-Clang-Cygwin-Remove-erroneous-_WIN32-define-and-clea.patch" + "0108-Clang-Cygwin-don-t-use-Bsymbolic-functions-138217.patch" "0109-hack-cygwin-allow-multiple-definition-c-index-test.patch" "0110-Clang-Driver-add-a-Cygwin-ToolChain.patch" - "0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.patch" + "0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.-.patch" "0112-hack-cygwin-define-_GLIBCXX_USE_CXX11_ABI-to-1-if-no.patch" "0201-LLD-MinGW-Implement-dll-search-prefix-option.patch" "0203-LLD-COFF-add-__-data-bss-_-start-end-__-symbols-for-.patch" "0204-LLD-MinGW-Fall-back-to-using-default-target-if-no-m-.patch" + "0205-LLD-COFF-Ensure-.bss-is-merged-at-the-end-of-a-secti.patch" ) sha256sums=('e5dc9b9d842c5f79080f67860a084077e163430de1e2cd3a74e8bee86e186751' 'SKIP' @@ -69,23 +72,26 @@ sha256sums=('e5dc9b9d842c5f79080f67860a084077e163430de1e2cd3a74e8bee86e186751' 'SKIP' '6394d8f111288c918421756037c10c4f8471325992e37c44cf8811b4e3dde00b' 'SKIP' - '68053c76fc82309a8a2c6f91ee9344f40d943f5a3078681c9d76388cc901b66b' - '233010fa91dc741ef6a7fd8b864f92766d37b3ce50c5d39811ca883ea6d1d859' - '834ed176bc5bad1dabde4558aa38e768b6d454f82081f1cdedb44163f0962be6' - '6bf8f75ac82b60d13198e206c0cf1bac7cdf1a84dc1db0a86d7686f1c0f346f1' - 'a73568d353fd27ff7cae0bdddbced0d0119274a465befe8a0bda6cae4721da0b' - 'f93d3b3227ee5958880d070451f92129c62a645e6cdc94bac9a13fa0144b3e23' - 'f489cec6ee4a7dcfbe90be4d58fa853d0dfab893d024a8e878074dfab1fd4bfd' - '312ee451a8f67d3fbc5e723a93a6ad311a6ba95942d32bb8757ba7d2840b53a9' - 'a6d9beedc80cc22bc2e41c2ab101cf519ac7013ec66912b27953224ec48bc1e8' - 'e85fe8c8bb079b2b153ff50254576816196957361c97181ab58883321d02c2bb' - 'e153bc3904747a16b547816d37d7cbd2fc103cb47d694644540202af9b3de6c6' - '5ee936d5050b5376ba3026578a2e43319fda477c42a091aa66d57c8980638e4f' - '5a383313e4a2432471b0cd2946786eb3bafd9f6dfc5f2ff005c594b77a82470d' - '4587f6bd019e69df04fab9b7ba6c9245cd1a26167ce2557530eb185d495f3717' - '92edbcd4cb2c9d6706a31bd64c25865931025e3c430d23c16900ac39a408785f' - 'e94efca8f2336bbd76265847dc449dcc537b8c6a4f740473884bc70249ca8b02' - '9df6ecfdd5a18a875442f529fbe08a86eae07986557b0633c3c01404cf6ba3ea') + '0f446bd4886fc6eac575c7a7e8dcfc84d1186eb79f73e321966bccc214e57271' + '32419b37a32c8387dc0df1a54d9459a046eaf8ba6564df6573c54829b50b850a' + '01adbbd20926ea99c2eba7a8d691dbe12755315fb27e1000d822b6e2691705f9' + '3b4fdc72da4f23c7656b8a2f0a168904b294abcd7dcc2151e59a7aa63581e37a' + '19be8aaa4ea24249ca750ab2a84fdf6ab9a03aee012f3f377d9525d7a6d3e7d9' + '93b81f87a9444d8a1375c8f47cb1caed22359048839ae4eca0db52dd40c24077' + 'ff593fa117c7a05fc1d68622d78b8e9d62fbf1fd647ac955cb3e3fc2138a1b30' + 'ee018e5a11ccd72808ef0a757a50e6119576620c0176e09104ddd3f6ac898f66' + 'ddf4d7ae7aa1ec974a4c6f927572823f51e6e3af0e82a6142c37fe2c83be2eb5' + '46d4270226003ba4777f45a3f45d1a391bbde4dcecd9bf0c24242d3fa828f1a2' + '325069aa129cd7507e52541c3bd23577e99b0208a9d14053ee7d49da37bdcc51' + 'a47b97820b0bd158d9e00f4abd0195cc5379f1861e359485dafc433604d0a64a' + 'ba77a47634a0e99080ce3097d6d87b02b4904d80f4a809cac0124d31a2a0e829' + '606624dc18235ca8b0cef113c65f1561e85f99ead4cfae08005e7439b18ffe32' + '97184a6e90a682ae1726d57994e959d1a56cf066f7e5f23129d395d116b384e3' + '1816172f86c5fe8f742d7b08fef250c351c1efef8e35f8da367fcf188ba6ac56' + '0ddada23a1d060817b06a081d6f3fbb45a86dea9c0632d79f747c9a35a7a26b4' + '63fbf5fb4845521772fdd3d699188f8cf30a99999ed639a66bdb1d236a14e5d4' + 'c5cbfb64eb7b19d6f1f1c1eb9c3278fcfbed8bfc482f8f36025cbdd3eef642a5' + 'a94a90b514105550e4e1a0502c1400d470d800fb137df4cf45f9a03fea224804') validpgpkeys=('B6C8F98282B944E3B0D5C2530FC3042E345AD05D' # Hans Wennborg, Google. '474E22316ABF4785A88C6E8EA2C794A986419D8A' # Tom Stellard 'D574BD5D1D0E98895E3BF90044F2485E45D59042') # Tobias Hieta @@ -129,21 +135,23 @@ prepare() { # Patch llvm cd "${srcdir}"/llvm apply_git_patch_with_msg 0001-LLVM-Cygwin-Fix-symbol-visibility-definition.patch - apply_git_patch_with_msg 0002-undef-i386.patch - apply_git_patch_with_msg 0003-LLVM-Cygwin-Fix-llvm-config-shared-library-names.patch + apply_git_patch_with_msg 0002-LLVM-Cygwin-Remove-special-case-for-CXX-extensions-o.patch + apply_git_patch_with_msg 0003-LLVM-Cygwin-Fix-shared-library-name-136599.patch apply_git_patch_with_msg 0004-LLVM-Cygwin-Fix-Signals-compatibility-with-Cygwin-AP.patch + apply_git_patch_with_msg 0005-LLVM-TargetParser-Handle-msys-targets-the-same-as-cy.patch + apply_git_patch_with_msg 0006-LLVM-Cygwin-Define-_GNU_SOURCE-on-Cygwin-as-well.-13.patch # Patch clang cd "${srcdir}"/clang apply_git_patch_with_msg 0102-Clang-Cygwin-Enable-few-conditions-that-are-shared-w.patch apply_git_patch_with_msg 0103-Clang-Cygwin-Enable-TLS.patch - apply_git_patch_with_msg 0104-Clang-Cygwin-Fix-symbol-visibility-definition.patch - apply_git_patch_with_msg 0106-disable-shared-libs-on-Cygwin-by-default.patch - apply_git_patch_with_msg 0107-Clang-Cygwin-Remove-erroneous-define.patch - apply_git_patch_with_msg 0108-Clang-Cygwin-dont-use-Bsymbolic-functions.patch + apply_git_patch_with_msg 0104-Clang-Cygwin-Fix-symbol-visibility-definition-138118.patch + apply_git_patch_with_msg 0106-Clang-Cygwin-Disable-shared-libs-on-Cygwin-by-defaul.patch + apply_git_patch_with_msg 0107-Clang-Cygwin-Remove-erroneous-_WIN32-define-and-clea.patch + apply_git_patch_with_msg 0108-Clang-Cygwin-don-t-use-Bsymbolic-functions-138217.patch apply_git_patch_with_msg 0109-hack-cygwin-allow-multiple-definition-c-index-test.patch apply_git_patch_with_msg 0110-Clang-Driver-add-a-Cygwin-ToolChain.patch - apply_git_patch_with_msg 0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.patch + apply_git_patch_with_msg 0111-Clang-Driver-use-__cxa_atexit-by-default-on-Cygwin.-.patch apply_git_patch_with_msg 0112-hack-cygwin-define-_GLIBCXX_USE_CXX11_ABI-to-1-if-no.patch # Patch lld @@ -151,6 +159,7 @@ prepare() { apply_git_patch_with_msg 0201-LLD-MinGW-Implement-dll-search-prefix-option.patch apply_git_patch_with_msg 0203-LLD-COFF-add-__-data-bss-_-start-end-__-symbols-for-.patch apply_git_patch_with_msg 0204-LLD-MinGW-Fall-back-to-using-default-target-if-no-m-.patch + apply_git_patch_with_msg 0205-LLD-COFF-Ensure-.bss-is-merged-at-the-end-of-a-secti.patch } build() {