Update to a LLVM 5.0-ish version from trunk
Using the 5.0 release branch should work equally well except for aarch64/win support.
This commit is contained in:
1 parent
9fe9a5e2e4
commit
bf656d77e7
23 files changed
+655
-4236
No files matched your search
+143
-61
@@ -14,10 +14,18 @@ RUN git config --global user.name "VideoLAN Buildbot" && \
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
RUN git clone -b release_40 --depth=1 https://github.com/llvm-mirror/llvm.git
|
||||
# release_50 should work just as well as the pinned hash, except for arm64 support.
|
||||
# When cloning master and checking out a pinned old hash, we can't use --depth=1.
|
||||
RUN git clone -b master https://github.com/llvm-mirror/llvm.git
|
||||
RUN cd llvm/tools && \
|
||||
git clone -b release_40 --depth=1 https://github.com/llvm-mirror/clang.git && \
|
||||
git clone -b release_40 --depth=1 https://github.com/llvm-mirror/lld.git
|
||||
git clone -b master https://github.com/llvm-mirror/clang.git && \
|
||||
git clone -b master https://github.com/llvm-mirror/lld.git && \
|
||||
cd .. && \
|
||||
git checkout ee09c63e57866e6d47964f0094a7d884ae99b7ef && \
|
||||
cd tools/clang && \
|
||||
git checkout c778ea4b266d5fdcf3ab2d2509b19083bc43a91e && \
|
||||
cd ../lld && \
|
||||
git checkout ccf03952480f7b995f53263f0b529a57497230ff
|
||||
|
||||
#RUN cd llvm/projects && \
|
||||
# git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxx.git && \
|
||||
@@ -26,13 +34,7 @@ RUN cd llvm/tools && \
|
||||
|
||||
RUN mkdir /build/patches
|
||||
|
||||
COPY patches/llvm-*.patch patches/clang-*.patch patches/lld-*.patch /build/patches/
|
||||
|
||||
RUN cd llvm && \
|
||||
git am /build/patches/llvm-*.patch
|
||||
|
||||
RUN cd llvm/tools/clang && \
|
||||
git am /build/patches/clang-*.patch
|
||||
COPY patches/lld-*.patch /build/patches/
|
||||
|
||||
RUN cd llvm/tools/lld && \
|
||||
git am /build/patches/lld-*.patch
|
||||
@@ -52,35 +54,43 @@ RUN cd llvm && mkdir build && cd build && cmake \
|
||||
-DLLVM_ENABLE_RTTI=ON \
|
||||
-DLLVM_ENABLE_FFI=OFF \
|
||||
-DLLVM_ENABLE_SPHINX=OFF \
|
||||
-DLLVM_TARGETS_TO_BUILD="ARM;AArch64;X86" \
|
||||
-DCMAKE_CXX_FLAGS="-D_GNU_SOURCE -D_LIBCPP_HAS_NO_CONSTEXPR" \
|
||||
../ && \
|
||||
make -j4 && \
|
||||
make install
|
||||
|
||||
RUN git clone --depth=1 git://git.code.sf.net/p/mingw-w64/mingw-w64
|
||||
RUN git clone --depth=1 git://git.code.sf.net/p/mingw-w64/mingw-w64 && \
|
||||
cd mingw-w64 && \
|
||||
git checkout 4e3188bff2fd44cf1e1bf155b64b28f67f5c4457
|
||||
COPY patches/mingw-*.patch /build/patches/
|
||||
RUN cd mingw-w64 && \
|
||||
git am /build/patches/mingw-*.patch
|
||||
|
||||
#FIXME: Move this UP!
|
||||
ENV TOOLCHAIN_PREFIX=/build/prefix
|
||||
ENV TARGET_TUPLE=armv7-w64-mingw32
|
||||
ENV MINGW_PREFIX=$TOOLCHAIN_PREFIX/$TARGET_TUPLE
|
||||
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
||||
|
||||
RUN mkdir $MINGW_PREFIX
|
||||
RUN ln -s $MINGW_PREFIX $TOOLCHAIN_PREFIX/mingw
|
||||
|
||||
RUN cd mingw-w64/mingw-w64-headers && mkdir build && cd build && \
|
||||
../configure --host=$TARGET_TUPLE --prefix=$MINGW_PREFIX \
|
||||
RUN cd mingw-w64/mingw-w64-headers && \
|
||||
for arch in armv7 aarch64 i686 x86_64; do \
|
||||
mkdir build-${arch} && cd build-${arch} && \
|
||||
../configure --host=${arch}-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/${arch}-w64-mingw32 \
|
||||
--enable-secure-api && \
|
||||
make install
|
||||
make install && \
|
||||
cd ..; \
|
||||
done
|
||||
|
||||
# Install the usual $TUPLE-clang binary
|
||||
COPY wrappers/* $TOOLCHAIN_PREFIX/bin/
|
||||
RUN mkdir /build/wrappers
|
||||
COPY wrappers/clang-target-wrapper /build/wrappers
|
||||
RUN for arch in armv7 aarch64 i686 x86_64; do \
|
||||
for exec in clang clang++; do \
|
||||
cp wrappers/clang-target-wrapper $TOOLCHAIN_PREFIX/bin/${arch}-w64-mingw32-${exec}; \
|
||||
done; \
|
||||
done
|
||||
|
||||
ENV CC=armv7-w64-mingw32-clang
|
||||
ENV CXX=armv7-w64-mingw32-clang++
|
||||
#ENV CC=armv7-w64-mingw32-clang
|
||||
#ENV CXX=armv7-w64-mingw32-clang++
|
||||
ENV AR=llvm-ar
|
||||
ENV RANLIB=llvm-ranlib
|
||||
ENV LD=lld
|
||||
@@ -95,21 +105,46 @@ ENV NM=llvm-nm
|
||||
# Force the flag -format gnu to llvm-ar in this step to work around this issue.
|
||||
RUN cd mingw-w64/mingw-w64-crt && \
|
||||
autoreconf -vif && \
|
||||
mkdir build && cd build && \
|
||||
AR="llvm-ar -format gnu" ../configure --host=$TARGET_TUPLE --prefix=$MINGW_PREFIX \
|
||||
--disable-lib32 --disable-lib64 --enable-libarm32 \
|
||||
--with-genlib=llvm-dlltool && \
|
||||
make -j4 && \
|
||||
make install
|
||||
mkdir build-arm32 && cd build-arm32 && \
|
||||
CC=armv7-w64-mingw32-clang \
|
||||
AR="llvm-ar -format gnu" DLLTOOL=llvm-dlltool ../configure --host=armv7-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/armv7-w64-mingw32 \
|
||||
--disable-lib32 --disable-lib64 --enable-libarm32 && \
|
||||
make -j4 && make install && \
|
||||
cd .. && \
|
||||
mkdir build-arm64 && cd build-arm64 && \
|
||||
CC=aarch64-w64-mingw32-clang \
|
||||
AR="llvm-ar -format gnu" DLLTOOL=llvm-dlltool ../configure --host=aarch64-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/aarch64-w64-mingw32 \
|
||||
--disable-lib32 --disable-lib64 --enable-libarm64 && \
|
||||
make -j4 && make install && \
|
||||
cd .. && \
|
||||
mkdir build-i686 && cd build-i686 && \
|
||||
CC=i686-w64-mingw32-clang \
|
||||
AR="llvm-ar -format gnu" DLLTOOL=llvm-dlltool ../configure --host=i686-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/i686-w64-mingw32 \
|
||||
--enable-lib32 --disable-lib64 && \
|
||||
make -j4 && make install && \
|
||||
cd .. && \
|
||||
mkdir build-x86_64 && cd build-x86_64 && \
|
||||
CC=x86_64-w64-mingw32-clang \
|
||||
AR="llvm-ar -format gnu" DLLTOOL=llvm-dlltool ../configure --host=x86_64-w64-mingw32 --prefix=$TOOLCHAIN_PREFIX/x86_64-w64-mingw32 \
|
||||
--enable-lib64 --disable-lib32 && \
|
||||
make -j4 && make install && \
|
||||
cd ..
|
||||
|
||||
RUN cp /build/mingw-w64/mingw-w64-libraries/winpthreads/include/* $MINGW_PREFIX/include/
|
||||
#RUN cp /build/mingw-w64/mingw-w64-libraries/winpthreads/include/* $MINGW_PREFIX/include/
|
||||
|
||||
RUN git clone -b release_40 --depth=1 https://github.com/llvm-mirror/compiler-rt.git
|
||||
RUN git clone -b master https://github.com/llvm-mirror/compiler-rt.git && \
|
||||
cd compiler-rt && \
|
||||
git checkout 8293838e866814d904640f6359954d00852f2421
|
||||
|
||||
COPY patches/compiler-rt-*.patch /build/patches/
|
||||
|
||||
RUN cd compiler-rt && \
|
||||
git am /build/patches/compiler-rt-*.patch
|
||||
|
||||
# Manually build compiler-rt as a standalone project
|
||||
RUN cd compiler-rt && mkdir build && cd build && cmake \
|
||||
-DCMAKE_C_COMPILER=$CC \
|
||||
-DCMAKE_CXX_COMPILER=$CXX \
|
||||
RUN cd compiler-rt && \
|
||||
mkdir build-armv7 && cd build-armv7 && cmake \
|
||||
-DCMAKE_C_COMPILER=armv7-w64-mingw32-clang \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
@@ -119,24 +154,66 @@ RUN cd compiler-rt && mkdir build && cd build && cmake \
|
||||
-DCMAKE_SIZEOF_VOID_P=4 \
|
||||
../lib/builtins && \
|
||||
make -j4 && \
|
||||
mkdir -p /build/prefix/lib/clang/4.0.1/lib/windows && \
|
||||
cp lib/windows/libclang_rt.builtins-arm.a /build/prefix/lib/clang/4.0.1/lib/windows
|
||||
|
||||
RUN cd mingw-w64/mingw-w64-libraries && cd winstorecompat && \
|
||||
autoreconf -vif && \
|
||||
mkdir build && cd build && \
|
||||
../configure --host=$TARGET_TUPLE --prefix=$MINGW_PREFIX && make && make install
|
||||
|
||||
RUN cd /build/mingw-w64/mingw-w64-tools/widl && \
|
||||
mkdir build && cd build && \
|
||||
CC=gcc \
|
||||
../configure --prefix=$TOOLCHAIN_PREFIX --target=$TARGET_TUPLE && \
|
||||
mkdir -p /build/prefix/lib/clang/6.0.0/lib/windows && \
|
||||
cp lib/windows/libclang_rt.builtins-arm.a /build/prefix/lib/clang/6.0.0/lib/windows && \
|
||||
cd .. && \
|
||||
mkdir build-aarch64 && cd build-aarch64 && cmake \
|
||||
-DCMAKE_C_COMPILER=aarch64-w64-mingw32-clang \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||
-DLLVM_CONFIG_PATH=$TOOLCHAIN_PREFIX/bin/llvm-config \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="aarch64--windows-gnu" \
|
||||
-DCMAKE_SIZEOF_VOID_P=8 \
|
||||
../lib/builtins && \
|
||||
make -j4 && \
|
||||
make install
|
||||
mkdir -p /build/prefix/lib/clang/6.0.0/lib/windows && \
|
||||
cp lib/windows/libclang_rt.builtins-aarch64.a /build/prefix/lib/clang/6.0.0/lib/windows && \
|
||||
cd .. && \
|
||||
mkdir build-i686 && cd build-i686 && cmake \
|
||||
-DCMAKE_C_COMPILER=i686-w64-mingw32-clang \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||
-DLLVM_CONFIG_PATH=$TOOLCHAIN_PREFIX/bin/llvm-config \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="i686--windows-gnu" \
|
||||
-DCMAKE_SIZEOF_VOID_P=4 \
|
||||
../lib/builtins && \
|
||||
make -j4 && \
|
||||
mkdir -p /build/prefix/lib/clang/6.0.0/lib/windows && \
|
||||
cp lib/windows/libclang_rt.builtins-i386.a /build/prefix/lib/clang/6.0.0/lib/windows/libclang_rt.builtins-i686.a && \
|
||||
cd .. && \
|
||||
mkdir build-x86_64 && cd build-x86_64 && cmake \
|
||||
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-clang \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_AR=$TOOLCHAIN_PREFIX/bin/$AR \
|
||||
-DCMAKE_RANLIB=$TOOLCHAIN_PREFIX/bin/$RANLIB \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||
-DLLVM_CONFIG_PATH=$TOOLCHAIN_PREFIX/bin/llvm-config \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_TRIPLE="x86_64--windows-gnu" \
|
||||
-DCMAKE_SIZEOF_VOID_P=8 \
|
||||
../lib/builtins && \
|
||||
make -j4 && \
|
||||
mkdir -p /build/prefix/lib/clang/6.0.0/lib/windows && \
|
||||
cp lib/windows/libclang_rt.builtins-x86_64.a /build/prefix/lib/clang/6.0.0/lib/windows
|
||||
|
||||
RUN git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxx.git && \
|
||||
git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxxabi.git && \
|
||||
git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libunwind.git
|
||||
#RUN cd mingw-w64/mingw-w64-libraries && cd winstorecompat && \
|
||||
# autoreconf -vif && \
|
||||
# mkdir build && cd build && \
|
||||
# ../configure --host=$TARGET_TUPLE --prefix=$MINGW_PREFIX && make && make install
|
||||
|
||||
#RUN cd /build/mingw-w64/mingw-w64-tools/widl && \
|
||||
# mkdir build && cd build && \
|
||||
# CC=gcc \
|
||||
# ../configure --prefix=$TOOLCHAIN_PREFIX --target=$TARGET_TUPLE && \
|
||||
# make -j4 && \
|
||||
# make install
|
||||
|
||||
#RUN git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxx.git && \
|
||||
# git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxxabi.git && \
|
||||
# git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libunwind.git
|
||||
|
||||
#COPY patches/libcxx-*.patch /build/patches/
|
||||
#RUN cd libcxx && \
|
||||
@@ -220,27 +297,32 @@ RUN git clone -b release_40 --depth=1 https://github.com/llvm-mirror/libcxx.git
|
||||
|
||||
#RUN cd /build/prefix/include && ln -s /build/prefix/$TARGET_TUPLE/include/c++ .
|
||||
|
||||
RUN mkdir gaspp && cd gaspp && \
|
||||
wget -q https://raw.githubusercontent.com/libav/gas-preprocessor/master/gas-preprocessor.pl && \
|
||||
chmod +x gas-preprocessor.pl
|
||||
# gaspp is no longer required with clang 5.0
|
||||
#RUN mkdir gaspp && cd gaspp && \
|
||||
# wget -q https://raw.githubusercontent.com/libav/gas-preprocessor/master/gas-preprocessor.pl && \
|
||||
# chmod +x gas-preprocessor.pl
|
||||
|
||||
ENV PATH=/build/gaspp:$PATH
|
||||
|
||||
ENV AS="gas-preprocessor.pl ${CC}"
|
||||
ENV ASCPP="gas-preprocessor.pl ${CC}"
|
||||
ENV CCAS="gas-preprocessor.pl ${CC}"
|
||||
ENV LDFLAGS="-lmsvcr120_app ${LDFLAGS}"
|
||||
#ENV PATH=/build/gaspp:$PATH
|
||||
#
|
||||
#ENV AS="gas-preprocessor.pl ${CC}"
|
||||
#ENV ASCPP="gas-preprocessor.pl ${CC}"
|
||||
#ENV CCAS="gas-preprocessor.pl ${CC}"
|
||||
#ENV LDFLAGS="-lmsvcr120_app ${LDFLAGS}"
|
||||
|
||||
RUN mkdir -p /build/hello
|
||||
COPY hello.c hello.cpp /build/hello/
|
||||
RUN cd /build/hello && armv7-w64-mingw32-clang hello.c -o hello.exe
|
||||
RUN cd /build/hello && \
|
||||
armv7-w64-mingw32-clang hello.c -o hello-armv7.exe && \
|
||||
aarch64-w64-mingw32-clang hello.c -o hello-aarch64.exe && \
|
||||
x86_64-w64-mingw32-clang hello.c -o hello-x86_64.exe && \
|
||||
i686-w64-mingw32-clang hello.c -o hello-i686.exe
|
||||
|
||||
#RUN cd /build/hello && armv7-w64-mingw32-clang++ hello.cpp -o hello-cpp.exe -fno-exceptions
|
||||
|
||||
RUN git clone --depth=1 git://git.libav.org/libav.git
|
||||
|
||||
# Clear LDFLAGS, lld seems to fail with msvcr120_app for some reason (recheck this)
|
||||
RUN cd /build/libav && \
|
||||
mkdir build && cd build && \
|
||||
LDFLAGS="" ../configure --arch=arm --cpu=armv7-a --target-os=mingw32 --cc=armv7-w64-mingw32-clang --ar=llvm-ar --nm=llvm-nm --enable-cross-compile --enable-gpl && \
|
||||
../configure --arch=aarch64 --target-os=mingw32 --cc=aarch64-w64-mingw32-clang --ar=llvm-ar --nm=llvm-nm --enable-cross-compile --enable-gpl && \
|
||||
make -j4 all testprogs
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
From 82a145503d9b1aecf8cf45bd7b536543f3342345 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Wed, 16 Dec 2015 02:07:06 -0800
|
||||
Subject: [PATCH 1/4] mingw-w64: setup new defaults for target
|
||||
|
||||
runtime: compiler-rt
|
||||
c++ lib: libc++
|
||||
linker: lld
|
||||
---
|
||||
lib/Driver/ToolChains.h | 9 +++++++++
|
||||
lib/Driver/Tools.cpp | 2 +-
|
||||
2 files changed, 10 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
|
||||
index 3240357..3be7f25 100644
|
||||
--- a/lib/Driver/ToolChains.h
|
||||
+++ b/lib/Driver/ToolChains.h
|
||||
@@ -714,6 +714,15 @@ public:
|
||||
|
||||
void printVerboseInfo(raw_ostream &OS) const override;
|
||||
|
||||
+ RuntimeLibType GetDefaultRuntimeLibType() const override {
|
||||
+ return RuntimeLibType::RLT_CompilerRT;
|
||||
+ }
|
||||
+
|
||||
+ CXXStdlibType
|
||||
+ GetCXXStdlibType(const llvm::opt::ArgList &Args) const override {
|
||||
+ return ToolChain::CST_Libcxx;
|
||||
+ }
|
||||
+
|
||||
protected:
|
||||
Tool *getTool(Action::ActionClass AC) const override;
|
||||
Tool *buildLinker() const override;
|
||||
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
|
||||
index 3c3d453..2a9a09d 100644
|
||||
--- a/lib/Driver/Tools.cpp
|
||||
+++ b/lib/Driver/Tools.cpp
|
||||
@@ -11216,7 +11216,7 @@ void MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
// handled somewhere else.
|
||||
Args.ClaimAllArgs(options::OPT_w);
|
||||
|
||||
- StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "ld");
|
||||
+ StringRef LinkerName = Args.getLastArgValue(options::OPT_fuse_ld_EQ, "lld");
|
||||
if (LinkerName.equals_lower("lld")) {
|
||||
CmdArgs.push_back("-flavor");
|
||||
CmdArgs.push_back("gnu");
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
From 553e9229258fd4127e35ad983217b7e4825fdfef Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
|
||||
Date: Mon, 2 May 2016 15:58:31 +0200
|
||||
Subject: [PATCH 2/4] Manually revert 0e2452f3055e2e2cad06a55c5ca9c2be13404781
|
||||
|
||||
This re-enables mingw detection
|
||||
---
|
||||
lib/Driver/MinGWToolChain.cpp | 14 ++++----------
|
||||
1 file changed, 4 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/lib/Driver/MinGWToolChain.cpp b/lib/Driver/MinGWToolChain.cpp
|
||||
index e971869..1ac3bd3 100644
|
||||
--- a/lib/Driver/MinGWToolChain.cpp
|
||||
+++ b/lib/Driver/MinGWToolChain.cpp
|
||||
@@ -64,23 +64,17 @@ MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||
: ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) {
|
||||
getProgramPaths().push_back(getDriver().getInstalledDir());
|
||||
|
||||
-// In Windows there aren't any standard install locations, we search
|
||||
-// for gcc on the PATH. In Linux the base is always /usr.
|
||||
-#ifdef LLVM_ON_WIN32
|
||||
+ // On Windows if there is no sysroot we search for gcc on the PATH.
|
||||
if (getDriver().SysRoot.size())
|
||||
Base = getDriver().SysRoot;
|
||||
+#ifdef LLVM_ON_WIN32
|
||||
else if (llvm::ErrorOr<std::string> GPPName =
|
||||
llvm::sys::findProgramByName("gcc"))
|
||||
Base = llvm::sys::path::parent_path(
|
||||
llvm::sys::path::parent_path(GPPName.get()));
|
||||
- else
|
||||
- Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
|
||||
-#else
|
||||
- if (getDriver().SysRoot.size())
|
||||
- Base = getDriver().SysRoot;
|
||||
- else
|
||||
- Base = "/usr";
|
||||
#endif
|
||||
+ if (!Base.size())
|
||||
+ Base = llvm::sys::path::parent_path(getDriver().getInstalledDir());
|
||||
|
||||
Base += llvm::sys::path::get_separator();
|
||||
findGccLibDir();
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
From ebade0c4f7558bb16b2504f06076585d1f618a4c Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Mon, 15 Aug 2016 20:57:27 -0700
|
||||
Subject: [PATCH 3/4] mingw-w64: enable support for __declspec(selectany)
|
||||
|
||||
---
|
||||
include/clang/Basic/Attr.td | 5 ++---
|
||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td
|
||||
index fa60d51..0739511 100644
|
||||
--- a/include/clang/Basic/Attr.td
|
||||
+++ b/include/clang/Basic/Attr.td
|
||||
@@ -2180,9 +2180,8 @@ def DLLImport : InheritableAttr, TargetSpecificAttr<TargetWindows> {
|
||||
let Documentation = [DLLImportDocs];
|
||||
}
|
||||
|
||||
-def SelectAny : InheritableAttr {
|
||||
- let Spellings = [Declspec<"selectany">];
|
||||
- let LangOpts = [MicrosoftExt];
|
||||
+def SelectAny : InheritableAttr, TargetSpecificAttr<TargetWindows> {
|
||||
+ let Spellings = [Declspec<"selectany">, GCC<"selectany">];
|
||||
let Documentation = [Undocumented];
|
||||
}
|
||||
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
From 2488a5d11c8a5ff0c5ab3749dd36ef8ba53bfac1 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Fri, 5 Aug 2016 21:50:38 -0700
|
||||
Subject: [PATCH 4/4] mingw-w64: support static builds of libc++
|
||||
|
||||
Static builds require libc++abi to be linked
|
||||
Will add support for both modes in future
|
||||
---
|
||||
lib/Driver/MinGWToolChain.cpp | 15 +++++++++++++++
|
||||
lib/Driver/ToolChains.h | 4 ++++
|
||||
2 files changed, 19 insertions(+)
|
||||
|
||||
diff --git a/lib/Driver/MinGWToolChain.cpp b/lib/Driver/MinGWToolChain.cpp
|
||||
index 1ac3bd3..3c3e319 100644
|
||||
--- a/lib/Driver/MinGWToolChain.cpp
|
||||
+++ b/lib/Driver/MinGWToolChain.cpp
|
||||
@@ -249,3 +249,18 @@ void MinGW::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
|
||||
break;
|
||||
}
|
||||
}
|
||||
+
|
||||
+void MinGW::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
+ ArgStringList &CmdArgs) const {
|
||||
+ switch (GetCXXStdlibType(Args)) {
|
||||
+ case ToolChain::CST_Libcxx:
|
||||
+ CmdArgs.push_back("-lc++");
|
||||
+ // Support only static libc++ for now
|
||||
+ CmdArgs.push_back("-lc++abi");
|
||||
+ break;
|
||||
+
|
||||
+ case ToolChain::CST_Libstdcxx:
|
||||
+ CmdArgs.push_back("-lstdc++");
|
||||
+ break;
|
||||
+ }
|
||||
+}
|
||||
diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h
|
||||
index 3be7f25..f62207d 100644
|
||||
--- a/lib/Driver/ToolChains.h
|
||||
+++ b/lib/Driver/ToolChains.h
|
||||
@@ -705,6 +705,10 @@ public:
|
||||
void
|
||||
AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
+
|
||||
+ void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
|
||||
+ llvm::opt::ArgStringList &CmdArgs) const override;
|
||||
+
|
||||
void AddClangCXXStdlibIncludeArgs(
|
||||
const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
From 5d4ad66bdde2ff103c848dc2709a5a67f4d2844f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
|
||||
Date: Tue, 22 Aug 2017 13:25:25 +0300
|
||||
Subject: [PATCH] Fix cross compilation of compiler-rt for i386 mingw64
|
||||
|
||||
---
|
||||
This patch hasn't been sent for review anywhere yet - the real issue hasn't
|
||||
been analyzed properly yet.
|
||||
---
|
||||
cmake/base-config-ix.cmake | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/cmake/base-config-ix.cmake b/cmake/base-config-ix.cmake
|
||||
index b38c6ca..103bca0 100644
|
||||
--- a/cmake/base-config-ix.cmake
|
||||
+++ b/cmake/base-config-ix.cmake
|
||||
@@ -134,19 +134,19 @@ macro(test_targets)
|
||||
if(COMPILER_RT_DEFAULT_TARGET_ONLY)
|
||||
add_default_target_arch(${COMPILER_RT_DEFAULT_TARGET_ARCH})
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "i[2-6]86|x86|amd64")
|
||||
- if(NOT MSVC)
|
||||
- test_target_arch(x86_64 "" "-m64")
|
||||
- # FIXME: We build runtimes for both i686 and i386, as "clang -m32" may
|
||||
- # target different variant than "$CMAKE_C_COMPILER -m32". This part should
|
||||
- # be gone after we resolve PR14109.
|
||||
- test_target_arch(i686 __i686__ "-m32")
|
||||
- test_target_arch(i386 __i386__ "-m32")
|
||||
- else()
|
||||
+# if(NOT MSVC)
|
||||
+# test_target_arch(x86_64 "" "-m64")
|
||||
+# # FIXME: We build runtimes for both i686 and i386, as "clang -m32" may
|
||||
+# # target different variant than "$CMAKE_C_COMPILER -m32". This part should
|
||||
+# # be gone after we resolve PR14109.
|
||||
+# test_target_arch(i686 __i686__ "-m32")
|
||||
+# test_target_arch(i386 __i386__ "-m32")
|
||||
+# else()
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
test_target_arch(i386 "" "")
|
||||
else()
|
||||
test_target_arch(x86_64 "" "")
|
||||
- endif()
|
||||
+# endif()
|
||||
endif()
|
||||
elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "powerpc")
|
||||
TEST_BIG_ENDIAN(HOST_IS_BIG_ENDIAN)
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,268 +0,0 @@
|
||||
From 57d48bf47108014aa5e0c5435c107581e86e3045 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Sat, 6 Aug 2016 03:54:22 -0700
|
||||
Subject: [PATCH] mingw-w64 hack and slash fixes for libc++
|
||||
|
||||
CMAKE_HOST_WIN32 change can be upstreamed in a different patch
|
||||
|
||||
This is very hacky but gets libcxx to compile
|
||||
Make sure you only install the headers after building
|
||||
Will need to run the test suite and do more work here
|
||||
|
||||
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
|
||||
index 219d1b7..2a9337f 100644
|
||||
--- a/include/CMakeLists.txt
|
||||
+++ b/include/CMakeLists.txt
|
||||
@@ -27,7 +27,7 @@ if (LIBCXX_INSTALL_HEADERS)
|
||||
|
||||
if (LIBCXX_NEEDS_SITE_CONFIG)
|
||||
set(UNIX_CAT cat)
|
||||
- if (WIN32)
|
||||
+ if (CMAKE_HOST_WIN32)
|
||||
set(UNIX_CAT type)
|
||||
endif()
|
||||
# Generate and install a custom __config header. The new header is created
|
||||
diff --git a/include/__config b/include/__config
|
||||
index 353ca10..b58c350 100644
|
||||
--- a/include/__config
|
||||
+++ b/include/__config
|
||||
@@ -152,6 +152,8 @@
|
||||
# // If mingw not explicitly detected, assume using MS C runtime only.
|
||||
# ifndef __MINGW32__
|
||||
# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
|
||||
+# else
|
||||
+# define _LIBCPP_HAS_NO_CONSTEXPR
|
||||
# endif
|
||||
#endif // _WIN32
|
||||
|
||||
@@ -177,7 +179,7 @@
|
||||
// including accesses to the special files under /dev. C++11's
|
||||
// std::random_device is instead exposed through a NaCl syscall.
|
||||
# define _LIBCPP_USING_NACL_RANDOM
|
||||
-#elif defined(_WIN32)
|
||||
+#elif defined(_MSC_VER)
|
||||
# define _LIBCPP_USING_WIN32_RANDOM
|
||||
#else
|
||||
# define _LIBCPP_USING_DEV_RANDOM
|
||||
@@ -831,7 +833,8 @@ extern "C" void __sanitizer_annotate_contiguous_container(
|
||||
defined(__linux__) || \
|
||||
defined(__APPLE__) || \
|
||||
defined(__CloudABI__) || \
|
||||
- defined(__sun__)
|
||||
+ defined(__sun__) || \
|
||||
+ defined(__MINGW32__)
|
||||
# define _LIBCPP_HAS_THREAD_API_PTHREAD
|
||||
# else
|
||||
# error "No thread API"
|
||||
diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h
|
||||
index 7f3710e..d167309 100644
|
||||
--- a/include/support/win32/locale_win32.h
|
||||
+++ b/include/support/win32/locale_win32.h
|
||||
@@ -64,6 +64,15 @@ isupper_l(int c, _locale_t loc)
|
||||
return _isupper_l((int)c, loc);
|
||||
}
|
||||
|
||||
+#define open _open
|
||||
+#define close _close
|
||||
+#define read _read
|
||||
+
|
||||
+#define strtod_l _strtod_l
|
||||
+
|
||||
+// TODO: add _strtof_l to mingw-w64
|
||||
+#define strtof_l _strtod_l
|
||||
+
|
||||
#define isdigit_l _isdigit_l
|
||||
#define isxdigit_l _isxdigit_l
|
||||
#define strcoll_l _strcoll_l
|
||||
@@ -93,6 +102,33 @@ int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...);
|
||||
int asprintf_l( char **ret, locale_t loc, const char *format, ... );
|
||||
int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
|
||||
|
||||
+#ifdef __MINGW32__
|
||||
+
|
||||
+// Stubs
|
||||
+inline _locale_t _get_current_locale(void) {
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+inline _locale_t _create_locale(int _Category,const char *_Locale) {
|
||||
+ _locale_t loc;
|
||||
+ return loc;
|
||||
+}
|
||||
+//extern "C" void _free_locale(_locale_t _Locale) {}
|
||||
+//void __cdecl _free_locale(_locale_t _Locale);
|
||||
+inline _locale_t _free_locale(_locale_t _Locale) {
|
||||
+ _locale_t loc;
|
||||
+ return loc;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+#include <time.h>
|
||||
+
|
||||
+inline size_t _strftime_l(char* s, size_t n, const char * f, const struct tm * tm, _locale_t l)
|
||||
+{
|
||||
+ return strftime(s, n, f, tm);
|
||||
+}
|
||||
+
|
||||
+#endif
|
||||
|
||||
// not-so-pressing FIXME: use locale to determine blank characters
|
||||
inline int isblank_l( int c, locale_t /*loc*/ )
|
||||
@@ -104,7 +140,7 @@ inline int iswblank_l( wint_t c, locale_t /*loc*/ )
|
||||
return ( c == L' ' || c == L'\t' );
|
||||
}
|
||||
|
||||
-#if defined(_LIBCPP_MSVCRT)
|
||||
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
inline int isblank( int c, locale_t /*loc*/ )
|
||||
{ return ( c == ' ' || c == '\t' ); }
|
||||
inline int iswblank( wint_t c, locale_t /*loc*/ )
|
||||
diff --git a/include/support/win32/support.h b/include/support/win32/support.h
|
||||
index 5765bab..4955b3a 100644
|
||||
--- a/include/support/win32/support.h
|
||||
+++ b/include/support/win32/support.h
|
||||
@@ -37,12 +37,13 @@ extern "C" {
|
||||
|
||||
int vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
|
||||
int asprintf(char **sptr, const char *__restrict fmt, ...);
|
||||
+}
|
||||
+#endif // __MINGW32__
|
||||
+
|
||||
size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
|
||||
size_t nmc, size_t len, mbstate_t *__restrict ps);
|
||||
size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
|
||||
size_t nwc, size_t len, mbstate_t *__restrict ps);
|
||||
-}
|
||||
-#endif // __MINGW32__
|
||||
|
||||
#if defined(_LIBCPP_MSVCRT)
|
||||
#define snprintf _snprintf
|
||||
diff --git a/include/type_traits b/include/type_traits
|
||||
index 0d578bb..88dfd99 100644
|
||||
--- a/include/type_traits
|
||||
+++ b/include/type_traits
|
||||
@@ -1671,7 +1671,7 @@ _CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x800);
|
||||
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x1000);
|
||||
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x2000);
|
||||
// MSDN says that MSVC does not support alignment beyond 8192 (=0x2000)
|
||||
-#if !defined(_LIBCPP_MSVC)
|
||||
+#if !defined(_LIBCPP_MSVC) && !defined(__MINGW32__)
|
||||
_CREATE_ALIGNED_STORAGE_SPECIALIZATION(0x4000);
|
||||
#endif // !_LIBCPP_MSVC
|
||||
|
||||
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
|
||||
index cabf2e6..8729707 100644
|
||||
--- a/lib/CMakeLists.txt
|
||||
+++ b/lib/CMakeLists.txt
|
||||
@@ -33,9 +33,11 @@ add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}"
|
||||
|
||||
add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}")
|
||||
|
||||
+if(NOT MINGW)
|
||||
add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic")
|
||||
add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
|
||||
add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive")
|
||||
+endif()
|
||||
|
||||
if (APPLE AND LLVM_USE_SANITIZER)
|
||||
if ("${LLVM_USE_SANITIZER}" STREQUAL "Address")
|
||||
@@ -71,9 +73,14 @@ add_library_flags_if(LIBCXX_HAS_RT_LIB rt)
|
||||
add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s)
|
||||
add_library_flags_if(LIBCXX_HAVE_CXX_ATOMICS_WITH_LIB atomic)
|
||||
|
||||
-# Setup flags.
|
||||
add_flags_if_supported(-fPIC)
|
||||
-add_link_flags_if_supported(-nodefaultlibs)
|
||||
+
|
||||
+# Setup flags.
|
||||
+if (NOT MINGW)
|
||||
+ add_link_flags_if_supported(-nodefaultlibs)
|
||||
+else()
|
||||
+ add_library_flags(-lc++abi)
|
||||
+endif()
|
||||
|
||||
if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
|
||||
LIBCXX_CXX_ABI_LIBNAME STREQUAL "none"))
|
||||
diff --git a/src/locale.cpp b/src/locale.cpp
|
||||
index da2fd11..03696a7 100644
|
||||
--- a/src/locale.cpp
|
||||
+++ b/src/locale.cpp
|
||||
@@ -26,9 +26,9 @@
|
||||
#include "cstring"
|
||||
#include "cwctype"
|
||||
#include "__sso_allocator"
|
||||
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
+#if defined(_LIBCPP_MSVCRT)
|
||||
#include "support/win32/locale_win32.h"
|
||||
-#elif !defined(__ANDROID__)
|
||||
+#elif !defined(__ANDROID__) && !defined(__MINGW32__)
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
diff --git a/src/support/win32/locale_win32.cpp b/src/support/win32/locale_win32.cpp
|
||||
index 5a43743..b220afe 100644
|
||||
--- a/src/support/win32/locale_win32.cpp
|
||||
+++ b/src/support/win32/locale_win32.cpp
|
||||
@@ -8,6 +8,11 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
+#ifdef __MINGW32__
|
||||
+#define _GNU_SOURCE
|
||||
+#include <support/win32/support.h>
|
||||
+#endif
|
||||
+
|
||||
#include <locale>
|
||||
#include <cstdarg> // va_start, va_end
|
||||
|
||||
diff --git a/src/support/win32/support.cpp b/src/support/win32/support.cpp
|
||||
index e989681..0d60ef4 100644
|
||||
--- a/src/support/win32/support.cpp
|
||||
+++ b/src/support/win32/support.cpp
|
||||
@@ -8,6 +8,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
+#ifdef __MINGW32__
|
||||
+#define _GNU_SOURCE
|
||||
+#endif
|
||||
+
|
||||
#include <cstdarg> // va_start, va_end
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdlib> // malloc
|
||||
@@ -17,6 +21,7 @@
|
||||
|
||||
// Some of these functions aren't standard or if they conform, the name does not.
|
||||
|
||||
+#ifndef __MINGW32__
|
||||
int asprintf(char **sptr, const char *__restrict format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -51,6 +56,7 @@ int vasprintf( char **sptr, const char *__restrict format, va_list ap )
|
||||
*sptr = p;
|
||||
return count;
|
||||
}
|
||||
+#endif
|
||||
|
||||
// Returns >= 0: the number of wide characters found in the
|
||||
// multi byte sequence src (of src_size_bytes), that fit in the buffer dst
|
||||
diff --git a/src/system_error.cpp b/src/system_error.cpp
|
||||
index 87f35ae..fdd56ea 100644
|
||||
--- a/src/system_error.cpp
|
||||
+++ b/src/system_error.cpp
|
||||
@@ -70,6 +70,12 @@ string do_strerror_r(int ev) {
|
||||
char* ret = ::strerror_r(ev, buffer, strerror_buff_size);
|
||||
return string(ret);
|
||||
}
|
||||
+#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
|
||||
+string do_strerror_r(int ev) {
|
||||
+ char buffer[strerror_buff_size];
|
||||
+ std::snprintf(buffer, strerror_buff_size, "Win32 Unsupported %d", ev);
|
||||
+ return string(buffer);
|
||||
+}
|
||||
#else
|
||||
// POSIX version
|
||||
string do_strerror_r(int ev) {
|
||||
--
|
||||
2.8.3
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
From a91ea0b2d56e1dc45dbe3edda9e16a8724311d21 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Thu, 25 Aug 2016 12:59:57 +0300
|
||||
Subject: [PATCH 2/2] Hack
|
||||
|
||||
Also remove unnecessary defines for open/read/close that are handled
|
||||
by linker aliases now.
|
||||
---
|
||||
include/support/win32/locale_win32.h | 6 ++----
|
||||
src/new.cpp | 2 +-
|
||||
2 files changed, 3 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/include/support/win32/locale_win32.h b/include/support/win32/locale_win32.h
|
||||
index d167309..c4cdd93 100644
|
||||
--- a/include/support/win32/locale_win32.h
|
||||
+++ b/include/support/win32/locale_win32.h
|
||||
@@ -64,10 +64,6 @@ isupper_l(int c, _locale_t loc)
|
||||
return _isupper_l((int)c, loc);
|
||||
}
|
||||
|
||||
-#define open _open
|
||||
-#define close _close
|
||||
-#define read _read
|
||||
-
|
||||
#define strtod_l _strtod_l
|
||||
|
||||
// TODO: add _strtof_l to mingw-w64
|
||||
@@ -104,6 +100,7 @@ int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap );
|
||||
|
||||
#ifdef __MINGW32__
|
||||
|
||||
+#if 0
|
||||
// Stubs
|
||||
inline _locale_t _get_current_locale(void) {
|
||||
return NULL;
|
||||
@@ -120,6 +117,7 @@ inline _locale_t _free_locale(_locale_t _Locale) {
|
||||
return loc;
|
||||
}
|
||||
|
||||
+#endif
|
||||
|
||||
#include <time.h>
|
||||
|
||||
diff --git a/src/new.cpp b/src/new.cpp
|
||||
index f4f73d8..62222e1 100644
|
||||
--- a/src/new.cpp
|
||||
+++ b/src/new.cpp
|
||||
@@ -31,7 +31,7 @@
|
||||
#endif // _LIBCPPABI_VERSION
|
||||
#endif
|
||||
|
||||
-#ifndef __GLIBCXX__
|
||||
+#if 0
|
||||
|
||||
// Implement all new and delete operators as weak definitions
|
||||
// in this shared library, so that they can be overridden by programs
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
From af6e844261dda2786985ff43fcd6873b636b57aa Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Sat, 27 Aug 2016 14:02:18 +0300
|
||||
Subject: [PATCH] Hack cmake configure
|
||||
|
||||
---
|
||||
CMakeLists.txt | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 300d6da..d00a942 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -47,7 +47,7 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
|
||||
set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
|
||||
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
|
||||
- set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake")
|
||||
+ set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib/cmake/llvm")
|
||||
set(LLVM_LIT_PATH "${LLVM_PATH}/utils/lit/lit.py")
|
||||
else()
|
||||
message(FATAL_ERROR "llvm-config not found and LLVM_MAIN_SRC_DIR not defined. "
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
From 46a001b37a0355b588ad99a3aab5593926fa31bc Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Tue, 21 Jul 2015 04:35:55 +0100
|
||||
Subject: [PATCH 1/2] libunwind add support for mingw-w64
|
||||
|
||||
---
|
||||
include/unwind.h | 2 +-
|
||||
src/AddressSpace.hpp | 11 +++++++----
|
||||
src/UnwindLevel1-gcc-ext.c | 2 +-
|
||||
src/assembly.h | 2 ++
|
||||
src/config.h | 14 ++++++++++++++
|
||||
5 files changed, 25 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/include/unwind.h b/include/unwind.h
|
||||
index f3860d9..8f54d4d 100644
|
||||
--- a/include/unwind.h
|
||||
+++ b/include/unwind.h
|
||||
@@ -121,7 +121,7 @@ struct _Unwind_Exception {
|
||||
_Unwind_Exception *exc);
|
||||
uintptr_t private_1; // non-zero means forced unwind
|
||||
uintptr_t private_2; // holds sp that phase1 found for phase2 to use
|
||||
-#ifndef __LP64__
|
||||
+#if !defined(__LP64__) && !defined(_WIN64)
|
||||
// The implementation of _Unwind_Exception uses an attribute mode on the
|
||||
// above fields which has the side effect of causing this whole struct to
|
||||
// round up to 32 bytes in size. To be more explicit, we add pad fields
|
||||
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp
|
||||
index da1b6a4..892950f 100644
|
||||
--- a/src/AddressSpace.hpp
|
||||
+++ b/src/AddressSpace.hpp
|
||||
@@ -18,7 +18,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
-#ifndef _LIBUNWIND_IS_BAREMETAL
|
||||
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
@@ -109,7 +109,7 @@ struct UnwindInfoSections {
|
||||
/// making local unwinds fast.
|
||||
class __attribute__((visibility("hidden"))) LocalAddressSpace {
|
||||
public:
|
||||
-#ifdef __LP64__
|
||||
+#if defined(__LP64__) || defined(_WIN64)
|
||||
typedef uint64_t pint_t;
|
||||
typedef int64_t sint_t;
|
||||
#else
|
||||
@@ -161,7 +161,7 @@ public:
|
||||
};
|
||||
|
||||
inline uintptr_t LocalAddressSpace::getP(pint_t addr) {
|
||||
-#ifdef __LP64__
|
||||
+#if defined(__LP64__) || defined(_WIN64)
|
||||
return get64(addr);
|
||||
#else
|
||||
return get32(addr);
|
||||
@@ -439,6 +439,7 @@ inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,
|
||||
},
|
||||
&cb_data);
|
||||
return static_cast<bool>(found);
|
||||
+#elif defined(_WIN32)
|
||||
#else
|
||||
#error "_LIBUNWIND_SUPPORT_DWARF_UNWIND requires _LIBUNWIND_SUPPORT_DWARF_INDEX on this platform."
|
||||
#endif
|
||||
@@ -462,7 +463,9 @@ inline bool LocalAddressSpace::findOtherFDE(pint_t targetAddr, pint_t &fde) {
|
||||
inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
|
||||
size_t bufLen,
|
||||
unw_word_t *offset) {
|
||||
-#ifndef _LIBUNWIND_IS_BAREMETAL
|
||||
+#ifdef _WIN32
|
||||
+// FIXME: support DLLs on Windows.
|
||||
+#elif !defined(_LIBUNWIND_IS_BAREMETAL)
|
||||
Dl_info dyldInfo;
|
||||
if (dladdr((void *)addr, &dyldInfo)) {
|
||||
if (dyldInfo.dli_sname != NULL) {
|
||||
diff --git a/src/UnwindLevel1-gcc-ext.c b/src/UnwindLevel1-gcc-ext.c
|
||||
index 28ba092..0decf77 100644
|
||||
--- a/src/UnwindLevel1-gcc-ext.c
|
||||
+++ b/src/UnwindLevel1-gcc-ext.c
|
||||
@@ -29,7 +29,7 @@
|
||||
_LIBUNWIND_EXPORT _Unwind_Reason_Code
|
||||
_Unwind_Resume_or_Rethrow(_Unwind_Exception *exception_object) {
|
||||
#if _LIBUNWIND_ARM_EHABI
|
||||
- _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%ld\n",
|
||||
+ _LIBUNWIND_TRACE_API("_Unwind_Resume_or_Rethrow(ex_obj=%p), private_1=%" PRIdPTR "\n",
|
||||
(void *)exception_object,
|
||||
(long)exception_object->unwinder_cache.reserved1);
|
||||
#else
|
||||
diff --git a/src/assembly.h b/src/assembly.h
|
||||
index 06b29b3..96f46e3 100644
|
||||
--- a/src/assembly.h
|
||||
+++ b/src/assembly.h
|
||||
@@ -26,6 +26,8 @@
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#define HIDDEN_DIRECTIVE .private_extern
|
||||
+#elif defined(_WIN32)
|
||||
+#define HIDDEN_DIRECTIVE .globl
|
||||
#else
|
||||
#define HIDDEN_DIRECTIVE .hidden
|
||||
#endif
|
||||
diff --git a/src/config.h b/src/config.h
|
||||
index a50222f..acc52a5 100644
|
||||
--- a/src/config.h
|
||||
+++ b/src/config.h
|
||||
@@ -39,6 +39,14 @@
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
|
||||
#define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
|
||||
#endif
|
||||
+#elif defined(_WIN32)
|
||||
+
|
||||
+ #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 1
|
||||
+ #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
|
||||
+ #define _LIBUNWIND_SUPPORT_DWARF_INDEX 0
|
||||
+ // libcxx may have defined __USE_MINGW_ANSI_STDIO.
|
||||
+ // Here we would like to get the regular versions, not the _mingw ones.
|
||||
+ #undef __USE_MINGW_ANSI_STDIO
|
||||
#else
|
||||
#if defined(__ARM_DWARF_EH__) || !defined(__arm__)
|
||||
#define _LIBUNWIND_SUPPORT_COMPACT_UNWIND 0
|
||||
@@ -51,9 +59,14 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+#ifdef _WIN32
|
||||
+#define _LIBUNWIND_EXPORT
|
||||
+#define _LIBUNWIND_HIDDEN
|
||||
+#else
|
||||
// FIXME: these macros are not correct for COFF targets
|
||||
#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
|
||||
#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
|
||||
+#endif
|
||||
|
||||
#if (defined(__APPLE__) && defined(__arm__)) || defined(__USING_SJLJ_EXCEPTIONS__)
|
||||
#define _LIBUNWIND_BUILD_SJLJ_APIS 1
|
||||
@@ -69,6 +82,7 @@
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__) || \
|
||||
(!defined(__APPLE__) && defined(__arm__)) || \
|
||||
+ (defined(_WIN32)) || \
|
||||
(defined(__arm64__) || defined(__aarch64__)) || \
|
||||
(defined(__APPLE__) && defined(__mips__))
|
||||
#define _LIBUNWIND_BUILD_ZERO_COST_APIS 1
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
From 17e850de43aefe7da87db8c2eaa521e5159c1cbb Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
|
||||
Date: Fri, 13 May 2016 15:07:26 +0200
|
||||
Subject: [PATCH 2/2] Define _Unwind_Ptr on windows
|
||||
|
||||
---
|
||||
src/AddressSpace.hpp | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/src/AddressSpace.hpp b/src/AddressSpace.hpp
|
||||
index 892950f..9751d9e 100644
|
||||
--- a/src/AddressSpace.hpp
|
||||
+++ b/src/AddressSpace.hpp
|
||||
@@ -47,6 +47,8 @@ extern "C" _Unwind_Ptr __gnu_Unwind_Find_exidx(_Unwind_Ptr addr, int *len);
|
||||
// Emulate the BSD dl_unwind_find_exidx API when on a GNU libdl system.
|
||||
#define dl_unwind_find_exidx __gnu_Unwind_Find_exidx
|
||||
|
||||
+#elif defined(_WIN32)
|
||||
+typedef void *_Unwind_Ptr;
|
||||
#elif !defined(_LIBUNWIND_IS_BAREMETAL)
|
||||
#include <link.h>
|
||||
#else // !defined(_LIBUNWIND_IS_BAREMETAL)
|
||||
--
|
||||
2.7.4
|
||||
|
||||
+381
-140
@@ -1,159 +1,401 @@
|
||||
From d2b8d30134e620ec5d36be0765e52c7bf9bc57d6 Mon Sep 17 00:00:00 2001
|
||||
From ece347fc2af075b7149776c301ec59825868f969 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Wed, 28 Oct 2015 19:32:16 +0000
|
||||
Subject: [PATCH 1/2] add support for gnu arguments in lld coff
|
||||
Date: Tue, 22 Aug 2017 10:11:15 +0300
|
||||
Subject: [PATCH] COFF: Introduce LD shim around LINK
|
||||
|
||||
---
|
||||
COFF/Driver.cpp | 31 ++++++++++++++++++++++++++++++-
|
||||
COFF/Driver.h | 3 +++
|
||||
COFF/DriverUtils.cpp | 2 +-
|
||||
COFF/Options.td | 20 ++++++++++++++++++++
|
||||
tools/lld/lld.cpp | 21 +++++++++++++++++++++
|
||||
5 files changed, 75 insertions(+), 2 deletions(-)
|
||||
This patch is up for review at https://reviews.llvm.org/D33880.
|
||||
---
|
||||
CMakeLists.txt | 1 +
|
||||
ELF/Driver.cpp | 8 +-
|
||||
MinGW/CMakeLists.txt | 20 +++++
|
||||
MinGW/Driver.cpp | 205 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
MinGW/Options.td | 38 ++++++++
|
||||
include/lld/Driver/Driver.h | 5 ++
|
||||
test/COFF/out.test | 5 ++
|
||||
tools/lld/CMakeLists.txt | 1 +
|
||||
tools/lld/lld.cpp | 12 +++
|
||||
9 files changed, 289 insertions(+), 6 deletions(-)
|
||||
create mode 100644 MinGW/CMakeLists.txt
|
||||
create mode 100644 MinGW/Driver.cpp
|
||||
create mode 100644 MinGW/Options.td
|
||||
|
||||
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp
|
||||
index 4dabd9e..4992296 100644
|
||||
--- a/COFF/Driver.cpp
|
||||
+++ b/COFF/Driver.cpp
|
||||
@@ -232,6 +232,7 @@ void LinkerDriver::parseDirectives(StringRef S) {
|
||||
case OPT_fastfail:
|
||||
case OPT_guardsym:
|
||||
case OPT_throwingnew:
|
||||
+ case OPT_aligncomm:
|
||||
break;
|
||||
default:
|
||||
fatal(Arg->getSpelling() + " is not allowed in .drectve");
|
||||
@@ -260,6 +261,31 @@ StringRef LinkerDriver::doFindFile(StringRef Filename) {
|
||||
return Filename;
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index e2ab0e3..1893e6b 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -221,4 +221,5 @@ endif()
|
||||
add_subdirectory(docs)
|
||||
add_subdirectory(COFF)
|
||||
add_subdirectory(ELF)
|
||||
+add_subdirectory(MinGW)
|
||||
|
||||
diff --git a/ELF/Driver.cpp b/ELF/Driver.cpp
|
||||
index b0962c7..ee86569 100644
|
||||
--- a/ELF/Driver.cpp
|
||||
+++ b/ELF/Driver.cpp
|
||||
@@ -113,12 +113,8 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef Emul) {
|
||||
.Case("elf_iamcu", {ELF32LEKind, EM_IAMCU})
|
||||
.Default({ELFNoneKind, EM_NONE});
|
||||
|
||||
- if (Ret.first == ELFNoneKind) {
|
||||
- if (S == "i386pe" || S == "i386pep" || S == "thumb2pe")
|
||||
- error("Windows targets are not supported on the ELF frontend: " + Emul);
|
||||
- else
|
||||
- error("unknown emulation: " + Emul);
|
||||
- }
|
||||
+ if (Ret.first == ELFNoneKind)
|
||||
+ error("unknown emulation: " + Emul);
|
||||
return std::make_tuple(Ret.first, Ret.second, OSABI);
|
||||
}
|
||||
|
||||
+// Searches a given library from input search paths, which are filled
|
||||
+// from -L command line switches. Returns a path to an existent library file.
|
||||
+StringRef LinkerDriver::searchLibrary(StringRef Filename) {
|
||||
diff --git a/MinGW/CMakeLists.txt b/MinGW/CMakeLists.txt
|
||||
new file mode 100644
|
||||
index 0000000..32992bc
|
||||
--- /dev/null
|
||||
+++ b/MinGW/CMakeLists.txt
|
||||
@@ -0,0 +1,20 @@
|
||||
+set(LLVM_TARGET_DEFINITIONS Options.td)
|
||||
+tablegen(LLVM Options.inc -gen-opt-parser-defs)
|
||||
+add_public_tablegen_target(ShimOptionsTableGen)
|
||||
+
|
||||
+ std::vector<std::string> Names;
|
||||
+ if (Filename[0] == ':') {
|
||||
+ Names.push_back(Filename.drop_front());
|
||||
+ } else {
|
||||
+ //if (!Config->Static)
|
||||
+ Names.push_back(("lib" + Filename + ".dll.a").str());
|
||||
+ Names.push_back(("lib" + Filename + ".a").str());
|
||||
+ }
|
||||
+if(NOT LLD_BUILT_STANDALONE)
|
||||
+ set(tablegen_deps intrinsics_gen)
|
||||
+endif()
|
||||
+
|
||||
+ for (const std::string &Name : Names) {
|
||||
+ for (StringRef Dir : SearchPaths) {
|
||||
+ SmallString<128> Path = Dir;
|
||||
+ llvm::sys::path::append(Path, Name.c_str());
|
||||
+ if (llvm::sys::fs::exists(Path.str()))
|
||||
+ return Saver.save(Path.str());
|
||||
+ }
|
||||
+ }
|
||||
+ fatal("Unable to find library -l" + Filename);
|
||||
+ return "";
|
||||
+add_lld_library(lldMinGW
|
||||
+ Driver.cpp
|
||||
+
|
||||
+ LINK_LIBS
|
||||
+ lldConfig
|
||||
+ lldCore
|
||||
+ ${LLVM_PTHREAD_LIB}
|
||||
+
|
||||
+ DEPENDS
|
||||
+ ShimOptionsTableGen
|
||||
+ ${tablegen_deps}
|
||||
+)
|
||||
diff --git a/MinGW/Driver.cpp b/MinGW/Driver.cpp
|
||||
new file mode 100644
|
||||
index 0000000..7df3cc0
|
||||
--- /dev/null
|
||||
+++ b/MinGW/Driver.cpp
|
||||
@@ -0,0 +1,205 @@
|
||||
+//===- MinGW/Driver.cpp ---------------------------------------------------===//
|
||||
+//
|
||||
+// The LLVM Linker
|
||||
+//
|
||||
+// This file is distributed under the University of Illinois Open Source
|
||||
+// License. See LICENSE.TXT for details.
|
||||
+//
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+///
|
||||
+/// GNU ld style linker driver for COFF currently supporting mingw-w64.
|
||||
+///
|
||||
+//===----------------------------------------------------------------------===//
|
||||
+
|
||||
+#include "lld/Driver/Driver.h"
|
||||
+#include "llvm/ADT/ArrayRef.h"
|
||||
+#include "llvm/ADT/Optional.h"
|
||||
+#include "llvm/ADT/StringRef.h"
|
||||
+#include "llvm/ADT/StringSwitch.h"
|
||||
+#include "llvm/ADT/Triple.h"
|
||||
+#include "llvm/Option/Arg.h"
|
||||
+#include "llvm/Option/ArgList.h"
|
||||
+#include "llvm/Option/Option.h"
|
||||
+#include "llvm/Support/CommandLine.h"
|
||||
+#include "llvm/Support/FileSystem.h"
|
||||
+#include "llvm/Support/Path.h"
|
||||
+#include "llvm/Support/StringSaver.h"
|
||||
+
|
||||
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
|
||||
+#include <unistd.h>
|
||||
+#endif
|
||||
+
|
||||
+using namespace lld;
|
||||
+using namespace llvm;
|
||||
+
|
||||
+namespace lld {
|
||||
+namespace mingw {
|
||||
+namespace {
|
||||
+
|
||||
+// Create OptTable
|
||||
+enum {
|
||||
+ OPT_INVALID = 0,
|
||||
+#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11, _12) OPT_##ID,
|
||||
+#include "Options.inc"
|
||||
+#undef OPTION
|
||||
+};
|
||||
+
|
||||
+// Create prefix string literals used in Options.td
|
||||
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
|
||||
+#include "Options.inc"
|
||||
+#undef PREFIX
|
||||
+
|
||||
+// Create table mapping all options defined in Options.td
|
||||
+static const opt::OptTable::Info infoTable[] = {
|
||||
+#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X7, X8, X9, X10, X11, X12) \
|
||||
+ {X1, X2, X10, X11, OPT_##ID, opt::Option::KIND##Class, \
|
||||
+ X9, X8, OPT_##GROUP, OPT_##ALIAS, X7, X12},
|
||||
+#include "Options.inc"
|
||||
+#undef OPTION
|
||||
+};
|
||||
+
|
||||
+class COFFLdOptTable : public opt::OptTable {
|
||||
+public:
|
||||
+ COFFLdOptTable() : OptTable(infoTable, false) {}
|
||||
+ opt::InputArgList parse(ArrayRef<const char *> Argv);
|
||||
+};
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
+BumpPtrAllocator BAlloc;
|
||||
+StringSaver Saver{BAlloc};
|
||||
+static SmallVector<const char *, 256> LinkArgs;
|
||||
+static std::vector<StringRef> SearchPaths;
|
||||
+
|
||||
+static void error(const Twine &Msg) {
|
||||
+ errs() << Msg << "\n";
|
||||
+ llvm_shutdown();
|
||||
+ outs().flush();
|
||||
+ errs().flush();
|
||||
+ exit(1);
|
||||
+}
|
||||
+
|
||||
// Resolves a file path. This never returns the same path
|
||||
// (in that case, it returns None).
|
||||
Optional<StringRef> LinkerDriver::findFile(StringRef Filename) {
|
||||
@@ -667,6 +693,9 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
for (auto *Arg : Args.filtered(OPT_defaultlib))
|
||||
if (Optional<StringRef> Path = findLib(Arg->getValue()))
|
||||
enqueuePath(*Path);
|
||||
+ for (auto *Arg : Args.filtered(OPT_l))
|
||||
+ if (Optional<StringRef> Path = searchLibrary(Arg->getValue()))
|
||||
+ enqueuePath(*Path);
|
||||
|
||||
// Windows specific -- Create a resource file containing a manifest file.
|
||||
if (Config->Manifest == Configuration::Embed)
|
||||
@@ -753,7 +782,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
if (Config->ImageBase == uint64_t(-1))
|
||||
Config->ImageBase = getDefaultImageBase();
|
||||
|
||||
- Symtab.addRelative(mangle("__ImageBase"), 0);
|
||||
+ Symtab.addRelative(mangle("__image_base__"), 0);
|
||||
if (Config->Machine == I386) {
|
||||
Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0);
|
||||
Config->SEHCount = Symtab.addAbsolute("___safe_se_handler_count", 0);
|
||||
diff --git a/COFF/Driver.h b/COFF/Driver.h
|
||||
index 4489426..d293014 100644
|
||||
--- a/COFF/Driver.h
|
||||
+++ b/COFF/Driver.h
|
||||
@@ -86,6 +86,9 @@ private:
|
||||
StringRef doFindFile(StringRef Filename);
|
||||
StringRef doFindLib(StringRef Filename);
|
||||
|
||||
+ // Searches for a gnu library
|
||||
+ StringRef searchLibrary(StringRef Path);
|
||||
+// Find a file by concatenating given paths.
|
||||
+static Optional<std::string> findFile(StringRef Path1, const Twine &Path2) {
|
||||
+ SmallString<128> S;
|
||||
+ sys::path::append(S, Path1, Path2);
|
||||
+ if (sys::fs::exists(S))
|
||||
+ return S.str().str();
|
||||
+ return None;
|
||||
+}
|
||||
+
|
||||
// Parses LIB environment which contains a list of search paths.
|
||||
void addLibSearchPaths();
|
||||
+Optional<std::string> findFromSearchPaths(StringRef Path) {
|
||||
+ for (StringRef Dir : SearchPaths)
|
||||
+ if (Optional<std::string> S = findFile(Dir, Path))
|
||||
+ return S;
|
||||
+ return None;
|
||||
+}
|
||||
+
|
||||
+// This is for -lfoo. We'll look for libfoo.dll.a or libfoo.a from search paths.
|
||||
+Optional<std::string> searchLibrary(StringRef Name, bool IgnoreShared = false) {
|
||||
+ if (Name.startswith(":"))
|
||||
+ return findFromSearchPaths(Name.substr(1));
|
||||
+ for (StringRef Dir : SearchPaths) {
|
||||
+ if (!IgnoreShared)
|
||||
+ if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".dll.a"))
|
||||
+ return S;
|
||||
+ if (Optional<std::string> S = findFile(Dir, "lib" + Name + ".a"))
|
||||
+ return S;
|
||||
+ }
|
||||
+ return None;
|
||||
+}
|
||||
+
|
||||
+// Add a given library by searching it from input search paths.
|
||||
+void addLibrary(StringRef Name, bool StaticOnly) {
|
||||
+ if (Optional<std::string> Path = searchLibrary(Name, StaticOnly))
|
||||
+ LinkArgs.push_back(Saver.save(*Path).data());
|
||||
+ else
|
||||
+ error("unable to find library -l" + Name);
|
||||
+}
|
||||
+
|
||||
+void createFiles(opt::InputArgList &Args) {
|
||||
+ for (auto *Arg : Args) {
|
||||
+ switch (Arg->getOption().getID()) {
|
||||
+ case OPT_l:
|
||||
+ addLibrary(Arg->getValue(), Args.hasArg(OPT_Bstatic));
|
||||
+ break;
|
||||
+ case OPT_INPUT:
|
||||
+ LinkArgs.push_back(Saver.save(Arg->getValue()).data());
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static std::vector<StringRef> getArgs(opt::InputArgList &Args, int Id) {
|
||||
+ std::vector<StringRef> V;
|
||||
+ for (auto *Arg : Args.filtered(Id))
|
||||
+ V.push_back(Arg->getValue());
|
||||
+ return V;
|
||||
+}
|
||||
+
|
||||
+static void forward(opt::InputArgList &Args, unsigned Key, StringRef OutArg,
|
||||
+ const char *Default = nullptr) {
|
||||
+ StringRef S = Args.getLastArgValue(Key);
|
||||
+ if (S.size()) {
|
||||
+ LinkArgs.push_back(Saver.save(Twine("-" + OutArg + ":" + S)).data());
|
||||
+ } else if (Default) {
|
||||
+ LinkArgs.push_back(
|
||||
+ Saver.save(Twine("-" + OutArg + ":" + StringRef(Default))).data());
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static void forwardValue(opt::InputArgList &Args, unsigned Key,
|
||||
+ StringRef CmpArg, StringRef OutArg,
|
||||
+ StringRef OutValueArg) {
|
||||
+ StringRef S = Args.getLastArgValue(Key);
|
||||
+ if (S == CmpArg)
|
||||
+ LinkArgs.push_back(
|
||||
+ Saver.save(Twine("-" + OutArg + ":" + OutValueArg)).data());
|
||||
+}
|
||||
+
|
||||
+opt::InputArgList COFFLdOptTable::parse(ArrayRef<const char *> Argv) {
|
||||
+ unsigned MissingIndex;
|
||||
+ unsigned MissingCount;
|
||||
+ SmallVector<const char *, 256> Vec(Argv.data(), Argv.data() + Argv.size());
|
||||
+ opt::InputArgList Args = this->ParseArgs(Vec, MissingIndex, MissingCount);
|
||||
+ if (MissingCount)
|
||||
+ error(Twine(Args.getArgString(MissingIndex)) + ": missing argument");
|
||||
+ if (!Args.hasArgNoClaim(OPT_INPUT) && !Args.hasArgNoClaim(OPT_l))
|
||||
+ error("no input files");
|
||||
+ for (auto *Arg : Args.filtered(OPT_UNKNOWN))
|
||||
+ error("unknown argument: " + Arg->getSpelling());
|
||||
+ return Args;
|
||||
+}
|
||||
+
|
||||
+bool link(ArrayRef<const char *> ArgsArr, raw_ostream &Diag) {
|
||||
+ COFFLdOptTable Parser;
|
||||
+ opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
|
||||
+ LinkArgs.push_back(ArgsArr[0]);
|
||||
+
|
||||
+ forwardValue(Args, OPT_m, "i386pe", "MACHINE", "X86");
|
||||
+ forwardValue(Args, OPT_m, "i386pep", "MACHINE", "X64");
|
||||
+ forwardValue(Args, OPT_m, "thumb2pe", "MACHINE", "ARM");
|
||||
+ forwardValue(Args, OPT_m, "arm64pe", "MACHINE", "ARM64");
|
||||
+
|
||||
+ forward(Args, OPT_o, "OUT", "a.exe");
|
||||
+ forward(Args, OPT_entry, "ENTRY");
|
||||
+ forward(Args, OPT_subs, "SUBSYSTEM");
|
||||
+ forward(Args, OPT_shared, "DLL");
|
||||
+ forward(Args, OPT_outlib, "IMPLIB");
|
||||
+ forward(Args, OPT_stack, "STACK");
|
||||
+
|
||||
+ SearchPaths = getArgs(Args, OPT_L);
|
||||
+ createFiles(Args);
|
||||
+
|
||||
+ // handle __image_base__
|
||||
+ auto M = Args.getLastArg(OPT_m);
|
||||
+ if (M && StringRef(M->getValue()) == "i386pe")
|
||||
+ LinkArgs.push_back("/alternatename:__image_base__=___ImageBase");
|
||||
+ else
|
||||
+ LinkArgs.push_back("/alternatename:__image_base__=__ImageBase");
|
||||
+
|
||||
+ return coff::link(LinkArgs);
|
||||
+}
|
||||
+
|
||||
+} // namespace mingw
|
||||
+} // namespace lld
|
||||
diff --git a/MinGW/Options.td b/MinGW/Options.td
|
||||
new file mode 100644
|
||||
index 0000000..abf53c9
|
||||
--- /dev/null
|
||||
+++ b/MinGW/Options.td
|
||||
@@ -0,0 +1,38 @@
|
||||
+include "llvm/Option/OptParser.td"
|
||||
+
|
||||
+class F<string name>: Flag<["--", "-"], name>;
|
||||
+class J<string name>: Joined<["--", "-"], name>;
|
||||
+class S<string name>: Separate<["--", "-"], name>;
|
||||
+
|
||||
+def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"<dir>">,
|
||||
+ HelpText<"Add a directory to the library search path">;
|
||||
+def entry: S<"entry">, MetaVarName<"<entry>">,
|
||||
+ HelpText<"Name of entry point symbol">;
|
||||
+def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">;
|
||||
+def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"<path>">,
|
||||
+ HelpText<"Path to file to write output">;
|
||||
+def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">,
|
||||
+ HelpText<"Root name of library to use">;
|
||||
+def shared: F<"shared">, HelpText<"Build a shared object">;
|
||||
+def subs: Separate<["--"], "subsystem">, HelpText<"Specify subsystem">;
|
||||
+def stack: Flag<["--"], "stack">, Alias<stack>;
|
||||
+def outlib: Separate<["--"], "out-implib">, HelpText<"Import library name">;
|
||||
+
|
||||
+// Currently stubs to avoid errors
|
||||
+def Bdynamic: F<"Bdynamic">, HelpText<"Link against shared libraries">;
|
||||
+def Bstatic: F<"Bstatic">, HelpText<"Do not link against shared libraries">;
|
||||
+def major_image_version: Separate<["--"], "major-image-version">;
|
||||
+def minor_image_version: Separate<["--"], "minor-image-version">;
|
||||
+def enable_auto_image_base: Flag<["--"], "enable-auto-image-base">;
|
||||
+def full_shutdown: Flag<["--"], "full-shutdown">;
|
||||
+def O: Joined<["-"], "O">, HelpText<"Optimize output file size">;
|
||||
+def v: Flag<["-"], "v">, HelpText<"Display the version number">;
|
||||
+def verbose: F<"verbose">, HelpText<"Verbose mode">;
|
||||
+def version: F<"version">, HelpText<"Display the version number and exit">;
|
||||
+
|
||||
+// Alias
|
||||
+def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
|
||||
+
|
||||
+// Style
|
||||
+def rsp_quoting: J<"rsp-quoting=">,
|
||||
+ HelpText<"Quoting style for response files. Values supported: windows|posix">;
|
||||
diff --git a/include/lld/Driver/Driver.h b/include/lld/Driver/Driver.h
|
||||
index 4ba0994..655fcfe 100644
|
||||
--- a/include/lld/Driver/Driver.h
|
||||
+++ b/include/lld/Driver/Driver.h
|
||||
@@ -19,6 +19,11 @@ bool link(llvm::ArrayRef<const char *> Args,
|
||||
llvm::raw_ostream &Diag = llvm::errs());
|
||||
}
|
||||
|
||||
diff --git a/COFF/DriverUtils.cpp b/COFF/DriverUtils.cpp
|
||||
index 14dd004..f5f3d6d 100644
|
||||
--- a/COFF/DriverUtils.cpp
|
||||
+++ b/COFF/DriverUtils.cpp
|
||||
@@ -637,7 +637,7 @@ static const llvm::opt::OptTable::Info infoTable[] = {
|
||||
+namespace mingw {
|
||||
+bool link(llvm::ArrayRef<const char *> Args,
|
||||
+ llvm::raw_ostream &Diag = llvm::errs());
|
||||
+}
|
||||
+
|
||||
namespace elf {
|
||||
bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly,
|
||||
llvm::raw_ostream &Diag = llvm::errs());
|
||||
diff --git a/test/COFF/out.test b/test/COFF/out.test
|
||||
index a7b5614..976191c 100644
|
||||
--- a/test/COFF/out.test
|
||||
+++ b/test/COFF/out.test
|
||||
@@ -4,14 +4,19 @@
|
||||
# RUN: cp %t.obj %T/out/out1.obj
|
||||
# RUN: cp %t.obj %T/out/tmp/out2
|
||||
# RUN: cp %t.obj %T/out/tmp/out3.xyz
|
||||
+# RUN: cp %t.obj %T/out/out4.obj
|
||||
|
||||
class COFFOptTable : public llvm::opt::OptTable {
|
||||
public:
|
||||
- COFFOptTable() : OptTable(infoTable, true) {}
|
||||
+ COFFOptTable() : OptTable(infoTable) {}
|
||||
};
|
||||
# RUN: rm -f out1.exe out2.exe out3.exe out3.dll
|
||||
# RUN: lld-link /entry:main %T/out/out1.obj
|
||||
# RUN: lld-link /entry:main %T/out/tmp/out2
|
||||
# RUN: lld-link /dll /entry:main %T/out/tmp/out3.xyz
|
||||
|
||||
// Parses a given list of options.
|
||||
diff --git a/COFF/Options.td b/COFF/Options.td
|
||||
index 9dfbcc8..b3b30a3 100644
|
||||
--- a/COFF/Options.td
|
||||
+++ b/COFF/Options.td
|
||||
@@ -99,6 +99,26 @@ def dumppdb : Joined<["/", "-"], "dumppdb">;
|
||||
def lldmap : F<"lldmap">;
|
||||
def lldmap_file : Joined<["/", "-"], "lldmap:">;
|
||||
+# RUN: rm -f a.exe
|
||||
+# RUN: ld.lld -m i386pep --entry main %T/out/out4.obj
|
||||
+
|
||||
# RUN: llvm-readobj out1.exe | FileCheck %s
|
||||
# RUN: llvm-readobj out2.exe | FileCheck %s
|
||||
# RUN: llvm-readobj out3.dll | FileCheck %s
|
||||
+# RUN: llvm-readobj a.exe | FileCheck %s
|
||||
|
||||
+
|
||||
+def output : Separate<["-"], "o">, Alias<out>;
|
||||
+def L : Joined<["-"], "L">, Alias<libpath>;
|
||||
+def e : Separate<["-"], "e">, Alias<entry>;
|
||||
+def subs : Separate<["--"], "subsystem">, Alias<subsystem>;
|
||||
+
|
||||
+def l : JoinedOrSeparate<["-"], "l">, MetaVarName<"<libName>">;
|
||||
+
|
||||
+// Used to silence some gnu warnings
|
||||
+def aligncomm : P<"aligncomm", "Comm Alignment">;
|
||||
+def Bdynamic: Flag<["-"], "Bdynamic">;
|
||||
+
|
||||
+// Used to override gnu pe targets
|
||||
+def m : Separate<["-"], "m">, MetaVarName<"<emulation>">,
|
||||
+ HelpText<"Select target emulation">;
|
||||
+
|
||||
+// Select an optional flavor
|
||||
+def flavor: Separate<["-"], "flavor">,
|
||||
+ HelpText<"Flavor for linking, options are gnu/darwin/link">;
|
||||
+
|
||||
//==============================================================================
|
||||
// The flags below do nothing. They are defined only for link.exe compatibility.
|
||||
//==============================================================================
|
||||
CHECK: File:
|
||||
diff --git a/tools/lld/CMakeLists.txt b/tools/lld/CMakeLists.txt
|
||||
index 2df1069..fc80fbd 100644
|
||||
--- a/tools/lld/CMakeLists.txt
|
||||
+++ b/tools/lld/CMakeLists.txt
|
||||
@@ -10,6 +10,7 @@ target_link_libraries(lld
|
||||
lldDriver
|
||||
lldCOFF
|
||||
lldELF
|
||||
+ lldMinGW
|
||||
)
|
||||
|
||||
install(TARGETS lld
|
||||
diff --git a/tools/lld/lld.cpp b/tools/lld/lld.cpp
|
||||
index 0c32ff1..5bd823a 100644
|
||||
index 09f8079..3b45aec 100644
|
||||
--- a/tools/lld/lld.cpp
|
||||
+++ b/tools/lld/lld.cpp
|
||||
@@ -49,6 +49,24 @@ static Flavor getFlavor(StringRef S) {
|
||||
@@ -49,6 +49,16 @@ static Flavor getFlavor(StringRef S) {
|
||||
.Default(Invalid);
|
||||
}
|
||||
|
||||
+static bool isPETarget(const std::vector<const char *> &V) {
|
||||
+ for (auto It = V.begin(); It != V.end(); It++) {
|
||||
+ if (*It == StringRef("-m")) {
|
||||
+ It++;
|
||||
+ if (It == V.end())
|
||||
+ return false;
|
||||
+ if (*It == StringRef("i386pe"))
|
||||
+ return true;
|
||||
+ if (*It == StringRef("i386pep"))
|
||||
+ return true;
|
||||
+ if (*It == StringRef("thumb2pe"))
|
||||
+ return true;
|
||||
+ return false;
|
||||
+ }
|
||||
+ for (auto It = V.begin(); It + 1 != V.end(); ++It) {
|
||||
+ if (StringRef(*It) != "-m")
|
||||
+ continue;
|
||||
+ StringRef S = *(It + 1);
|
||||
+ return S == "i386pe" || S == "i386pep" || S == "thumb2pe" || S == "arm64pe";
|
||||
+ }
|
||||
+ return false;
|
||||
+}
|
||||
@@ -161,16 +403,15 @@ index 0c32ff1..5bd823a 100644
|
||||
static Flavor parseProgname(StringRef Progname) {
|
||||
#if __APPLE__
|
||||
// Use Darwin driver for "ld" on Darwin.
|
||||
@@ -99,6 +117,9 @@ int main(int Argc, const char **Argv) {
|
||||
llvm_shutdown_obj Shutdown;
|
||||
|
||||
@@ -101,6 +111,8 @@ int main(int Argc, const char **Argv) {
|
||||
std::vector<const char *> Args(Argv, Argv + Argc);
|
||||
+ if (isPETarget(Args))
|
||||
+ return !coff::link(Args);
|
||||
+
|
||||
switch (parseFlavor(Args)) {
|
||||
case Gnu:
|
||||
+ if (isPETarget(Args))
|
||||
+ return !mingw::link(Args);
|
||||
return !elf::link(Args, true);
|
||||
case WinLink:
|
||||
return !coff::link(Args);
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
From 6fa2a85b5bfc696204939659c7f51c185d1d8b47 Mon Sep 17 00:00:00 2001
|
||||
From: Martin Storsjo <martin@martin.st>
|
||||
Date: Mon, 8 Aug 2016 15:37:59 +0300
|
||||
Subject: [PATCH 2/2] Make the "gnu arguments in lld coff" patch not break
|
||||
using lld-link in normal MSVC mode
|
||||
|
||||
---
|
||||
COFF/Driver.cpp | 1 +
|
||||
COFF/DriverUtils.cpp | 5 ++++-
|
||||
COFF/Options.td | 2 ++
|
||||
3 files changed, 7 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/COFF/Driver.cpp b/COFF/Driver.cpp
|
||||
index 4992296..b19998f 100644
|
||||
--- a/COFF/Driver.cpp
|
||||
+++ b/COFF/Driver.cpp
|
||||
@@ -782,6 +782,7 @@ void LinkerDriver::link(ArrayRef<const char *> ArgsArr) {
|
||||
if (Config->ImageBase == uint64_t(-1))
|
||||
Config->ImageBase = getDefaultImageBase();
|
||||
|
||||
+ Symtab.addRelative(mangle("__ImageBase"), 0);
|
||||
Symtab.addRelative(mangle("__image_base__"), 0);
|
||||
if (Config->Machine == I386) {
|
||||
Config->SEHTable = Symtab.addRelative("___safe_se_handler_table", 0);
|
||||
diff --git a/COFF/DriverUtils.cpp b/COFF/DriverUtils.cpp
|
||||
index f5f3d6d..aab554f 100644
|
||||
--- a/COFF/DriverUtils.cpp
|
||||
+++ b/COFF/DriverUtils.cpp
|
||||
@@ -637,7 +637,10 @@ static const llvm::opt::OptTable::Info infoTable[] = {
|
||||
|
||||
class COFFOptTable : public llvm::opt::OptTable {
|
||||
public:
|
||||
- COFFOptTable() : OptTable(infoTable) {}
|
||||
+ // GNU ld option style support requires case sensitive option matching
|
||||
+ // (for -L vs -l), needing aliases for a few link.exe options that can
|
||||
+ // appear in upper case in embedded directives in libraries.
|
||||
+ COFFOptTable() : OptTable(infoTable, false) {}
|
||||
};
|
||||
|
||||
// Parses a given list of options.
|
||||
diff --git a/COFF/Options.td b/COFF/Options.td
|
||||
index b3b30a3..dec6a0a 100644
|
||||
--- a/COFF/Options.td
|
||||
+++ b/COFF/Options.td
|
||||
@@ -19,11 +19,13 @@ def align : P<"align", "Section alignment">;
|
||||
def alternatename : P<"alternatename", "Define weak alias">;
|
||||
def base : P<"base", "Base address of the program">;
|
||||
def defaultlib : P<"defaultlib", "Add the library to the list of input files">;
|
||||
+def DEFAULTLIB : P<"DEFAULTLIB", "">, Alias<defaultlib>;
|
||||
def delayload : P<"delayload", "Delay loaded DLL name">;
|
||||
def entry : P<"entry", "Name of entry point symbol">;
|
||||
def export : P<"export", "Export a function">;
|
||||
// No help text because /failifmismatch is not intended to be used by the user.
|
||||
def failifmismatch : P<"failifmismatch", "">;
|
||||
+def FAILIFMISMATCH : P<"FAILIFMISMATCH", "">, Alias<failifmismatch>;
|
||||
def heap : P<"heap", "Size of the heap">;
|
||||
def implib : P<"implib", "Import library name">;
|
||||
def libpath : P<"libpath", "Additional library search path">;
|
||||
--
|
||||
2.7.4
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,68 +0,0 @@
|
||||
From 44892d7c172014a45e9a191fc36b2d4cca343890 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Tue, 16 Aug 2016 13:05:23 -0700
|
||||
Subject: [PATCH 2/3] COFF: Fix short import lib import name type bitshift
|
||||
|
||||
llvm-readobj: Support short import objects from within an archive
|
||||
The import magic was previous just checked against the archive as a whole
|
||||
|
||||
As per the PE COFF spec (section 8.3, Import Name Type)
|
||||
Offset: 18 Size 2 bits Name: Type
|
||||
Offset: 20 Size 3 bits Name: Name Type
|
||||
|
||||
Offset: 20 added based on 18+2
|
||||
---
|
||||
.../llvm-readobj/Inputs/imports.mangle.coff-x86_64 | Bin 0 -> 2108 bytes
|
||||
test/tools/llvm-readobj/imports-mangle.test | 17 +++++++++++++++++
|
||||
2 files changed, 17 insertions(+)
|
||||
create mode 100644 test/tools/llvm-readobj/Inputs/imports.mangle.coff-x86_64
|
||||
create mode 100644 test/tools/llvm-readobj/imports-mangle.test
|
||||
|
||||
diff --git a/test/tools/llvm-readobj/Inputs/imports.mangle.coff-x86_64 b/test/tools/llvm-readobj/Inputs/imports.mangle.coff-x86_64
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..af6e583a31b953d1c9451266b09bee50093b8d54
|
||||
GIT binary patch
|
||||
literal 2108
|
||||
zcmb_d&2JJ>5dX1!Db|LlF)`5wn<nZ7VRs80{8+RmU@2`V9Q3k9)>@hpnzkM|G&UYM
|
||||
z`7e0zkMPE!S8sYU9@>AzL!H_8-m)OpZqrTX&6^Kq-uu0o;qIg6PHW>y;$dp^%bG^c
|
||||
zDC9Dk{HQ)7MLna--C6>`6+oK-A_XA23B(U19TR7o6%-o)v4L%umsXZ*b$j8(>hoH8
|
||||
zrM_IV*SlTVcC}Hd{B6VsvI<+h)Tl1n3&nboyxW~^d$-rg!d*OBXIYnab}%5;r?fXM
|
||||
z>s7H-vR+I3s4g%H*&zyXf?-Aj3K3v43LKE)m}r)05OX0y93g15#t=bNu3?OxAuu}P
|
||||
z;^RRW99vv|2$T;aVIv0@K7BIAgnQcA+VWueUsafSRW54@rys`8kDnXi5O9gG;V<pH
|
||||
zee?d^+^Ud($F%vR1j#KVpQYPQbFVq4E7J|yd?PxNiZF2tnM3K9lWI55Z=WCQEu;?V
|
||||
zSul;uEFvy1br08*{AS->EigrVzjtk^-P-BycGve(_iGPQm2!1a+D8~W^C6h1?A=|G
|
||||
zR(f~R$qcYs-Oe_haldzjlM}x;xlti7sjFImd&~``aW5ruNFS4Z=tuB;=7$>A-{wVr
|
||||
z937aK5;F}iX$@Rn6Pqs)v@&!v=gkYJuep`+)jbp+ZE|He!sM;K$}p6YE8~k2B<ISw
|
||||
z@E1SJTi&4q{Bwu}Ml4_OAtrk17bOr6I~lQ4ddaH<?nUk;|7XEcy<{pq`~6UY<m`8$
|
||||
z$esn&Ta<ia5e7xnRKq&O|5@CSPM;^#P4{+FV{=$FanLM=DW7dD%QR&P(S#C%_uSEq
|
||||
b$<eP;bd3g)JJ40|z+Gyb8Xe+~)r<ZIjQx$i
|
||||
|
||||
literal 0
|
||||
HcmV?d00001
|
||||
|
||||
diff --git a/test/tools/llvm-readobj/imports-mangle.test b/test/tools/llvm-readobj/imports-mangle.test
|
||||
new file mode 100644
|
||||
index 0000000..211fc57
|
||||
--- /dev/null
|
||||
+++ b/test/tools/llvm-readobj/imports-mangle.test
|
||||
@@ -0,0 +1,17 @@
|
||||
+RUN: llvm-readobj --coff-imports %p/Inputs/imports.mangle.coff-x86_64 | FileCheck -check-prefix=X64 %s
|
||||
+
|
||||
+X64: Name type: undecorate
|
||||
+X64-NEXT: Symbol: __imp_?sym4@@YAHH@Z
|
||||
+X64-NEXT: Symbol: ?sym4@@YAHH@Z
|
||||
+
|
||||
+X64: Name type: noprefix
|
||||
+X64-NEXT: Symbol: __imp__sym3
|
||||
+X64-NEXT: Symbol: _sym3
|
||||
+
|
||||
+X64: Name type: name
|
||||
+X64-NEXT: Symbol: __imp_sym1
|
||||
+X64-NEXT: Symbol: sym1
|
||||
+
|
||||
+X64: Name type: ordinal
|
||||
+X64-NEXT: Symbol: __imp_sym2
|
||||
+X64-NEXT: Symbol: sym2
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
From b0e293af0bdcb46da3ec6fd90d67e1deaa7ab907 Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Tue, 16 Aug 2016 12:55:01 -0700
|
||||
Subject: [PATCH 3/3] mingw-w64: use MSVC style ByteAlignment
|
||||
|
||||
We can do alignment without -aligncomm derectives in PE COFF
|
||||
Until we support GNU style in lld we should use this
|
||||
---
|
||||
lib/MC/WinCOFFStreamer.cpp | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/lib/MC/WinCOFFStreamer.cpp b/lib/MC/WinCOFFStreamer.cpp
|
||||
index 6383d87..06a5aef 100644
|
||||
--- a/lib/MC/WinCOFFStreamer.cpp
|
||||
+++ b/lib/MC/WinCOFFStreamer.cpp
|
||||
@@ -217,7 +217,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size,
|
||||
auto *Symbol = cast<MCSymbolCOFF>(S);
|
||||
|
||||
const Triple &T = getContext().getObjectFileInfo()->getTargetTriple();
|
||||
- if (T.isKnownWindowsMSVCEnvironment()) {
|
||||
+ if (T.getEnvironment() != Triple::Cygnus) {
|
||||
if (ByteAlignment > 32)
|
||||
report_fatal_error("alignment is limited to 32-bytes");
|
||||
|
||||
@@ -229,7 +229,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol(MCSymbol *S, uint64_t Size,
|
||||
Symbol->setExternal(true);
|
||||
Symbol->setCommon(Size, ByteAlignment);
|
||||
|
||||
- if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
|
||||
+ if (T.getEnvironment() == Triple::Cygnus && ByteAlignment > 1) {
|
||||
SmallString<128> Directive;
|
||||
raw_svector_ostream OS(Directive);
|
||||
const MCObjectFileInfo *MFI = getContext().getObjectFileInfo();
|
||||
--
|
||||
2.7.4
|
||||
|
||||
+77
-23
@@ -1,36 +1,90 @@
|
||||
From 077f2318a219db191588d0ab00df58bb694c2931 Mon Sep 17 00:00:00 2001
|
||||
From beb5ab5b7b18e82cc2d73ed23639cf9aa1a8ec6f Mon Sep 17 00:00:00 2001
|
||||
From: Martell Malone <martellmalone@gmail.com>
|
||||
Date: Fri, 5 Aug 2016 20:09:41 -0700
|
||||
Subject: [PATCH] Handle __CTOR_LIST__ for clang
|
||||
Date: Fri, 18 Aug 2017 19:59:20 +0100
|
||||
Subject: [PATCH] crt: Handle .ctors and .dtors within mingw-w64
|
||||
|
||||
When building with clang we currently assume you will be
|
||||
linking with llvm's lld or a bleeding edge binutils.
|
||||
In future this will become the default method once
|
||||
binutils support has settled and bumped a few versions.
|
||||
---
|
||||
This patch is up for review at
|
||||
https://sourceforge.net/p/mingw-w64/mailman/message/36002789/.
|
||||
---
|
||||
|
||||
diff --git a/mingw-w64-crt/crt/crtbegin.c b/mingw-w64-crt/crt/crtbegin.c
|
||||
index 39c0d85..231dafc 100644
|
||||
--- a/mingw-w64-crt/crt/crtbegin.c
|
||||
+++ b/mingw-w64-crt/crt/crtbegin.c
|
||||
@@ -4,3 +4,7 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
+#ifdef __clang__
|
||||
+__attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_LIST__ = (void *) -1;
|
||||
+__attribute__ (( __section__ (".dtors"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_LIST__ = (void *) -1;
|
||||
+#endif
|
||||
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
|
||||
index ae37e0f..ad91f25 100644
|
||||
--- a/mingw-w64-crt/crt/crtexe.c
|
||||
+++ b/mingw-w64-crt/crt/crtexe.c
|
||||
@@ -60,6 +60,11 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
|
||||
diff --git a/mingw-w64-crt/crt/crtdll.c b/mingw-w64-crt/crt/crtdll.c
|
||||
index 07a18408..85035d49 100644
|
||||
--- a/mingw-w64-crt/crt/crtdll.c
|
||||
+++ b/mingw-w64-crt/crt/crtdll.c
|
||||
@@ -40,6 +40,13 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
|
||||
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
|
||||
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
|
||||
|
||||
+#ifdef __clang__
|
||||
+extern _CRTALLOC(".ctors$zzz") void *__CTOR_END__[] = {(void*)0};
|
||||
+extern _CRTALLOC(".dtors$zzz") void *__DTOR_END__[] = {(void*)0};
|
||||
+__attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_LIST__ = (void *) -1;
|
||||
+__attribute__ (( __section__ (".dtors"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_LIST__ = (void *) -1;
|
||||
+__attribute__ (( __section__ (".ctors$zzz"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_END__ = (void *) 0;
|
||||
+__attribute__ (( __section__ (".dtors$zzz"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_END__ = (void *) 0;
|
||||
+#endif
|
||||
+
|
||||
/* TLS initialization hook. */
|
||||
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
|
||||
|
||||
diff --git a/mingw-w64-crt/crt/crtexe.c b/mingw-w64-crt/crt/crtexe.c
|
||||
index ae37e0fe..e3a84784 100644
|
||||
--- a/mingw-w64-crt/crt/crtexe.c
|
||||
+++ b/mingw-w64-crt/crt/crtexe.c
|
||||
@@ -60,6 +60,13 @@ extern _CRTALLOC(".CRT$XIZ") _PIFV __xi_z[];
|
||||
extern _CRTALLOC(".CRT$XCA") _PVFV __xc_a[];
|
||||
extern _CRTALLOC(".CRT$XCZ") _PVFV __xc_z[];
|
||||
|
||||
+#ifdef __clang__
|
||||
+__attribute__ (( __section__ (".ctors"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_LIST__ = (void *) -1;
|
||||
+__attribute__ (( __section__ (".dtors"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_LIST__ = (void *) -1;
|
||||
+__attribute__ (( __section__ (".ctors$zzz"), __used__ , aligned(sizeof(void *)))) const void * __CTOR_END__ = (void *) 0;
|
||||
+__attribute__ (( __section__ (".dtors$zzz"), __used__ , aligned(sizeof(void *)))) const void * __DTOR_END__ = (void *) 0;
|
||||
+#endif
|
||||
+
|
||||
/* TLS initialization hook. */
|
||||
extern const PIMAGE_TLS_CALLBACK __dyn_tls_init_callback;
|
||||
|
||||
diff --git a/mingw-w64-crt/crt/gccmain.c b/mingw-w64-crt/crt/gccmain.c
|
||||
index fc0e3500..54cbf02b 100644
|
||||
--- a/mingw-w64-crt/crt/gccmain.c
|
||||
+++ b/mingw-w64-crt/crt/gccmain.c
|
||||
@@ -28,6 +28,23 @@ __do_global_dtors (void)
|
||||
}
|
||||
}
|
||||
|
||||
+#ifdef __clang__
|
||||
+extern func_ptr __CTOR_END__[];
|
||||
+extern func_ptr __DTOR_END__[];
|
||||
+
|
||||
+void __do_global_ctors (void)
|
||||
+{
|
||||
+ static func_ptr *p = __CTOR_END__ - 1;
|
||||
+ while (*p != (func_ptr) -1) {
|
||||
+ (*(p))();
|
||||
+ p--;
|
||||
+ }
|
||||
+ atexit (__do_global_dtors);
|
||||
+}
|
||||
+
|
||||
+#else
|
||||
+// old method that iterates the list twice because old linker scripts do not have __CTOR_END__
|
||||
+
|
||||
void
|
||||
__do_global_ctors (void)
|
||||
{
|
||||
@@ -47,6 +64,8 @@ __do_global_ctors (void)
|
||||
atexit (__do_global_dtors);
|
||||
}
|
||||
|
||||
+#endif
|
||||
+
|
||||
static int initialized = 0;
|
||||
|
||||
void
|
||||
--
|
||||
2.8.3
|
||||
2.14.1
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
From 5592b70cca64935b0d090fe5030b3110ba17068c Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= <hugo@beauzee.fr>
|
||||
Date: Fri, 13 May 2016 15:17:56 +0200
|
||||
Subject: [PATCH] yvals.h: Don't create a _Bool typedef if a macro already
|
||||
exists
|
||||
|
||||
---
|
||||
mingw-w64-headers/crt/yvals.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/mingw-w64-headers/crt/yvals.h b/mingw-w64-headers/crt/yvals.h
|
||||
index 70593c4..98b6921 100644
|
||||
--- a/mingw-w64-headers/crt/yvals.h
|
||||
+++ b/mingw-w64-headers/crt/yvals.h
|
||||
@@ -163,10 +163,12 @@
|
||||
#define _Restrict __restrict__
|
||||
|
||||
#ifdef __cplusplus
|
||||
+#ifndef _Bool
|
||||
_STD_BEGIN
|
||||
typedef bool _Bool;
|
||||
_STD_END
|
||||
#endif
|
||||
+#endif
|
||||
|
||||
#define _LONGLONG /* __MINGW_EXTENSION */ __int64
|
||||
#define _ULONGLONG /* __MINGW_EXTENSION */ unsigned __int64
|
||||
--
|
||||
2.8.1
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,25 +0,0 @@
|
||||
From cf2434c417310703cfda61943c66f33fa23bde57 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st>
|
||||
Date: Thu, 18 Aug 2016 09:48:29 +0300
|
||||
Subject: [PATCH] Add aliases for open/read/write/close and setmode
|
||||
|
||||
---
|
||||
mingw-w64-crt/libarm32/msvcrt.def | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/mingw-w64-crt/libarm32/msvcrt.def b/mingw-w64-crt/libarm32/msvcrt.def
|
||||
index 2533d5a..4e3fe25 100644
|
||||
--- a/mingw-w64-crt/libarm32/msvcrt.def
|
||||
+++ b/mingw-w64-crt/libarm32/msvcrt.def
|
||||
@@ -1278,3 +1278,8 @@ wprintf
|
||||
wprintf_s
|
||||
wscanf
|
||||
wscanf_s
|
||||
+open = _open
|
||||
+read = _read
|
||||
+write = _write
|
||||
+close = _close
|
||||
+setmode = _setmode
|
||||
--
|
||||
2.7.4
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
$DIR/clang -target armv7-windows-gnu "$@"
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
$DIR/clang++ -target armv7-windows-gnu "$@"
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
TARGET="$(basename $0 | sed 's/-clang.*//')"
|
||||
EXE=$(basename $0 | sed 's/.*-\(clang.*\)/\1/')
|
||||
# We could set these defaults in the clang frontend driver, but that's not yet merged upstream
|
||||
$DIR/$EXE -target $TARGET -rtlib=compiler-rt -stdlib=libc++ -fuse-ld=lld -Qunused-arguments "$@"
|
||||
Reference in new issue
Block a user