From bf656d77e785f8e7095ced1826de00857d574534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 22 Aug 2017 12:02:47 +0300 Subject: [PATCH] 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. --- Dockerfile | 204 ++-- patches/clang-0001.patch | 49 - patches/clang-0002.patch | 45 - patches/clang-0003.patch | 28 - patches/clang-0004.patch | 53 - patches/compiler-rt-0001.patch | 48 + patches/libcxx-0001.patch | 268 ----- patches/libcxx-0002.patch | 59 - patches/libcxxabi-0001.patch | 25 - patches/libunwind-0001.patch | 147 --- patches/libunwind-0002.patch | 25 - patches/lld-0001.patch | 521 ++++++--- patches/lld-0002.patch | 61 -- patches/llvm-0001.patch | 1447 ------------------------ patches/llvm-0002.patch | 68 -- patches/llvm-0003.patch | 36 - patches/mingw-0001.patch | 100 +- patches/mingw-0002.patch | 30 - patches/mingw-0003.patch | 1640 ---------------------------- patches/mingw-0004.patch | 25 - wrappers/armv7-w64-mingw32-clang | 3 - wrappers/armv7-w64-mingw32-clang++ | 3 - wrappers/clang-target-wrapper | 6 + 23 files changed, 655 insertions(+), 4236 deletions(-) delete mode 100644 patches/clang-0001.patch delete mode 100644 patches/clang-0002.patch delete mode 100644 patches/clang-0003.patch delete mode 100644 patches/clang-0004.patch create mode 100644 patches/compiler-rt-0001.patch delete mode 100644 patches/libcxx-0001.patch delete mode 100644 patches/libcxx-0002.patch delete mode 100644 patches/libcxxabi-0001.patch delete mode 100644 patches/libunwind-0001.patch delete mode 100644 patches/libunwind-0002.patch delete mode 100644 patches/lld-0002.patch delete mode 100644 patches/llvm-0001.patch delete mode 100644 patches/llvm-0002.patch delete mode 100644 patches/llvm-0003.patch delete mode 100644 patches/mingw-0002.patch delete mode 100644 patches/mingw-0003.patch delete mode 100644 patches/mingw-0004.patch delete mode 100755 wrappers/armv7-w64-mingw32-clang delete mode 100755 wrappers/armv7-w64-mingw32-clang++ create mode 100755 wrappers/clang-target-wrapper diff --git a/Dockerfile b/Dockerfile index db75b01..994fbb0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/patches/clang-0001.patch b/patches/clang-0001.patch deleted file mode 100644 index 436df53..0000000 --- a/patches/clang-0001.patch +++ /dev/null @@ -1,49 +0,0 @@ -From 82a145503d9b1aecf8cf45bd7b536543f3342345 Mon Sep 17 00:00:00 2001 -From: Martell Malone -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 - diff --git a/patches/clang-0002.patch b/patches/clang-0002.patch deleted file mode 100644 index 19ae700..0000000 --- a/patches/clang-0002.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 553e9229258fd4127e35ad983217b7e4825fdfef Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -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 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 - diff --git a/patches/clang-0003.patch b/patches/clang-0003.patch deleted file mode 100644 index 18159f1..0000000 --- a/patches/clang-0003.patch +++ /dev/null @@ -1,28 +0,0 @@ -From ebade0c4f7558bb16b2504f06076585d1f618a4c Mon Sep 17 00:00:00 2001 -From: Martell Malone -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 { - let Documentation = [DLLImportDocs]; - } - --def SelectAny : InheritableAttr { -- let Spellings = [Declspec<"selectany">]; -- let LangOpts = [MicrosoftExt]; -+def SelectAny : InheritableAttr, TargetSpecificAttr { -+ let Spellings = [Declspec<"selectany">, GCC<"selectany">]; - let Documentation = [Undocumented]; - } - --- -2.7.4 - diff --git a/patches/clang-0004.patch b/patches/clang-0004.patch deleted file mode 100644 index 973532d..0000000 --- a/patches/clang-0004.patch +++ /dev/null @@ -1,53 +0,0 @@ -From 2488a5d11c8a5ff0c5ab3749dd36ef8ba53bfac1 Mon Sep 17 00:00:00 2001 -From: Martell Malone -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 - diff --git a/patches/compiler-rt-0001.patch b/patches/compiler-rt-0001.patch new file mode 100644 index 0000000..2f1ced0 --- /dev/null +++ b/patches/compiler-rt-0001.patch @@ -0,0 +1,48 @@ +From 5d4ad66bdde2ff103c848dc2709a5a67f4d2844f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= +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 + diff --git a/patches/libcxx-0001.patch b/patches/libcxx-0001.patch deleted file mode 100644 index ea4f9b0..0000000 --- a/patches/libcxx-0001.patch +++ /dev/null @@ -1,268 +0,0 @@ -From 57d48bf47108014aa5e0c5435c107581e86e3045 Mon Sep 17 00:00:00 2001 -From: Martell Malone -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 -+ -+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 - #endif - #include -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 -+#endif -+ - #include - #include // 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 // va_start, va_end - #include // size_t - #include // 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 - diff --git a/patches/libcxx-0002.patch b/patches/libcxx-0002.patch deleted file mode 100644 index 72a6d91..0000000 --- a/patches/libcxx-0002.patch +++ /dev/null @@ -1,59 +0,0 @@ -From a91ea0b2d56e1dc45dbe3edda9e16a8724311d21 Mon Sep 17 00:00:00 2001 -From: Martin Storsjo -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 - -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 - diff --git a/patches/libcxxabi-0001.patch b/patches/libcxxabi-0001.patch deleted file mode 100644 index f15f747..0000000 --- a/patches/libcxxabi-0001.patch +++ /dev/null @@ -1,25 +0,0 @@ -From af6e844261dda2786985ff43fcd6873b636b57aa Mon Sep 17 00:00:00 2001 -From: Martin Storsjo -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 - diff --git a/patches/libunwind-0001.patch b/patches/libunwind-0001.patch deleted file mode 100644 index cbe9708..0000000 --- a/patches/libunwind-0001.patch +++ /dev/null @@ -1,147 +0,0 @@ -From 46a001b37a0355b588ad99a3aab5593926fa31bc Mon Sep 17 00:00:00 2001 -From: Martell Malone -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 - #include - --#ifndef _LIBUNWIND_IS_BAREMETAL -+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) - #include - #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(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 - diff --git a/patches/libunwind-0002.patch b/patches/libunwind-0002.patch deleted file mode 100644 index 49d5b48..0000000 --- a/patches/libunwind-0002.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 17e850de43aefe7da87db8c2eaa521e5159c1cbb Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -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 - #else // !defined(_LIBUNWIND_IS_BAREMETAL) --- -2.7.4 - diff --git a/patches/lld-0001.patch b/patches/lld-0001.patch index efcc4ae..15db859 100644 --- a/patches/lld-0001.patch +++ b/patches/lld-0001.patch @@ -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 -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 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 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 ++#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 Argv); ++}; ++ ++} // namespace ++ ++BumpPtrAllocator BAlloc; ++StringSaver Saver{BAlloc}; ++static SmallVector LinkArgs; ++static std::vector 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 LinkerDriver::findFile(StringRef Filename) { -@@ -667,6 +693,9 @@ void LinkerDriver::link(ArrayRef ArgsArr) { - for (auto *Arg : Args.filtered(OPT_defaultlib)) - if (Optional Path = findLib(Arg->getValue())) - enqueuePath(*Path); -+ for (auto *Arg : Args.filtered(OPT_l)) -+ if (Optional 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 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 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 findFromSearchPaths(StringRef Path) { ++ for (StringRef Dir : SearchPaths) ++ if (Optional 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 searchLibrary(StringRef Name, bool IgnoreShared = false) { ++ if (Name.startswith(":")) ++ return findFromSearchPaths(Name.substr(1)); ++ for (StringRef Dir : SearchPaths) { ++ if (!IgnoreShared) ++ if (Optional S = findFile(Dir, "lib" + Name + ".dll.a")) ++ return S; ++ if (Optional 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 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 getArgs(opt::InputArgList &Args, int Id) { ++ std::vector 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 Argv) { ++ unsigned MissingIndex; ++ unsigned MissingCount; ++ SmallVector 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 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: Flag<["--", "-"], name>; ++class J: Joined<["--", "-"], name>; ++class S: Separate<["--", "-"], name>; ++ ++def L: JoinedOrSeparate<["-"], "L">, MetaVarName<"">, ++ HelpText<"Add a directory to the library search path">; ++def entry: S<"entry">, MetaVarName<"">, ++ HelpText<"Name of entry point symbol">; ++def m: JoinedOrSeparate<["-"], "m">, HelpText<"Set target emulation">; ++def o: JoinedOrSeparate<["-"], "o">, MetaVarName<"">, ++ HelpText<"Path to file to write output">; ++def l: JoinedOrSeparate<["-"], "l">, MetaVarName<"">, ++ 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; ++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; ++ ++// 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 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 Args, ++ llvm::raw_ostream &Diag = llvm::errs()); ++} ++ + namespace elf { + bool link(llvm::ArrayRef 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; -+def L : Joined<["-"], "L">, Alias; -+def e : Separate<["-"], "e">, Alias; -+def subs : Separate<["--"], "subsystem">, Alias; -+ -+def l : JoinedOrSeparate<["-"], "l">, MetaVarName<"">; -+ -+// 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<"">, -+ 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 &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 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 diff --git a/patches/lld-0002.patch b/patches/lld-0002.patch deleted file mode 100644 index e100cfa..0000000 --- a/patches/lld-0002.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 6fa2a85b5bfc696204939659c7f51c185d1d8b47 Mon Sep 17 00:00:00 2001 -From: Martin Storsjo -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 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; - 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; - 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 - diff --git a/patches/llvm-0001.patch b/patches/llvm-0001.patch deleted file mode 100644 index eb23f7d..0000000 --- a/patches/llvm-0001.patch +++ /dev/null @@ -1,1447 +0,0 @@ -From 23fe55b344184414deed5713cc3033e1706056aa Mon Sep 17 00:00:00 2001 -From: Martell Malone -Date: Tue, 9 Aug 2016 17:52:46 -0700 -Subject: [PATCH 1/3] genlib: named as llvm-dlltool - -A PE COFF spec compliant import library generator. -Intended to be used with mingw-w64. - -Supports: -PE COFF spec (section 8, Import Library Format) -PE COFF spec (Aux Format 3: Weak Externals) ---- - include/llvm/DllDriver/DllDriver.h | 24 ++ - lib/CMakeLists.txt | 1 + - lib/DLLDriver/CMakeLists.txt | 11 + - lib/DLLDriver/Config.h | 119 ++++++++ - lib/DLLDriver/DllDriver.cpp | 185 ++++++++++++ - lib/DLLDriver/LLVMBuild.txt | 22 ++ - lib/DLLDriver/Librarian.cpp | 603 +++++++++++++++++++++++++++++++++++++ - lib/DLLDriver/ModuleDef.cpp | 321 ++++++++++++++++++++ - lib/DLLDriver/Options.td | 5 + - lib/Object/ArchiveWriter.cpp | 3 +- - tools/llvm-ar/CMakeLists.txt | 2 + - tools/llvm-ar/llvm-ar.cpp | 6 +- - 12 files changed, 1300 insertions(+), 2 deletions(-) - create mode 100644 include/llvm/DllDriver/DllDriver.h - create mode 100644 lib/DLLDriver/CMakeLists.txt - create mode 100644 lib/DLLDriver/Config.h - create mode 100644 lib/DLLDriver/DllDriver.cpp - create mode 100644 lib/DLLDriver/LLVMBuild.txt - create mode 100644 lib/DLLDriver/Librarian.cpp - create mode 100644 lib/DLLDriver/ModuleDef.cpp - create mode 100644 lib/DLLDriver/Options.td - -diff --git a/include/llvm/DllDriver/DllDriver.h b/include/llvm/DllDriver/DllDriver.h -new file mode 100644 -index 0000000..79fb7b7 ---- /dev/null -+++ b/include/llvm/DllDriver/DllDriver.h -@@ -0,0 +1,24 @@ -+//===- llvm/DLLDriver/DLLDriver.h - dlltool.exe-compatible driver ---*- C++ -*-===// -+// -+// The LLVM Compiler Infrastructure -+// -+// This file is distributed under the University of Illinois Open Source -+// License. See LICENSE.TXT for details. -+// -+//===----------------------------------------------------------------------===// -+// -+// Defines an interface to a dlltool.exe-compatible driver that also understands -+// bitcode files. Used by llvm-dlltool and lld. -+// -+//===----------------------------------------------------------------------===// -+ -+#ifndef LLVM_DLLDRIVER_DLLDRIVER_H -+#define LLVM_DLLDRIVER_DLLDRIVER_H -+ -+namespace llvm { -+template class ArrayRef; -+ -+int dllToolDriverMain(ArrayRef ARgs); -+} -+ -+#endif -diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt -index 7654954..bebb628 100644 ---- a/lib/CMakeLists.txt -+++ b/lib/CMakeLists.txt -@@ -21,5 +21,6 @@ add_subdirectory(LineEditor) - add_subdirectory(ProfileData) - add_subdirectory(Fuzzer) - add_subdirectory(Passes) -+add_subdirectory(DLLDriver) - add_subdirectory(LibDriver) - add_subdirectory(XRay) -diff --git a/lib/DLLDriver/CMakeLists.txt b/lib/DLLDriver/CMakeLists.txt -new file mode 100644 -index 0000000..91fb2f0 ---- /dev/null -+++ b/lib/DLLDriver/CMakeLists.txt -@@ -0,0 +1,11 @@ -+set(LLVM_TARGET_DEFINITIONS Options.td) -+tablegen(LLVM Options.inc -gen-opt-parser-defs) -+add_public_tablegen_target(DllOptionsTableGen) -+ -+add_llvm_library(LLVMDllDriver -+ DllDriver.cpp -+ ModuleDef.cpp -+ Librarian.cpp -+ ) -+ -+add_dependencies(LLVMDllDriver DllOptionsTableGen) -diff --git a/lib/DLLDriver/Config.h b/lib/DLLDriver/Config.h -new file mode 100644 -index 0000000..d5a3d26 ---- /dev/null -+++ b/lib/DLLDriver/Config.h -@@ -0,0 +1,119 @@ -+#ifndef LLVM_COFF_CONFIG_H -+#define LLVM_COFF_CONFIG_H -+ -+#include "llvm/ADT/StringRef.h" -+#include "llvm/Object/COFF.h" -+#include -+#include -+#include -+#include -+ -+namespace llvm { -+ -+using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; -+using llvm::COFF::WindowsSubsystem; -+using llvm::StringRef; -+ -+// Short aliases. -+static const auto AMD64 = llvm::COFF::IMAGE_FILE_MACHINE_AMD64; -+static const auto ARMNT = llvm::COFF::IMAGE_FILE_MACHINE_ARMNT; -+static const auto I386 = llvm::COFF::IMAGE_FILE_MACHINE_I386; -+ -+struct Export { -+ StringRef Name; // N in N or E=N -+ StringRef ExtName; // E in E=N -+ -+ uint16_t Ordinal = 0; -+ bool Noname = false; -+ bool Data = false; -+ bool Private = false; -+ -+ // True if this /export option was in .drectves section. -+ bool Directives = false; -+ StringRef SymbolName; -+ StringRef ExportName; // Name in DLL -+ -+ bool isWeak() { -+ if(ExtName.size() && Name != ExtName) -+ return true; -+ return false; -+ } -+}; -+ -+// Global configuration. -+struct Configuration { -+ enum ManifestKind { SideBySide, Embed, No }; -+ bool is64() { return Machine == AMD64; } -+ std::vector Exports; -+ -+ llvm::COFF::MachineTypes Machine = IMAGE_FILE_MACHINE_UNKNOWN; -+ bool Verbose = false; -+ WindowsSubsystem Subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN; -+ bool NoEntry = false; -+ std::string OutputFile; -+ bool DoGC = true; -+ bool DoICF = true; -+ bool Relocatable = true; -+ bool Force = false; -+ bool Debug = false; -+ bool WriteSymtab = true; -+ -+ std::set NoDefaultLibs; -+ bool NoDefaultLibAll = false; -+ -+ // True if we are creating a DLL. -+ bool DLL = false; -+ StringRef Implib; -+ std::set DelayLoads; -+ std::map DLLOrder; -+ -+ // Used for /opt:lldlto=N -+ unsigned LTOOptLevel = 2; -+ -+ // Used for /opt:lldltojobs=N -+ unsigned LTOJobs = 1; -+ -+ // Used for /merge:from=to (e.g. /merge:.rdata=.text) -+ std::map Merge; -+ -+ // Used for /section=.name,{DEKPRSW} to set section attributes. -+ std::map Section; -+ -+ // Options for manifest files. -+ ManifestKind Manifest = SideBySide; -+ int ManifestID = 1; -+ StringRef ManifestDependency; -+ bool ManifestUAC = true; -+ std::vector ManifestInput; -+ StringRef ManifestLevel = "'asInvoker'"; -+ StringRef ManifestUIAccess = "'false'"; -+ StringRef ManifestFile; -+ -+ // Used for /failifmismatch. -+ std::map MustMatch; -+ -+ // Used for /alternatename. -+ std::map AlternateNames; -+ -+ uint64_t ImageBase = -1; -+ uint64_t StackReserve = 1024 * 1024; -+ uint64_t StackCommit = 4096; -+ uint64_t HeapReserve = 1024 * 1024; -+ uint64_t HeapCommit = 4096; -+ uint32_t MajorImageVersion = 0; -+ uint32_t MinorImageVersion = 0; -+ uint32_t MajorOSVersion = 6; -+ uint32_t MinorOSVersion = 0; -+ bool DynamicBase = true; -+ bool AllowBind = true; -+ bool NxCompat = true; -+ bool AllowIsolation = true; -+ bool TerminalServerAware = true; -+ bool LargeAddressAware = false; -+ bool HighEntropyVA = false; -+}; -+ -+extern Configuration *Config; -+} // namespace llvm -+ -+#endif -\ No newline at end of file -diff --git a/lib/DLLDriver/DllDriver.cpp b/lib/DLLDriver/DllDriver.cpp -new file mode 100644 -index 0000000..aa9adc8 ---- /dev/null -+++ b/lib/DLLDriver/DllDriver.cpp -@@ -0,0 +1,185 @@ -+//===- DllDriver.cpp - dlltool.exe-compatible driver --------------------------===// -+// -+// The LLVM Compiler Infrastructure -+// -+// This file is distributed under the University of Illinois Open Source -+// License. See LICENSE.TXT for details. -+// -+//===----------------------------------------------------------------------===// -+// -+// Defines an interface to a dlltool.exe-compatible driver that also understands -+// bitcode files. -+// -+//===----------------------------------------------------------------------===// -+ -+#include "llvm/DllDriver/DllDriver.h" -+#include "llvm/ADT/STLExtras.h" -+#include "llvm/Object/ArchiveWriter.h" -+#include "llvm/Option/Arg.h" -+#include "llvm/Option/ArgList.h" -+#include "llvm/Object/COFF.h" -+#include "llvm/Option/Option.h" -+#include "llvm/Support/CommandLine.h" -+#include "llvm/Support/StringSaver.h" -+#include "llvm/Support/Path.h" -+#include "llvm/Support/Process.h" -+#include "llvm/Support/raw_ostream.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "Config.h" -+ -+using namespace llvm; -+ -+namespace llvm{ -+Configuration *Config; -+void parseModuleDefs(MemoryBufferRef MB, StringSaver *Alloc); -+} -+ -+namespace { -+ -+enum { -+ OPT_INVALID = 0, -+#define OPTION(_1, _2, ID, _4, _5, _6, _7, _8, _9, _10, _11) OPT_##ID, -+#include "Options.inc" -+#undef OPTION -+}; -+ -+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE; -+#include "Options.inc" -+#undef PREFIX -+ -+static const llvm::opt::OptTable::Info infoTable[] = { -+#define OPTION(X1, X2, ID, KIND, GROUP, ALIAS, X6, X7, X8, X9, X10) \ -+ { \ -+ X1, X2, X9, X10, OPT_##ID, llvm::opt::Option::KIND##Class, X8, X7, \ -+ OPT_##GROUP, OPT_##ALIAS, X6 \ -+ }, -+#include "Options.inc" -+#undef OPTION -+}; -+ -+class DllOptTable : public llvm::opt::OptTable { -+public: -+ DllOptTable() : OptTable(infoTable, false) {} -+}; -+ -+} -+ -+std::vector> OwningMBs; -+ -+// Opens a file. Path has to be resolved already. -+// Newly created memory buffers are owned by this driver. -+MemoryBufferRef openFile(StringRef Path) { -+ llvm::ErrorOr> MB = -+ MemoryBuffer::getFile(Path); -+ -+ if (std::error_code EC = MB.getError()) -+ llvm::errs() << "fail openFile: " << EC.message() << "\n"; -+ -+ MemoryBufferRef MBRef = MB.get()->getMemBufferRef(); -+ OwningMBs.push_back(std::move(MB.get())); // take ownership -+ return MBRef; -+} -+ -+#include "llvm/Support/raw_ostream.h" -+ -+#include "llvm/ADT/StringSwitch.h" -+#include "llvm/Option/Arg.h" -+#include "llvm/Option/ArgList.h" -+#include "llvm/Support/StringSaver.h" -+ -+static llvm::COFF::MachineTypes getEmulation(StringRef S) { -+ return StringSwitch(S) -+ .Case("x86", llvm::COFF::IMAGE_FILE_MACHINE_I386) -+ .Case("x86_64", llvm::COFF::IMAGE_FILE_MACHINE_AMD64) -+ .Case("arm", llvm::COFF::IMAGE_FILE_MACHINE_ARMNT) -+ .Default(llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN); -+} -+ -+static std::string getImplibPath() { -+ if (!Config->Implib.empty()) -+ return Config->Implib; -+ SmallString<128> Out = StringRef(Config->OutputFile); -+ sys::path::replace_extension(Out, ".lib"); -+ return Out.str(); -+} -+ -+int writeImportLibrary(std::string &Path); -+ -+int llvm::dllToolDriverMain(llvm::ArrayRef ArgsArr) { -+ SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end()); -+ BumpPtrAllocator Alloc; -+ StringSaver Saver(Alloc); -+ cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs); -+ ArgsArr = NewArgs; -+ -+ Configuration C; -+ Config = &C; -+ -+ DllOptTable Table; -+ unsigned MissingIndex; -+ unsigned MissingCount; -+ llvm::opt::InputArgList Args = -+ Table.ParseArgs(ArgsArr.slice(1), MissingIndex, MissingCount); -+ if (MissingCount) { -+ llvm::errs() << "missing arg value for \"" -+ << Args.getArgString(MissingIndex) << "\", expected " -+ << MissingCount -+ << (MissingCount == 1 ? " argument.\n" : " arguments.\n"); -+ return 1; -+ } -+ for (auto *Arg : Args.filtered(OPT_UNKNOWN)) -+ llvm::errs() << "ignoring unknown argument: " << Arg->getSpelling() << "\n"; -+ -+ if (Args.filtered_begin(OPT_INPUT) == Args.filtered_end()) { -+ llvm::outs() << "NO ARGS" << "\n"; -+ return 0; -+ } -+ -+ if (Args.filtered_begin(OPT_emu) == Args.filtered_end()) { -+ llvm::outs() << "Need to set an emulation mode" << "\n"; -+ return -1; -+ } -+ -+ std::string Path; -+ MemoryBufferRef MB; -+ int i=0; -+ for (auto *Arg : Args.filtered(OPT_INPUT)) { -+ if(i==0) -+ MB = openFile(Arg->getValue()); -+ if(i==1) -+ Path = Arg->getValue(); -+ i++; -+ } -+ -+ if (auto *Arg = Args.getLastArg(OPT_out)) -+ Path = Arg->getValue(); -+ -+ if(!Path.length()) -+ Path = getImplibPath(); -+ -+ llvm::outs() << Path << "\n"; -+ -+ Config->Machine = IMAGE_FILE_MACHINE_UNKNOWN; -+ if (auto *Arg = Args.getLastArg(OPT_emu)) -+ Config->Machine = getEmulation(Arg->getValue()); -+ -+ if(Config->Machine == IMAGE_FILE_MACHINE_UNKNOWN) { -+ llvm::outs() << "Need to set a valid emulation mode" << "\n"; -+ return -2; -+ } -+ -+ llvm::parseModuleDefs(MB, &Saver); -+ -+ // has to happen after the parser -+ if (auto *Arg = Args.getLastArg(OPT_dll)) -+ Config->OutputFile = Arg->getValue(); -+ -+ return writeImportLibrary(Path); -+ -+} -diff --git a/lib/DLLDriver/LLVMBuild.txt b/lib/DLLDriver/LLVMBuild.txt -new file mode 100644 -index 0000000..8e2b1d65 ---- /dev/null -+++ b/lib/DLLDriver/LLVMBuild.txt -@@ -0,0 +1,22 @@ -+;===- ./lib/LibDriver/LLVMBuild.txt ----------------------------*- Conf -*--===; -+; -+; The LLVM Compiler Infrastructure -+; -+; This file is distributed under the University of Illinois Open Source -+; License. See LICENSE.TXT for details. -+; -+;===------------------------------------------------------------------------===; -+; -+; This is an LLVMBuild description file for the components in this subdirectory. -+; -+; For more information on the LLVMBuild system, please see: -+; -+; http://llvm.org/docs/LLVMBuild.html -+; -+;===------------------------------------------------------------------------===; -+ -+[component_0] -+type = Library -+name = DllDriver -+parent = Libraries -+required_libraries = Object Option Support -diff --git a/lib/DLLDriver/Librarian.cpp b/lib/DLLDriver/Librarian.cpp -new file mode 100644 -index 0000000..486733e ---- /dev/null -+++ b/lib/DLLDriver/Librarian.cpp -@@ -0,0 +1,603 @@ -+//===- Librarian.cpp ------------------------------------------------------===// -+// -+// The LLVM Linker -+// -+// This file is distributed under the University of Illinois Open Source -+// License. See LICENSE.TXT for details. -+// -+//===----------------------------------------------------------------------===// -+// -+// This file contains functions for the Librarian. The librarian creates and -+// manages libraries of the Common Object File Format (COFF) object files. It -+// primarily is used for creating static libraries and import libraries. -+// -+//===----------------------------------------------------------------------===// -+ -+#include "llvm/Object/Archive.h" -+#include "llvm/Object/ArchiveWriter.h" -+#include "llvm/Object/COFF.h" -+#include "llvm/Support/Error.h" -+#include "llvm/Support/Path.h" -+ -+#include -+#include -+#include -+#include -+#include -+ -+#include "Config.h" -+ -+using namespace llvm; -+using namespace llvm::COFF; -+using namespace llvm::object; -+ -+static bool is32bit() { -+ switch (Config->Machine) { -+ default: -+ llvm_unreachable("unsupported machine"); -+ case IMAGE_FILE_MACHINE_AMD64: -+ return false; -+ case IMAGE_FILE_MACHINE_ARMNT: -+ case IMAGE_FILE_MACHINE_I386: -+ return true; -+ } -+} -+ -+static uint16_t getImgRelRelocation() { -+ switch (Config->Machine) { -+ default: -+ llvm_unreachable("unsupported machine"); -+ case IMAGE_FILE_MACHINE_AMD64: -+ return IMAGE_REL_AMD64_ADDR32NB; -+ case IMAGE_FILE_MACHINE_ARMNT: -+ return IMAGE_REL_ARM_ADDR32NB; -+ case IMAGE_FILE_MACHINE_I386: -+ return IMAGE_REL_I386_DIR32NB; -+ } -+} -+ -+template static void append(std::vector &B, const T &Data) { -+ size_t S = B.size(); -+ B.resize(S + sizeof(T)); -+ memcpy(&B[S], &Data, sizeof(T)); -+} -+ -+static void writeStringTable(std::vector &B, -+ ArrayRef Strings) { -+ // The COFF string table consists of a 4-byte value which is the size of the -+ // table, including the length field itself. This value is followed by the -+ // string content itself, which is an array of null-terminated C-style -+ // strings. The termination is important as they are referenced to by offset -+ // by the symbol entity in the file format. -+ -+ std::vector::size_type Pos = B.size(); -+ std::vector::size_type Offset = B.size(); -+ -+ // Skip over the length field, we will fill it in later as we will have -+ // computed the length while emitting the string content itself. -+ Pos += sizeof(uint32_t); -+ -+ for (const auto &S : Strings) { -+ B.resize(Pos + S.length() + 1); -+ strcpy(reinterpret_cast(&B[Pos]), S.c_str()); -+ Pos += S.length() + 1; -+ } -+ -+ // Backfill the length of the table now that it has been computed. -+ support::ulittle32_t Length(B.size() - Offset); -+ memcpy(&B[Offset], &Length, sizeof(Length)); -+} -+ -+static ImportNameType getNameType(StringRef Sym, StringRef ExtName) { -+ if (Sym != ExtName) -+ return IMPORT_NAME_UNDECORATE; -+ if (Config->Machine == I386 && Sym.startswith("_")) -+ return IMPORT_NAME_NOPREFIX; -+ return IMPORT_NAME; -+} -+ -+static const std::string NullImportDescriptorSymbolName = -+ "__NULL_IMPORT_DESCRIPTOR"; -+ -+namespace { -+// This class constructs various small object files necessary to support linking -+// symbols imported from a DLL. The contents are pretty strictly defined and -+// nearly entirely static. The details of the structures files are defined in -+// WINNT.h and the PE/COFF specification. -+class ObjectFactory { -+ using u16 = support::ulittle16_t; -+ using u32 = support::ulittle32_t; -+ -+ BumpPtrAllocator Alloc; -+ StringRef DLLName; -+ StringRef Library; -+ std::string ImportDescriptorSymbolName; -+ std::string NullThunkSymbolName; -+ -+public: -+ ObjectFactory(StringRef S) -+ : DLLName(S), Library(S.drop_back(4)), -+ ImportDescriptorSymbolName(("__IMPORT_DESCRIPTOR_" + Library).str()), -+ NullThunkSymbolName(("\x7f" + Library + "_NULL_THUNK_DATA").str()) {} -+ -+ // Creates an Import Descriptor. This is a small object file which contains a -+ // reference to the terminators and contains the library name (entry) for the -+ // import name table. It will force the linker to construct the necessary -+ // structure to import symbols from the DLL. -+ NewArchiveMember createImportDescriptor(std::vector &Buffer); -+ -+ // Creates a NULL import descriptor. This is a small object file whcih -+ // contains a NULL import descriptor. It is used to terminate the imports -+ // from a specific DLL. -+ NewArchiveMember createNullImportDescriptor(std::vector &Buffer); -+ -+ // Create a NULL Thunk Entry. This is a small object file which contains a -+ // NULL Import Address Table entry and a NULL Import Lookup Table Entry. It -+ // is used to terminate the IAT and ILT. -+ NewArchiveMember createNullThunk(std::vector &Buffer); -+ -+ // Create a short import file which is described in PE/COFF spec 7. Import -+ // Library Format. -+ NewArchiveMember createShortImport(StringRef Sym, uint16_t Ordinal, -+ ImportNameType NameType, bool isData); -+ -+ // Create a weak external file which is described in PE/COFF Aux Format 3. -+ NewArchiveMember createWeakExternal(std::vector &Buffer, StringRef Sym, StringRef Weak, bool imp); -+}; -+} -+ -+NewArchiveMember -+ObjectFactory::createImportDescriptor(std::vector &Buffer) { -+ static const uint32_t NumberOfSections = 2; -+ static const uint32_t NumberOfSymbols = 8; -+ static const uint32_t NumberOfRelocations = 3; -+ -+ // COFF Header -+ coff_file_header Header{ -+ u16(Config->Machine), u16(NumberOfSections), u32(0), -+ u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section)) + -+ // .idata$2 -+ sizeof(coff_import_directory_table_entry) + -+ NumberOfRelocations * sizeof(coff_relocation) + -+ // .idata$6 -+ (DLLName.size() + 1)), -+ u32(NumberOfSymbols), u16(0), -+ u16(is32bit() ? IMAGE_FILE_32BIT_MACHINE : 0), -+ }; -+ append(Buffer, Header); -+ -+ // Section Header Table -+ static const coff_section SectionTable[NumberOfSections] = { -+ {{'.', 'i', 'd', 'a', 't', 'a', '$', '2'}, -+ u32(0), -+ u32(0), -+ u32(sizeof(coff_import_directory_table_entry)), -+ u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section)), -+ u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) + -+ sizeof(coff_import_directory_table_entry)), -+ u32(0), -+ u16(NumberOfRelocations), -+ u16(0), -+ u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA | -+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)}, -+ {{'.', 'i', 'd', 'a', 't', 'a', '$', '6'}, -+ u32(0), -+ u32(0), -+ u32(DLLName.size() + 1), -+ u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) + -+ sizeof(coff_import_directory_table_entry) + -+ NumberOfRelocations * sizeof(coff_relocation)), -+ u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) + -+ sizeof(coff_import_directory_table_entry)), -+ u32(0), -+ u16(0), -+ u16(0), -+ u32(IMAGE_SCN_ALIGN_2BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA | -+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)}, -+ }; -+ append(Buffer, SectionTable); -+ -+ // .idata$2 -+ static const coff_import_directory_table_entry ImportDescriptor{ -+ u32(0), u32(0), u32(0), u32(0), u32(0), -+ }; -+ append(Buffer, ImportDescriptor); -+ -+ static const coff_relocation RelocationTable[NumberOfRelocations] = { -+ {u32(offsetof(coff_import_directory_table_entry, NameRVA)), u32(3), -+ u16(getImgRelRelocation())}, -+ {u32(offsetof(coff_import_directory_table_entry, ImportLookupTableRVA)), -+ u32(4), u16(getImgRelRelocation())}, -+ {u32(offsetof(coff_import_directory_table_entry, ImportAddressTableRVA)), -+ u32(5), u16(getImgRelRelocation())}, -+ }; -+ append(Buffer, RelocationTable); -+ -+ // .idata$6 -+ auto S = Buffer.size(); -+ Buffer.resize(S + DLLName.size() + 1); -+ memcpy(&Buffer[S], DLLName.data(), DLLName.size()); -+ Buffer[S + DLLName.size()] = '\0'; -+ -+ // Symbol Table -+ coff_symbol16 SymbolTable[NumberOfSymbols] = { -+ {{{'@', 'c', 'o', 'm', 'p', '.', 'i', 'd'}}, -+ u32(0), -+ u16(0xFFFF), -+ u16(0), -+ IMAGE_SYM_CLASS_STATIC, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(2), -+ u16(0), -+ IMAGE_SYM_CLASS_EXTERNAL, -+ 0}, -+ {{{'.', 'i', 'd', 'a', 't', 'a', '$', '2'}}, -+ u32(0), -+ u16(2), -+ u16(0), -+ IMAGE_SYM_CLASS_SECTION, -+ 0}, -+ {{{'.', 'i', 'd', 'a', 't', 'a', '$', '6'}}, -+ u32(0), -+ u16(3), -+ u16(0), -+ IMAGE_SYM_CLASS_STATIC, -+ 0}, -+ {{{'.', 'i', 'd', 'a', 't', 'a', '$', '4'}}, -+ u32(0), -+ u16(0), -+ u16(0), -+ IMAGE_SYM_CLASS_SECTION, -+ 0}, -+ {{{'.', 'i', 'd', 'a', 't', 'a', '$', '5'}}, -+ u32(0), -+ u16(0), -+ u16(0), -+ IMAGE_SYM_CLASS_SECTION, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(2), -+ u16(0), -+ IMAGE_SYM_CLASS_NULL, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(2), -+ u16(0), -+ IMAGE_SYM_CLASS_NULL, -+ 0}, -+ }; -+ reinterpret_cast(SymbolTable[1].Name).Offset = -+ sizeof(uint32_t); -+ reinterpret_cast(SymbolTable[6].Name).Offset = -+ sizeof(uint32_t) + ImportDescriptorSymbolName.length() + 1; -+ reinterpret_cast(SymbolTable[7].Name).Offset = -+ sizeof(uint32_t) + ImportDescriptorSymbolName.length() + 1 + -+ NullImportDescriptorSymbolName.length() + 1; -+ append(Buffer, SymbolTable); -+ -+ // String Table -+ writeStringTable(Buffer, -+ {ImportDescriptorSymbolName, NullImportDescriptorSymbolName, -+ NullThunkSymbolName}); -+ -+ StringRef F{reinterpret_cast(Buffer.data()), Buffer.size()}; -+ return {MemoryBufferRef(F, DLLName)}; -+} -+ -+NewArchiveMember -+ObjectFactory::createNullImportDescriptor(std::vector &Buffer) { -+ static const uint32_t NumberOfSections = 1; -+ static const uint32_t NumberOfSymbols = 2; -+ -+ // COFF Header -+ coff_file_header Header{ -+ u16(Config->Machine), u16(NumberOfSections), u32(0), -+ u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section)) + -+ // .idata$3 -+ sizeof(coff_import_directory_table_entry)), -+ u32(NumberOfSymbols), u16(0), -+ u16(is32bit() ? IMAGE_FILE_32BIT_MACHINE : 0), -+ }; -+ append(Buffer, Header); -+ -+ // Section Header Table -+ static const coff_section SectionTable[NumberOfSections] = { -+ {{'.', 'i', 'd', 'a', 't', 'a', '$', '3'}, -+ u32(0), -+ u32(0), -+ u32(sizeof(coff_import_directory_table_entry)), -+ u32(sizeof(coff_file_header) + -+ (NumberOfSections * sizeof(coff_section))), -+ u32(0), -+ u32(0), -+ u16(0), -+ u16(0), -+ u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA | -+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)}, -+ }; -+ append(Buffer, SectionTable); -+ -+ // .idata$3 -+ static const coff_import_directory_table_entry ImportDescriptor{ -+ u32(0), u32(0), u32(0), u32(0), u32(0), -+ }; -+ append(Buffer, ImportDescriptor); -+ -+ // Symbol Table -+ coff_symbol16 SymbolTable[NumberOfSymbols] = { -+ {{{'@', 'c', 'o', 'm', 'p', '.', 'i', 'd'}}, -+ u32(0), -+ u16(0xFFFF), -+ u16(0), -+ IMAGE_SYM_CLASS_STATIC, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(2), -+ u16(0), -+ IMAGE_SYM_CLASS_EXTERNAL, -+ 0}, -+ }; -+ reinterpret_cast(SymbolTable[1].Name).Offset = -+ sizeof(uint32_t); -+ append(Buffer, SymbolTable); -+ -+ // String Table -+ writeStringTable(Buffer, {NullImportDescriptorSymbolName}); -+ -+ StringRef F{reinterpret_cast(Buffer.data()), Buffer.size()}; -+ return {MemoryBufferRef(F, DLLName)}; -+} -+ -+NewArchiveMember ObjectFactory::createNullThunk(std::vector &Buffer) { -+ static const uint32_t NumberOfSections = 2; -+ static const uint32_t NumberOfSymbols = 2; -+ -+ // COFF Header -+ coff_file_header Header{ -+ u16(Config->Machine), u16(NumberOfSections), u32(0), -+ u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section)) + -+ // .idata$5 -+ sizeof(export_address_table_entry) + -+ // .idata$4 -+ sizeof(export_address_table_entry)), -+ u32(NumberOfSymbols), u16(0), -+ u16(is32bit() ? IMAGE_FILE_32BIT_MACHINE : 0), -+ }; -+ append(Buffer, Header); -+ -+ // Section Header Table -+ static const coff_section SectionTable[NumberOfSections] = { -+ {{'.', 'i', 'd', 'a', 't', 'a', '$', '5'}, -+ u32(0), -+ u32(0), -+ u32(sizeof(export_address_table_entry)), -+ u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section)), -+ u32(0), -+ u32(0), -+ u16(0), -+ u16(0), -+ u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA | -+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)}, -+ {{'.', 'i', 'd', 'a', 't', 'a', '$', '4'}, -+ u32(0), -+ u32(0), -+ u32(sizeof(export_address_table_entry)), -+ u32(sizeof(coff_file_header) + NumberOfSections * sizeof(coff_section) + -+ sizeof(export_address_table_entry)), -+ u32(0), -+ u32(0), -+ u16(0), -+ u16(0), -+ u32(IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_CNT_INITIALIZED_DATA | -+ IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_WRITE)}, -+ }; -+ append(Buffer, SectionTable); -+ -+ // .idata$5 -+ static const export_address_table_entry ILT{u32(0)}; -+ append(Buffer, ILT); -+ -+ // .idata$4 -+ static const export_address_table_entry IAT{u32(0)}; -+ append(Buffer, IAT); -+ -+ // Symbol Table -+ coff_symbol16 SymbolTable[NumberOfSymbols] = { -+ {{{'@', 'c', 'o', 'm', 'p', '.', 'i', 'd'}}, -+ u32(0), -+ u16(0xFFFF), -+ u16(0), -+ IMAGE_SYM_CLASS_STATIC, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(2), -+ u16(0), -+ IMAGE_SYM_CLASS_EXTERNAL, -+ 0}, -+ }; -+ reinterpret_cast(SymbolTable[1].Name).Offset = -+ sizeof(uint32_t); -+ append(Buffer, SymbolTable); -+ -+ // String Table -+ writeStringTable(Buffer, {NullThunkSymbolName}); -+ -+ StringRef F{reinterpret_cast(Buffer.data()), Buffer.size()}; -+ return {MemoryBufferRef{F, DLLName}}; -+} -+ -+NewArchiveMember ObjectFactory::createShortImport(StringRef Sym, -+ uint16_t Ordinal, -+ ImportNameType NameType, -+ bool isData) { -+ size_t ImpSize = DLLName.size() + Sym.size() + 2; // +2 for NULs -+ size_t Size = sizeof(coff_import_header) + ImpSize; -+ char *Buf = Alloc.Allocate(Size); -+ memset(Buf, 0, Size); -+ char *P = Buf; -+ -+ // Write short import library. -+ auto *Imp = reinterpret_cast(P); -+ P += sizeof(*Imp); -+ Imp->Sig2 = 0xFFFF; -+ Imp->Machine = Config->Machine; -+ Imp->SizeOfData = ImpSize; -+ if (Ordinal > 0) -+ Imp->OrdinalHint = Ordinal; -+ Imp->TypeInfo = (isData ? IMPORT_DATA : IMPORT_CODE); -+ -+ if(Config->Machine == IMAGE_FILE_MACHINE_I386) { -+ if(Sym.find('@') != StringRef::npos) -+ Imp->TypeInfo |= IMPORT_NAME_UNDECORATE << 2; -+ else -+ Imp->TypeInfo |= IMPORT_NAME_NOPREFIX << 2; -+ } -+ else -+ Imp->TypeInfo |= IMPORT_NAME << 2; -+ -+ // Write symbol name and DLL name. -+ memcpy(P, Sym.data(), Sym.size()); -+ P += Sym.size() + 1; -+ memcpy(P, DLLName.data(), DLLName.size()); -+ -+ return {MemoryBufferRef(StringRef(Buf, Size), DLLName)}; -+} -+ -+NewArchiveMember ObjectFactory::createWeakExternal(std::vector &Buffer, -+ StringRef Sym, StringRef Weak, bool imp) { -+ static const uint32_t NumberOfSections = 1; -+ static const uint32_t NumberOfSymbols = 5; -+ -+ // COFF Header -+ coff_file_header Header{ -+ u16(0), u16(NumberOfSections), u32(0), -+ u32(sizeof(Header) + (NumberOfSections * sizeof(coff_section))), -+ u32(NumberOfSymbols), u16(0), -+ u16(0), -+ }; -+ append(Buffer, Header); -+ -+ // Section Header Table -+ static const coff_section SectionTable[NumberOfSections] = { -+ {{'.', 'd', 'r', 'e', 'c', 't', 'v', 'e'}, -+ u32(0), -+ u32(0), -+ u32(0), -+ u32(0), -+ u32(0), -+ u32(0), -+ u16(0), -+ u16(0), -+ u32(IMAGE_SCN_LNK_INFO | IMAGE_SCN_LNK_REMOVE)} -+ }; -+ append(Buffer, SectionTable); -+ -+ // Symbol Table -+ coff_symbol16 SymbolTable[NumberOfSymbols] = { -+ {{{'@', 'c', 'o', 'm', 'p', '.', 'i', 'd'}}, -+ u32(0), -+ u16(0xFFFF), -+ u16(0), -+ IMAGE_SYM_CLASS_STATIC, -+ 0}, -+ {{{'@', 'f', 'e', 'a', 't', '.', '0', '0'}}, -+ u32(0), -+ u16(0xFFFF), -+ u16(0), -+ IMAGE_SYM_CLASS_STATIC, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(0), -+ u16(0), -+ IMAGE_SYM_CLASS_EXTERNAL, -+ 0}, -+ {{{0, 0, 0, 0, 0, 0, 0, 0}}, -+ u32(0), -+ u16(0), -+ u16(0), -+ IMAGE_SYM_CLASS_WEAK_EXTERNAL, -+ 1}, -+ {{{2, 0, 0, 0, 3, 0, 0, 0}}, -+ u32(0), -+ u16(0), -+ u16(0), -+ uint8_t(0), -+ 0}, -+ }; -+ reinterpret_cast(SymbolTable[2].Name).Offset = -+ sizeof(uint32_t); -+ -+ if(imp) -+ reinterpret_cast(SymbolTable[3].Name).Offset = -+ sizeof(uint32_t) + Sym.size() + 1 + 6; //__imp_ -+ else -+ reinterpret_cast(SymbolTable[3].Name).Offset = -+ sizeof(uint32_t) + Sym.size() + 1;// + 6; //__imp_ -+ -+ append(Buffer, SymbolTable); -+ -+ // String Table -+ if(imp) -+ writeStringTable(Buffer, {std::string("__imp_").append(Sym), std::string("__imp_").append(Weak)}); -+ else -+ writeStringTable(Buffer, {Sym, Weak}); -+ -+ StringRef F{reinterpret_cast(Buffer.data()), Buffer.size()}; -+ return {MemoryBufferRef{F, DLLName}}; -+ -+} -+ -+// Creates an import library for a DLL. In this function, we first -+// create an empty import library using lib.exe and then adds short -+// import files to that file. -+int writeImportLibrary(std::string &Path) { -+ -+ std::vector Members; -+ -+ ObjectFactory OF(llvm::sys::path::filename(Config->OutputFile)); -+ -+ std::vector ImportDescriptor; -+ Members.push_back(OF.createImportDescriptor(ImportDescriptor)); -+ -+ std::vector NullImportDescriptor; -+ Members.push_back(OF.createNullImportDescriptor(NullImportDescriptor)); -+ -+ std::vector NullThunk; -+ Members.push_back(OF.createNullThunk(NullThunk)); -+ -+ for (Export &E : Config->Exports) { -+ if (E.Private) -+ continue; -+ -+ if (E.isWeak()) { -+ std::vector *WeakBuffer1 = new std::vector(); -+ std::vector *WeakBuffer2 = new std::vector(); -+ Members.push_back(OF.createWeakExternal(*WeakBuffer1, E.Name, E.ExtName, false)); -+ Members.push_back(OF.createWeakExternal(*WeakBuffer2, E.Name, E.ExtName, true)); -+ continue; -+ } -+ -+ if(E.ExtName.size() == 0) { -+ E.ExtName = E.Name; -+ } -+ -+ ImportNameType Type = getNameType(E.SymbolName, E.Name); -+ Members.push_back(OF.createShortImport(E.Name, E.Ordinal, Type, E.Data)); -+ } -+ -+ std::pair Result = -+ writeArchive(Path, Members, /*WriteSymtab*/ true, object::Archive::K_GNU, -+ /*Deterministic*/ true, /*Thin*/ false); -+ -+ if (Result.second) -+ return -1; -+ -+ return 0; -+} -diff --git a/lib/DLLDriver/ModuleDef.cpp b/lib/DLLDriver/ModuleDef.cpp -new file mode 100644 -index 0000000..428049a ---- /dev/null -+++ b/lib/DLLDriver/ModuleDef.cpp -@@ -0,0 +1,321 @@ -+//===- COFF/ModuleDef.cpp -------------------------------------------------===// -+// -+// The LLVM Linker -+// -+// This file is distributed under the University of Illinois Open Source -+// License. See LICENSE.TXT for details. -+// -+//===----------------------------------------------------------------------===// -+// -+// Windows-specific. -+// A parser for the module-definition file (.def file). -+// Parsed results are directly written to Config global variable. -+// -+// The format of module-definition files are described in this document: -+// https://msdn.microsoft.com/en-us/library/28d6s79h.aspx -+// -+//===----------------------------------------------------------------------===// -+ -+#include "Config.h" -+//#include "Error.h" -+#include "llvm/ADT/StringRef.h" -+#include "llvm/ADT/StringSwitch.h" -+#include "llvm/Object/COFF.h" -+#include "llvm/Support/StringSaver.h" -+#include "llvm/Support/raw_ostream.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+ -+using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; -+using llvm::COFF::WindowsSubsystem; -+using llvm::StringRef; -+ -+using namespace llvm::COFF; -+using namespace llvm::object; -+using namespace llvm; -+ -+#include "llvm/Support/Error.h" -+ -+void fatal(const Twine &Msg) { -+ llvm::errs() << Msg << "\n"; -+ exit(1); -+} -+ -+void fatal(std::error_code EC, const Twine &Msg) { -+ fatal(Msg + ": " + EC.message()); -+} -+ -+void fatal(llvm::Error &Err, const Twine &Msg) { -+ fatal(errorToErrorCode(std::move(Err)), Msg); -+} -+ -+namespace llvm { -+namespace { -+ -+enum Kind { -+ Unknown, -+ Eof, -+ Identifier, -+ Comma, -+ Equal, -+ KwBase, -+ KwData, -+ KwExports, -+ KwHeapsize, -+ KwLibrary, -+ KwName, -+ KwNoname, -+ KwPrivate, -+ KwStacksize, -+ KwVersion, -+}; -+ -+struct Token { -+ explicit Token(Kind T = Unknown, StringRef S = "") : K(T), Value(S) {} -+ Kind K; -+ StringRef Value; -+}; -+ -+static bool isDecorated(StringRef Sym) { -+ // Disable Sym.startswith("_") because mingw-w64 is weird about this -+ return Sym.startswith("@") || Sym.startswith("?"); -+} -+ -+class Lexer { -+public: -+ explicit Lexer(StringRef S) : Buf(S) {} -+ -+ Token lex() { -+ Buf = Buf.trim(); -+ if (Buf.empty()) -+ return Token(Eof); -+ -+ switch (Buf[0]) { -+ case '\0': -+ return Token(Eof); -+ case ';': { -+ size_t End = Buf.find('\n'); -+ Buf = (End == Buf.npos) ? "" : Buf.drop_front(End); -+ return lex(); -+ } -+ case '=': -+ // TODO: Fix HACK TO WORK AROUND "==" in mingw-w64 -+ if(Buf[1] == '=') -+ Buf = Buf.drop_front(); -+ Buf = Buf.drop_front(); -+ return Token(Equal, "="); -+ case ',': -+ Buf = Buf.drop_front(); -+ return Token(Comma, ","); -+ case '"': { -+ StringRef S; -+ std::tie(S, Buf) = Buf.substr(1).split('"'); -+ return Token(Identifier, S); -+ } -+ default: { -+ size_t End = Buf.find_first_of("=,\r\n \t\v"); -+ StringRef Word = Buf.substr(0, End); -+ Kind K = llvm::StringSwitch(Word) -+ .Case("BASE", KwBase) -+ .Case("DATA", KwData) -+ .Case("EXPORTS", KwExports) -+ .Case("HEAPSIZE", KwHeapsize) -+ .Case("LIBRARY", KwLibrary) -+ .Case("NAME", KwName) -+ .Case("NONAME", KwNoname) -+ .Case("PRIVATE", KwPrivate) -+ .Case("STACKSIZE", KwStacksize) -+ .Case("VERSION", KwVersion) -+ .Default(Identifier); -+ Buf = (End == Buf.npos) ? "" : Buf.drop_front(End); -+ return Token(K, Word); -+ } -+ } -+ } -+ -+private: -+ StringRef Buf; -+}; -+ -+class Parser { -+public: -+ explicit Parser(StringRef S, StringSaver *A) : Lex(S), Alloc(A) {} -+ -+ void parse() { -+ do { -+ parseOne(); -+ } while (Tok.K != Eof); -+ } -+ -+private: -+ void read() { -+ if (Stack.empty()) { -+ Tok = Lex.lex(); -+ return; -+ } -+ Tok = Stack.back(); -+ Stack.pop_back(); -+ } -+ -+ void readAsInt(uint64_t *I) { -+ read(); -+ if (Tok.K != Identifier || Tok.Value.getAsInteger(10, *I)) -+ fatal("integer expected"); -+ } -+ -+ void expect(Kind Expected, StringRef Msg) { -+ read(); -+ if (Tok.K != Expected) -+ fatal(Msg); -+ } -+ -+ void unget() { Stack.push_back(Tok); } -+ -+ void parseOne() { -+ read(); -+ switch (Tok.K) { -+ case Eof: -+ return; -+ case KwExports: -+ for (;;) { -+ read(); -+ if (Tok.K != Identifier) { -+ unget(); -+ return; -+ } -+ parseExport(); -+ } -+ case KwHeapsize: -+ parseNumbers(&Config->HeapReserve, &Config->HeapCommit); -+ return; -+ case KwLibrary: -+ parseName(&Config->OutputFile, &Config->ImageBase); -+ if (!StringRef(Config->OutputFile).endswith_lower(".dll")) -+ Config->OutputFile += ".dll"; -+ return; -+ case KwStacksize: -+ parseNumbers(&Config->StackReserve, &Config->StackCommit); -+ return; -+ case KwName: -+ parseName(&Config->OutputFile, &Config->ImageBase); -+ return; -+ case KwVersion: -+ parseVersion(&Config->MajorImageVersion, &Config->MinorImageVersion); -+ return; -+ default: -+ fatal("unknown directive: " + Tok.Value); -+ } -+ } -+ -+ void parseExport() { -+ Export E; -+ E.Name = Tok.Value; -+ read(); -+ if (Tok.K == Equal) { -+ read(); -+ if (Tok.K != Identifier) -+ fatal("identifier expected, but got " + Tok.Value); -+ E.ExtName = E.Name; -+ E.Name = Tok.Value; -+ } else { -+ unget(); -+ } -+ -+ if (Config->Machine == I386) { -+ if (!isDecorated(E.Name)) -+ E.Name = Alloc->save("_" + E.Name); -+ if (!E.ExtName.empty() && !isDecorated(E.ExtName)) -+ E.ExtName = Alloc->save("_" + E.ExtName); -+ } -+ -+ for (;;) { -+ read(); -+ if (Tok.K == Identifier && Tok.Value[0] == '@') { -+ Tok.Value.drop_front().getAsInteger(10, E.Ordinal); -+ read(); -+ if (Tok.K == KwNoname) { -+ E.Noname = true; -+ } else { -+ unget(); -+ } -+ continue; -+ } -+ if (Tok.K == KwData) { -+ E.Data = true; -+ continue; -+ } -+ if (Tok.K == KwPrivate) { -+ E.Private = true; -+ continue; -+ } -+ unget(); -+ Config->Exports.push_back(E); -+ return; -+ } -+ } -+ -+ // HEAPSIZE/STACKSIZE reserve[,commit] -+ void parseNumbers(uint64_t *Reserve, uint64_t *Commit) { -+ readAsInt(Reserve); -+ read(); -+ if (Tok.K != Comma) { -+ unget(); -+ Commit = nullptr; -+ return; -+ } -+ readAsInt(Commit); -+ } -+ -+ // NAME outputPath [BASE=address] -+ void parseName(std::string *Out, uint64_t *Baseaddr) { -+ read(); -+ if (Tok.K == Identifier) { -+ *Out = Tok.Value; -+ } else { -+ *Out = ""; -+ unget(); -+ return; -+ } -+ read(); -+ if (Tok.K == KwBase) { -+ expect(Equal, "'=' expected"); -+ readAsInt(Baseaddr); -+ } else { -+ unget(); -+ *Baseaddr = 0; -+ } -+ } -+ -+ // VERSION major[.minor] -+ void parseVersion(uint32_t *Major, uint32_t *Minor) { -+ read(); -+ if (Tok.K != Identifier) -+ fatal("identifier expected, but got " + Tok.Value); -+ StringRef V1, V2; -+ std::tie(V1, V2) = Tok.Value.split('.'); -+ if (V1.getAsInteger(10, *Major)) -+ fatal("integer expected, but got " + Tok.Value); -+ if (V2.empty()) -+ *Minor = 0; -+ else if (V2.getAsInteger(10, *Minor)) -+ fatal("integer expected, but got " + Tok.Value); -+ } -+ -+ Lexer Lex; -+ Token Tok; -+ std::vector Stack; -+ StringSaver *Alloc; -+}; -+ -+} // anonymous namespace -+ -+void parseModuleDefs(MemoryBufferRef MB, StringSaver *Alloc) { -+ Parser(MB.getBuffer(), Alloc).parse(); -+} -+ -+} // namespace llvm -diff --git a/lib/DLLDriver/Options.td b/lib/DLLDriver/Options.td -new file mode 100644 -index 0000000..62f33f3 ---- /dev/null -+++ b/lib/DLLDriver/Options.td -@@ -0,0 +1,5 @@ -+include "llvm/Option/OptParser.td" -+ -+def emu: JoinedOrSeparate<["-"], "a">, HelpText<"Set target arch">; -+def out: JoinedOrSeparate<["-"], "o">, HelpText<"Set output file">; -+def dll: JoinedOrSeparate<["-"], "d">, HelpText<"Set dll name">; -diff --git a/lib/Object/ArchiveWriter.cpp b/lib/Object/ArchiveWriter.cpp -index f8e3c5a..d5f067e 100644 ---- a/lib/Object/ArchiveWriter.cpp -+++ b/lib/Object/ArchiveWriter.cpp -@@ -299,7 +299,8 @@ writeSymbolTable(raw_fd_ostream &Out, object::Archive::Kind Kind, - continue; - if (!(Symflags & object::SymbolRef::SF_Global)) - continue; -- if (Symflags & object::SymbolRef::SF_Undefined) -+ if (Symflags & object::SymbolRef::SF_Undefined && -+ !(Symflags & object::SymbolRef::SF_Weak)) - continue; - - unsigned NameOffset = NameOS.tell(); -diff --git a/tools/llvm-ar/CMakeLists.txt b/tools/llvm-ar/CMakeLists.txt -index 3bb0c8f..14732b4 100644 ---- a/tools/llvm-ar/CMakeLists.txt -+++ b/tools/llvm-ar/CMakeLists.txt -@@ -1,6 +1,7 @@ - set(LLVM_LINK_COMPONENTS - ${LLVM_TARGETS_TO_BUILD} - Core -+ DllDriver - LibDriver - Object - Support -@@ -15,3 +16,4 @@ add_llvm_tool(llvm-ar - - add_llvm_tool_symlink(llvm-ranlib llvm-ar) - add_llvm_tool_symlink(llvm-lib llvm-ar) -+add_llvm_tool_symlink(llvm-dlltool llvm-ar) -diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp -index b99a396..23e323c 100644 ---- a/tools/llvm-ar/llvm-ar.cpp -+++ b/tools/llvm-ar/llvm-ar.cpp -@@ -16,6 +16,7 @@ - #include "llvm/ADT/Triple.h" - #include "llvm/IR/LLVMContext.h" - #include "llvm/IR/Module.h" -+#include "llvm/DllDriver/DllDriver.h" - #include "llvm/LibDriver/LibDriver.h" - #include "llvm/Object/Archive.h" - #include "llvm/Object/ArchiveWriter.h" -@@ -850,6 +851,9 @@ int main(int argc, char **argv) { - llvm::InitializeAllAsmParsers(); - - StringRef Stem = sys::path::stem(ToolName); -+ if (Stem.find("dlltool") != StringRef::npos) -+ return dllToolDriverMain(makeArrayRef(argv, argc)); -+ - if (Stem.find("ranlib") == StringRef::npos && - Stem.find("lib") != StringRef::npos) - return libDriverMain(makeArrayRef(argv, argc)); -@@ -865,5 +869,5 @@ int main(int argc, char **argv) { - return ranlib_main(); - if (Stem.find("ar") != StringRef::npos) - return ar_main(); -- fail("Not ranlib, ar or lib!"); -+ fail("Not ranlib, ar, lib or dlltool!"); - } --- -2.7.4 - diff --git a/patches/llvm-0002.patch b/patches/llvm-0002.patch deleted file mode 100644 index eb9a614..0000000 --- a/patches/llvm-0002.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 44892d7c172014a45e9a191fc36b2d4cca343890 Mon Sep 17 00:00:00 2001 -From: Martell Malone -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@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;VEigrVzjtk^-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 -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(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 - diff --git a/patches/mingw-0001.patch b/patches/mingw-0001.patch index 8f3acae..6816385 100644 --- a/patches/mingw-0001.patch +++ b/patches/mingw-0001.patch @@ -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 -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 + diff --git a/patches/mingw-0002.patch b/patches/mingw-0002.patch deleted file mode 100644 index 4a8ded1..0000000 --- a/patches/mingw-0002.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 5592b70cca64935b0d090fe5030b3110ba17068c Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -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 - diff --git a/patches/mingw-0003.patch b/patches/mingw-0003.patch deleted file mode 100644 index 133a174..0000000 --- a/patches/mingw-0003.patch +++ /dev/null @@ -1,1640 +0,0 @@ -From 356e3a906c8df030e67e8a1c86297e75e9ab99e4 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Hugo=20Beauz=C3=A9e-Luyssen?= -Date: Mon, 16 May 2016 18:36:05 +0200 -Subject: [PATCH 5/9] crt: Add msvcr120_app for arm - ---- - mingw-w64-crt/Makefile.am | 5 +- - mingw-w64-crt/libarm32/msvcr120_app.def.in | 1598 ++++++++++++++++++++++++++++ - 2 files changed, 1601 insertions(+), 2 deletions(-) - create mode 100644 mingw-w64-crt/libarm32/msvcr120_app.def.in - -diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am -index 52d1dc7..0bfbb26 100644 ---- a/mingw-w64-crt/Makefile.am -+++ b/mingw-w64-crt/Makefile.am -@@ -1399,14 +1399,15 @@ libarm32_LIBRARIES += libarm32/libmingwthrd.a - libarm32_libmingwthrd_a_SOURCES = $(src_libmingwthrd) - libarm32_libmingwthrd_a_CPPFLAGS=$(CPPFLAGSARM32) $(sysincludes) - --processed_defs += libarm32/msvcrt.def libarm32/msvcr80.def libarm32/msvcr90.def libarm32/msvcr90d.def libarm32/msvcr100.def libarm32/msvcr110.def -+processed_defs += libarm32/msvcrt.def libarm32/msvcr80.def libarm32/msvcr90.def libarm32/msvcr90d.def libarm32/msvcr100.def libarm32/msvcr110.def \ -+ libarm32/msvcr120_app.def - - endif - - include libarm32/Makefile.am - - if !W32API --libarm32_DATA += libarm32/libmsvcp60.a libarm32/libmsvcr110.a -+libarm32_DATA += libarm32/libmsvcp60.a libarm32/libmsvcr110.a libarm32/libmsvcr120_app.a - endif - - # combine these two rules with the ones for lib64 -diff --git a/mingw-w64-crt/libarm32/msvcr120_app.def.in b/mingw-w64-crt/libarm32/msvcr120_app.def.in -new file mode 100644 -index 0000000..091269a ---- /dev/null -+++ b/mingw-w64-crt/libarm32/msvcr120_app.def.in -@@ -0,0 +1,1598 @@ -+; -+; Definition file of msvcr120_app.dll -+; Automatic generated by gendef -+; written by Kai Tietz 2008 -+; -+LIBRARY "msvcr120_app.dll" -+EXPORTS -+ -+#include "msvcrt-common.def.in" -+ -+$I10_OUTPUT -+??0?$_SpinWait@$00@details@Concurrency@@QAA@P6AXXZ@Z -+??0?$_SpinWait@$0A@@details@Concurrency@@QAA@P6AXXZ@Z -+??0SchedulerPolicy@Concurrency@@QAA@ABV01@@Z -+??0SchedulerPolicy@Concurrency@@QAA@IZZ -+??0SchedulerPolicy@Concurrency@@QAA@XZ -+??0_Cancellation_beacon@details@Concurrency@@QAA@XZ -+??0_Condition_variable@details@Concurrency@@QAA@XZ -+??0_Context@details@Concurrency@@QAA@PAVContext@2@@Z -+??0_Interruption_exception@details@Concurrency@@QAA@PBD@Z -+??0_Interruption_exception@details@Concurrency@@QAA@XZ -+??0_NonReentrantBlockingLock@details@Concurrency@@QAA@XZ -+??0_NonReentrantPPLLock@details@Concurrency@@QAA@XZ -+??0_ReaderWriterLock@details@Concurrency@@QAA@XZ -+??0_ReentrantBlockingLock@details@Concurrency@@QAA@XZ -+??0_ReentrantLock@details@Concurrency@@QAA@XZ -+??0_ReentrantPPLLock@details@Concurrency@@QAA@XZ -+??0_Scheduler@details@Concurrency@@QAA@PAVScheduler@2@@Z -+??0_Scoped_lock@_NonReentrantPPLLock@details@Concurrency@@QAA@AAV123@@Z -+??0_Scoped_lock@_ReentrantPPLLock@details@Concurrency@@QAA@AAV123@@Z -+??0_SpinLock@details@Concurrency@@QAA@ACJ@Z -+??0_StructuredTaskCollection@details@Concurrency@@QAA@PAV_CancellationTokenState@12@@Z -+??0_TaskCollection@details@Concurrency@@QAA@PAV_CancellationTokenState@12@@Z -+??0_TaskCollection@details@Concurrency@@QAA@XZ -+??0_Timer@details@Concurrency@@IAA@I_N@Z -+??0__non_rtti_object@std@@QAA@ABV01@@Z -+??0__non_rtti_object@std@@QAA@PBD@Z -+??0bad_cast@std@@AAA@PBQBD@Z -+??0bad_cast@std@@QAA@ABV01@@Z -+??0bad_cast@std@@QAA@PBD@Z -+??0bad_target@Concurrency@@QAA@PBD@Z -+??0bad_target@Concurrency@@QAA@XZ -+??0bad_typeid@std@@QAA@ABV01@@Z -+??0bad_typeid@std@@QAA@PBD@Z -+??0context_self_unblock@Concurrency@@QAA@PBD@Z -+??0context_self_unblock@Concurrency@@QAA@XZ -+??0context_unblock_unbalanced@Concurrency@@QAA@PBD@Z -+??0context_unblock_unbalanced@Concurrency@@QAA@XZ -+??0critical_section@Concurrency@@QAA@XZ -+??0default_scheduler_exists@Concurrency@@QAA@PBD@Z -+??0default_scheduler_exists@Concurrency@@QAA@XZ -+??0event@Concurrency@@QAA@XZ -+??0exception@std@@QAA@ABQBD@Z -+??0exception@std@@QAA@ABQBDH@Z -+??0exception@std@@QAA@ABV01@@Z -+??0exception@std@@QAA@XZ -+??0improper_lock@Concurrency@@QAA@PBD@Z -+??0improper_lock@Concurrency@@QAA@XZ -+??0improper_scheduler_attach@Concurrency@@QAA@PBD@Z -+??0improper_scheduler_attach@Concurrency@@QAA@XZ -+??0improper_scheduler_detach@Concurrency@@QAA@PBD@Z -+??0improper_scheduler_detach@Concurrency@@QAA@XZ -+??0improper_scheduler_reference@Concurrency@@QAA@PBD@Z -+??0improper_scheduler_reference@Concurrency@@QAA@XZ -+??0invalid_link_target@Concurrency@@QAA@PBD@Z -+??0invalid_link_target@Concurrency@@QAA@XZ -+??0invalid_multiple_scheduling@Concurrency@@QAA@PBD@Z -+??0invalid_multiple_scheduling@Concurrency@@QAA@XZ -+??0invalid_operation@Concurrency@@QAA@PBD@Z -+??0invalid_operation@Concurrency@@QAA@XZ -+??0invalid_oversubscribe_operation@Concurrency@@QAA@PBD@Z -+??0invalid_oversubscribe_operation@Concurrency@@QAA@XZ -+??0invalid_scheduler_policy_key@Concurrency@@QAA@PBD@Z -+??0invalid_scheduler_policy_key@Concurrency@@QAA@XZ -+??0invalid_scheduler_policy_thread_specification@Concurrency@@QAA@PBD@Z -+??0invalid_scheduler_policy_thread_specification@Concurrency@@QAA@XZ -+??0invalid_scheduler_policy_value@Concurrency@@QAA@PBD@Z -+??0invalid_scheduler_policy_value@Concurrency@@QAA@XZ -+??0message_not_found@Concurrency@@QAA@PBD@Z -+??0message_not_found@Concurrency@@QAA@XZ -+??0missing_wait@Concurrency@@QAA@PBD@Z -+??0missing_wait@Concurrency@@QAA@XZ -+??0nested_scheduler_missing_detach@Concurrency@@QAA@PBD@Z -+??0nested_scheduler_missing_detach@Concurrency@@QAA@XZ -+??0operation_timed_out@Concurrency@@QAA@PBD@Z -+??0operation_timed_out@Concurrency@@QAA@XZ -+??0reader_writer_lock@Concurrency@@QAA@XZ -+??0scheduler_not_attached@Concurrency@@QAA@PBD@Z -+??0scheduler_not_attached@Concurrency@@QAA@XZ -+??0scheduler_resource_allocation_error@Concurrency@@QAA@J@Z -+??0scheduler_resource_allocation_error@Concurrency@@QAA@PBDJ@Z -+??0scheduler_worker_creation_error@Concurrency@@QAA@J@Z -+??0scheduler_worker_creation_error@Concurrency@@QAA@PBDJ@Z -+??0scoped_lock@critical_section@Concurrency@@QAA@AAV12@@Z -+??0scoped_lock@reader_writer_lock@Concurrency@@QAA@AAV12@@Z -+??0scoped_lock_read@reader_writer_lock@Concurrency@@QAA@AAV12@@Z -+??0task_canceled@Concurrency@@QAA@PBD@Z -+??0task_canceled@Concurrency@@QAA@XZ -+??0unsupported_os@Concurrency@@QAA@PBD@Z -+??0unsupported_os@Concurrency@@QAA@XZ -+??1SchedulerPolicy@Concurrency@@QAA@XZ -+??1_Cancellation_beacon@details@Concurrency@@QAA@XZ -+??1_Condition_variable@details@Concurrency@@QAA@XZ -+??1_NonReentrantBlockingLock@details@Concurrency@@QAA@XZ -+??1_ReentrantBlockingLock@details@Concurrency@@QAA@XZ -+??1_Scoped_lock@_NonReentrantPPLLock@details@Concurrency@@QAA@XZ -+??1_Scoped_lock@_ReentrantPPLLock@details@Concurrency@@QAA@XZ -+??1_SpinLock@details@Concurrency@@QAA@XZ -+??1_StructuredTaskCollection@details@Concurrency@@QAA@XZ -+??1_TaskCollection@details@Concurrency@@QAA@XZ -+??1_Timer@details@Concurrency@@MAA@XZ -+??1__non_rtti_object@std@@UAA@XZ -+??1bad_cast@std@@UAA@XZ -+??1bad_typeid@std@@UAA@XZ -+??1critical_section@Concurrency@@QAA@XZ -+??1event@Concurrency@@QAA@XZ -+??1exception@std@@UAA@XZ -+??1reader_writer_lock@Concurrency@@QAA@XZ -+??1scoped_lock@critical_section@Concurrency@@QAA@XZ -+??1scoped_lock@reader_writer_lock@Concurrency@@QAA@XZ -+??1scoped_lock_read@reader_writer_lock@Concurrency@@QAA@XZ -+??1type_info@@UAA@XZ -+??2@YAPAXI@Z -+??2@YAPAXIHPBDH@Z -+??3@YAXPAX@Z -+??3@YAXPAXHPBDH@Z -+??4?$_SpinWait@$00@details@Concurrency@@QAAAAV012@ABV012@@Z -+??4?$_SpinWait@$0A@@details@Concurrency@@QAAAAV012@ABV012@@Z -+??4SchedulerPolicy@Concurrency@@QAAAAV01@ABV01@@Z -+??4__non_rtti_object@std@@QAAAAV01@ABV01@@Z -+??4bad_cast@std@@QAAAAV01@ABV01@@Z -+??4bad_typeid@std@@QAAAAV01@ABV01@@Z -+??4exception@std@@QAAAAV01@ABV01@@Z -+??8type_info@@QBA_NABV0@@Z -+??9type_info@@QBA_NABV0@@Z -+??_7__non_rtti_object@std@@6B@ DATA -+??_7bad_cast@std@@6B@ DATA -+??_7bad_typeid@std@@6B@ DATA -+??_7exception@std@@6B@ DATA -+??_F?$_SpinWait@$00@details@Concurrency@@QAAXXZ -+??_F?$_SpinWait@$0A@@details@Concurrency@@QAAXXZ -+??_F_Context@details@Concurrency@@QAAXXZ -+??_F_Scheduler@details@Concurrency@@QAAXXZ -+??_Fbad_cast@std@@QAAXXZ -+??_Fbad_typeid@std@@QAAXXZ -+??_U@YAPAXI@Z -+??_U@YAPAXIHPBDH@Z -+??_V@YAXPAX@Z -+??_V@YAXPAXHPBDH@Z -+?Alloc@Concurrency@@YAPAXI@Z -+?Block@Context@Concurrency@@SAXXZ -+?CaptureCallstack@platform@details@Concurrency@@YAIPAPAXII@Z -+?Create@CurrentScheduler@Concurrency@@SAXABVSchedulerPolicy@2@@Z -+?Create@Scheduler@Concurrency@@SAPAV12@ABVSchedulerPolicy@2@@Z -+?CreateResourceManager@Concurrency@@YAPAUIResourceManager@1@XZ -+?CreateScheduleGroup@CurrentScheduler@Concurrency@@SAPAVScheduleGroup@2@AAVlocation@2@@Z -+?CreateScheduleGroup@CurrentScheduler@Concurrency@@SAPAVScheduleGroup@2@XZ -+?CurrentContext@Context@Concurrency@@SAPAV12@XZ -+?Detach@CurrentScheduler@Concurrency@@SAXXZ -+?DisableTracing@Concurrency@@YAJXZ -+?EnableTracing@Concurrency@@YAJXZ -+?Free@Concurrency@@YAXPAX@Z -+?Get@CurrentScheduler@Concurrency@@SAPAVScheduler@2@XZ -+?GetCurrentThreadId@platform@details@Concurrency@@YAJXZ -+?GetExecutionContextId@Concurrency@@YAIXZ -+?GetNumberOfVirtualProcessors@CurrentScheduler@Concurrency@@SAIXZ -+?GetOSVersion@Concurrency@@YA?AW4OSVersion@IResourceManager@1@XZ -+?GetPolicy@CurrentScheduler@Concurrency@@SA?AVSchedulerPolicy@2@XZ -+?GetPolicyValue@SchedulerPolicy@Concurrency@@QBAIW4PolicyElementKey@2@@Z -+?GetProcessorCount@Concurrency@@YAIXZ -+?GetProcessorNodeCount@Concurrency@@YAIXZ -+?GetSchedulerId@Concurrency@@YAIXZ -+?GetSharedTimerQueue@details@Concurrency@@YAPAXXZ -+?Id@Context@Concurrency@@SAIXZ -+?Id@CurrentScheduler@Concurrency@@SAIXZ -+?IsAvailableLocation@CurrentScheduler@Concurrency@@SA_NABVlocation@2@@Z -+?IsCurrentTaskCollectionCanceling@Context@Concurrency@@SA_NXZ -+?Log2@details@Concurrency@@YAKI@Z -+?Oversubscribe@Context@Concurrency@@SAX_N@Z -+?RegisterShutdownEvent@CurrentScheduler@Concurrency@@SAXPAX@Z -+?ResetDefaultSchedulerPolicy@Scheduler@Concurrency@@SAXXZ -+?ScheduleGroupId@Context@Concurrency@@SAIXZ -+?ScheduleTask@CurrentScheduler@Concurrency@@SAXP6AXPAX@Z0@Z -+?ScheduleTask@CurrentScheduler@Concurrency@@SAXP6AXPAX@Z0AAVlocation@2@@Z -+?SetConcurrencyLimits@SchedulerPolicy@Concurrency@@QAAXII@Z -+?SetDefaultSchedulerPolicy@Scheduler@Concurrency@@SAXABVSchedulerPolicy@2@@Z -+?SetPolicyValue@SchedulerPolicy@Concurrency@@QAAIW4PolicyElementKey@2@I@Z -+?VirtualProcessorId@Context@Concurrency@@SAIXZ -+?Yield@Context@Concurrency@@SAXXZ -+?_Abort@_StructuredTaskCollection@details@Concurrency@@AAAXXZ -+?_Acquire@_NonReentrantBlockingLock@details@Concurrency@@QAAXXZ -+?_Acquire@_NonReentrantPPLLock@details@Concurrency@@QAAXPAX@Z -+?_Acquire@_ReentrantBlockingLock@details@Concurrency@@QAAXXZ -+?_Acquire@_ReentrantLock@details@Concurrency@@QAAXXZ -+?_Acquire@_ReentrantPPLLock@details@Concurrency@@QAAXPAX@Z -+?_AcquireRead@_ReaderWriterLock@details@Concurrency@@QAAXXZ -+?_AcquireWrite@_ReaderWriterLock@details@Concurrency@@QAAXXZ -+?_Cancel@_StructuredTaskCollection@details@Concurrency@@QAAXXZ -+?_Cancel@_TaskCollection@details@Concurrency@@QAAXXZ -+?_CheckTaskCollection@_UnrealizedChore@details@Concurrency@@IAAXXZ -+?_CleanupToken@_StructuredTaskCollection@details@Concurrency@@AAAXXZ -+?_ConcRT_CoreAssert@details@Concurrency@@YAXPBD0H@Z -+?_ConcRT_Trace@details@Concurrency@@YAXHPB_WZZ -+?_Confirm_cancel@_Cancellation_beacon@details@Concurrency@@QAA_NXZ -+?_Copy_str@exception@std@@AAAXPBD@Z -+?_CurrentContext@_Context@details@Concurrency@@SA?AV123@XZ -+?_Current_node@location@Concurrency@@SA?AV12@XZ -+?_Destroy@_AsyncTaskCollection@details@Concurrency@@EAAXXZ -+?_DoYield@?$_SpinWait@$00@details@Concurrency@@IAAXXZ -+?_DoYield@?$_SpinWait@$0A@@details@Concurrency@@IAAXXZ -+?_Get@_CurrentScheduler@details@Concurrency@@SA?AV_Scheduler@23@XZ -+?_GetConcRTTraceInfo@Concurrency@@YAPBU_CONCRT_TRACE_INFO@details@1@XZ -+?_GetConcurrency@details@Concurrency@@YAIXZ -+?_GetCurrentInlineDepth@_StackGuard@details@Concurrency@@CAAAIXZ -+?_GetNumberOfVirtualProcessors@_CurrentScheduler@details@Concurrency@@SAIXZ -+?_GetScheduler@_Scheduler@details@Concurrency@@QAAPAVScheduler@3@XZ -+?_Id@_CurrentScheduler@details@Concurrency@@SAIXZ -+?_IsCanceling@_StructuredTaskCollection@details@Concurrency@@QAA_NXZ -+?_IsCanceling@_TaskCollection@details@Concurrency@@QAA_NXZ -+?_IsSynchronouslyBlocked@_Context@details@Concurrency@@QBA_NXZ -+?_Name_base@type_info@@CAPBDPBV1@PAU__type_info_node@@@Z -+?_Name_base_internal@type_info@@CAPBDPBV1@PAU__type_info_node@@@Z -+?_NewCollection@_AsyncTaskCollection@details@Concurrency@@SAPAV123@PAV_CancellationTokenState@23@@Z -+?_NumberOfSpins@?$_SpinWait@$00@details@Concurrency@@IAAKXZ -+?_NumberOfSpins@?$_SpinWait@$0A@@details@Concurrency@@IAAKXZ -+?_Oversubscribe@_Context@details@Concurrency@@SAX_N@Z -+?_Reference@_Scheduler@details@Concurrency@@QAAIXZ -+?_Release@_NonReentrantBlockingLock@details@Concurrency@@QAAXXZ -+?_Release@_NonReentrantPPLLock@details@Concurrency@@QAAXXZ -+?_Release@_ReentrantBlockingLock@details@Concurrency@@QAAXXZ -+?_Release@_ReentrantLock@details@Concurrency@@QAAXXZ -+?_Release@_ReentrantPPLLock@details@Concurrency@@QAAXXZ -+?_Release@_Scheduler@details@Concurrency@@QAAIXZ -+?_ReleaseRead@_ReaderWriterLock@details@Concurrency@@QAAXXZ -+?_ReleaseWrite@_ReaderWriterLock@details@Concurrency@@QAAXXZ -+?_ReportUnobservedException@details@Concurrency@@YAXXZ -+?_Reset@?$_SpinWait@$00@details@Concurrency@@IAAXXZ -+?_Reset@?$_SpinWait@$0A@@details@Concurrency@@IAAXXZ -+?_RunAndWait@_StructuredTaskCollection@details@Concurrency@@QAA?AW4_TaskCollectionStatus@23@PAV_UnrealizedChore@23@@Z -+?_RunAndWait@_TaskCollection@details@Concurrency@@QAA?AW4_TaskCollectionStatus@23@PAV_UnrealizedChore@23@@Z -+?_Schedule@_StructuredTaskCollection@details@Concurrency@@QAAXPAV_UnrealizedChore@23@@Z -+?_Schedule@_StructuredTaskCollection@details@Concurrency@@QAAXPAV_UnrealizedChore@23@PAVlocation@3@@Z -+?_Schedule@_TaskCollection@details@Concurrency@@QAAXPAV_UnrealizedChore@23@@Z -+?_Schedule@_TaskCollection@details@Concurrency@@QAAXPAV_UnrealizedChore@23@PAVlocation@3@@Z -+?_ScheduleTask@_CurrentScheduler@details@Concurrency@@SAXP6AXPAX@Z0@Z -+?_SetSpinCount@?$_SpinWait@$00@details@Concurrency@@QAAXI@Z -+?_SetSpinCount@?$_SpinWait@$0A@@details@Concurrency@@QAAXI@Z -+?_SetUnobservedExceptionHandler@details@Concurrency@@YAXP6AXXZ@Z -+?_ShouldSpinAgain@?$_SpinWait@$00@details@Concurrency@@IAA_NXZ -+?_ShouldSpinAgain@?$_SpinWait@$0A@@details@Concurrency@@IAA_NXZ -+?_SpinOnce@?$_SpinWait@$00@details@Concurrency@@QAA_NXZ -+?_SpinOnce@?$_SpinWait@$0A@@details@Concurrency@@QAA_NXZ -+?_SpinYield@Context@Concurrency@@SAXXZ -+?_Start@_Timer@details@Concurrency@@IAAXXZ -+?_Stop@_Timer@details@Concurrency@@IAAXXZ -+?_Tidy@exception@std@@AAAXXZ -+?_Trace_agents@Concurrency@@YAXW4Agents_EventType@1@_JZZ -+?_Trace_ppl_function@Concurrency@@YAXABU_GUID@@EW4ConcRT_EventType@1@@Z -+?_TryAcquire@_NonReentrantBlockingLock@details@Concurrency@@QAA_NXZ -+?_TryAcquire@_ReentrantBlockingLock@details@Concurrency@@QAA_NXZ -+?_TryAcquire@_ReentrantLock@details@Concurrency@@QAA_NXZ -+?_TryAcquireWrite@_ReaderWriterLock@details@Concurrency@@QAA_NXZ -+?_Type_info_dtor@type_info@@CAXPAV1@@Z -+?_Type_info_dtor_internal@type_info@@CAXPAV1@@Z -+?_UnderlyingYield@details@Concurrency@@YAXXZ -+?_ValidateExecute@@YAHP6AHXZ@Z -+?_ValidateRead@@YAHPBXI@Z -+?_ValidateWrite@@YAHPAXI@Z -+?_Value@_SpinCount@details@Concurrency@@SAIXZ -+?_Yield@_Context@details@Concurrency@@SAXXZ -+?__ExceptionPtrAssign@@YAXPAXPBX@Z -+?__ExceptionPtrCompare@@YA_NPBX0@Z -+?__ExceptionPtrCopy@@YAXPAXPBX@Z -+?__ExceptionPtrCopyException@@YAXPAXPBX1@Z -+?__ExceptionPtrCreate@@YAXPAX@Z -+?__ExceptionPtrCurrentException@@YAXPAX@Z -+?__ExceptionPtrDestroy@@YAXPAX@Z -+?__ExceptionPtrRethrow@@YAXPBX@Z -+?__ExceptionPtrSwap@@YAXPAX0@Z -+?__ExceptionPtrToBool@@YA_NPBX@Z -+__uncaught_exception -+?_inconsistency@@YAXXZ -+?_invalid_parameter@@YAXPBG00II@Z -+?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z -+?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z -+?_open@@YAHPBDHH@Z -+?_query_new_handler@@YAP6AHI@ZXZ -+?_query_new_mode@@YAHXZ -+?_set_new_handler@@YAP6AHI@ZH@Z -+?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z -+?_set_new_mode@@YAHH@Z -+?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZH@Z -+?_set_se_translator@@YAP6AXIPAU_EXCEPTION_POINTERS@@@ZP6AXI0@Z@Z -+?_sopen@@YAHPBDHHH@Z -+?_type_info_dtor_internal_method@type_info@@QAAXXZ -+?_wopen@@YAHPB_WHH@Z -+?_wsopen@@YAHPB_WHHH@Z -+?before@type_info@@QBA_NABV1@@Z -+?current@location@Concurrency@@SA?AV12@XZ -+?from_numa_node@location@Concurrency@@SA?AV12@G@Z -+?get_error_code@scheduler_resource_allocation_error@Concurrency@@QBAJXZ -+?lock@critical_section@Concurrency@@QAAXXZ -+?lock@reader_writer_lock@Concurrency@@QAAXXZ -+?lock_read@reader_writer_lock@Concurrency@@QAAXXZ -+?name@type_info@@QBAPBDPAU__type_info_node@@@Z -+?native_handle@critical_section@Concurrency@@QAAAAV12@XZ -+?notify_all@_Condition_variable@details@Concurrency@@QAAXXZ -+?notify_one@_Condition_variable@details@Concurrency@@QAAXXZ -+?raw_name@type_info@@QBAPBDXZ -+?reset@event@Concurrency@@QAAXXZ -+?set@event@Concurrency@@QAAXXZ -+?set_new_handler@@YAP6AXXZP6AXXZ@Z -+?set_task_execution_resources@Concurrency@@YAXGPAU_GROUP_AFFINITY@@@Z -+?set_task_execution_resources@Concurrency@@YAXK@Z -+?set_terminate@@YAP6AXXZH@Z -+?set_terminate@@YAP6AXXZP6AXXZ@Z -+?set_unexpected@@YAP6AXXZH@Z -+?set_unexpected@@YAP6AXXZP6AXXZ@Z -+?terminate@@YAXXZ -+?try_lock@critical_section@Concurrency@@QAA_NXZ -+?try_lock@reader_writer_lock@Concurrency@@QAA_NXZ -+?try_lock_for@critical_section@Concurrency@@QAA_NI@Z -+?try_lock_read@reader_writer_lock@Concurrency@@QAA_NXZ -+?unexpected@@YAXXZ -+?unlock@critical_section@Concurrency@@QAAXXZ -+?unlock@reader_writer_lock@Concurrency@@QAAXXZ -+?wait@Concurrency@@YAXI@Z -+?wait@_Condition_variable@details@Concurrency@@QAAXAAVcritical_section@3@@Z -+?wait@event@Concurrency@@QAAII@Z -+?wait_for@_Condition_variable@details@Concurrency@@QAA_NAAVcritical_section@3@I@Z -+?wait_for_multiple@event@Concurrency@@SAIPAPAV12@I_NI@Z -+?what@exception@std@@UBAPBDXZ -+_Cbuild -+_CreateFrameInfo -+_CxxThrowException -+_FCbuild -+_FPE_Raise -+_FindAndUnlinkFrame -+_Getdays -+_Getmonths -+_Gettnames -+_HUGE DATA -+_IsExceptionObjectToBeDestroyed -+_LCbuild -+_SetWinRTOutOfMemoryExceptionCallback -+_Strftime -+_W_Getdays -+_W_Getmonths -+_W_Gettnames -+_Wcsftime -+_XcptFilter -+__AdjustPointer -+__BuildCatchObject -+__BuildCatchObjectHelper -+__C_specific_handler -+__CppXcptFilter -+__CxxDetectRethrow -+__CxxExceptionFilter -+__CxxFrameHandler -+__CxxFrameHandler2 -+__CxxFrameHandler3 -+__CxxQueryExceptionSize -+__CxxRegisterExceptionObject -+__CxxUnregisterExceptionObject -+__DestructExceptionObject -+__FrameUnwindFilter -+__GetPlatformExceptionInfo -+__NLG_Dispatch2 -+__NLG_Return2 -+__RTCastToVoid -+__RTDynamicCast -+__RTtypeid -+__STRINGTOLD -+__STRINGTOLD_L -+__TypeMatch -+___lc_codepage_func -+___lc_collate_cp_func -+___lc_locale_name_func -+___mb_cur_max_func -+___mb_cur_max_l_func -+___setlc_active_func -+___unguarded_readlc_active_add_func -+__argc DATA -+__argv DATA -+__badioinfo DATA -+__clean_type_info_names_internal -+__create_locale -+__crtCloseWinRTThreadHandle -+__crtCompareStringA -+__crtCompareStringW -+__crtCreateWinRTThread -+__crtGetCurrentWinRTThread -+__crtGetCurrentWinRTThreadId -+__crtGetExitCodeWinRTThread -+__crtIsPackagedApp -+__crtLCMapStringA -+__crtLCMapStringW -+__crtSleep -+__crtWaitForWinRTThreadExit -+__crt_debugger_hook -+__daylight -+__dllonexit -+__doserrno -+__dstbias -+__fpecode -+__free_locale -+__get_current_locale -+__get_flsindex -+__get_tlsindex -+__getmainargs -+__initenv DATA -+__iob_func -+__isascii -+__iscsym -+__iscsymf -+__iswcsym -+__iswcsymf -+__jump_unwind -+__lconv DATA -+__lconv_init -+__mb_cur_max DATA -+__p___argc -+__p___argv -+__p___mb_cur_max -+__p___wargv -+__p__acmdln -+__p__commode -+__p__daylight -+__p__dstbias -+__p__fmode -+__p__iob -+__p__mbcasemap -+__p__mbctype -+__p__pctype -+__p__pgmptr -+__p__pwctype -+__p__timezone -+__p__tzname -+__p__wcmdln -+__p__wpgmptr -+__pctype_func -+__pioinfo DATA -+__pwctype_func -+__pxcptinfoptrs -+__report_gsfailure -+__setlc_active DATA -+__setusermatherr -+__strncnt -+__swprintf_l -+__sys_errlist -+__sys_nerr -+__threadhandle -+__threadid -+__timezone -+__toascii -+__tzname -+__unDName -+__unDNameEx -+__unDNameHelper -+__unguarded_readlc_active DATA -+__vswprintf_l -+__wargv DATA -+__wcserror -+__wcserror_s -+__wcsncnt -+__wgetmainargs -+__winitenv DATA -+_abs64 -+_access -+_access_s -+_acmdln DATA -+_aligned_free -+_aligned_malloc -+_aligned_msize -+_aligned_offset_malloc -+_aligned_offset_realloc -+_aligned_offset_recalloc -+_aligned_realloc -+_aligned_recalloc -+_amsg_exit -+_assert -+_atodbl -+_atodbl_l -+_atof_l -+_atoflt -+_atoflt_l -+_atoi64 -+_atoi64_l -+_atoi_l -+_atol_l -+_atoldbl -+_atoldbl_l -+_atoll_l -+_byteswap_uint64 -+_byteswap_ulong -+_byteswap_ushort -+_c_exit -+_cabs -+_callnewh -+_calloc_crt -+_cexit -+_chgsign -+_chgsignf -+_chmod -+_chsize -+_chsize_s -+_clearfp -+_close -+_commit -+_commode DATA -+_configthreadlocale -+_control87 -+_controlfp -+_controlfp_s -+_copysign -+_copysignf -+_creat -+_create_locale -+_ctime32 -+_ctime32_s -+_ctime64 -+_ctime64_s -+_daylight DATA -+_dclass -+_difftime32 -+_difftime64 -+_dosmaperr -+_dpcomp -+_dsign -+_dstbias DATA -+_dtest -+_dup -+_dup2 -+_ecvt -+_ecvt_s -+_environ DATA -+_eof -+_errno -+_exit -+_exit_app -+_expand -+_fclose_nolock -+_fcloseall -+_fcvt -+_fcvt_s -+_fdclass -+_fdopen -+_fdpcomp -+_fdsign -+_fdtest -+_fflush_nolock -+_fgetchar -+_fgetwc_nolock -+_fgetwchar -+_filbuf -+_filelength -+_filelengthi64 -+_fileno -+_findclose -+_findfirst32 -+_findfirst32i64 -+_findfirst64 -+_findfirst64i32 -+_findnext32 -+_findnext32i64 -+_findnext64 -+_findnext64i32 -+_finite -+_flsbuf -+_flushall -+_fmode DATA -+_fpclass -+_fpieee_flt -+_fpreset -+_fprintf_l -+_fprintf_p -+_fprintf_p_l -+_fprintf_s_l -+_fputchar -+_fputwc_nolock -+_fputwchar -+_fread_nolock -+_fread_nolock_s -+_free_locale -+_freea -+_freea_s -+_freefls -+_fscanf_l -+_fscanf_s_l -+_fseek_nolock -+_fseeki64 -+_fseeki64_nolock -+_fsopen -+_fstat32 -+_fstat32i64 -+_fstat64 -+_fstat64i32 -+_ftell_nolock -+_ftelli64 -+_ftelli64_nolock -+_ftime32 -+_ftime32_s -+_ftime64 -+_ftime64_s -+_fullpath -+_futime32 -+_futime64 -+_fwprintf_l -+_fwprintf_p -+_fwprintf_p_l -+_fwprintf_s_l -+_fwrite_nolock -+_fwscanf_l -+_fwscanf_s_l -+_gcvt -+_gcvt_s -+_get_current_locale -+_get_daylight -+_get_doserrno -+_get_dstbias -+_get_errno -+_get_fmode -+_get_heap_handle -+_get_invalid_parameter_handler -+_get_osfhandle -+_get_output_format -+_get_pgmptr -+_get_printf_count_output -+_get_purecall_handler -+_get_terminate -+_get_timezone -+_get_tzname -+_get_unexpected -+_get_wpgmptr -+_getc_nolock -+_getmaxstdio -+_getmbcp -+_getptd -+_getw -+_getws -+_getws_s -+_gmtime32 -+_gmtime32_s -+_gmtime64 -+_gmtime64_s -+_hypot -+_hypotf -+_i64toa -+_i64toa_s -+_i64tow -+_i64tow_s -+_initptd -+_initterm -+_initterm_e -+_invalid_parameter -+_invalid_parameter_noinfo -+_invalid_parameter_noinfo_noreturn -+_invoke_watson -+_iob DATA -+_isalnum_l -+_isalpha_l -+_isatty -+_isblank_l -+_iscntrl_l -+_isctype -+_isctype_l -+_isdigit_l -+_isgraph_l -+_isleadbyte_l -+_islower_l -+_ismbbalnum -+_ismbbalnum_l -+_ismbbalpha -+_ismbbalpha_l -+_ismbbblank -+_ismbbblank_l -+_ismbbgraph -+_ismbbgraph_l -+_ismbbkalnum -+_ismbbkalnum_l -+_ismbbkana -+_ismbbkana_l -+_ismbbkprint -+_ismbbkprint_l -+_ismbbkpunct -+_ismbbkpunct_l -+_ismbblead -+_ismbblead_l -+_ismbbprint -+_ismbbprint_l -+_ismbbpunct -+_ismbbpunct_l -+_ismbbtrail -+_ismbbtrail_l -+_isnan -+_isprint_l -+_ispunct_l -+_isspace_l -+_isupper_l -+_iswalnum_l -+_iswalpha_l -+_iswblank_l -+_iswcntrl_l -+_iswcsym_l -+_iswcsymf_l -+_iswctype_l -+_iswdigit_l -+_iswgraph_l -+_iswlower_l -+_iswprint_l -+_iswpunct_l -+_iswspace_l -+_iswupper_l -+_iswxdigit_l -+_isxdigit_l -+_itoa -+_itoa_s -+_itow -+_itow_s -+_j0 -+_j1 -+_jn -+_ldclass -+_ldpcomp -+_ldsign -+_ldtest -+_lfind -+_lfind_s -+_localtime32 -+_localtime32_s -+_localtime64 -+_localtime64_s -+_lock -+_lock_file -+_locking -+_logb -+_logbf -+_lrotl -+_lrotr -+_lsearch -+_lsearch_s -+_lseek -+_lseeki64 -+_ltoa -+_ltoa_s -+_ltow -+_ltow_s -+_makepath -+_makepath_s -+_malloc_crt -+_mbcasemap DATA -+_mbctype DATA -+_mblen_l -+_mbstowcs_l -+_mbstowcs_s_l -+_mbstrlen -+_mbstrlen_l -+_mbstrnlen -+_mbstrnlen_l -+_mbtowc_l -+_memccpy -+_memicmp -+_memicmp_l -+_mkdir -+_mkgmtime32 -+_mkgmtime64 -+_mktemp -+_mktemp_s -+_mktime32 -+_mktime64 -+_msize -+_nextafter -+_onexit -+_open -+_open_osfhandle -+_pctype DATA -+_pgmptr DATA -+_printf_l -+_printf_p -+_printf_p_l -+_printf_s_l -+_purecall -+_putw -+_putws -+_pwctype DATA -+_read -+_realloc_crt -+_recalloc -+_recalloc_crt -+_rmdir -+_rmtmp -+_rotl -+_rotl64 -+_rotr -+_rotr64 -+_scalb -+_scanf_l -+_scanf_s_l -+_scprintf -+_scprintf_l -+_scprintf_p -+_scprintf_p_l -+_scwprintf -+_scwprintf_l -+_scwprintf_p -+_scwprintf_p_l -+_set_abort_behavior -+_set_controlfp -+_set_doserrno -+_set_errno -+_set_error_mode -+_set_fmode -+_set_invalid_parameter_handler -+_set_malloc_crt_max_wait -+_set_output_format -+_set_printf_count_output -+_set_purecall_handler -+_setjmp -+_setjmpex -+_setmaxstdio -+_setmbcp -+_setmode -+_snprintf -+_snprintf_c -+_snprintf_c_l -+_snprintf_l -+_snprintf_s -+_snprintf_s_l -+_snscanf -+_snscanf_l -+_snscanf_s -+_snscanf_s_l -+_snwprintf -+_snwprintf_l -+_snwprintf_s -+_snwprintf_s_l -+_snwscanf -+_snwscanf_l -+_snwscanf_s -+_snwscanf_s_l -+_sopen -+_sopen_s -+_splitpath -+_splitpath_s -+_sprintf_l -+_sprintf_p -+_sprintf_p_l -+_sprintf_s_l -+_sscanf_l -+_sscanf_s_l -+_stat32 -+_stat32i64 -+_stat64 -+_stat64i32 -+_statusfp -+_strcoll_l -+_strdate -+_strdate_s -+_strdup -+_strerror -+_strerror_s -+_strftime_l -+_stricmp -+_stricmp_l -+_stricoll -+_stricoll_l -+_strlwr -+_strlwr_l -+_strlwr_s -+_strlwr_s_l -+_strncoll -+_strncoll_l -+_strnicmp -+_strnicmp_l -+_strnicoll -+_strnicoll_l -+_strnset -+_strnset_s -+_strrev -+_strset -+_strset_s -+_strtime -+_strtime_s -+_strtod_l -+_strtof_l -+_strtoi64 -+_strtoi64_l -+_strtoimax_l -+_strtol_l -+_strtold_l -+_strtoll_l -+_strtoui64 -+_strtoui64_l -+_strtoul_l -+_strtoull_l -+_strtoumax_l -+_strupr -+_strupr_l -+_strupr_s -+_strupr_s_l -+_strxfrm_l -+_swab -+_swprintf -+_swprintf_c -+_swprintf_c_l -+_swprintf_p -+_swprintf_p_l -+_swprintf_s_l -+_swscanf_l -+_swscanf_s_l -+_sys_errlist DATA -+_sys_nerr DATA -+_tell -+_telli64 -+_tempnam -+_time32 -+_time64 -+_timezone DATA -+_tolower -+_tolower_l -+_toupper -+_toupper_l -+_towlower_l -+_towupper_l -+_tzname DATA -+_tzset -+_ui64toa -+_ui64toa_s -+_ui64tow -+_ui64tow_s -+_ultoa -+_ultoa_s -+_ultow -+_ultow_s -+_umask -+_umask_s -+_ungetc_nolock -+_ungetwc_nolock -+_unlink -+_unlock -+_unlock_file -+_utime32 -+_utime64 -+_vacopy -+_vfprintf_l -+_vfprintf_p -+_vfprintf_p_l -+_vfprintf_s_l -+_vfwprintf_l -+_vfwprintf_p -+_vfwprintf_p_l -+_vfwprintf_s_l -+_vprintf_l -+_vprintf_p -+_vprintf_p_l -+_vprintf_s_l -+_vscprintf -+_vscprintf_l -+_vscprintf_p -+_vscprintf_p_l -+_vscwprintf -+_vscwprintf_l -+_vscwprintf_p -+_vscwprintf_p_l -+_vsnprintf -+_vsnprintf_c -+_vsnprintf_c_l -+_vsnprintf_l -+_vsnprintf_s -+_vsnprintf_s_l -+_vsnwprintf -+_vsnwprintf_l -+_vsnwprintf_s -+_vsnwprintf_s_l -+_vsprintf_l -+_vsprintf_p -+_vsprintf_p_l -+_vsprintf_s_l -+_vswprintf -+_vswprintf_c -+_vswprintf_c_l -+_vswprintf_l -+_vswprintf_p -+_vswprintf_p_l -+_vswprintf_s_l -+_vwprintf_l -+_vwprintf_p -+_vwprintf_p_l -+_vwprintf_s_l -+_waccess -+_waccess_s -+_wasctime -+_wasctime_s -+_wassert -+_wchmod -+_wcmdln DATA -+_wcreat -+_wcreate_locale -+_wcscoll_l -+_wcsdup -+_wcserror -+_wcserror_s -+_wcsftime_l -+_wcsicmp -+_wcsicmp_l -+_wcsicoll -+_wcsicoll_l -+_wcslwr -+_wcslwr_l -+_wcslwr_s -+_wcslwr_s_l -+_wcsncoll -+_wcsncoll_l -+_wcsnicmp -+_wcsnicmp_l -+_wcsnicoll -+_wcsnicoll_l -+_wcsnset -+_wcsnset_s -+_wcsrev -+_wcsset -+_wcsset_s -+_wcstod_l -+_wcstof_l -+_wcstoi64 -+_wcstoi64_l -+_wcstoimax_l -+_wcstol_l -+_wcstold_l -+_wcstoll_l -+_wcstombs_l -+_wcstombs_s_l -+_wcstoui64 -+_wcstoui64_l -+_wcstoul_l -+_wcstoull_l -+_wcstoumax_l -+_wcsupr -+_wcsupr_l -+_wcsupr_s -+_wcsupr_s_l -+_wcsxfrm_l -+_wctime32 -+_wctime32_s -+_wctime64 -+_wctime64_s -+_wctomb_l -+_wctomb_s_l -+_wctype DATA -+_wenviron DATA -+_wfdopen -+_wfindfirst32 -+_wfindfirst32i64 -+_wfindfirst64 -+_wfindfirst64i32 -+_wfindnext32 -+_wfindnext32i64 -+_wfindnext64 -+_wfindnext64i32 -+_wfopen -+_wfopen_s -+_wfreopen -+_wfreopen_s -+_wfsopen -+_wfullpath -+_wmakepath -+_wmakepath_s -+_wmkdir -+_wmktemp -+_wmktemp_s -+_wopen -+_wperror -+_wpgmptr DATA -+_wprintf_l -+_wprintf_p -+_wprintf_p_l -+_wprintf_s_l -+_wremove -+_wrename -+_write -+_wrmdir -+_wscanf_l -+_wscanf_s_l -+_wsetlocale -+_wsopen -+_wsopen_s -+_wsplitpath -+_wsplitpath_s -+_wstat32 -+_wstat32i64 -+_wstat64 -+_wstat64i32 -+_wstrdate -+_wstrdate_s -+_wstrtime -+_wstrtime_s -+_wtempnam -+_wtmpnam -+_wtmpnam_s -+_wtof -+_wtof_l -+_wtoi -+_wtoi64 -+_wtoi64_l -+_wtoi_l -+_wtol -+_wtol_l -+_wtoll -+_wtoll_l -+_wunlink -+_wutime32 -+_wutime64 -+_y0 -+_y1 -+_yn -+abort -+abs -+acos -+acosf -+acosh -+acoshf -+acoshl -+asctime -+asctime_s -+asin -+asinf -+asinh -+asinhf -+asinhl -+atan -+atan2 -+atan2f -+atanf -+atanh -+atanhf -+atanhl -+atexit -+atof -+atoi -+atol -+atoll -+bsearch -+bsearch_s -+btowc -+cabs -+cabsf -+cabsl -+cacos -+cacosf -+cacosh -+cacoshf -+cacoshl -+cacosl -+calloc -+carg -+cargf -+cargl -+casin -+casinf -+casinh -+casinhf -+casinhl -+casinl -+catan -+catanf -+catanh -+catanhf -+catanhl -+catanl -+cbrt -+cbrtf -+cbrtl -+ccos -+ccosf -+ccosh -+ccoshf -+ccoshl -+ccosl -+ceil -+ceilf -+cexp -+cexpf -+cexpl -+cimag -+cimagf -+cimagl -+clearerr -+clearerr_s -+clock -+clog -+clog10 -+clog10f -+clog10l -+clogf -+clogl -+conj -+conjf -+conjl -+copysign -+copysignf -+copysignl -+cos -+cosf -+cosh -+coshf -+cpow -+cpowf -+cpowl -+cproj -+cprojf -+cprojl -+creal -+crealf -+creall -+csin -+csinf -+csinh -+csinhf -+csinhl -+csinl -+csqrt -+csqrtf -+csqrtl -+ctan -+ctanf -+ctanh -+ctanhf -+ctanhl -+ctanl -+div -+erf -+erfc -+erfcf -+erfcl -+erff -+erfl -+exit -+exp -+exp2 -+exp2f -+exp2l -+expf -+expm1 -+expm1f -+expm1l -+fabs -+fabsf -+fclose -+fdim -+fdimf -+fdiml -+feclearexcept -+fegetenv -+fegetexceptflag -+fegetround -+feholdexcept -+feof -+feraiseexcept -+ferror -+fesetenv -+fesetexceptflag -+fesetround -+fetestexcept -+feupdateenv -+fflush -+fgetc -+fgetpos -+fgets -+fgetwc -+fgetws -+floor -+floorf -+fma -+fmaf -+fmal -+fmax -+fmaxf -+fmaxl -+fmin -+fminf -+fminl -+fmod -+fmodf -+fopen -+fopen_s -+fprintf -+fprintf_s -+fputc -+fputs -+fputwc -+fputws -+fread -+fread_s -+free -+freopen -+freopen_s -+frexp -+fscanf -+fscanf_s -+fseek -+fsetpos -+ftell -+fwprintf -+fwprintf_s -+fwrite -+fwscanf -+fwscanf_s -+getc -+getchar -+gets -+gets_s -+getwc -+getwchar -+ilogb -+ilogbf -+ilogbl -+imaxabs -+imaxdiv -+isalnum -+isalpha -+isblank -+iscntrl -+isdigit -+isgraph -+isleadbyte -+islower -+isprint -+ispunct -+isspace -+isupper -+iswalnum -+iswalpha -+iswascii -+iswblank -+iswcntrl -+iswctype -+iswdigit -+iswgraph -+iswlower -+iswprint -+iswpunct -+iswspace -+iswupper -+iswxdigit -+isxdigit -+labs -+ldexp -+ldiv -+lgamma -+lgammaf -+lgammal -+llabs -+lldiv -+llrint -+llrintf -+llrintl -+llround -+llroundf -+llroundl -+localeconv -+log -+log10 -+log10f -+log1p -+log1pf -+log1pl -+log2 -+log2f -+log2l -+logb -+logbf -+logbl -+logf -+longjmp -+lrint -+lrintf -+lrintl -+lround -+lroundf -+lroundl -+malloc -+mblen -+mbrlen -+mbrtowc -+mbsrtowcs -+mbsrtowcs_s -+mbstowcs -+mbstowcs_s -+mbtowc -+memchr -+memcmp -+memcpy -+memcpy_s -+memmove -+memmove_s -+memset -+modf -+modff -+nan -+nanf -+nanl -+nearbyint -+nearbyintf -+nearbyintl -+nextafter -+nextafterf -+nextafterl -+nexttoward -+nexttowardf -+nexttowardl -+norm -+normf -+norml -+perror -+pow -+powf -+printf -+printf_s -+putc -+putchar -+puts -+putwc -+putwchar -+qsort -+qsort_s -+raise -+rand -+rand_s -+realloc -+remainder -+remainderf -+remainderl -+remove -+remquo -+remquof -+remquol -+rename -+rewind -+rint -+rintf -+rintl -+round -+roundf -+roundl -+scalbln -+scalblnf -+scalblnl -+scalbn -+scalbnf -+scalbnl -+scanf -+scanf_s -+setbuf -+setjmp -+setlocale -+setvbuf -+signal -+sin -+sinf -+sinh -+sinhf -+sprintf -+sprintf_s -+sqrt -+sqrtf -+srand -+sscanf -+sscanf_s -+strcat -+strcat_s -+strchr -+strcmp -+strcoll -+strcpy -+strcpy_s -+strcspn -+strerror -+strerror_s -+strftime -+strlen -+strncat -+strncat_s -+strncmp -+strncpy -+strncpy_s -+strnlen -+strpbrk -+strrchr -+strspn -+strstr -+strtod -+strtof -+strtoimax -+strtok -+strtok_s -+strtol -+strtold -+strtoll -+strtoul -+strtoull -+strtoumax -+strxfrm -+swprintf_s -+swscanf -+swscanf_s -+tan -+tanf -+tanh -+tanhf -+tgamma -+tgammaf -+tgammal -+tmpfile -+tmpfile_s -+tmpnam -+tmpnam_s -+tolower -+toupper -+towctrans -+towlower -+towupper -+trunc -+truncf -+truncl -+ungetc -+ungetwc -+vfprintf -+vfprintf_s -+vfscanf -+vfscanf_s -+vfwprintf -+vfwprintf_s -+vfwscanf -+vfwscanf_s -+vprintf -+vprintf_s -+vscanf -+vscanf_s -+vsprintf -+vsprintf_s -+vsscanf -+vsscanf_s -+vswprintf_s -+vswscanf -+vswscanf_s -+vwprintf -+vwprintf_s -+vwscanf -+vwscanf_s -+wcrtomb -+wcrtomb_s -+wcscat -+wcscat_s -+wcschr -+wcscmp -+wcscoll -+wcscpy -+wcscpy_s -+wcscspn -+wcsftime -+wcslen -+wcsncat -+wcsncat_s -+wcsncmp -+wcsncpy -+wcsncpy_s -+wcsnlen -+wcspbrk -+wcsrchr -+wcsrtombs -+wcsrtombs_s -+wcsspn -+wcsstr -+wcstod -+wcstof -+wcstoimax -+wcstok -+wcstok_s -+wcstol -+wcstold -+wcstoll -+wcstombs -+wcstombs_s -+wcstoul -+wcstoull -+wcstoumax -+wcsxfrm -+wctob -+wctomb -+wctomb_s -+wctrans -+wctype -+wmemcpy_s -+wmemmove_s -+wprintf -+wprintf_s -+wscanf -+wscanf_s --- -2.8.1 - diff --git a/patches/mingw-0004.patch b/patches/mingw-0004.patch deleted file mode 100644 index b3eec86..0000000 --- a/patches/mingw-0004.patch +++ /dev/null @@ -1,25 +0,0 @@ -From cf2434c417310703cfda61943c66f33fa23bde57 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Martin=20Storsj=C3=B6?= -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 - diff --git a/wrappers/armv7-w64-mingw32-clang b/wrappers/armv7-w64-mingw32-clang deleted file mode 100755 index 13ffcdf..0000000 --- a/wrappers/armv7-w64-mingw32-clang +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -$DIR/clang -target armv7-windows-gnu "$@" diff --git a/wrappers/armv7-w64-mingw32-clang++ b/wrappers/armv7-w64-mingw32-clang++ deleted file mode 100755 index 2994fa3..0000000 --- a/wrappers/armv7-w64-mingw32-clang++ +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -$DIR/clang++ -target armv7-windows-gnu "$@" diff --git a/wrappers/clang-target-wrapper b/wrappers/clang-target-wrapper new file mode 100755 index 0000000..6319b7b --- /dev/null +++ b/wrappers/clang-target-wrapper @@ -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 "$@"