forked from xt-sys/xtchain
Compare commits
93
Commits
1.3
..
crosscompile
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6808e3b1d7
|
||
|
|
c152b99327
|
||
|
|
a458cb0219
|
||
|
|
9219ebca83
|
||
|
|
11cc5e47bc
|
||
|
|
fc8f97b84d
|
||
|
|
63a9e40408
|
||
|
|
6664e9be64
|
||
|
|
12ed36ca0e
|
||
|
|
79cca854bc
|
||
|
|
460d5820da
|
||
|
|
83e84c3ebf
|
||
|
|
eeb1953d87
|
||
|
|
e9707563d7
|
||
|
|
11d0593c9e
|
||
|
|
22a5abd279
|
||
|
|
8c047d6083
|
||
|
|
1832a39ed3
|
||
|
|
2a00526666
|
||
|
|
1f72016fc2
|
||
|
|
a522cdc583
|
||
|
|
37230435aa
|
||
|
|
737dda2960
|
||
|
|
0d468bf245
|
||
|
|
b0baae79ba
|
||
|
|
ecd243ed0d
|
||
|
|
b9d0458a65
|
||
|
|
7fb2227034
|
||
|
|
0e49773bf4
|
||
|
|
5684623164
|
||
|
|
14f2f7cf1f
|
||
|
|
37e38daf36
|
||
|
|
b65a92d147
|
||
|
|
173b6d6dd0
|
||
|
|
2da20a4eba
|
||
|
|
c9ef8a6484
|
||
|
|
be63d61cf4
|
||
|
|
9fd40e9617
|
||
|
|
116d309962
|
||
|
|
6845594e6a
|
||
|
|
69ae9afb88
|
||
|
|
3ae3ceaabb
|
||
|
|
361c0a1cdb
|
||
|
|
d6531be5ee
|
||
|
|
771d3783fa
|
||
|
|
2e7c7ec1d7
|
||
|
|
99f0b83ac7
|
||
|
|
9cc7d052dd
|
||
|
|
abefcf8fe2
|
||
|
|
015bc8a666
|
||
|
|
546d8718d2
|
||
|
|
a65685de5c
|
||
|
|
f9af39e058
|
||
|
|
9b7d73e0e9
|
||
|
|
8eb76f6b90
|
||
|
|
00c659911d
|
||
|
|
b1de0a02b6
|
||
|
|
36df8e42e6
|
||
|
|
7d802e0835
|
||
|
|
1904f94583
|
||
|
|
3096bf9255
|
||
|
|
fdd5e32ea0
|
||
|
|
3a35c39c8e
|
||
|
|
9e200f0139
|
||
|
|
80bbcab65d
|
||
|
|
952db3582a
|
||
|
|
04edfa61dd
|
||
|
|
d7d7ac54b6
|
||
|
|
757c207121
|
||
|
|
7be4e21ea1
|
||
|
|
1d621de2be
|
||
|
|
ca2ba1345c
|
||
|
|
dbf05e76f3
|
||
|
|
323e7d0ce1
|
||
|
|
69ab76846e
|
||
|
|
5c901f2d31
|
||
|
|
7529ec4918
|
||
|
|
c9e595cbb0
|
||
|
|
91b34c1656
|
||
|
|
4cc4e3fa3c
|
||
|
|
a5c591db22
|
||
|
|
f34719b83a
|
||
|
|
50cc5fb1a0
|
||
|
|
51284f1845
|
||
|
|
17fb057dce
|
||
|
|
1fe8fdaca9
|
||
|
|
84f02ccf72
|
||
|
|
31d2bc7e7e
|
||
|
|
1dd591ba93
|
||
|
|
cfd2192e63
|
||
|
|
cf334d86dd
|
||
|
|
ff2c349be3
|
||
|
|
9f712e2ebc
|
@@ -0,0 +1,20 @@
|
||||
name: Builds
|
||||
run-name: ${{ github.actor }} runs Gitea Actions
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
XTChain:
|
||||
runs-on: oscw
|
||||
container:
|
||||
image: codingworkshop/oscw-runner:latest
|
||||
steps:
|
||||
- name: Clone repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Build XTChain
|
||||
run: CORES=10 ./build-linux.sh
|
||||
- name: Publish binaries
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
env:
|
||||
OSCW_GITHUB_USERNAME: ${{ secrets.OSCW_GITHUB_USERNAME }}
|
||||
OSCW_GITHUB_PASSWORD: ${{ secrets.OSCW_GITHUB_PASSWORD }}
|
||||
run: github_publish $OSCW_GITHUB_USERNAME $OSCW_GITHUB_PASSWORD $(ls xtchain-*-linux.tar.zst)
|
||||
@@ -0,0 +1,3 @@
|
||||
binaries/*
|
||||
sources/*
|
||||
xtchain-*.zst
|
||||
@@ -1,22 +1,52 @@
|
||||
<p align=center>
|
||||
<a href="https://git.codingworkshop.eu.org/xt-sys/xtchain">
|
||||
<img alt="GIT Repository" src="https://img.shields.io/badge/Source-GIT-purple">
|
||||
</a>
|
||||
<a href="https://git.codingworkshop.eu.org/xt-sys/xtchain/actions">
|
||||
<img alt="Build Status" src="https://codingworkshop.eu.org/actions.php?project=xt-sys/xtchain">
|
||||
</a>
|
||||
<a href="https://github.com/xt-sys/xtchain/releases">
|
||||
<img alt="Releases" src="https://img.shields.io/github/v/release/xt-sys/xtchain?label=Release&color=blueviolet">
|
||||
</a>
|
||||
<a href="https://git.codingworkshop.eu.org/xt-sys/xtchain/src/branch/master/COPYING.md">
|
||||
<img alt="License" src="https://img.shields.io/badge/License-GPLv3-blue.svg">
|
||||
</a>
|
||||
<a href="https://github.com/sponsors/xt-sys/">
|
||||
<img alt="Sponsors" src="https://img.shields.io/badge/Sponsor-%E2%9D%A4-red?logo=GitHub">
|
||||
</a>
|
||||
<a href="https://discord.com/invite/3zgjQDVmAe">
|
||||
<img alt="Discord" src="https://img.shields.io/discord/723186294540206100?label=Chat">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
---
|
||||
|
||||
## XT Toolchain
|
||||
This is a GNU-based mingw-w64 toolchain. It currently supports C and C++, and provides a variety of
|
||||
tools including IDL, message and resource compilers. The XT Toolchain is also the official build
|
||||
environment for compiling XT software, including the FerretOS. Currently, it is targeted at Linux
|
||||
host only, however it should be possible to build it in MSYS2 as well.
|
||||
This is a LLVM/Clang/LLD based mingw-w64 toolchain. It currently supports C and C++, and provides
|
||||
a variety of tools including IDL, message and resource compilers. The XT Toolchain is also the
|
||||
official build environment for compiling XT software, including the XT OS. Currently, it is
|
||||
targeted at Linux host only, however it should be possible to build it in MSYS2 as well.
|
||||
|
||||
Benefits of a LLVM based MinGW toolchain are:
|
||||
* Single toolchain targeting all architectures (i686, x86_64, armv7 and aarch64),
|
||||
* Support for generating debug info in PDB format,
|
||||
* Support for targeting ARM/AARCH64 architectures and ability to produce Windows ARM binaries.
|
||||
|
||||
This software includes:
|
||||
* Binutils
|
||||
* CMake
|
||||
* GCC
|
||||
* GNU Assembler
|
||||
* LLVM
|
||||
* Make
|
||||
* Mingw-w64
|
||||
* Ninja
|
||||
* Wine
|
||||
|
||||
This software is based on [LLVM MinGW Toolchain](https://github.com/mstorsjo/llvm-mingw).
|
||||
|
||||
## Licensing
|
||||
The XTchain project includes the scripts for building and assembling a toolchain as well as
|
||||
environmental shell. These are licensed under the GPLv3 license. It covers only mentioned
|
||||
components that are provided by XTchain directly. For more information on that, refer to the
|
||||
COPYING.md file. The final pre-built toolchain is covered by the licenses of the individual,
|
||||
The XTchain project includes the scripts for building and assembling a toolchain as well as wrappers
|
||||
for LLVM tools and environmental shell. These are licensed under the GPLv3 license. It covers only
|
||||
mentioned components that are provided by XTchain directly. For more information on that, refer to
|
||||
the COPYING.md file. The final pre-built toolchain is covered by the licenses of the individual,
|
||||
external projects. The full list of software incorporated into this toolchain is available in the
|
||||
README.md file.
|
||||
|
||||
+211
-124
@@ -13,48 +13,44 @@ SRCDIR="$(pwd)/sources"
|
||||
WRKDIR="$(pwd)"
|
||||
|
||||
# Architecture Settings
|
||||
ARCHS="i686 x86_64"
|
||||
ARCHS="aarch64 armv7 i686 x86_64"
|
||||
GENERIC="generic-w64-mingw32"
|
||||
|
||||
# Compiler Flags
|
||||
CFLAGS="-march=x86-64 -mtune=generic -O2 -s -pipe"
|
||||
CXXFLAGS="${CFLAGS}"
|
||||
|
||||
# Binutils Settings
|
||||
BINUTILSDIR="${SRCDIR}/binutils"
|
||||
BINUTILSTAG="binutils-2_35"
|
||||
BINUTILSTAG="binutils-2_41"
|
||||
BINUTILSVCS="git://sourceware.org/git/binutils-gdb.git"
|
||||
|
||||
# CMake Settings
|
||||
CMAKEDIR="${SRCDIR}/cmake"
|
||||
CMAKETAG="v3.18.1"
|
||||
CMAKETAG="v3.27.6"
|
||||
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
|
||||
|
||||
# GCC Settings
|
||||
GCCDIR="${SRCDIR}/gcc"
|
||||
GCCTAG="releases/gcc-9.3.0"
|
||||
GCCVCS="git://gcc.gnu.org/git/gcc.git"
|
||||
# LLVM Settings
|
||||
LLVMDIR="${SRCDIR}/llvm"
|
||||
LLVMTAG="llvmorg-17.0.6"
|
||||
LLVMVCS="https://github.com/llvm/llvm-project.git"
|
||||
|
||||
# Make Settings
|
||||
MAKEDIR="${SRCDIR}/make"
|
||||
MAKETAG="4.3"
|
||||
MAKETAG="4.4.1"
|
||||
MAKEVCS="git://git.savannah.gnu.org/make"
|
||||
|
||||
# Mingw-w64 Settings
|
||||
MINGWDIR="${SRCDIR}/mingw-w64"
|
||||
MINGWLIB="ucrt"
|
||||
MINGWTAG="v7.0.0"
|
||||
MINGWTAG="master"
|
||||
MINGWNTV="0x601"
|
||||
MINGWVCS="https://github.com/mirror/mingw-w64.git"
|
||||
|
||||
# Ninja Settings
|
||||
NINJADIR="${SRCDIR}/ninja"
|
||||
NINJATAG="v1.10.0"
|
||||
NINJATAG="v1.11.1"
|
||||
NINJAVCS="https://github.com/ninja-build/ninja.git"
|
||||
|
||||
# Wine Settings
|
||||
WINEDIR="${SRCDIR}/wine"
|
||||
WINETAG="wine-5.15"
|
||||
WINETAG="wine-8.17"
|
||||
WINEVCS="git://source.winehq.org/git/wine.git"
|
||||
|
||||
|
||||
@@ -83,39 +79,45 @@ apply_patches()
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and installs BINUTILS
|
||||
# This function compiles and installs GNU BINUTILS
|
||||
binutils_build()
|
||||
{
|
||||
echo ">>> Building BINUTILS ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> Building BINUTILS for ${ARCH} ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${BINUTILSDIR}/build-${ARCH}
|
||||
mkdir -p ${BINUTILSDIR}/build-${ARCH}
|
||||
cd ${BINUTILSDIR}/build-${ARCH}
|
||||
case ${ARCH} in
|
||||
"armv7")
|
||||
TARGET="arm"
|
||||
;;
|
||||
*)
|
||||
TARGET="${ARCH}"
|
||||
;;
|
||||
esac
|
||||
../configure \
|
||||
--target=${ARCH}-w64-mingw32 \
|
||||
--prefix=${BINDIR} \
|
||||
--with-sysroot=${BINDIR} \
|
||||
--with-zlib=yes \
|
||||
--target=${TARGET}-w64-mingw32 \
|
||||
--disable-binutils \
|
||||
--disable-gdb \
|
||||
--disable-gprof \
|
||||
--disable-ld \
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-werror \
|
||||
--enable-gold \
|
||||
--enable-lto \
|
||||
--enable-plugins
|
||||
--with-zlib=yes
|
||||
make -j${CORES}
|
||||
make install
|
||||
cp ${BINUTILSDIR}/build-${ARCH}/gas/as-new ${BINDIR}/bin/${ARCH}-w64-mingw32-gas
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads BINUTILS from VCS
|
||||
# This function downloads GNU BINUTILS from VCS
|
||||
binutils_fetch()
|
||||
{
|
||||
if [ ! -d ${BINUTILSDIR} ]; then
|
||||
echo ">>> Downloading BINUTILS ..."
|
||||
git clone ${BINUTILSVCS} ${BINUTILSDIR}
|
||||
git clone --depth 1 --branch ${BINUTILSTAG} ${BINUTILSVCS} ${BINUTILSDIR}
|
||||
cd ${BINUTILSDIR}
|
||||
git checkout tags/${BINUTILSTAG}
|
||||
apply_patches ${BINUTILSDIR##*/} ${BINUTILSTAG##*-}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
@@ -142,68 +144,145 @@ cmake_fetch()
|
||||
{
|
||||
if [ ! -d ${CMAKEDIR} ]; then
|
||||
echo ">>> Downloading CMAKE ..."
|
||||
git clone ${CMAKEVCS} ${CMAKEDIR}
|
||||
git clone --depth 1 --branch ${CMAKETAG} ${CMAKEVCS} ${CMAKEDIR}
|
||||
cd ${CMAKEDIR}
|
||||
git checkout tags/${CMAKETAG}
|
||||
apply_patches ${CMAKEDIR##*/} ${CMAKETAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and install GCC (phase 1)
|
||||
gcc_build_phase1()
|
||||
# This function compiles and install LLVM
|
||||
llvm_build()
|
||||
{
|
||||
echo ">>> Building LLVM ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/llvm/build
|
||||
LLVM_ARCHS=()
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> Building GCC (phase1) for ${ARCH} ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${GCCDIR}/build-${ARCH}
|
||||
mkdir -p ${GCCDIR}/build-${ARCH}
|
||||
cd ${GCCDIR}/build-${ARCH}
|
||||
../configure \
|
||||
--target=${ARCH}-w64-mingw32 \
|
||||
--prefix=${BINDIR} \
|
||||
--with-sysroot=${BINDIR} \
|
||||
--with-pkgversion="FerretOS Build Environment" \
|
||||
--without-zstd \
|
||||
--disable-libstdcxx-verbose \
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-shared \
|
||||
--disable-werror \
|
||||
--disable-win32-registry \
|
||||
--enable-fully-dynamic-string \
|
||||
--enable-languages=c,c++ \
|
||||
--enable-lto \
|
||||
--enable-sjlj-exceptions \
|
||||
--enable-version-specific-runtime-libs
|
||||
make -j${CORES} all-gcc
|
||||
make install-gcc
|
||||
make install-lto-plugin
|
||||
case ${ARCH} in
|
||||
"aarch64")
|
||||
LLVM_ARCHS+=( "AArch64" )
|
||||
;;
|
||||
"armv7")
|
||||
LLVM_ARCHS+=( "ARM" )
|
||||
;;
|
||||
"i686"|"x86_64")
|
||||
LLVM_ARCHS+=( "X86" )
|
||||
;;
|
||||
esac
|
||||
done
|
||||
LLVM_ARCHS=( $(for ARCH in ${LLVM_ARCHS[@]}; do echo ${ARCH}; done | sort -u) )
|
||||
cd ${LLVMDIR}/llvm/tools
|
||||
for UTIL in clang lld; do
|
||||
if [ ! -e ${UTIL} ]; then
|
||||
ln -sf ../../${UTIL} .
|
||||
fi
|
||||
done
|
||||
mkdir -p ${LLVMDIR}/llvm/build
|
||||
cd ${LLVMDIR}/llvm/build
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_INSTALL_PREFIX=${BINDIR} \
|
||||
-DLLDB_INCLUDE_TESTS=FALSE \
|
||||
-DLLVM_ENABLE_ASSERTIONS=FALSE \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" \
|
||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
|
||||
-DLLVM_LINK_LLVM_DYLIB=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="$(echo ${LLVM_ARCHS[@]} | tr ' ' ';')" \
|
||||
-DLLVM_TOOLCHAIN_TOOLS="llvm-addr2line;llvm-ar;llvm-as;llvm-cov;llvm-cvtres;llvm-dlltool;llvm-lib;llvm-ml;llvm-nm;llvm-objdump;llvm-objcopy;llvm-pdbutil;llvm-profdata;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-strings;llvm-strip;llvm-symbolizer;llvm-windres" \
|
||||
..
|
||||
ninja install/strip
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and install LIBCXX & LIBUNWIND
|
||||
llvm_build_libs()
|
||||
{
|
||||
echo ">>> Building LLVM libraries (libcxx) ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/runtimes/build-${ARCH}
|
||||
mkdir -p ${LLVMDIR}/runtimes/build-${ARCH}
|
||||
cd ${LLVMDIR}/runtimes/build-${ARCH}
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_INSTALL_PREFIX="${BINDIR}/${ARCH}-w64-mingw32" \
|
||||
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
|
||||
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||
-DCMAKE_C_FLAGS_INIT=-mguard=cf \
|
||||
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
|
||||
-DCMAKE_CXX_COMPILER_TARGET=${ARCH}-w64-windows-gnu \
|
||||
-DCMAKE_CXX_COMPILER_WORKS=1 \
|
||||
-DCMAKE_CXX_FLAGS_INIT=-mguard=cf \
|
||||
-DCMAKE_CROSSCOMPILING=TRUE \
|
||||
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
|
||||
-DCMAKE_SYSTEM_NAME="Windows" \
|
||||
-DLLVM_PATH="${LLVMDIR}/llvm" \
|
||||
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx" \
|
||||
-DLIBUNWIND_USE_COMPILER_RT=TRUE \
|
||||
-DLIBUNWIND_ENABLE_SHARED=TRUE \
|
||||
-DLIBUNWIND_ENABLE_STATIC=TRUE \
|
||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
||||
-DLIBCXX_ENABLE_SHARED=TRUE \
|
||||
-DLIBCXX_ENABLE_STATIC=TRUE \
|
||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
|
||||
-DLIBCXX_CXX_ABI="libcxxabi" \
|
||||
-DLIBCXX_LIBDIR_SUFFIX="" \
|
||||
-DLIBCXX_INCLUDE_TESTS=FALSE \
|
||||
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_LIBDIR_SUFFIX="" \
|
||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
||||
..
|
||||
ninja
|
||||
ninja install
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and install GCC (phase 2)
|
||||
gcc_build_phase2()
|
||||
# This function compiles and install LLVM runtime
|
||||
llvm_build_runtime()
|
||||
{
|
||||
echo ">>> Building LLVM compiler runtime ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> Building GCC (phase2) for ${ARCH} ..."
|
||||
cd ${GCCDIR}/build-${ARCH}
|
||||
make -j${CORES}
|
||||
make install
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/compiler-rt/build-${ARCH}
|
||||
mkdir -p ${LLVMDIR}/compiler-rt/build-${ARCH}
|
||||
cd ${LLVMDIR}/compiler-rt/build-${ARCH}
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
|
||||
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
|
||||
-DCMAKE_C_COMPILER_TARGET="${ARCH}-windows-gnu" \
|
||||
-DCMAKE_C_FLAGS_INIT="-mguard=cf" \
|
||||
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
|
||||
-DCMAKE_CXX_FLAGS_INIT="-mguard=cf" \
|
||||
-DCMAKE_FIND_ROOT_PATH="${BINDIR}/${ARCH}-w64-mingw32" \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
|
||||
-DCMAKE_INSTALL_PREFIX=$(${BINDIR}/bin/${ARCH}-w64-mingw32-clang --print-resource-dir) \
|
||||
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
|
||||
-DCMAKE_SYSTEM_NAME="Windows" \
|
||||
-DCOMPILER_RT_BUILD_BUILTINS=TRUE \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \
|
||||
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=TRUE \
|
||||
-DLLVM_CONFIG_PATH="" \
|
||||
-DSANITIZER_CXX_ABI="libc++" \
|
||||
../lib/builtins
|
||||
ninja
|
||||
ninja install
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads GCC from VCS
|
||||
gcc_fetch()
|
||||
# This function downloads LLVM from VCS
|
||||
llvm_fetch()
|
||||
{
|
||||
if [ ! -d ${GCCDIR} ]; then
|
||||
echo ">>> Downloading GCC ..."
|
||||
git clone ${GCCVCS} ${GCCDIR}
|
||||
cd ${GCCDIR}
|
||||
git checkout tags/${GCCTAG}
|
||||
apply_patches ${GCCDIR##*/} ${GCCTAG##*-}
|
||||
./contrib/download_prerequisites
|
||||
if [ ! -d ${LLVMDIR} ]; then
|
||||
echo ">>> Downloading LLVM ..."
|
||||
git clone --depth 1 --branch ${LLVMTAG} ${LLVMVCS} ${LLVMDIR}
|
||||
cd ${LLVMDIR}
|
||||
apply_patches ${LLVMDIR##*/} ${LLVMTAG##*-}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
@@ -237,9 +316,8 @@ make_fetch()
|
||||
{
|
||||
if [ ! -d ${MAKEDIR} ]; then
|
||||
echo ">>> Downloading Make ..."
|
||||
git clone ${MAKEVCS} ${MAKEDIR}
|
||||
git clone --depth 1 --branch ${MAKETAG} ${MAKEVCS} ${MAKEDIR}
|
||||
cd ${MAKEDIR}
|
||||
git checkout tags/${MAKETAG}
|
||||
apply_patches ${MAKEDIR##*/} ${MAKETAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
@@ -249,15 +327,21 @@ make_fetch()
|
||||
mingw_build_crt()
|
||||
{
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> Building Mingw-w64 (CRT) for ${ARCH} ..."
|
||||
echo ">>> Building Mingw-W64 (CRT) for ${ARCH} ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||
mkdir -p ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||
cd ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||
case ${ARCH} in
|
||||
i686)
|
||||
"aarch64")
|
||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm64"
|
||||
;;
|
||||
"armv7")
|
||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm32"
|
||||
;;
|
||||
"i686")
|
||||
FLAGS="--enable-lib32 --disable-lib64"
|
||||
;;
|
||||
x86_64)
|
||||
"x86_64")
|
||||
FLAGS="--disable-lib32 --enable-lib64"
|
||||
;;
|
||||
esac
|
||||
@@ -268,6 +352,7 @@ mingw_build_crt()
|
||||
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
||||
--with-sysroot=${BINDIR} \
|
||||
--with-default-msvcrt=${MINGWLIB} \
|
||||
--enable-cfguard \
|
||||
${FLAGS}
|
||||
make -j${CORES}
|
||||
make install
|
||||
@@ -279,7 +364,7 @@ mingw_build_crt()
|
||||
# This function compiles and installs MINGW headers
|
||||
mingw_build_headers()
|
||||
{
|
||||
echo ">>> Building Mingw-w64 (headers) ..."
|
||||
echo ">>> Building Mingw-W64 (headers) ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||
mkdir -p ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||
cd ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||
@@ -290,10 +375,6 @@ mingw_build_headers()
|
||||
--with-default-win32-winnt=${MINGWNTV}
|
||||
make -j${CORES}
|
||||
make install
|
||||
mkdir -p ${BINDIR}/mingw
|
||||
if [ ! -e ${BINDIR}/mingw/include ]; then
|
||||
ln -sfn ../${GENERIC}/include ${BINDIR}/mingw/include
|
||||
fi
|
||||
for ARCH in ${ARCHS}; do
|
||||
mkdir -p ${BINDIR}/${ARCH}-w64-mingw32
|
||||
if [ ! -e ${BINDIR}/${ARCH}-w64-mingw32/include ]; then
|
||||
@@ -306,7 +387,7 @@ mingw_build_headers()
|
||||
# This function compiles and install MINGW libraries
|
||||
mingw_build_libs()
|
||||
{
|
||||
for LIB in libmangle winstorecompat; do
|
||||
for LIB in libmangle winpthreads winstorecompat; do
|
||||
echo ">>> Building Mingw-w64 (libs) for ${ARCH} ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
|
||||
@@ -317,7 +398,9 @@ mingw_build_libs()
|
||||
../configure \
|
||||
--host=${ARCH}-w64-mingw32 \
|
||||
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
||||
--libdir=${BINDIR}/${ARCH}-w64-mingw32/lib
|
||||
--libdir=${BINDIR}/${ARCH}-w64-mingw32/lib \
|
||||
CFLAGS="-O2 -mguard=cf" \
|
||||
CXXFLAGS="-O2 -mguard=cf"
|
||||
make -j${CORES}
|
||||
make install
|
||||
PATH="${ORIGPATH}"
|
||||
@@ -352,10 +435,9 @@ mingw_build_tools()
|
||||
mingw_fetch()
|
||||
{
|
||||
if [ ! -d ${MINGWDIR} ]; then
|
||||
echo ">>> Downloading Mingw-w64 ..."
|
||||
git clone ${MINGWVCS} ${MINGWDIR}
|
||||
echo ">>> Downloading MinGW-w64 ..."
|
||||
git clone --depth 1 --branch ${MINGWTAG} ${MINGWVCS} ${MINGWDIR}
|
||||
cd ${MINGWDIR}
|
||||
git checkout tags/${MINGWTAG}
|
||||
apply_patches ${MINGWDIR##*/} ${MINGWTAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
@@ -378,9 +460,8 @@ ninja_fetch()
|
||||
{
|
||||
if [ ! -d ${NINJADIR} ]; then
|
||||
echo ">>> Downloading NINJA ..."
|
||||
git clone ${NINJAVCS} ${NINJADIR}
|
||||
git clone --depth 1 --branch ${NINJATAG} ${NINJAVCS} ${NINJADIR}
|
||||
cd ${NINJADIR}
|
||||
git checkout tags/${NINJATAG}
|
||||
apply_patches ${NINJADIR##*/} ${NINJATAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
@@ -393,9 +474,11 @@ wine_build()
|
||||
mkdir -p ${WINEDIR}/build
|
||||
cd ${WINEDIR}/build
|
||||
../configure \
|
||||
-enable-win64
|
||||
-enable-win64 \
|
||||
--without-freetype \
|
||||
--without-x
|
||||
for TOOL in winedump wmc wrc; do
|
||||
make -j${CORES} tools/${TOOL}
|
||||
make -j${CORES} tools/${TOOL}/all
|
||||
cp tools/${TOOL}/${TOOL} ${BINDIR}/bin/
|
||||
for ARCH in ${ARCHS}; do
|
||||
if [ ! -e ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL} ]; then
|
||||
@@ -411,9 +494,8 @@ wine_fetch()
|
||||
{
|
||||
if [ ! -d ${WINEDIR} ]; then
|
||||
echo ">>> Downloading WINE ..."
|
||||
git clone ${WINEVCS} ${WINEDIR}
|
||||
git clone --depth 1 --branch ${WINETAG} ${WINEVCS} ${WINEDIR}
|
||||
cd ${WINEDIR}
|
||||
git checkout tags/${WINETAG}
|
||||
apply_patches ${WINEDIR##*/} ${WINETAG##*-}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
@@ -426,8 +508,18 @@ xtchain_build()
|
||||
mkdir -p ${BINDIR}/bin
|
||||
mkdir -p ${BINDIR}/lib/xtchain
|
||||
mkdir -p ${BINDIR}/${GENERIC}/bin
|
||||
cp ${WRKDIR}/scripts/*-wrapper ${BINDIR}/${GENERIC}/bin
|
||||
for ARCH in ${ARCHS}; do
|
||||
for EXEC in xtcspecc; do
|
||||
for EXEC in c++ c11 c99 cc clang clang++ g++ gcc; do
|
||||
ln -sf ../${GENERIC}/bin/clang-target-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
for EXEC in addr2line ar as nm objcopy pdbutil ranlib rc strings strip; do
|
||||
ln -sf llvm-${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
for EXEC in dlltool ld objdump; do
|
||||
ln -sf ../${GENERIC}/bin/${EXEC}-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
for EXEC in bin2c exetool xtcspecc; do
|
||||
if [ ! -e ${BINDIR}/bin/${EXEC} ]; then
|
||||
gcc ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
|
||||
fi
|
||||
@@ -436,58 +528,46 @@ xtchain_build()
|
||||
done
|
||||
cp ${WRKDIR}/scripts/xtclib ${BINDIR}/lib/xtchain/
|
||||
cp ${WRKDIR}/scripts/xtchain ${BINDIR}/
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
|
||||
# Exit immediately on any failure
|
||||
set -e
|
||||
|
||||
# Check if script launched as root
|
||||
if [ "$(whoami)" = "root" ]; then
|
||||
echo "This script cannot be run as root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check number of CPU cores available
|
||||
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
|
||||
: ${CORES:=$(nproc 2>/dev/null)}
|
||||
: ${CORES:=1}
|
||||
if [[ ! -n ${CORES} ]]; then
|
||||
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
|
||||
: ${CORES:=$(nproc 2>/dev/null)}
|
||||
: ${CORES:=1}
|
||||
fi
|
||||
|
||||
# Create working directories
|
||||
mkdir -p ${BINDIR}
|
||||
mkdir -p ${SRCDIR}
|
||||
|
||||
# Export compiler flags
|
||||
export CFLAGS
|
||||
export CXXFLAGS
|
||||
|
||||
# XTchain
|
||||
xtchain_build
|
||||
|
||||
# Download LLVM
|
||||
llvm_fetch
|
||||
|
||||
# Build and install LLVM
|
||||
llvm_build
|
||||
|
||||
# Download Mingw-W64
|
||||
mingw_fetch
|
||||
|
||||
# Build and install Mingw-W64 headers
|
||||
mingw_build_headers
|
||||
|
||||
# Download Binutils
|
||||
binutils_fetch
|
||||
|
||||
# Build and install Binutils
|
||||
binutils_build
|
||||
|
||||
# Download GCC
|
||||
gcc_fetch
|
||||
|
||||
# Build and install minimal GCC
|
||||
gcc_build_phase1
|
||||
|
||||
# Build and install MSVCRT
|
||||
# Build and install Mingw-W64 CRT
|
||||
mingw_build_crt
|
||||
|
||||
# Build and install GCC
|
||||
gcc_build_phase2
|
||||
# Build and install LLVM compiler runtime
|
||||
llvm_build_runtime
|
||||
|
||||
# Build and install LLVM compiler libraries
|
||||
llvm_build_libs
|
||||
|
||||
# Build and install Mingw-W64 libraries
|
||||
mingw_build_libs
|
||||
@@ -495,6 +575,12 @@ mingw_build_libs
|
||||
# Build and install Mingw-W64 tools
|
||||
mingw_build_tools
|
||||
|
||||
# Download Binutils
|
||||
binutils_fetch
|
||||
|
||||
# Build and install Binutils
|
||||
binutils_build
|
||||
|
||||
# Download Wine
|
||||
wine_fetch
|
||||
|
||||
@@ -521,12 +607,13 @@ ninja_build
|
||||
|
||||
# Remove unneeded files to save disk space
|
||||
echo ">>> Removing unneeded files to save disk space ..."
|
||||
rm -rf ${BINDIR}/{doc,include,mingw,share/{bash-completion,emacs,gcc*,info,man,vim}}
|
||||
rm -rf ${BINDIR}/{doc,include,share/{bash-completion,emacs,info,locale,man,vim}}
|
||||
rm -rf ${BINDIR}/bin/amdgpu-arch,{clang-{check,exdef-mapping,import-test,offload-*,rename,scan-deps},diagtool,hmaptool,ld64.lld,modularize,nxptx-arch,wasm-ld}
|
||||
|
||||
# Save XT Toolchain version
|
||||
cd ${WRKDIR}
|
||||
: ${XTCVER:=$(git describe --exact-match --tags 2>/dev/null)}
|
||||
: ${XTCVER:=DEV}
|
||||
: ${XTCVER:=DEVEL}
|
||||
echo "${XTCVER}" > ${BINDIR}/Version
|
||||
|
||||
# Prepare archive
|
||||
|
||||
Executable
+699
@@ -0,0 +1,699 @@
|
||||
#!/bin/bash
|
||||
# PROJECT: XTchain
|
||||
# LICENSE: See the COPYING.md in the top level directory
|
||||
# FILE: build-linux.sh
|
||||
# DESCRIPTION: Toolchain building and assembly script
|
||||
# DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
|
||||
|
||||
# Working Directories
|
||||
BINDIR="$(pwd)/binaries"
|
||||
PCHDIR="$(pwd)/patches"
|
||||
SRCDIR="$(pwd)/sources"
|
||||
WRKDIR="$(pwd)"
|
||||
|
||||
# Architecture Settings
|
||||
ARCHS="aarch64 armv7 i686 x86_64"
|
||||
GENERIC="generic-w64-mingw32"
|
||||
|
||||
# Binutils Settings
|
||||
BINUTILSDIR="${SRCDIR}/binutils"
|
||||
BINUTILSTAG="binutils-2_41"
|
||||
BINUTILSVCS="git://sourceware.org/git/binutils-gdb.git"
|
||||
|
||||
# CMake Settings
|
||||
CMAKEDIR="${SRCDIR}/cmake"
|
||||
CMAKETAG="v3.27.6"
|
||||
CMAKEVCS="https://gitlab.kitware.com/cmake/cmake.git"
|
||||
|
||||
# LLVM Settings
|
||||
LLVMDIR="${SRCDIR}/llvm"
|
||||
LLVMTAG="llvmorg-17.0.6"
|
||||
LLVMVCS="https://github.com/llvm/llvm-project.git"
|
||||
|
||||
# Make Settings
|
||||
MAKEDIR="${SRCDIR}/make"
|
||||
MAKETAG="4.4.1"
|
||||
MAKEVCS="git://git.savannah.gnu.org/make"
|
||||
|
||||
# Mingw-w64 Settings
|
||||
MINGWDIR="${SRCDIR}/mingw-w64"
|
||||
MINGWLIB="ucrt"
|
||||
MINGWTAG="master"
|
||||
MINGWNTV="0x601"
|
||||
MINGWVCS="https://github.com/mirror/mingw-w64.git"
|
||||
|
||||
# Ninja Settings
|
||||
NINJADIR="${SRCDIR}/ninja"
|
||||
NINJATAG="v1.11.1"
|
||||
NINJAVCS="https://github.com/ninja-build/ninja.git"
|
||||
|
||||
# Wine Settings
|
||||
WINEDIR="${SRCDIR}/wine"
|
||||
WINETAG="wine-8.17"
|
||||
WINEVCS="git://source.winehq.org/git/wine.git"
|
||||
|
||||
|
||||
# This function applies a patches to the 3rd party project
|
||||
apply_patches()
|
||||
{
|
||||
local PACKAGE="${1}"
|
||||
local VERSION="${2}"
|
||||
if [ -d "${PCHDIR}/${PACKAGE}/${VERSION}" ]; then
|
||||
PATCHES="$(find ${PCHDIR}/${PACKAGE}/${VERSION} -name '*.diff' -o -name '*.patch' | sort -n)"
|
||||
echo ">>> Applying custom patches ..."
|
||||
for PATCH in ${PATCHES}; do
|
||||
if [ -f "${PATCH}" ] && [ -r "${PATCH}" ]; then
|
||||
for PREFIX in {0..5}; do
|
||||
if patch -i${PATCH} -p${PREFIX} --silent --dry-run >/dev/null; then
|
||||
patch -i${PATCH} -p${PREFIX} --silent
|
||||
echo ">>> Patch ${PATCH} applied ..."
|
||||
break;
|
||||
elif [ ${PREFIX} -ge 5 ]; then
|
||||
echo "Patch ${PATCH} does not fit. Failed applying patch ..."
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and installs GNU BINUTILS
|
||||
binutils_build_OLD()
|
||||
{
|
||||
echo ">>> Building BINUTILS ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
[ -z ${CLEAN} ] || rm -rf ${BINUTILSDIR}/build-${ARCH}
|
||||
mkdir -p ${BINUTILSDIR}/build-${ARCH}
|
||||
cd ${BINUTILSDIR}/build-${ARCH}
|
||||
case ${ARCH} in
|
||||
"armv7")
|
||||
TARGET="arm"
|
||||
;;
|
||||
*)
|
||||
TARGET="${ARCH}"
|
||||
;;
|
||||
esac
|
||||
../configure \
|
||||
--target=${TARGET}-w64-mingw32 \
|
||||
--disable-binutils \
|
||||
--disable-gdb \
|
||||
--disable-gprof \
|
||||
--disable-ld \
|
||||
--disable-multilib \
|
||||
--disable-nls \
|
||||
--disable-werror \
|
||||
--with-zlib=yes
|
||||
make -j${CORES}
|
||||
cp ${BINUTILSDIR}/build-${ARCH}/gas/as-new ${BINDIR}/bin/${ARCH}-w64-mingw32-gas
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads GNU BINUTILS from VCS
|
||||
binutils_fetch()
|
||||
{
|
||||
if [ ! -d ${BINUTILSDIR} ]; then
|
||||
echo ">>> Downloading BINUTILS ..."
|
||||
git clone --depth 1 --branch ${BINUTILSTAG} ${BINUTILSVCS} ${BINUTILSDIR}
|
||||
cd ${BINUTILSDIR}
|
||||
apply_patches ${BINUTILSDIR##*/} ${BINUTILSTAG##*-}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and installs CMAKE
|
||||
cmake_build_OLD()
|
||||
{
|
||||
echo ">>> Building CMAKE ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${CMAKEDIR}/build-${GENERIC}
|
||||
mkdir -p ${CMAKEDIR}/build-${GENERIC}
|
||||
cd ${CMAKEDIR}/build-${GENERIC}
|
||||
../bootstrap \
|
||||
--prefix=${BINDIR} \
|
||||
--parallel=${CORES} \
|
||||
-- -DCMAKE_USE_OPENSSL=OFF
|
||||
make -j${CORES}
|
||||
make install
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads CMAKE from VCS
|
||||
cmake_fetch()
|
||||
{
|
||||
if [ ! -d ${CMAKEDIR} ]; then
|
||||
echo ">>> Downloading CMAKE ..."
|
||||
git clone --depth 1 --branch ${CMAKETAG} ${CMAKEVCS} ${CMAKEDIR}
|
||||
cd ${CMAKEDIR}
|
||||
apply_patches ${CMAKEDIR##*/} ${CMAKETAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and install LLVM
|
||||
llvm_build_OLD()
|
||||
{
|
||||
echo ">>> Building LLVM ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/llvm/build
|
||||
LLVM_ARCHS=()
|
||||
for ARCH in ${ARCHS}; do
|
||||
case ${ARCH} in
|
||||
"aarch64")
|
||||
LLVM_ARCHS+=( "AArch64" )
|
||||
;;
|
||||
"armv7")
|
||||
LLVM_ARCHS+=( "ARM" )
|
||||
;;
|
||||
"i686"|"x86_64")
|
||||
LLVM_ARCHS+=( "X86" )
|
||||
;;
|
||||
esac
|
||||
done
|
||||
LLVM_ARCHS=( $(for ARCH in ${LLVM_ARCHS[@]}; do echo ${ARCH}; done | sort -u) )
|
||||
cd ${LLVMDIR}/llvm/tools
|
||||
for UTIL in clang lld; do
|
||||
if [ ! -e ${UTIL} ]; then
|
||||
ln -sf ../../${UTIL} .
|
||||
fi
|
||||
done
|
||||
mkdir -p ${LLVMDIR}/llvm/build
|
||||
cd ${LLVMDIR}/llvm/build
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_INSTALL_PREFIX=${BINDIR} \
|
||||
-DLLDB_INCLUDE_TESTS=FALSE \
|
||||
-DLLVM_ENABLE_ASSERTIONS=FALSE \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" \
|
||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
|
||||
-DLLVM_LINK_LLVM_DYLIB=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="$(echo ${LLVM_ARCHS[@]} | tr ' ' ';')" \
|
||||
-DLLVM_TOOLCHAIN_TOOLS="llvm-addr2line;llvm-ar;llvm-as;llvm-cov;llvm-cvtres;llvm-dlltool;llvm-lib;llvm-ml;llvm-nm;llvm-objdump;llvm-objcopy;llvm-pdbutil;llvm-profdata;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-strings;llvm-strip;llvm-symbolizer;llvm-windres" \
|
||||
..
|
||||
ninja install/strip
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and install LIBCXX & LIBUNWIND
|
||||
llvm_build_libs_OLD()
|
||||
{
|
||||
echo ">>> Building LLVM libraries (libcxx) ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/runtimes/build-${ARCH}
|
||||
mkdir -p ${LLVMDIR}/runtimes/build-${ARCH}
|
||||
cd ${LLVMDIR}/runtimes/build-${ARCH}
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_INSTALL_PREFIX="${BINDIR}/${ARCH}-w64-mingw32" \
|
||||
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
|
||||
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
|
||||
-DCMAKE_C_COMPILER_WORKS=1 \
|
||||
-DCMAKE_C_FLAGS_INIT=-mguard=cf \
|
||||
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
|
||||
-DCMAKE_CXX_COMPILER_TARGET=${ARCH}-w64-windows-gnu \
|
||||
-DCMAKE_CXX_COMPILER_WORKS=1 \
|
||||
-DCMAKE_CXX_FLAGS_INIT=-mguard=cf \
|
||||
-DCMAKE_CROSSCOMPILING=TRUE \
|
||||
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
|
||||
-DCMAKE_SYSTEM_NAME="Windows" \
|
||||
-DLLVM_PATH="${LLVMDIR}/llvm" \
|
||||
-DLLVM_ENABLE_RUNTIMES="libunwind;libcxxabi;libcxx" \
|
||||
-DLIBUNWIND_USE_COMPILER_RT=TRUE \
|
||||
-DLIBUNWIND_ENABLE_SHARED=TRUE \
|
||||
-DLIBUNWIND_ENABLE_STATIC=TRUE \
|
||||
-DLIBCXX_USE_COMPILER_RT=ON \
|
||||
-DLIBCXX_ENABLE_SHARED=TRUE \
|
||||
-DLIBCXX_ENABLE_STATIC=TRUE \
|
||||
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF \
|
||||
-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=TRUE \
|
||||
-DLIBCXX_CXX_ABI="libcxxabi" \
|
||||
-DLIBCXX_LIBDIR_SUFFIX="" \
|
||||
-DLIBCXX_INCLUDE_TESTS=FALSE \
|
||||
-DLIBCXX_ENABLE_ABI_LINKER_SCRIPT=FALSE \
|
||||
-DLIBCXXABI_USE_COMPILER_RT=ON \
|
||||
-DLIBCXXABI_ENABLE_SHARED=OFF \
|
||||
-DLIBCXXABI_LIBDIR_SUFFIX="" \
|
||||
-DLIBCXXABI_USE_LLVM_UNWINDER=ON \
|
||||
..
|
||||
ninja
|
||||
ninja install
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and install LLVM runtime
|
||||
llvm_build_runtime_OLD()
|
||||
{
|
||||
echo ">>> Building LLVM compiler runtime ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/compiler-rt/build-${ARCH}
|
||||
mkdir -p ${LLVMDIR}/compiler-rt/build-${ARCH}
|
||||
cd ${LLVMDIR}/compiler-rt/build-${ARCH}
|
||||
cmake -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_AR="${BINDIR}/bin/llvm-ar" \
|
||||
-DCMAKE_C_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang" \
|
||||
-DCMAKE_C_COMPILER_TARGET="${ARCH}-windows-gnu" \
|
||||
-DCMAKE_C_FLAGS_INIT="-mguard=cf" \
|
||||
-DCMAKE_CXX_COMPILER="${BINDIR}/bin/${ARCH}-w64-mingw32-clang++" \
|
||||
-DCMAKE_CXX_FLAGS_INIT="-mguard=cf" \
|
||||
-DCMAKE_FIND_ROOT_PATH="${BINDIR}/${ARCH}-w64-mingw32" \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
|
||||
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY \
|
||||
-DCMAKE_INSTALL_PREFIX=$(${BINDIR}/bin/${ARCH}-w64-mingw32-clang --print-resource-dir) \
|
||||
-DCMAKE_RANLIB="${BINDIR}/bin/llvm-ranlib" \
|
||||
-DCMAKE_SYSTEM_NAME="Windows" \
|
||||
-DCOMPILER_RT_BUILD_BUILTINS=TRUE \
|
||||
-DCOMPILER_RT_DEFAULT_TARGET_ONLY=TRUE \
|
||||
-DCOMPILER_RT_USE_BUILTINS_LIBRARY=TRUE \
|
||||
-DLLVM_CONFIG_PATH="" \
|
||||
-DSANITIZER_CXX_ABI="libc++" \
|
||||
../lib/builtins
|
||||
ninja
|
||||
ninja install
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads LLVM from VCS
|
||||
llvm_fetch()
|
||||
{
|
||||
if [ ! -d ${LLVMDIR} ]; then
|
||||
echo ">>> Downloading LLVM ..."
|
||||
git clone --depth 1 --branch ${LLVMTAG} ${LLVMVCS} ${LLVMDIR}
|
||||
cd ${LLVMDIR}
|
||||
apply_patches ${LLVMDIR##*/} ${LLVMTAG##*-}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and install MAKE
|
||||
make_build_OLD()
|
||||
{
|
||||
echo ">>> Building Make ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${MAKEDIR}/build
|
||||
cd ${MAKEDIR}
|
||||
./bootstrap
|
||||
sed -i "s/-Werror//" maintMakefile
|
||||
mkdir -p ${MAKEDIR}/build
|
||||
cd ${MAKEDIR}/build
|
||||
../configure \
|
||||
--prefix=${BINDIR} \
|
||||
--disable-dependency-tracking \
|
||||
--disable-silent-rules \
|
||||
--program-prefix=g \
|
||||
--without-guile
|
||||
make -j${CORES}
|
||||
make install
|
||||
if [ ! -e ${BINDIR}/bin/make ]; then
|
||||
ln -sf gmake ${BINDIR}/bin/make
|
||||
fi
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads MAKE from VCS
|
||||
make_fetch()
|
||||
{
|
||||
if [ ! -d ${MAKEDIR} ]; then
|
||||
echo ">>> Downloading Make ..."
|
||||
git clone --depth 1 --branch ${MAKETAG} ${MAKEVCS} ${MAKEDIR}
|
||||
cd ${MAKEDIR}
|
||||
apply_patches ${MAKEDIR##*/} ${MAKETAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
# This function compiles and install MINGW libraries
|
||||
mingw_build_libs_OLD()
|
||||
{
|
||||
for LIB in libmangle winpthreads winstorecompat; do
|
||||
echo ">>> Building Mingw-w64 (libs) for ${ARCH} ..."
|
||||
for ARCH in ${ARCHS}; do
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
|
||||
mkdir -p ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
|
||||
cd ${MINGWDIR}/mingw-w64-libraries/${LIB}/build-${ARCH}
|
||||
ORIGPATH="${PATH}"
|
||||
PATH="${BINDIR}/bin:${PATH}"
|
||||
../configure \
|
||||
--host=${ARCH}-w64-mingw32 \
|
||||
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
||||
--libdir=${BINDIR}/${ARCH}-w64-mingw32/lib \
|
||||
CFLAGS="-O2 -mguard=cf" \
|
||||
CXXFLAGS="-O2 -mguard=cf"
|
||||
make -j${CORES}
|
||||
make install
|
||||
PATH="${ORIGPATH}"
|
||||
done
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and installs MINGW tools
|
||||
mingw_build_tools_OLD()
|
||||
{
|
||||
for TOOL in gendef genidl genlib genpeimg widl; do
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> Building Mingw-w64 (tools) for ${ARCH} ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
|
||||
mkdir -p ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
|
||||
cd ${MINGWDIR}/mingw-w64-tools/${TOOL}/build-${ARCH}
|
||||
../configure \
|
||||
--target=${ARCH}-w64-mingw32 \
|
||||
--prefix=${BINDIR}
|
||||
make -j${CORES}
|
||||
make install
|
||||
if [ -e ${BINDIR}/bin/${TOOL} ]; then
|
||||
mv ${BINDIR}/bin/${TOOL} ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL}
|
||||
fi
|
||||
done
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads MINGW from VCS
|
||||
mingw_fetch()
|
||||
{
|
||||
if [ ! -d ${MINGWDIR} ]; then
|
||||
echo ">>> Downloading MinGW-w64 ..."
|
||||
git clone --depth 1 --branch ${MINGWTAG} ${MINGWVCS} ${MINGWDIR}
|
||||
cd ${MINGWDIR}
|
||||
apply_patches ${MINGWDIR##*/} ${MINGWTAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and installs NINJA
|
||||
ninja_build_OLD()
|
||||
{
|
||||
echo ">>> Building NINJA ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${NINJADIR}/build-${GENERIC}
|
||||
mkdir -p ${NINJADIR}/build-${GENERIC}
|
||||
cd ${NINJADIR}/build-${GENERIC}
|
||||
../configure.py --bootstrap
|
||||
install ninja ${BINDIR}/bin/
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads NINJA from VCS
|
||||
ninja_fetch()
|
||||
{
|
||||
if [ ! -d ${NINJADIR} ]; then
|
||||
echo ">>> Downloading NINJA ..."
|
||||
git clone --depth 1 --branch ${NINJATAG} ${NINJAVCS} ${NINJADIR}
|
||||
cd ${NINJADIR}
|
||||
apply_patches ${NINJADIR##*/} ${NINJATAG}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function compiles and install WINE tools
|
||||
wine_build_OLD()
|
||||
{
|
||||
echo ">>> Building Wine ..."
|
||||
mkdir -p ${WINEDIR}/build
|
||||
cd ${WINEDIR}/build
|
||||
../configure \
|
||||
-enable-win64 \
|
||||
--without-freetype \
|
||||
--without-x
|
||||
for TOOL in winedump wmc wrc; do
|
||||
make -j${CORES} tools/${TOOL}/all
|
||||
cp tools/${TOOL}/${TOOL} ${BINDIR}/bin/
|
||||
for ARCH in ${ARCHS}; do
|
||||
if [ ! -e ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL} ]; then
|
||||
ln -sf ${TOOL} ${BINDIR}/bin/${ARCH}-w64-mingw32-${TOOL}
|
||||
fi
|
||||
done
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function downloads WINE from VCS
|
||||
wine_fetch()
|
||||
{
|
||||
if [ ! -d ${WINEDIR} ]; then
|
||||
echo ">>> Downloading WINE ..."
|
||||
git clone --depth 1 --branch ${WINETAG} ${WINEVCS} ${WINEDIR}
|
||||
cd ${WINEDIR}
|
||||
apply_patches ${WINEDIR##*/} ${WINETAG##*-}
|
||||
cd ${WRKDIR}
|
||||
fi
|
||||
}
|
||||
|
||||
# This function installs XTCHAIN scripts, wrappers and symlinks
|
||||
xtchain_build_OLD()
|
||||
{
|
||||
echo ">>> Building XTchain ..."
|
||||
mkdir -p ${BINDIR}/bin
|
||||
mkdir -p ${BINDIR}/lib/xtchain
|
||||
mkdir -p ${BINDIR}/${GENERIC}/bin
|
||||
cp ${WRKDIR}/scripts/*-wrapper ${BINDIR}/${GENERIC}/bin
|
||||
for ARCH in ${ARCHS}; do
|
||||
for EXEC in c++ c11 c99 cc clang clang++ g++ gcc; do
|
||||
ln -sf ../${GENERIC}/bin/clang-target-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
for EXEC in addr2line ar as nm objcopy pdbutil ranlib rc strings strip; do
|
||||
ln -sf llvm-${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
for EXEC in dlltool ld objdump; do
|
||||
ln -sf ../${GENERIC}/bin/${EXEC}-wrapper ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
for EXEC in bin2c exetool xtcspecc; do
|
||||
if [ ! -e ${BINDIR}/bin/${EXEC} ]; then
|
||||
gcc ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}
|
||||
fi
|
||||
ln -sf ${EXEC} ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}
|
||||
done
|
||||
done
|
||||
cp ${WRKDIR}/scripts/xtclib ${BINDIR}/lib/xtchain/
|
||||
cp ${WRKDIR}/scripts/xtchain ${BINDIR}/
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# This function compiles and install LLVM
|
||||
llvm_build()
|
||||
{
|
||||
echo ">>> Building LLVM ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${LLVMDIR}/llvm/build
|
||||
LLVM_ARCHS=()
|
||||
for ARCH in ${ARCHS}; do
|
||||
case ${ARCH} in
|
||||
"aarch64")
|
||||
LLVM_ARCHS+=( "AArch64" )
|
||||
;;
|
||||
"armv7")
|
||||
LLVM_ARCHS+=( "ARM" )
|
||||
;;
|
||||
"i686"|"x86_64")
|
||||
LLVM_ARCHS+=( "X86" )
|
||||
;;
|
||||
esac
|
||||
done
|
||||
LLVM_ARCHS=( $(for ARCH in ${LLVM_ARCHS[@]}; do echo ${ARCH}; done | sort -u) )
|
||||
cd ${LLVMDIR}/llvm/tools
|
||||
for UTIL in clang lld; do
|
||||
if [ ! -e ${UTIL} ]; then
|
||||
ln -sf ../../${UTIL} .
|
||||
fi
|
||||
done
|
||||
mkdir -p ${LLVMDIR}/llvm/build
|
||||
cd ${LLVMDIR}/llvm/build
|
||||
cmake -G Ninja \
|
||||
-DLLVM_HOST_TRIPLE="x86_64-w64-mingw32" \
|
||||
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
|
||||
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
|
||||
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_BUILD_TYPE="Release" \
|
||||
-DCMAKE_INSTALL_PREFIX=${BINDIR} \
|
||||
-DLLDB_INCLUDE_TESTS=FALSE \
|
||||
-DLLVM_ENABLE_ASSERTIONS=FALSE \
|
||||
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;lld;lldb" \
|
||||
-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON \
|
||||
-DLLVM_LINK_LLVM_DYLIB=ON \
|
||||
-DLLVM_TARGETS_TO_BUILD="$(echo ${LLVM_ARCHS[@]} | tr ' ' ';')" \
|
||||
-DLLVM_TOOLCHAIN_TOOLS="llvm-addr2line;llvm-ar;llvm-as;llvm-cov;llvm-cvtres;llvm-dlltool;llvm-lib;llvm-ml;llvm-nm;llvm-objdump;llvm-objcopy;llvm-pdbutil;llvm-profdata;llvm-ranlib;llvm-rc;llvm-readelf;llvm-readobj;llvm-strings;llvm-strip;llvm-symbolizer;llvm-windres" \
|
||||
..
|
||||
ninja install/strip
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and installs MINGW CRT
|
||||
mingw_build_crt()
|
||||
{
|
||||
for ARCH in ${ARCHS}; do
|
||||
echo ">>> Building Mingw-W64 (CRT) for ${ARCH} ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||
mkdir -p ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||
cd ${MINGWDIR}/mingw-w64-crt/build-${ARCH}
|
||||
case ${ARCH} in
|
||||
"aarch64")
|
||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm64"
|
||||
;;
|
||||
"armv7")
|
||||
FLAGS="--disable-lib32 --disable-lib64 --enable-libarm32"
|
||||
;;
|
||||
"i686")
|
||||
FLAGS="--enable-lib32 --disable-lib64"
|
||||
;;
|
||||
"x86_64")
|
||||
FLAGS="--disable-lib32 --enable-lib64"
|
||||
;;
|
||||
esac
|
||||
ORIGPATH="${PATH}"
|
||||
PATH="${BINDIR}/bin:${PATH}"
|
||||
../configure \
|
||||
--disable-dependency-tracking \
|
||||
--host=${ARCH}-w64-mingw32 \
|
||||
--prefix=${BINDIR}/${ARCH}-w64-mingw32 \
|
||||
--with-sysroot=${BINDIR} \
|
||||
--with-default-msvcrt=${MINGWLIB} \
|
||||
--enable-cfguard \
|
||||
${FLAGS}
|
||||
make -j${CORES}
|
||||
make install
|
||||
PATH="${ORIGPATH}"
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and installs MINGW headers
|
||||
mingw_build_headers()
|
||||
{
|
||||
echo ">>> Building Mingw-W64 (headers) ..."
|
||||
[ -z ${CLEAN} ] || rm -rf ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||
mkdir -p ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||
cd ${MINGWDIR}/mingw-w64-headers/build-${GENERIC}
|
||||
../configure \
|
||||
--prefix=${BINDIR}/${GENERIC} \
|
||||
--enable-idl \
|
||||
--with-default-msvcrt=${MINGWLIB} \
|
||||
--with-default-win32-winnt=${MINGWNTV}
|
||||
make -j${CORES}
|
||||
make install
|
||||
for ARCH in ${ARCHS}; do
|
||||
mkdir -p ${BINDIR}/${ARCH}-w64-mingw32
|
||||
if [ ! -e ${BINDIR}/${ARCH}-w64-mingw32/include ]; then
|
||||
ln -sfn ../${GENERIC}/include ${BINDIR}/${ARCH}-w64-mingw32/include
|
||||
fi
|
||||
done
|
||||
cd ${WRKDIR}
|
||||
}
|
||||
|
||||
# This function compiles and installs XTCHAIN tools
|
||||
xtchain_build()
|
||||
{
|
||||
echo ">>> Building XTchain ..."
|
||||
mkdir -p ${BINDIR}/bin
|
||||
mkdir -p ${BINDIR}/lib/xtchain
|
||||
mkdir -p ${BINDIR}/${GENERIC}/bin
|
||||
cp ${WRKDIR}/scripts/*-wrapper ${BINDIR}/${GENERIC}/bin
|
||||
for ARCH in ${ARCHS}; do
|
||||
for EXEC in bin2c exetool xtcspecc; do
|
||||
if [ ! -e ${BINDIR}/bin/${EXEC}.exe ]; then
|
||||
x86_64-w64-mingw32-gcc ${WRKDIR}/tools/${EXEC}.c -o ${BINDIR}/bin/${EXEC}.exe
|
||||
fi
|
||||
cp ${BINDIR}/bin/${EXEC}.exe ${BINDIR}/bin/${ARCH}-w64-mingw32-${EXEC}.exe
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# Exit immediately on any failure
|
||||
set -e
|
||||
|
||||
# Check number of CPU cores available
|
||||
if [[ ! -n ${CORES} ]]; then
|
||||
: ${CORES:=$(sysctl -n hw.ncpu 2>/dev/null)}
|
||||
: ${CORES:=$(nproc 2>/dev/null)}
|
||||
: ${CORES:=1}
|
||||
fi
|
||||
|
||||
# Create working directories
|
||||
mkdir -p ${BINDIR}
|
||||
mkdir -p ${SRCDIR}
|
||||
|
||||
# XTchain
|
||||
#xtchain_build
|
||||
|
||||
# Download LLVM
|
||||
#llvm_fetch
|
||||
|
||||
# Build and install LLVM
|
||||
#llvm_build
|
||||
|
||||
# Download Mingw-W64
|
||||
#mingw_fetch
|
||||
|
||||
# Build and install Mingw-W64 headers
|
||||
#mingw_build_headers
|
||||
|
||||
# Build and install Mingw-W64 CRT
|
||||
mingw_build_crt
|
||||
exit 1
|
||||
|
||||
# Build and install LLVM compiler runtime
|
||||
llvm_build_runtime
|
||||
|
||||
# Build and install LLVM compiler libraries
|
||||
llvm_build_libs
|
||||
|
||||
# Build and install Mingw-W64 libraries
|
||||
mingw_build_libs
|
||||
|
||||
# Build and install Mingw-W64 tools
|
||||
mingw_build_tools
|
||||
|
||||
# Download Binutils
|
||||
binutils_fetch
|
||||
|
||||
# Build and install Binutils
|
||||
binutils_build
|
||||
|
||||
# Download Wine
|
||||
wine_fetch
|
||||
|
||||
# Build and install Wine tools
|
||||
wine_build
|
||||
|
||||
# Download Make
|
||||
make_fetch
|
||||
|
||||
# Build and install Make
|
||||
make_build
|
||||
|
||||
# Download CMake
|
||||
cmake_fetch
|
||||
|
||||
# Build and install CMake
|
||||
cmake_build
|
||||
|
||||
# Download Ninja
|
||||
ninja_fetch
|
||||
|
||||
# Build and install Ninja
|
||||
ninja_build
|
||||
|
||||
# Remove unneeded files to save disk space
|
||||
echo ">>> Removing unneeded files to save disk space ..."
|
||||
rm -rf ${BINDIR}/{doc,include,share/{bash-completion,emacs,info,locale,man,vim}}
|
||||
rm -rf ${BINDIR}/bin/amdgpu-arch,{clang-{check,exdef-mapping,import-test,offload-*,rename,scan-deps},diagtool,hmaptool,ld64.lld,modularize,nxptx-arch,wasm-ld}
|
||||
|
||||
# Save XT Toolchain version
|
||||
cd ${WRKDIR}
|
||||
: ${XTCVER:=$(git describe --exact-match --tags 2>/dev/null)}
|
||||
: ${XTCVER:=DEVEL}
|
||||
echo "${XTCVER}" > ${BINDIR}/Version
|
||||
|
||||
# Prepare archive
|
||||
echo ">>> Creating toolchain archive ..."
|
||||
tar -I 'zstd -19' -cpf xtchain-${XTCVER}-linux.tar.zst -C ${BINDIR} .
|
||||
@@ -1,126 +0,0 @@
|
||||
diff --git a/bfd/peXXigen.c b/bfd/peXXigen.c
|
||||
index 5149ef582b..f09e4b7382 100644
|
||||
--- a/bfd/peXXigen.c
|
||||
+++ b/bfd/peXXigen.c
|
||||
@@ -2952,6 +2952,25 @@ _bfd_XX_print_private_bfd_data_common (bfd * abfd, void * vfile)
|
||||
case IMAGE_SUBSYSTEM_XBOX:
|
||||
subsystem_name = "XBOX";
|
||||
break;
|
||||
+ /* These are the XT specific subsystems */
|
||||
+ case IMAGE_SUBSYSTEM_XT_DRIVER:
|
||||
+ subsystem_name = "XT driver";
|
||||
+ break;
|
||||
+ case IMAGE_SUBSYSTEM_XT_NATIVE:
|
||||
+ subsystem_name = "XT native";
|
||||
+ break;
|
||||
+ case IMAGE_SUBSYSTEM_XT_GDIAPP:
|
||||
+ subsystem_name = "XT GDI application";
|
||||
+ break;
|
||||
+ case IMAGE_SUBSYSTEM_XT_CLIAPP:
|
||||
+ subsystem_name = "XT CLI application";
|
||||
+ break;
|
||||
+ case IMAGE_SUBSYSTEM_XT_PSXAPP:
|
||||
+ subsystem_name = "XT PSX application";
|
||||
+ break;
|
||||
+ case IMAGE_SUBSYSTEM_XT_DYNLIB:
|
||||
+ subsystem_name = "XT dynamic library";
|
||||
+ break;
|
||||
/* Added default case for clarity - subsystem_name is NULL anyway. */
|
||||
default:
|
||||
subsystem_name = NULL;
|
||||
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
|
||||
index 3866c7f458..55e069831b 100644
|
||||
--- a/binutils/objcopy.c
|
||||
+++ b/binutils/objcopy.c
|
||||
@@ -4860,7 +4860,13 @@ set_pe_subsystem (const char *s)
|
||||
{ "efi-bsd", 1, IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER },
|
||||
{ "efi-rtd", 1, IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER },
|
||||
{ "sal-rtd", 1, IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER },
|
||||
- { "xbox", 0, IMAGE_SUBSYSTEM_XBOX }
|
||||
+ { "xbox", 0, IMAGE_SUBSYSTEM_XBOX },
|
||||
+ { "xt-driver", 0, IMAGE_SUBSYSTEM_XT_DRIVER },
|
||||
+ { "xt-native", 0, IMAGE_SUBSYSTEM_XT_NATIVE },
|
||||
+ { "xt-gdiapp", 0, IMAGE_SUBSYSTEM_XT_GDIAPP },
|
||||
+ { "xt-cliapp", 0, IMAGE_SUBSYSTEM_XT_CLIAPP },
|
||||
+ { "xt-psxapp", 0, IMAGE_SUBSYSTEM_XT_PSXAPP },
|
||||
+ { "xt-dynlib", 0, IMAGE_SUBSYSTEM_XT_DYNLIB }
|
||||
};
|
||||
short value;
|
||||
char *copy;
|
||||
diff --git a/include/coff/pe.h b/include/coff/pe.h
|
||||
index c83a958eee..deeea6b49a 100644
|
||||
--- a/include/coff/pe.h
|
||||
+++ b/include/coff/pe.h
|
||||
@@ -169,6 +169,12 @@
|
||||
#define IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
|
||||
#define IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13
|
||||
#define IMAGE_SUBSYSTEM_XBOX 14
|
||||
+#define IMAGE_SUBSYSTEM_XT_DRIVER 21
|
||||
+#define IMAGE_SUBSYSTEM_XT_NATIVE 22
|
||||
+#define IMAGE_SUBSYSTEM_XT_GDIAPP 23
|
||||
+#define IMAGE_SUBSYSTEM_XT_CLIAPP 24
|
||||
+#define IMAGE_SUBSYSTEM_XT_PSXAPP 25
|
||||
+#define IMAGE_SUBSYSTEM_XT_DYNLIB 26
|
||||
|
||||
/* NT allows long filenames, we want to accommodate this.
|
||||
This may break some of the bfd functions. */
|
||||
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
|
||||
index 3899c9d92c..c9277ded20 100644
|
||||
--- a/ld/emultempl/pe.em
|
||||
+++ b/ld/emultempl/pe.em
|
||||
@@ -539,6 +539,12 @@ set_entry_point (void)
|
||||
{ 7, "__PosixProcessStartup"},
|
||||
{ 9, "WinMainCRTStartup" },
|
||||
{14, "mainCRTStartup" },
|
||||
+ {21, "XtDriverStartup" },
|
||||
+ {22, "XtProcessStartup" },
|
||||
+ {23, "XtgMainProcessStartup" },
|
||||
+ {24, "XtcMainProcessStartup" },
|
||||
+ {25, "XtpMainProcessStartup" },
|
||||
+ {26, "XtlMainLibraryStartup" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
@@ -606,6 +611,12 @@ set_pe_subsystem (void)
|
||||
{ "posix", 7},
|
||||
{ "wince", 9},
|
||||
{ "xbox", 14},
|
||||
+ { "xt-driver", 21},
|
||||
+ { "xt-native", 22},
|
||||
+ { "xt-gdiapp", 23},
|
||||
+ { "xt-cliapp", 24},
|
||||
+ { "xt-psxapp", 25},
|
||||
+ { "xt-dynlib", 26},
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
diff --git a/ld/emultempl/pep.em b/ld/emultempl/pep.em
|
||||
index a0a7023e70..001aa34769 100644
|
||||
--- a/ld/emultempl/pep.em
|
||||
+++ b/ld/emultempl/pep.em
|
||||
@@ -504,6 +504,12 @@ set_entry_point (void)
|
||||
{ 7, "__PosixProcessStartup" },
|
||||
{ 9, "WinMainCRTStartup" },
|
||||
{14, "mainCRTStartup" },
|
||||
+ {21, "XtDriverStartup" },
|
||||
+ {22, "XtProcessStartup" },
|
||||
+ {23, "XtgMainProcessStartup" },
|
||||
+ {24, "XtcMainProcessStartup" },
|
||||
+ {25, "XtpMainProcessStartup" },
|
||||
+ {26, "XtlMainLibraryStartup" },
|
||||
{ 0, NULL }
|
||||
};
|
||||
|
||||
@@ -568,6 +573,12 @@ set_pep_subsystem (void)
|
||||
{ "posix", 7 },
|
||||
{ "wince", 9 },
|
||||
{ "xbox", 14 },
|
||||
+ { "xt-driver", 21},
|
||||
+ { "xt-native", 22},
|
||||
+ { "xt-gdiapp", 23},
|
||||
+ { "xt-cliapp", 24},
|
||||
+ { "xt-psxapp", 25},
|
||||
+ { "xt-dynlib", 26},
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
Though GOLD is not yet enabled for TDM-GCC, this patch will help
|
||||
|
||||
From: J.M. Eubank <john@thesnappy.net>
|
||||
|
||||
From
|
||||
<https://github.com/msys2/MINGW-packages/blob/master/mingw-w64-binutils/0001-enable-gold-on.mingw32.patch>
|
||||
---
|
||||
0 files changed
|
||||
|
||||
diff --git a/configure b/configure
|
||||
index 6a9719f6..f07a3b7f 100755
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -3001,6 +3001,7 @@ case "${ENABLE_GOLD}" in
|
||||
yes|default)
|
||||
# Check for ELF target.
|
||||
is_elf=no
|
||||
+ is_pe=no
|
||||
case "${target}" in
|
||||
*-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
|
||||
| *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
|
||||
@@ -3012,10 +3013,12 @@ case "${ENABLE_GOLD}" in
|
||||
*)
|
||||
is_elf=yes
|
||||
;;
|
||||
- esac
|
||||
+ esac;;
|
||||
+ *-*-mingw*)
|
||||
+ is_pe=yes;;
|
||||
esac
|
||||
|
||||
- if test "$is_elf" = "yes"; then
|
||||
+ if test "$is_elf" = "yes" -o "$is_pe" = "yes"; then
|
||||
# Check for target supported by gold.
|
||||
case "${target}" in
|
||||
i?86-*-* | x86_64-*-* | sparc*-*-* | powerpc*-*-* | arm*-*-* \
|
||||
@@ -0,0 +1,30 @@
|
||||
diff --git a/bfd/config.bfd b/bfd/config.bfd
|
||||
index bdee53957c0..04fff6e7df4 100644
|
||||
--- a/bfd/config.bfd
|
||||
+++ b/bfd/config.bfd
|
||||
@@ -407,6 +407,12 @@ case "${targ}" in
|
||||
targ_selvecs="arm_pe_le_vec arm_pe_be_vec arm_pei_le_vec arm_pei_be_vec"
|
||||
targ_underscore=yes
|
||||
;;
|
||||
+ arm-*-mingw*)
|
||||
+ targ_defvec=arm_pe_le_vec
|
||||
+ targ_selvecs="arm_pe_le_vec arm_pe_be_vec arm_pei_le_vec arm_pei_be_vec"
|
||||
+ targ_underscore=no
|
||||
+ targ_cflags="-DARM_COFF_BUGFIX"
|
||||
+ ;;
|
||||
arm-*-phoenix*)
|
||||
targ_defvec=arm_elf32_le_vec
|
||||
targ_selvecs=arm_elf32_be_vec
|
||||
diff --git a/gas/configure.tgt b/gas/configure.tgt
|
||||
index 3429f850d05..fa735da7ce6 100644
|
||||
--- a/gas/configure.tgt
|
||||
+++ b/gas/configure.tgt
|
||||
@@ -164,7 +164,7 @@ case ${generic_target} in
|
||||
arm-*-nto*) fmt=elf ;;
|
||||
arm-wince-pe | arm-*-wince | arm*-*-mingw32ce* | arm*-*-cegcc*)
|
||||
fmt=coff em=wince-pe ;;
|
||||
- arm-*-pe) fmt=coff em=pe ;;
|
||||
+ arm-*-pe | arm-*-mingw*) fmt=coff em=pe ;;
|
||||
arm-*-fuchsia*) fmt=elf ;;
|
||||
arm-*-haiku*) fmt=elf em=haiku ;;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
|
||||
index 818109f0b7..749377d193 100644
|
||||
--- a/Source/CMakeVersion.cmake
|
||||
+++ b/Source/CMakeVersion.cmake
|
||||
@@ -7,7 +7,7 @@ set(CMake_VERSION_IS_DIRTY 0)
|
||||
|
||||
# Start with the full version number used in tags. It has no dev info.
|
||||
set(CMake_VERSION
|
||||
- "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
|
||||
+ "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}-XTC")
|
||||
if(DEFINED CMake_VERSION_RC)
|
||||
set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}")
|
||||
endif()
|
||||
@@ -1,57 +0,0 @@
|
||||
Make GCC fully relocatable, not searching any fixed paths
|
||||
|
||||
From: J.M. Eubank <john@thesnappy.net>
|
||||
|
||||
that aren't relative to the current installation path
|
||||
|
||||
# HG changeset patch
|
||||
# Parent 2a1167ee4ed20c6ff3558a104218585837e9963f
|
||||
---
|
||||
0 files changed
|
||||
|
||||
diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h
|
||||
index 086c0e460..f0ceca42b 100644
|
||||
--- a/gcc/config/i386/mingw32.h
|
||||
+++ b/gcc/config/i386/mingw32.h
|
||||
@@ -78,7 +78,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#endif
|
||||
|
||||
#undef NATIVE_SYSTEM_HEADER_COMPONENT
|
||||
-#define NATIVE_SYSTEM_HEADER_COMPONENT "MINGW"
|
||||
+#undef NATIVE_SYSTEM_HEADER_DIR
|
||||
|
||||
#undef CPP_SPEC
|
||||
#define CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} " \
|
||||
@@ -183,17 +183,12 @@ along with GCC; see the file COPYING3. If not see
|
||||
|
||||
/* Override startfile prefix defaults. */
|
||||
#ifndef STANDARD_STARTFILE_PREFIX_1
|
||||
-#define STANDARD_STARTFILE_PREFIX_1 "/mingw/lib/"
|
||||
+#define STANDARD_STARTFILE_PREFIX_1 ""
|
||||
#endif
|
||||
#ifndef STANDARD_STARTFILE_PREFIX_2
|
||||
#define STANDARD_STARTFILE_PREFIX_2 ""
|
||||
#endif
|
||||
|
||||
-/* For native mingw-version we need to take care that NATIVE_SYSTEM_HEADER_DIR
|
||||
- macro contains POSIX-style path. See bug 52947. */
|
||||
-#undef NATIVE_SYSTEM_HEADER_DIR
|
||||
-#define NATIVE_SYSTEM_HEADER_DIR "/mingw/include"
|
||||
-
|
||||
/* Output STRING, a string representing a filename, to FILE.
|
||||
We canonicalize it to be in Unix format (backslashes are replaced
|
||||
forward slashes. */
|
||||
diff --git a/gcc/incpath.c b/gcc/incpath.c
|
||||
index bcbe20829..c5d4453d8 100644
|
||||
--- a/gcc/incpath.c
|
||||
+++ b/gcc/incpath.c
|
||||
@@ -183,8 +183,7 @@ add_standard_paths (const char *sysroot, const char *iprefix,
|
||||
str = concat (sysroot_no_trailing_dir_separator, p->fname, NULL);
|
||||
free (sysroot_no_trailing_dir_separator);
|
||||
}
|
||||
- else if (!p->add_sysroot && relocated
|
||||
- && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
|
||||
+ if (relocated && !filename_ncmp (p->fname, cpp_PREFIX, cpp_PREFIX_len))
|
||||
{
|
||||
static const char *relocated_prefix;
|
||||
char *ostr;
|
||||
+35
-42
@@ -1,7 +1,7 @@
|
||||
diff -apurN a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.am
|
||||
--- a/mingw-w64-tools/widl/Makefile.am 2020-07-31 23:17:43.793863913 +0200
|
||||
+++ b/mingw-w64-tools/widl/Makefile.am 2020-07-31 21:16:36.330432306 +0200
|
||||
@@ -30,6 +30,7 @@ widl_SOURCES = src/widl.h \
|
||||
--- a/mingw-w64-tools/widl/Makefile.am 2020-10-13 16:23:12.944066396 +0200
|
||||
+++ b/mingw-w64-tools/widl/Makefile.am 2020-10-13 16:19:00.523221067 +0200
|
||||
@@ -29,6 +29,7 @@ widl_SOURCES = src/widl.h \
|
||||
src/utils.c \
|
||||
src/widl.c \
|
||||
src/write_msft.c \
|
||||
@@ -10,18 +10,19 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.am b/mingw-w64-tools/widl/Makefile.a
|
||||
src/wpp/ppy.tab.h \
|
||||
src/wpp/ppl.yy.c \
|
||||
diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.in
|
||||
--- a/mingw-w64-tools/widl/Makefile.in 2020-07-31 23:17:43.793863913 +0200
|
||||
+++ b/mingw-w64-tools/widl/Makefile.in 2020-07-31 21:21:18.957064708 +0200
|
||||
@@ -117,7 +117,7 @@ am_widl_OBJECTS = src/widl-client.$(OBJE
|
||||
src/widl-widl.$(OBJEXT) src/widl-write_msft.$(OBJEXT) \
|
||||
src/wpp/widl-ppl.yy.$(OBJEXT) src/wpp/widl-ppy.tab.$(OBJEXT) \
|
||||
src/wpp/widl-preproc.$(OBJEXT) src/wpp/widl-wpp.$(OBJEXT) \
|
||||
- src/widl-pathtools.$(OBJEXT)
|
||||
+ src/widl-pathtools.$(OBJEXT) src/widl-write_sltg.$(OBJEXT)
|
||||
--- a/mingw-w64-tools/widl/Makefile.in 2020-10-13 16:23:12.944066396 +0200
|
||||
+++ b/mingw-w64-tools/widl/Makefile.in 2020-10-13 16:21:19.069027341 +0200
|
||||
@@ -117,7 +117,8 @@ am_widl_OBJECTS = src/widl-client.$(OBJE
|
||||
src/widl-utils.$(OBJEXT) src/widl-widl.$(OBJEXT) \
|
||||
src/widl-write_msft.$(OBJEXT) src/wpp/widl-ppl.yy.$(OBJEXT) \
|
||||
src/wpp/widl-ppy.tab.$(OBJEXT) src/wpp/widl-preproc.$(OBJEXT) \
|
||||
- src/wpp/widl-wpp.$(OBJEXT) src/widl-pathtools.$(OBJEXT)
|
||||
+ src/wpp/widl-wpp.$(OBJEXT) src/widl-pathtools.$(OBJEXT) \
|
||||
+ src/widl-write_sltg.$(OBJEXT)
|
||||
widl_OBJECTS = $(am_widl_OBJECTS)
|
||||
widl_LDADD = $(LDADD)
|
||||
widl_LINK = $(CCLD) $(widl_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
|
||||
@@ -340,6 +340,7 @@ widl_SOURCES = src/widl.h \
|
||||
@@ -356,6 +357,7 @@ widl_SOURCES = src/widl.h \
|
||||
src/utils.c \
|
||||
src/widl.c \
|
||||
src/write_msft.c \
|
||||
@@ -29,7 +30,7 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.i
|
||||
src/wpp/wpp_private.h \
|
||||
src/wpp/ppy.tab.h \
|
||||
src/wpp/ppl.yy.c \
|
||||
@@ -513,6 +514,8 @@ src/widl-widl.$(OBJEXT): src/$(am__dirst
|
||||
@@ -527,6 +529,8 @@ src/widl-widl.$(OBJEXT): src/$(am__dirst
|
||||
src/$(DEPDIR)/$(am__dirstamp)
|
||||
src/widl-write_msft.$(OBJEXT): src/$(am__dirstamp) \
|
||||
src/$(DEPDIR)/$(am__dirstamp)
|
||||
@@ -38,15 +39,7 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.i
|
||||
src/wpp/$(am__dirstamp):
|
||||
@$(MKDIR_P) src/wpp
|
||||
@: > src/wpp/$(am__dirstamp)
|
||||
@@ -559,6 +562,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-utils.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-widl.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-write_msft.Po@am__quote@
|
||||
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/widl-write_sltg.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/port/$(DEPDIR)/widl-getopt.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/port/$(DEPDIR)/widl-getopt1.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@src/port/$(DEPDIR)/widl-port.Po@am__quote@
|
||||
@@ -835,6 +839,20 @@ src/widl-write_msft.obj: src/write_msft.
|
||||
@@ -840,6 +845,20 @@ src/widl-write_msft.obj: src/write_msft.
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(widl_CPPFLAGS) $(CPPFLAGS) $(widl_CFLAGS) $(CFLAGS) -c -o src/widl-write_msft.obj `if test -f 'src/write_msft.c'; then $(CYGPATH_W) 'src/write_msft.c'; else $(CYGPATH_W) '$(srcdir)/src/write_msft.c'; fi`
|
||||
|
||||
@@ -68,9 +61,9 @@ diff -apurN a/mingw-w64-tools/widl/Makefile.in b/mingw-w64-tools/widl/Makefile.i
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(widl_CPPFLAGS) $(CPPFLAGS) $(widl_CFLAGS) $(CFLAGS) -MT src/wpp/widl-ppl.yy.o -MD -MP -MF src/wpp/$(DEPDIR)/widl-ppl.yy.Tpo -c -o src/wpp/widl-ppl.yy.o `test -f 'src/wpp/ppl.yy.c' || echo '$(srcdir)/'`src/wpp/ppl.yy.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/wpp/$(DEPDIR)/widl-ppl.yy.Tpo src/wpp/$(DEPDIR)/widl-ppl.yy.Po
|
||||
diff -apurN a/mingw-w64-tools/widl/src/register.c b/mingw-w64-tools/widl/src/register.c
|
||||
--- a/mingw-w64-tools/widl/src/register.c 2020-07-31 23:17:43.798863890 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/register.c 2020-07-31 21:13:59.935209986 +0200
|
||||
@@ -286,7 +286,12 @@ void write_typelib_regscript( const stat
|
||||
--- a/mingw-w64-tools/widl/src/register.c 2020-10-13 16:23:12.950066345 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/register.c 2020-10-13 16:19:00.523221067 +0200
|
||||
@@ -281,7 +281,12 @@ void write_typelib_regscript( const stat
|
||||
if (count && !strendswith( typelib_name, ".res" ))
|
||||
error( "Cannot store multiple typelibs into %s\n", typelib_name );
|
||||
else
|
||||
@@ -85,8 +78,8 @@ diff -apurN a/mingw-w64-tools/widl/src/register.c b/mingw-w64-tools/widl/src/reg
|
||||
}
|
||||
if (count && strendswith( typelib_name, ".res" )) flush_output_resources( typelib_name );
|
||||
diff -apurN a/mingw-w64-tools/widl/src/typelib.h b/mingw-w64-tools/widl/src/typelib.h
|
||||
--- a/mingw-w64-tools/widl/src/typelib.h 2020-07-31 23:17:43.537865053 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/typelib.h 2020-07-31 21:13:59.935209986 +0200
|
||||
--- a/mingw-w64-tools/widl/src/typelib.h 2020-10-13 16:23:12.950066345 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/typelib.h 2020-10-13 16:19:00.523221067 +0200
|
||||
@@ -83,4 +83,5 @@ enum VARENUM {
|
||||
extern unsigned short get_type_vt(type_t *t);
|
||||
|
||||
@@ -94,17 +87,17 @@ diff -apurN a/mingw-w64-tools/widl/src/typelib.h b/mingw-w64-tools/widl/src/type
|
||||
+extern int create_sltg_typelib(typelib_t *typelib);
|
||||
#endif
|
||||
diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
||||
--- a/mingw-w64-tools/widl/src/widl.c 2020-07-31 23:17:43.799863886 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/widl.c 2020-07-31 21:13:59.935209986 +0200
|
||||
@@ -62,6 +62,7 @@ static const char usage[] =
|
||||
" -m32, -m64 Set the target architecture (Win32 or Win64)\n"
|
||||
" -N Do not preprocess input\n"
|
||||
--- a/mingw-w64-tools/widl/src/widl.c 2020-10-13 16:23:12.951066337 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/widl.c 2020-10-13 16:22:05.493635687 +0200
|
||||
@@ -64,6 +64,7 @@ static const char usage[] =
|
||||
" --nostdinc Do not search the standard include path\n"
|
||||
" --ns_prefix Prefix namespaces with ABI namespace\n"
|
||||
" --oldnames Use old naming conventions\n"
|
||||
+" --oldtlb Use old typelib (SLTG) format\n"
|
||||
" -o, --output=NAME Set the output file name\n"
|
||||
" -Otype Type of stubs to generate (-Os, -Oi, -Oif)\n"
|
||||
" -p Generate proxy\n"
|
||||
@@ -114,6 +115,7 @@ int do_everything = 1;
|
||||
@@ -116,6 +117,7 @@ int do_everything = 1;
|
||||
static int preprocess_only = 0;
|
||||
int do_header = 0;
|
||||
int do_typelib = 0;
|
||||
@@ -112,23 +105,23 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
||||
int do_proxies = 0;
|
||||
int do_client = 0;
|
||||
int do_server = 0;
|
||||
@@ -164,6 +166,7 @@ enum {
|
||||
@@ -168,6 +170,7 @@ enum {
|
||||
DLLDATA_OPTION,
|
||||
DLLDATA_ONLY_OPTION,
|
||||
LOCAL_STUBS_OPTION,
|
||||
+ OLD_TYPELIB_OPTION,
|
||||
NOSTDINC_OPTION,
|
||||
PREFIX_ALL_OPTION,
|
||||
PREFIX_CLIENT_OPTION,
|
||||
PREFIX_SERVER_OPTION,
|
||||
@@ -188,6 +191,7 @@ static const struct option long_options[
|
||||
{ "local-stubs", 1, NULL, LOCAL_STUBS_OPTION },
|
||||
@@ -195,6 +198,7 @@ static const struct option long_options[
|
||||
{ "nostdinc", 0, NULL, NOSTDINC_OPTION },
|
||||
{ "ns_prefix", 0, NULL, RT_NS_PREFIX },
|
||||
{ "oldnames", 0, NULL, OLDNAMES_OPTION },
|
||||
+ { "oldtlb", 0, NULL, OLD_TYPELIB_OPTION },
|
||||
{ "output", 0, NULL, 'o' },
|
||||
{ "prefix-all", 1, NULL, PREFIX_ALL_OPTION },
|
||||
{ "prefix-client", 1, NULL, PREFIX_CLIENT_OPTION },
|
||||
@@ -325,6 +329,7 @@ static void set_everything(int x)
|
||||
@@ -333,6 +337,7 @@ static void set_everything(int x)
|
||||
{
|
||||
do_header = x;
|
||||
do_typelib = x;
|
||||
@@ -136,7 +129,7 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
||||
do_proxies = x;
|
||||
do_client = x;
|
||||
do_server = x;
|
||||
@@ -712,6 +717,9 @@ int main(int argc,char *argv[])
|
||||
@@ -749,6 +754,9 @@ int main(int argc,char *argv[])
|
||||
do_everything = 0;
|
||||
do_typelib = 1;
|
||||
break;
|
||||
@@ -147,8 +140,8 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.c b/mingw-w64-tools/widl/src/widl.c
|
||||
typelib_name = xstrdup(optarg);
|
||||
break;
|
||||
diff -apurN a/mingw-w64-tools/widl/src/widl.h b/mingw-w64-tools/widl/src/widl.h
|
||||
--- a/mingw-w64-tools/widl/src/widl.h 2020-07-31 23:17:43.537865053 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/widl.h 2020-07-31 21:13:59.935209986 +0200
|
||||
--- a/mingw-w64-tools/widl/src/widl.h 2020-10-13 16:23:12.951066337 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/widl.h 2020-10-13 16:19:00.524221058 +0200
|
||||
@@ -38,6 +38,7 @@ extern int pedantic;
|
||||
extern int do_everything;
|
||||
extern int do_header;
|
||||
@@ -159,7 +152,7 @@ diff -apurN a/mingw-w64-tools/widl/src/widl.h b/mingw-w64-tools/widl/src/widl.h
|
||||
extern int do_server;
|
||||
diff -apurN a/mingw-w64-tools/widl/src/write_sltg.c b/mingw-w64-tools/widl/src/write_sltg.c
|
||||
--- a/mingw-w64-tools/widl/src/write_sltg.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ b/mingw-w64-tools/widl/src/write_sltg.c 2020-07-31 21:13:59.936209981 +0200
|
||||
+++ b/mingw-w64-tools/widl/src/write_sltg.c 2020-10-13 16:19:00.524221058 +0200
|
||||
@@ -0,0 +1,1857 @@
|
||||
+/*
|
||||
+ * Typelib (SLTG) generation
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# PROJECT: XTchain
|
||||
# LICENSE: See the COPYING.md in the top level directory
|
||||
# FILE: scripts/clang-target-wrapper
|
||||
# DESCRIPTION: CLANG Wrapper
|
||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
|
||||
|
||||
# Set basic variables
|
||||
DIR="$(cd $(dirname $0) && pwd)"
|
||||
CLANG="$DIR/clang"
|
||||
BASENAME="$(basename $0)"
|
||||
TARGET="${BASENAME%-*}"
|
||||
EXECUTABLE="${BASENAME##*-}"
|
||||
DEFAULT_TARGET="x86_64-w64-mingw32"
|
||||
ARCH="${TARGET%%-*}"
|
||||
|
||||
# Set proper target
|
||||
if [ "${TARGET}" = "${BASENAME}" ]; then
|
||||
TARGET="${DEFAULT_TARGET}"
|
||||
fi
|
||||
|
||||
# Set lang-specific flags
|
||||
case ${EXECUTABLE} in
|
||||
"clang++"|"g++"|"c++")
|
||||
FLAGS="$FLAGS --driver-mode=g++"
|
||||
;;
|
||||
*)
|
||||
FLAGS=""
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set compiler flags
|
||||
FLAGS="${FLAGS} -target ${TARGET}"
|
||||
FLAGS="${FLAGS} -rtlib=compiler-rt"
|
||||
FLAGS="${FLAGS} -stdlib=libc++"
|
||||
FLAGS="${FLAGS} -fuse-ld=lld"
|
||||
FLAGS="${FLAGS} -Qunused-arguments"
|
||||
|
||||
# Launch the compiler
|
||||
$CLANG $FLAGS "$@"
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# PROJECT: XTchain
|
||||
# LICENSE: See the COPYING.md in the top level directory
|
||||
# FILE: scripts/dlltool-wrapper
|
||||
# DESCRIPTION: DLLTOOL Wrapper
|
||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
|
||||
|
||||
# Set basic variables
|
||||
DIR="$(cd $(dirname $0) && pwd)"
|
||||
BASENAME="$(basename $0)"
|
||||
TARGET="${BASENAME%-*}"
|
||||
DEFAULT_TARGET="x86_64-w64-mingw32"
|
||||
|
||||
# Update PATH
|
||||
export PATH="$DIR":"$PATH"
|
||||
|
||||
# Set proper target
|
||||
if [ "${TARGET}" = "${BASENAME}" ]; then
|
||||
TARGET="${DEFAULT_TARGET}"
|
||||
fi
|
||||
|
||||
# Set target machine
|
||||
ARCH="${TARGET%%-*}"
|
||||
case $ARCH in
|
||||
aarch64)
|
||||
M="arm64"
|
||||
;;
|
||||
armv7)
|
||||
M="arm"
|
||||
;;
|
||||
i686)
|
||||
M="i386"
|
||||
;;
|
||||
x86_64)
|
||||
M="i386:x86-64"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Launch the utility
|
||||
llvm-dlltool -m ${M} "$@"
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# PROJECT: XTchain
|
||||
# LICENSE: See the COPYING.md in the top level directory
|
||||
# FILE: scripts/ld-wrapper
|
||||
# DESCRIPTION: LLD Wrapper
|
||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
|
||||
|
||||
# Set basic variables
|
||||
DIR="$(cd $(dirname $0) && pwd)"
|
||||
BASENAME="$(basename $0)"
|
||||
TARGET="${BASENAME%-*}"
|
||||
DEFAULT_TARGET="x86_64-w64-mingw32"
|
||||
|
||||
# Update PATH
|
||||
export PATH="${DIR}":"${PATH}"
|
||||
|
||||
# Set proper target
|
||||
if [ "${TARGET}" = "${BASENAME}" ]; then
|
||||
TARGET="${DEFAULT_TARGET}"
|
||||
fi
|
||||
|
||||
# Set target machine
|
||||
ARCH="${TARGET%%-*}"
|
||||
case ${ARCH} in
|
||||
aarch64)
|
||||
M="arm64pe"
|
||||
;;
|
||||
armv7)
|
||||
M="thumb2pe"
|
||||
;;
|
||||
i686)
|
||||
M="i386pe"
|
||||
;;
|
||||
x86_64)
|
||||
M="i386pep"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Launch the linker
|
||||
ld.lld -m ${M} "$@"
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# PROJECT: XTchain
|
||||
# LICENSE: See the COPYING.md in the top level directory
|
||||
# FILE: scripts/objdump-wrapper
|
||||
# DESCRIPTION: OBJDUMP Wrapper
|
||||
# DEVELOPERS: Martin Storsjo <martin@martin.st>
|
||||
# Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
|
||||
|
||||
# Set basic variables
|
||||
DIR="$(cd $(dirname $0) && pwd)"
|
||||
|
||||
# Update PATH
|
||||
export PATH="$DIR":"$PATH"
|
||||
|
||||
# Libtool can try to run objdump -f and wants to see certain strings in
|
||||
# the output, to accept it being a valid windows (import) library
|
||||
if [ "$1" = "-f" ]; then
|
||||
llvm-readobj $2 | while read -r line; do
|
||||
case $line in
|
||||
File:*)
|
||||
file=$(echo $line | awk '{print $2}')
|
||||
;;
|
||||
Format:*)
|
||||
format=$(echo $line | awk '{print $2}')
|
||||
case $format in
|
||||
COFF-i386)
|
||||
format=pe-i386
|
||||
;;
|
||||
COFF-x86-64)
|
||||
format=pe-x86-64
|
||||
;;
|
||||
COFF-ARM*)
|
||||
# This is wrong; modern COFF armv7 isn't pe-arm-wince, and
|
||||
# arm64 definitely isn't, but libtool wants to see this
|
||||
# string (or some of the others) in order to accept it.
|
||||
format=pe-arm-wince
|
||||
;;
|
||||
esac
|
||||
echo $file: file format $format
|
||||
;;
|
||||
esac
|
||||
done
|
||||
else
|
||||
llvm-objdump "$@"
|
||||
fi
|
||||
@@ -6,12 +6,6 @@
|
||||
# DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
|
||||
|
||||
# Check if script launched as root
|
||||
if [ "$(whoami)" = "root" ]; then
|
||||
echo "This script cannot be run as root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get the absolute path to the XTchain
|
||||
export XTCDIR="$(realpath $(dirname ${0}))"
|
||||
|
||||
|
||||
+61
-6
@@ -14,8 +14,14 @@ charch()
|
||||
return
|
||||
fi
|
||||
case ${1} in
|
||||
"aarch64"|"arm64")
|
||||
export TARGET="aarch64"
|
||||
;;
|
||||
"arm"|"armv7")
|
||||
export TARGET="armv7"
|
||||
;;
|
||||
"i386"|"i486"|"i586"|"i686"|"x86")
|
||||
export TARGET="i386"
|
||||
export TARGET="i686"
|
||||
;;
|
||||
"amd64"|"x64"|"x86_64")
|
||||
export TARGET="amd64"
|
||||
@@ -27,23 +33,72 @@ charch()
|
||||
}
|
||||
export -f charch
|
||||
|
||||
# Sets the build type
|
||||
chbuild()
|
||||
{
|
||||
if [ "x${1}" == "x" ]; then
|
||||
echo "Syntax: chbuild [DEBUG|RELEASE]"
|
||||
return
|
||||
fi
|
||||
case ${1} in
|
||||
[Rr][Ee][Ll][Ee][Aa][Ss][Ee])
|
||||
export BUILD_TYPE="RELEASE"
|
||||
;;
|
||||
*)
|
||||
export BUILD_TYPE="DEBUG"
|
||||
esac
|
||||
echo "Target build type: ${BUILD_TYPE}"
|
||||
}
|
||||
export -f chbuild
|
||||
|
||||
# Prints help
|
||||
help()
|
||||
{
|
||||
version
|
||||
echo "XTChain defines an internal list of commands:"
|
||||
echo " * charch [arch] - sets the target CPU architecture [aarch64/armv7/i686/amd64]"
|
||||
echo " * chbuild [type] - sets build type [debug/release]"
|
||||
echo " * help - prints this message"
|
||||
echo " * version - prints XTChain and its components version"
|
||||
echo " * xbuild - builds an application with a Ninja build system"
|
||||
}
|
||||
export -f help
|
||||
|
||||
# Displays version banner
|
||||
version()
|
||||
{
|
||||
echo "###############################################################################"
|
||||
echo "# FerretOS Build Environment v${XTCVER} for Linux #"
|
||||
echo "# XT Toolchain v${XTCVER} for Linux #"
|
||||
echo "# by Rafal Kupiec <belliash@codingworkshop.eu.org> #"
|
||||
echo "###############################################################################"
|
||||
echo
|
||||
echo
|
||||
echo "Binutils Version: $(${XTCDIR}/bin/i686-w64-mingw32-ld -v | cut -d' ' -f5)"
|
||||
echo "GCC Version: $(${XTCDIR}/bin/i686-w64-mingw32-gcc -v 2>&1| grep 'gcc version' | cut -d' ' -f3)"
|
||||
echo "IDL Compiler Version: $(${XTCDIR}/bin/i686-w64-mingw32-widl -V | grep 'version' | cut -d' ' -f5)"
|
||||
echo "LLVM Compiler Version: $(${XTCDIR}/bin/clang --version | grep 'clang version' | cut -d' ' -f3)"
|
||||
echo "LLVM Windres Utility Version: $(${XTCDIR}/bin/i686-w64-mingw32-windres -V | cut -d' ' -f6)"
|
||||
echo "Mingw IDL Compiler Version: $(${XTCDIR}/bin/i686-w64-mingw32-widl -V | grep 'version' | cut -d' ' -f5)"
|
||||
echo "Wine Message Compiler Version: $(${XTCDIR}/bin/wmc -V | grep 'version' | cut -d' ' -f5)"
|
||||
echo "Wine Resource Compiler Version: $(${XTCDIR}/bin/wrc --version | grep 'version' | cut -d' ' -f5)"
|
||||
echo
|
||||
charch ${TARGET}
|
||||
charch ${TARGET:-amd64}
|
||||
chbuild ${BUILD_TYPE:-DEBUG}
|
||||
echo
|
||||
echo
|
||||
}
|
||||
export -f version
|
||||
|
||||
# Builds application (wrapper to Ninja)
|
||||
xbuild()
|
||||
{
|
||||
if [ ! -f build.arch ]; then
|
||||
ninja "$@"
|
||||
else
|
||||
ARCH=$(cat build.arch)
|
||||
if [ x"${ARCH}" != x"${TARGET}" ]; then
|
||||
echo "Build is configured for '${ARCH}' while current target set to '${TARGET}'!"
|
||||
echo "Cannot continue until conflict is resolved ..."
|
||||
return 1
|
||||
fi
|
||||
ninja "$@"
|
||||
fi
|
||||
}
|
||||
export -f xbuild
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/**
|
||||
* PROJECT: XTchain
|
||||
* LICENSE: See COPYING.md in the top level directory
|
||||
* FILE: tools/bin2c.c
|
||||
* DESCRIPTION: Binary to C converter
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
*/
|
||||
|
||||
#include "xtchain.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/* Check for proper number of arguments */
|
||||
if(argc != 4)
|
||||
{
|
||||
printf("Usage: %s <input binary> <output file> <structure name>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open the input binary file in binary mode */
|
||||
FILE *inputFile = fopen(argv[1], "rb");
|
||||
if(inputFile == NULL)
|
||||
{
|
||||
printf("Error: unable to open file %s\n", argv[1]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open the destination source code file in text mode */
|
||||
FILE *outputFile = fopen(argv[2], "w");
|
||||
if(outputFile == NULL)
|
||||
{
|
||||
printf("Error: unable to open file %s\n", argv[2]);
|
||||
fclose(inputFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Get the size of the binary file */
|
||||
fseek(inputFile, 0, SEEK_END);
|
||||
long binSize = ftell(inputFile);
|
||||
rewind(inputFile);
|
||||
|
||||
/* Allocate memory for the binary data */
|
||||
unsigned char *binData = (unsigned char *)malloc(binSize);
|
||||
if(binData == NULL)
|
||||
{
|
||||
printf("Error: unable to allocate memory for binary data\n");
|
||||
fclose(inputFile);
|
||||
fclose(outputFile);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Read the binary data into memory */
|
||||
fread(binData, sizeof(unsigned char), binSize, inputFile);
|
||||
|
||||
/* Write the C structure to the header file */
|
||||
fprintf(outputFile, "unsigned char %s[] = {", argv[3]);
|
||||
for(int i = 0; i < binSize; i++)
|
||||
{
|
||||
fprintf(outputFile, "0x%02X", binData[i]);
|
||||
if(i < binSize - 1)
|
||||
{
|
||||
fprintf(outputFile, ",");
|
||||
}
|
||||
}
|
||||
fprintf(outputFile, "};\nunsigned int %s_size = %ld;\n", argv[3], binSize);
|
||||
free(binData);
|
||||
|
||||
/* Close all open files */
|
||||
fclose(inputFile);
|
||||
fclose(outputFile);
|
||||
|
||||
printf("Binary data converted to C structure successfully.\n");
|
||||
return 0;
|
||||
}
|
||||
+182
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* PROJECT: XTchain
|
||||
* LICENSE: See COPYING.md in the top level directory
|
||||
* FILE: tools/exetool.c
|
||||
* DESCRIPTION: Portable Executable (PE) utility for changing its signature and subsystem
|
||||
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
|
||||
*/
|
||||
|
||||
#include "xtchain.h"
|
||||
|
||||
typedef struct _PE_SUBSYSTEM
|
||||
{
|
||||
int Identifier;
|
||||
char *Name;
|
||||
} PE_SUBSYSTEM, *PPE_SUBSYSTEM;
|
||||
|
||||
static PE_SUBSYSTEM SubSystems[] = {
|
||||
{0x00, "INVALID_SUBSYSTEM"},
|
||||
{0x01, "NT_NATIVE"},
|
||||
{0x02, "WINDOWS_GUI"},
|
||||
{0x03, "WINDOWS_CLI"},
|
||||
{0x04, "WINDOWS_CE_OLD"},
|
||||
{0x05, "OS2_CUI"},
|
||||
{0x07, "POSIX_CUI"},
|
||||
{0x08, "NATIVE_WINDOWS"},
|
||||
{0x09, "WINDOWS_CE_GUI"},
|
||||
{0x0A, "EFI_APPLICATION"},
|
||||
{0x0B, "EFI_BOOT_SERVICE_DRIVER"},
|
||||
{0x0C, "EFI_RUNTIME_DRIVER"},
|
||||
{0x0D, "EFI_ROM"},
|
||||
{0x0E, "XBOX"},
|
||||
{0x10, "WINDOWS_BOOT_APPLICATION"},
|
||||
{0x14, "XT_NATIVE_KERNEL"},
|
||||
{0x15, "XT_NATIVE_APPLICATION"},
|
||||
{0x16, "XT_NATIVE_DRIVER"},
|
||||
{0x17, "XT_DYNAMIC_LIBRARY"},
|
||||
{0x18, "XT_APPLICATION_CLI"},
|
||||
{0x19, "XT_APPLICATION_GDI"}
|
||||
};
|
||||
|
||||
PPE_SUBSYSTEM getSubSystem(char *Name)
|
||||
{
|
||||
int Index;
|
||||
int SubSystemsCount;
|
||||
PPE_SUBSYSTEM SubSystem;
|
||||
|
||||
/* Count number of subsystems avaialble */
|
||||
SubSystemsCount = sizeof(SubSystems) / sizeof(PE_SUBSYSTEM);
|
||||
|
||||
/* Find subsystem */
|
||||
for(Index = 0; Index < SubSystemsCount; Index++)
|
||||
{
|
||||
SubSystem = &SubSystems[Index];
|
||||
if(strcasecmp(SubSystem->Name, Name) == 0)
|
||||
{
|
||||
/* Subsystem found, return its ID */
|
||||
return SubSystem;
|
||||
}
|
||||
}
|
||||
|
||||
/* No valid subsystem found */
|
||||
return &SubSystems[0];
|
||||
}
|
||||
|
||||
char *getSubSystemName(int Identifier)
|
||||
{
|
||||
int Index;
|
||||
int SubSystemsCount;
|
||||
PPE_SUBSYSTEM SubSystem;
|
||||
|
||||
/* Count number of subsystems avaialble */
|
||||
SubSystemsCount = sizeof(SubSystems) / sizeof(PE_SUBSYSTEM);
|
||||
|
||||
/* Find subsystem */
|
||||
for(Index = 0; Index < SubSystemsCount; Index++)
|
||||
{
|
||||
SubSystem = &SubSystems[Index];
|
||||
if(SubSystem->Identifier == Identifier)
|
||||
{
|
||||
/* Subsystem found, return its ID */
|
||||
return SubSystem->Name;
|
||||
}
|
||||
}
|
||||
|
||||
/* No valid subsystem found */
|
||||
return SubSystems[0].Name;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
FILE *ExeFile;
|
||||
unsigned char Signature[4];
|
||||
unsigned int HeaderOffset;
|
||||
unsigned int ImageSignature;
|
||||
unsigned short SubSystem;
|
||||
PPE_SUBSYSTEM NewSubSystem;
|
||||
|
||||
/* Check for proper number of arguments */
|
||||
if(argc != 3)
|
||||
{
|
||||
printf("Usage: %s <filename> <new SubSystem>\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Parse the new SubSystem value from the command line argument */
|
||||
NewSubSystem = getSubSystem(argv[2]);
|
||||
if(NewSubSystem->Identifier == 0)
|
||||
{
|
||||
/* Invalid SubSystem provided */
|
||||
printf("Error: %s is not a valid PE SubSystem\n", argv[2]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Open the EXE file in binary mode */
|
||||
ExeFile = fopen(argv[1], "r+b");
|
||||
if(ExeFile == NULL)
|
||||
{
|
||||
/* Failed to open PE file */
|
||||
printf("ERROR: Unable to open file %s\n", argv[1]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Verify that the input file has a valid DOS header */
|
||||
fread(Signature, sizeof(unsigned char), 4, ExeFile);
|
||||
if(Signature[0] != 'M' || Signature[1] != 'Z')
|
||||
{
|
||||
/* Invalid DOS header */
|
||||
printf("ERROR: %s is not a valid EXE file\n", argv[1]);
|
||||
fclose(ExeFile);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Verify that the input file has a valid PE header */
|
||||
fseek(ExeFile, 0x3C, SEEK_SET);
|
||||
fread(&HeaderOffset, sizeof(unsigned int), 1, ExeFile);
|
||||
fseek(ExeFile, HeaderOffset, SEEK_SET);
|
||||
fread(Signature, sizeof(unsigned char), 4, ExeFile);
|
||||
if((Signature[0] != 'P' || Signature[1] != 'E' || Signature[2] != 0 || Signature[3] != 0) &&
|
||||
(Signature[0] != 'P' || Signature[1] != 'E' || Signature[2] != 'X' || Signature[3] != 'T'))
|
||||
{
|
||||
/* Invalid PE header */
|
||||
printf("Error: %s is not a valid PE file\n", argv[1]);
|
||||
fclose(ExeFile);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Check if setting XT subsystem */
|
||||
if(NewSubSystem->Identifier >= 0x14 && NewSubSystem->Identifier <= 0x19)
|
||||
{
|
||||
/* Write PEXT signature */
|
||||
ImageSignature = 0x54584550;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Write PE00 signature */
|
||||
ImageSignature = 0x00004550;
|
||||
}
|
||||
|
||||
/* Seek back to header offset and write new signature */
|
||||
fseek(ExeFile, HeaderOffset, SEEK_SET);
|
||||
fwrite(&ImageSignature, sizeof(ImageSignature), 1, ExeFile);
|
||||
|
||||
/* Seek to the offset of the SubSystem field in the optional header */
|
||||
fseek(ExeFile, HeaderOffset + 0x5C, SEEK_SET);
|
||||
|
||||
/* Read the current SubSystem value */
|
||||
fread(&SubSystem, sizeof(unsigned short), 1, ExeFile);
|
||||
|
||||
/* Seek back to the SubSystem field in the optional header */
|
||||
fseek(ExeFile, -sizeof(unsigned short), SEEK_CUR);
|
||||
|
||||
/* Write the new SubSystem value */
|
||||
fwrite(&NewSubSystem->Identifier, sizeof(unsigned short), 1, ExeFile);
|
||||
|
||||
/* Close the file */
|
||||
fclose(ExeFile);
|
||||
|
||||
/* Finished successfully */
|
||||
printf("PE SubSystem modified: 0x%02X <%s> to 0x%02X <%s>\n",
|
||||
SubSystem, getSubSystemName(SubSystem), NewSubSystem->Identifier, NewSubSystem->Name);
|
||||
return 0;
|
||||
}
|
||||
+8
-152
@@ -49,7 +49,6 @@ enum _ARCH
|
||||
};
|
||||
|
||||
typedef int (*PFNOUTLINE)(FILE *, EXPORT *);
|
||||
int gbMSComp = 0;
|
||||
int gbImportLib = 0;
|
||||
int gbNotPrivateNoWarn = 0;
|
||||
int gbTracing = 0;
|
||||
@@ -531,20 +530,13 @@ PrintName(FILE *fileDest,
|
||||
pcAt = ScanToken(pcName, '@');
|
||||
if(pcAt && (pcAt < (pcName + nNameLength)))
|
||||
{
|
||||
/* On GCC, we need to remove the leading stdcall underscore */
|
||||
if(!gbMSComp && (pexp->nCallingConvention == CC_STDCALL))
|
||||
{
|
||||
pcName++;
|
||||
nNameLength--;
|
||||
}
|
||||
|
||||
/* Print the already decorated function name */
|
||||
fprintf(fileDest, "%.*s", nNameLength, pcName);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Print the prefix, but skip it for (GCC && stdcall) */
|
||||
if(gbMSComp || (pexp->nCallingConvention != CC_STDCALL))
|
||||
/* Print the prefix, but skip it for stdcall */
|
||||
if(pexp->nCallingConvention != CC_STDCALL)
|
||||
{
|
||||
fprintf(fileDest, "%c", pexp->nCallingConvention == CC_FASTCALL ? '@' : '_');
|
||||
}
|
||||
@@ -560,10 +552,13 @@ PrintName(FILE *fileDest,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OutputLine_def_MS(FILE *fileDest,
|
||||
EXPORT *pexp)
|
||||
int
|
||||
OutputLine_def(FILE *fileDest,
|
||||
EXPORT *pexp)
|
||||
{
|
||||
DbgPrint("OutputLine_def: '%.*s'...\n", pexp->strName.len, pexp->strName.buf);
|
||||
fprintf(fileDest, " ");
|
||||
|
||||
PrintName(fileDest, pexp, &pexp->strName, 0);
|
||||
|
||||
if(gbImportLib)
|
||||
@@ -610,92 +605,6 @@ OutputLine_def_MS(FILE *fileDest,
|
||||
/* Redirect it to the relay-tracing trampoline */
|
||||
fprintf(fileDest, "=$relaytrace$%.*s", pexp->strName.len, pexp->strName.buf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
OutputLine_def_GCC(FILE *fileDest,
|
||||
EXPORT *pexp)
|
||||
{
|
||||
int bTracing = 0;
|
||||
/* Print the function name, with decoration for export libs */
|
||||
PrintName(fileDest, pexp, &pexp->strName, gbImportLib);
|
||||
DbgPrint("Generating def line for '%.*s'\n", pexp->strName.len, pexp->strName.buf);
|
||||
|
||||
/* Check if this is a forwarded export */
|
||||
if(pexp->strTarget.buf)
|
||||
{
|
||||
int fIsExternal = !!ScanToken(pexp->strTarget.buf, '.');
|
||||
DbgPrint("Got redirect '%.*s'\n", pexp->strTarget.len, pexp->strTarget.buf);
|
||||
|
||||
/* print the target name, don't decorate if it is external */
|
||||
fprintf(fileDest, "=");
|
||||
PrintName(fileDest, pexp, &pexp->strTarget, !fIsExternal);
|
||||
}
|
||||
else if(((pexp->uFlags & FL_STUB) || (pexp->nCallingConvention == CC_STUB)) &&
|
||||
(pexp->strName.buf[0] == '?'))
|
||||
{
|
||||
/* C++ stubs are forwarded to C stubs */
|
||||
fprintf(fileDest, "=stub_function%d", pexp->nNumber);
|
||||
}
|
||||
else if(gbTracing && ((pexp->uFlags & FL_NORELAY) == 0) &&
|
||||
(pexp->nCallingConvention == CC_STDCALL) &&
|
||||
(pexp->strName.buf[0] != '?'))
|
||||
{
|
||||
/* Redirect it to the relay-tracing trampoline */
|
||||
char buf[256];
|
||||
STRING strTarget;
|
||||
fprintf(fileDest, "=");
|
||||
sprintf(buf, "$relaytrace$%.*s", pexp->strName.len, pexp->strName.buf);
|
||||
strTarget.buf = buf;
|
||||
strTarget.len = pexp->strName.len + 12;
|
||||
PrintName(fileDest, pexp, &strTarget, 1);
|
||||
bTracing = 1;
|
||||
}
|
||||
|
||||
/* Special handling for stdcall and fastcall */
|
||||
if((giArch == ARCH_X86) &&
|
||||
((pexp->nCallingConvention == CC_STDCALL) ||
|
||||
(pexp->nCallingConvention == CC_FASTCALL)))
|
||||
{
|
||||
/* Is this the import lib? */
|
||||
if(gbImportLib)
|
||||
{
|
||||
/* Is the name in the spec file decorated? */
|
||||
const char* pcDeco = ScanToken(pexp->strName.buf, '@');
|
||||
if(pcDeco &&
|
||||
(pexp->strName.len > 1) &&
|
||||
(pcDeco < pexp->strName.buf + pexp->strName.len))
|
||||
{
|
||||
/* Write the name including the leading @ */
|
||||
fprintf(fileDest, "==%.*s", pexp->strName.len, pexp->strName.buf);
|
||||
}
|
||||
}
|
||||
else if((!pexp->strTarget.buf) && !(bTracing))
|
||||
{
|
||||
/* Write a forwarder to the actual decorated symbol */
|
||||
fprintf(fileDest, "=");
|
||||
PrintName(fileDest, pexp, &pexp->strName, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
OutputLine_def(FILE *fileDest,
|
||||
EXPORT *pexp)
|
||||
{
|
||||
DbgPrint("OutputLine_def: '%.*s'...\n", pexp->strName.len, pexp->strName.buf);
|
||||
fprintf(fileDest, " ");
|
||||
|
||||
if(gbMSComp)
|
||||
OutputLine_def_MS(fileDest, pexp);
|
||||
else
|
||||
OutputLine_def_GCC(fileDest, pexp);
|
||||
|
||||
/* On GCC builds we force ordinals */
|
||||
if((pexp->uFlags & FL_ORDINAL) || (!gbMSComp && !gbImportLib))
|
||||
{
|
||||
fprintf(fileDest, " @%d", pexp->nOrdinal);
|
||||
}
|
||||
|
||||
if(pexp->uFlags & FL_NONAME)
|
||||
{
|
||||
@@ -1028,10 +937,6 @@ ParseFile(char* pcStart,
|
||||
else if(CompareToken(pc, "-ordinal"))
|
||||
{
|
||||
exp.uFlags |= FL_ORDINAL;
|
||||
/* GCC doesn't automatically import by ordinal if an ordinal
|
||||
* is found in the def file. Force it. */
|
||||
if(gbImportLib && !gbMSComp)
|
||||
exp.uFlags |= FL_NONAME;
|
||||
}
|
||||
else if(CompareToken(pc, "-stub"))
|
||||
{
|
||||
@@ -1226,41 +1131,6 @@ ParseFile(char* pcStart,
|
||||
Fatal(pszSourceFileName, nLine, pcLine, pc, 0, "Ordinal export without ordinal");
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for special handling of OLE exports, only when MSVC
|
||||
* is not used, since otherwise this is handled by MS LINK.EXE.
|
||||
*/
|
||||
if(!gbMSComp)
|
||||
{
|
||||
/* Check whether the current export is not PRIVATE, or has an ordinal */
|
||||
int bIsNotPrivate = (!gbNotPrivateNoWarn && /*gbImportLib &&*/ !(exp.uFlags & FL_PRIVATE));
|
||||
int bHasOrdinal = (exp.uFlags & FL_ORDINAL);
|
||||
|
||||
/* Check whether the current export is an OLE export, in case any of these tests pass */
|
||||
if(bIsNotPrivate || bHasOrdinal)
|
||||
{
|
||||
for(i = 0; i < ARRAYSIZE(astrOlePrivateExports); ++i)
|
||||
{
|
||||
if(strlen(astrOlePrivateExports[i]) == exp.strName.len &&
|
||||
strncmp(exp.strName.buf, astrOlePrivateExports[i], exp.strName.len) == 0)
|
||||
{
|
||||
/* The current export is an OLE export: display the corresponding warning */
|
||||
if(bIsNotPrivate)
|
||||
{
|
||||
fprintf(stderr, "WARNING: %s line %d: Exported symbol '%.*s' should be PRIVATE\n",
|
||||
pszSourceFileName, nLine, exp.strName.len, exp.strName.buf);
|
||||
}
|
||||
if(bHasOrdinal)
|
||||
{
|
||||
fprintf(stderr, "WARNING: %s line %d: exported symbol '%.*s' should not be assigned an ordinal\n",
|
||||
pszSourceFileName, nLine, exp.strName.len, exp.strName.buf);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pexports[*cExports] = exp;
|
||||
(*cExports)++;
|
||||
gbDebug = 0;
|
||||
@@ -1329,7 +1199,6 @@ void usage(void)
|
||||
" -n=<name> name of the dll\n"
|
||||
" -a=<arch> set architecture to one of: aarch64, armv7, i686, x86_64\n"
|
||||
" --implib generate a def file for an import library\n"
|
||||
" --msvc MSVC compatibility\n"
|
||||
" --no-private-warnings suppress warnings about symbols that should be private\n"
|
||||
" --with-tracing generate wine-like \"+relay\" trace trampolines (needs -s)\n",
|
||||
XTCSPECC_VERSION,
|
||||
@@ -1393,10 +1262,6 @@ int main(int argc,
|
||||
{
|
||||
gbImportLib = 1;
|
||||
}
|
||||
else if(strcasecmp(argv[i], "--msvc") == 0)
|
||||
{
|
||||
gbMSComp = 1;
|
||||
}
|
||||
else if(strcasecmp(argv[i], "--no-private-warnings") == 0)
|
||||
{
|
||||
gbNotPrivateNoWarn = 1;
|
||||
@@ -1516,15 +1381,6 @@ int main(int argc,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!gbMSComp)
|
||||
{
|
||||
if(ApplyOrdinals(pexports, cExports) < 0)
|
||||
{
|
||||
fprintf(stderr, "error: could not apply ordinals!\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if(pszDefFileName)
|
||||
{
|
||||
/* Open output file */
|
||||
|
||||
Reference in New Issue
Block a user