Skip to content

Commit

Permalink
Add packages for bootstrapping Clang subsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
mati865 committed Nov 13, 2020
1 parent 354a1f4 commit 27e47e7
Show file tree
Hide file tree
Showing 25 changed files with 2,008 additions and 89 deletions.
29 changes: 29 additions & 0 deletions clang/0002-Fix-GetHostTriple-for-mingw-w64-in-msys.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From b47a00af69f3c662e54dc54e482fc9b0d4ba6480 Mon Sep 17 00:00:00 2001
From: Martell Malone <martellmalone@gmail.com>
Date: Sun, 28 Jun 2015 20:14:51 +0100
Subject: [PATCH 2/5] Fix GetHostTriple for mingw-w64 in msys

---
cmake/modules/GetHostTriple.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cmake/modules/GetHostTriple.cmake b/cmake/modules/GetHostTriple.cmake
index 0cad1db4eff..47e9f986e15 100644
--- a/cmake/modules/GetHostTriple.cmake
+++ b/cmake/modules/GetHostTriple.cmake
@@ -8,11 +8,11 @@
else()
set( value "i686-pc-windows-msvc" )
endif()
- elseif( MINGW AND NOT MSYS )
+ elseif( MINGW )
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( value "x86_64-w64-windows-gnu" )
else()
- set( value "i686-pc-windows-gnu" )
+ set( value "i686-w64-windows-gnu" )
endif()
else( MSVC )
set(config_guess ${LLVM_MAIN_SRC_DIR}/cmake/config.guess)
2.13.3

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 56c0371a3cbc98ef5dc039324ad43c153ff601c4 Mon Sep 17 00:00:00 2001
From: Mateusz Mikula <mati865@gmail.com>
Date: Thu, 2 Feb 2017 11:48:25 +0100
Subject: [PATCH 4/5] llvm-config: look for unversioned shared lib on win32

---
tools/llvm-config/llvm-config.cpp | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/llvm-config/llvm-config.cpp b/tools/llvm-config/llvm-config.cpp
index 08b096afb05..e388d9e5d3f 100644
--- a/tools/llvm-config/llvm-config.cpp
+++ b/tools/llvm-config/llvm-config.cpp
@@ -353,10 +353,11 @@ int main(int argc, char **argv) {
const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
if (HostTriple.isOSWindows()) {
SharedExt = "dll";
- SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
+ SharedVersionedExt = ".dll";
if (HostTriple.isOSCygMing()) {
StaticExt = "a";
StaticPrefix = "lib";
+ SharedPrefix = "lib";
} else {
StaticExt = "lib";
DirSep = "\\";
@@ -393,7 +393,7 @@

bool DyLibExists = false;
const std::string DyLibName =
- (SharedPrefix + "LLVM-" + SharedVersionedExt).str();
+ (SharedPrefix + (HostTriple.isOSWindows() ? "LLVM" : "LLVM-") + SharedVersionedExt).str();

// If LLVM_LINK_DYLIB is ON, the single shared library will be returned
// for "--libs", etc, if they exist. This behaviour can be overridden with
--
2.13.3
14 changes: 14 additions & 0 deletions clang/0006-add-coff-exported-flag.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Index: lib/Object/COFFObjectFile.cpp
===================================================================
--- a/lib/Object/COFFObjectFile.cpp (Revision 274558)
+++ b/lib/Object/COFFObjectFile.cpp (Arbeitskopie)
@@ -217,6 +217,9 @@
if (Symb.isExternal() || Symb.isWeakExternal())
Result |= SymbolRef::SF_Global;

+ if (Symb.isExternal())
+ Result |= SymbolRef::SF_Exported;
+
if (const coff_aux_weak_external *AWE = Symb.getWeakExternal()) {
Result |= SymbolRef::SF_Weak;
if (AWE->Characteristics != COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS)
45 changes: 45 additions & 0 deletions clang/0007-getLoadAddressWithOffset-assertion.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h
===================================================================
--- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h (revision 283036)
+++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h (working copy)
@@ -142,8 +142,7 @@
uint64_t Result =
RE.Sections.SectionA == static_cast<uint32_t>(-1)
? Value
- : Sections[RE.Sections.SectionA].getLoadAddressWithOffset(
- RE.Addend);
+ : Sections[RE.Sections.SectionA].getLoadAddress() + RE.Addend;
assert(Result <= UINT32_MAX && "relocation overflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_I386_DIR32"
@@ -159,7 +158,7 @@
// The target's 32-bit RVA.
// NOTE: use Section[0].getLoadAddress() as an approximation of ImageBase
uint64_t Result =
- Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend) -
+ Sections[RE.Sections.SectionA].getLoadAddress() + RE.Addend -
Sections[0].getLoadAddress();
assert(static_cast<int32_t>(Result) <= INT32_MAX &&
"relocation overflow");
Index: lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h
===================================================================
--- a/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h (revision 283036)
+++ b/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFThumb.h (working copy)
@@ -184,7 +184,7 @@
uint64_t Result =
RE.Sections.SectionA == static_cast<uint32_t>(-1)
? Value
- : Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend);
+ : Sections[RE.Sections.SectionA].getLoadAddress() + RE.Addend;
Result |= ISASelectionBit;
assert(Result <= UINT32_MAX && "relocation overflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
@@ -229,7 +229,7 @@
case COFF::IMAGE_REL_ARM_MOV32T: {
// 32-bit VA of the target applied to a contiguous MOVW+MOVT pair.
uint64_t Result =
- Sections[RE.Sections.SectionA].getLoadAddressWithOffset(RE.Addend);
+ Sections[RE.Sections.SectionA].getLoadAddress() + RE.Addend;
assert(Result <= UINT32_MAX && "relocation overflow");
DEBUG(dbgs() << "\t\tOffset: " << RE.Offset
<< " RelType: IMAGE_REL_ARM_MOV32T"
11 changes: 11 additions & 0 deletions clang/0009-empty-target-prefix-only-msvc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- llvm-6.0.0.src/cmake/modules/AddLLVM.cmake.orig 2018-06-01 17:52:24.905810400 +0300
+++ llvm-6.0.0.src/cmake/modules/AddLLVM.cmake 2018-06-01 17:54:31.858071700 +0300
@@ -473,7 +473,7 @@
endif()

if(ARG_SHARED)
- if(WIN32)
+ if(MSVC)
set_target_properties(${name} PROPERTIES
PREFIX ""
)
13 changes: 13 additions & 0 deletions clang/0010-mbig-obj-for-all.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- llvm-6.0.0.src/cmake/modules/HandleLLVMOptions.cmake.orig 2018-06-06 14:33:51.928460200 +0300
+++ llvm-6.0.0.src/cmake/modules/HandleLLVMOptions.cmake 2018-06-06 14:33:59.840471400 +0300
@@ -312,9 +312,7 @@
# Pass -mbig-obj to mingw gas on Win64. COFF has a 2**16 section limit, and
# on Win64, every COMDAT function creates at least 3 sections: .text, .pdata,
# and .xdata.
- if (CMAKE_SIZEOF_VOID_P EQUAL 8)
- append("-Wa,-mbig-obj" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
- endif()
+ append("-Wa,-mbig-obj" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
endif()

if( MSVC )
Loading

0 comments on commit 27e47e7

Please sign in to comment.