Skip to content

Commit 3b73277

Browse files
committed
Init.
0 parents  commit 3b73277

10 files changed

Lines changed: 547 additions & 0 deletions

File tree

.github/workflows/release.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
release:
6+
types:
7+
- published
8+
9+
jobs:
10+
build:
11+
name: Build
12+
runs-on: ubuntu-22.04
13+
strategy:
14+
fail-fast: true
15+
matrix:
16+
target:
17+
- i686-w64-mingw32
18+
- x86_64-w64-mingw32
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 1
24+
submodules: true
25+
- name: Build
26+
run: |
27+
sudo rm -rf /opt/*
28+
./scripts/make ${{ matrix.target }}
29+
- name: Upload package
30+
uses: actions/upload-artifact@v4
31+
with:
32+
name: ${{ matrix.target }}.tar.xz
33+
path: ${{ matrix.target }}.tar.xz
34+
if-no-files-found: error
35+
retention-days: 1
36+
- name: Upload checksum
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: ${{ matrix.target }}.tar.xz.sha256
40+
path: ${{ matrix.target }}.tar.xz.sha256
41+
if-no-files-found: error
42+
retention-days: 1
43+
44+
release:
45+
name: Release
46+
runs-on: ubuntu-22.04
47+
needs:
48+
- build
49+
if: github.event_name == 'release'
50+
steps:
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 1
55+
- name: Download artifacts
56+
uses: actions/download-artifact@v4
57+
with:
58+
path: release
59+
pattern: "*.tar.*"
60+
merge-multiple: true
61+
- name: Generate checksums
62+
run: |
63+
echo "| Filename | Sha256sum |" > RELEASE.md
64+
echo "| -------- | --------- |" >> RELEASE.md
65+
for i in release/*.sha256; do
66+
echo "| $(basename $i .sha256) | $(cat $i) |" >> RELEASE.md
67+
done
68+
- name: Upload artifacts
69+
env:
70+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
for i in release/*.tar.xz; do
73+
gh release upload ${{ github.event.release.tag_name }} $i $i.sha256
74+
done
75+
gh release edit ${{ github.event.release.tag_name }} -F RELEASE.md

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "builder"]
2+
path = builder
3+
url = https://github.com/crosstool-ng/crosstool-ng

License

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024 hev
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# mingw-cross
2+
3+
This is a simple, lightweight project for making cross-compilation toolchain with MinGW.
4+
5+
## Supported targets
6+
7+
| Target | Binutils | GCC | MinGW |
8+
|--------------------------------|----------|--------|--------|
9+
| i686-w64-mingw32 | 2.43.1 | 14.2.0 | 12.0.0 |
10+
| x86_64-w64-mingw32 | 2.43.1 | 14.2.0 | 12.0.0 |
11+
12+
## How to use
13+
14+
Download the tarball from the [release page](https://github.com/cross-tools/mingw-cross/releases) and extract it to `/opt/x-tools`:
15+
16+
```sh
17+
sudo mkdir -p /opt/x-tools
18+
sudo tar -xf ${target}.tar.xz -C /opt/x-tools
19+
```
20+
21+
## How to build
22+
23+
Fork this project and create a new release, or build manually:
24+
25+
```sh
26+
./scripts/make ${target}
27+
```
28+
29+
## License
30+
31+
MIT
32+
33+
## Acknowledgements
34+
35+
We would like to express our gratitude to the following individuals and projects:
36+
37+
- [crosstool-ng](https://github.com/crosstool-ng/crosstool-ng)
38+
- [mingw-w64](https://www.mingw-w64.org)

builder

Submodule builder added at 70c2b00

scripts/make

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
TARGET=$1
6+
7+
# packages
8+
sudo apt-get update
9+
sudo apt-get install -y --no-install-recommends \
10+
automake \
11+
bison \
12+
bzip2 \
13+
ca-certificates \
14+
curl \
15+
file \
16+
flex \
17+
g++ \
18+
gawk \
19+
gdb \
20+
git \
21+
gperf \
22+
help2man \
23+
libncurses-dev \
24+
libssl-dev \
25+
libtool-bin \
26+
make \
27+
patch \
28+
pkg-config \
29+
python3 \
30+
rsync \
31+
texinfo \
32+
unzip \
33+
wget \
34+
xz-utils
35+
36+
# patch
37+
pushd builder
38+
for i in ../targets/${TARGET}/*; do
39+
if [[ $i == *.patch ]]; then
40+
patch -Np1 -i $i
41+
fi
42+
done
43+
popd
44+
45+
# crosstool-ng
46+
if [ ! -e /usr/bin/ct-ng ]; then
47+
pushd builder
48+
./bootstrap
49+
./configure --prefix=/usr
50+
make -j`nproc`
51+
sudo make install
52+
popd
53+
fi
54+
55+
# build
56+
sudo mkdir -p /opt
57+
sudo chmod 0777 /opt
58+
mkdir -p build
59+
cp targets/${TARGET}/config build/.config
60+
pushd build
61+
ct-ng olddefconfig
62+
ct-ng build
63+
popd
64+
65+
# tarball
66+
sudo mv /opt/x-tools/${TARGET} .
67+
sudo chown -R root:root ${TARGET}
68+
sudo tar -cJvf ${TARGET}.tar.xz ${TARGET}
69+
sudo sha256sum ${TARGET}.tar.xz | awk '{ print $1 }' > ${TARGET}.tar.xz.sha256
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
From 4662d36343479db4f6a5de0b4bc0e1d72e6fc733 Mon Sep 17 00:00:00 2001
2+
From: hev <r@hev.cc>
3+
Date: Sun, 17 Mar 2024 19:35:45 +0800
4+
Subject: [PATCH] linux: Fix libc-compat
5+
6+
---
7+
...t-add-fallback-for-unsupported-libcs.patch | 136 ++++++++++++++++++
8+
1 file changed, 136 insertions(+)
9+
create mode 100644 packages/linux/4.4.302/0001-uapi-libc-compat-add-fallback-for-unsupported-libcs.patch
10+
11+
diff --git a/packages/linux/4.4.302/0001-uapi-libc-compat-add-fallback-for-unsupported-libcs.patch b/packages/linux/4.4.302/0001-uapi-libc-compat-add-fallback-for-unsupported-libcs.patch
12+
new file mode 100644
13+
index 00000000..ba7381ab
14+
--- /dev/null
15+
+++ b/packages/linux/4.4.302/0001-uapi-libc-compat-add-fallback-for-unsupported-libcs.patch
16+
@@ -0,0 +1,136 @@
17+
+From e3b2249821c579b72ddc0a6596cf597b9460ee04 Mon Sep 17 00:00:00 2001
18+
+From: Felix Janda <felix.janda@posteo.de>
19+
+Date: Mon, 1 Jan 2018 19:33:20 +0100
20+
+Subject: [PATCH] uapi libc compat: add fallback for unsupported libcs
21+
+
22+
+libc-compat.h aims to prevent symbol collisions between uapi and libc
23+
+headers for each supported libc. This requires continuous coordination
24+
+between them.
25+
+
26+
+The goal of this commit is to improve the situation for libcs (such as
27+
+musl) which are not yet supported and/or do not wish to be explicitly
28+
+supported, while not affecting supported libcs. More precisely, with
29+
+this commit, unsupported libcs can request the suppression of any
30+
+specific uapi definition by defining the correspondings _UAPI_DEF_*
31+
+macro as 0. This can fix symbol collisions for them, as long as the
32+
+libc headers are included before the uapi headers. Inclusion in the
33+
+other order is outside the scope of this commit.
34+
+
35+
+All infrastructure in order to enable this fallback for unsupported
36+
+libcs is already in place, except that libc-compat.h unconditionally
37+
+defines all _UAPI_DEF_* macros to 1 for all unsupported libcs so that
38+
+any previous definitions are ignored. In order to fix this, this commit
39+
+merely makes these definitions conditional.
40+
+
41+
+This commit together with the musl libc commit
42+
+
43+
+http://git.musl-libc.org/cgit/musl/commit/?id=04983f2272382af92eb8f8838964ff944fbb8258
44+
+
45+
+fixes for example the following compiler errors when <linux/in6.h> is
46+
+included after musl's <netinet/in.h>:
47+
+
48+
+./linux/in6.h:32:8: error: redefinition of 'struct in6_addr'
49+
+./linux/in6.h:49:8: error: redefinition of 'struct sockaddr_in6'
50+
+./linux/in6.h:59:8: error: redefinition of 'struct ipv6_mreq'
51+
+
52+
+The comments referencing glibc are still correct, but this file is not
53+
+only used for glibc any more.
54+
+
55+
+Signed-off-by: Felix Janda <felix.janda@posteo.de>
56+
+Reviewed-by: Hauke Mehrtens <hauke@hauke-m.de>
57+
+Signed-off-by: David S. Miller <davem@davemloft.net>
58+
+---
59+
+ include/uapi/linux/libc-compat.h | 45 +++++++++++++++++++++++++++++++-
60+
+ 1 file changed, 44 insertions(+), 1 deletion(-)
61+
+
62+
+diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h
63+
+index e4f048ee..93956d13 100644
64+
+--- a/include/uapi/linux/libc-compat.h
65+
++++ b/include/uapi/linux/libc-compat.h
66+
+@@ -148,39 +148,82 @@
67+
+
68+
+ /* If we did not see any headers from any supported C libraries,
69+
+ * or we are being included in the kernel, then define everything
70+
+- * that we need. */
71+
++ * that we need. Check for previous __UAPI_* definitions to give
72+
++ * unsupported C libraries a way to opt out of any kernel definition. */
73+
+ #else /* !defined(__GLIBC__) */
74+
+
75+
+ /* Definitions for if.h */
76+
++#ifndef __UAPI_DEF_IF_IFCONF
77+
+ #define __UAPI_DEF_IF_IFCONF 1
78+
++#endif
79+
++#ifndef __UAPI_DEF_IF_IFMAP
80+
+ #define __UAPI_DEF_IF_IFMAP 1
81+
++#endif
82+
++#ifndef __UAPI_DEF_IF_IFNAMSIZ
83+
+ #define __UAPI_DEF_IF_IFNAMSIZ 1
84+
++#endif
85+
++#ifndef __UAPI_DEF_IF_IFREQ
86+
+ #define __UAPI_DEF_IF_IFREQ 1
87+
++#endif
88+
+ /* Everything up to IFF_DYNAMIC, matches net/if.h until glibc 2.23 */
89+
++#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS
90+
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1
91+
++#endif
92+
+ /* For the future if glibc adds IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO */
93+
++#ifndef __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO
94+
+ #define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO 1
95+
++#endif
96+
+
97+
+ /* Definitions for in.h */
98+
++#ifndef __UAPI_DEF_IN_ADDR
99+
+ #define __UAPI_DEF_IN_ADDR 1
100+
++#endif
101+
++#ifndef __UAPI_DEF_IN_IPPROTO
102+
+ #define __UAPI_DEF_IN_IPPROTO 1
103+
++#endif
104+
++#ifndef __UAPI_DEF_IN_PKTINFO
105+
+ #define __UAPI_DEF_IN_PKTINFO 1
106+
++#endif
107+
++#ifndef __UAPI_DEF_IP_MREQ
108+
+ #define __UAPI_DEF_IP_MREQ 1
109+
++#endif
110+
++#ifndef __UAPI_DEF_SOCKADDR_IN
111+
+ #define __UAPI_DEF_SOCKADDR_IN 1
112+
++#endif
113+
++#ifndef __UAPI_DEF_IN_CLASS
114+
+ #define __UAPI_DEF_IN_CLASS 1
115+
++#endif
116+
+
117+
+ /* Definitions for in6.h */
118+
++#ifndef __UAPI_DEF_IN6_ADDR
119+
+ #define __UAPI_DEF_IN6_ADDR 1
120+
++#endif
121+
++#ifndef __UAPI_DEF_IN6_ADDR_ALT
122+
+ #define __UAPI_DEF_IN6_ADDR_ALT 1
123+
++#endif
124+
++#ifndef __UAPI_DEF_SOCKADDR_IN6
125+
+ #define __UAPI_DEF_SOCKADDR_IN6 1
126+
++#endif
127+
++#ifndef __UAPI_DEF_IPV6_MREQ
128+
+ #define __UAPI_DEF_IPV6_MREQ 1
129+
++#endif
130+
++#ifndef __UAPI_DEF_IPPROTO_V6
131+
+ #define __UAPI_DEF_IPPROTO_V6 1
132+
++#endif
133+
++#ifndef __UAPI_DEF_IPV6_OPTIONS
134+
+ #define __UAPI_DEF_IPV6_OPTIONS 1
135+
++#endif
136+
++#ifndef __UAPI_DEF_IN6_PKTINFO
137+
+ #define __UAPI_DEF_IN6_PKTINFO 1
138+
++#endif
139+
++#ifndef __UAPI_DEF_IP6_MTUINFO
140+
+ #define __UAPI_DEF_IP6_MTUINFO 1
141+
++#endif
142+
+
143+
+ /* Definitions for xattr.h */
144+
++#ifndef __UAPI_DEF_XATTR
145+
+ #define __UAPI_DEF_XATTR 1
146+
++#endif
147+
+
148+
+ #endif /* __GLIBC__ */
149+
+
150+
+--
151+
+2.25.1
152+
+
153+
--
154+
2.44.0
155+

targets/i686-w64-mingw32/config

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CT_CONFIG_VERSION="4"
2+
CT_EXPERIMENTAL=y
3+
CT_PREFIX_DIR="/opt/x-tools/${CT_TARGET}"
4+
# CT_LOG_PROGRESS_BAR is not set
5+
CT_ARCH_X86=y
6+
CT_ARCH_ARCH="i686"
7+
CT_TARGET_VENDOR="w64"
8+
CT_KERNEL_WINDOWS=y
9+
CT_BINUTILS_LINKER_LD_GOLD=y
10+
CT_BINUTILS_GOLD_THREADS=y
11+
CT_BINUTILS_LD_WRAPPER=y
12+
CT_BINUTILS_PLUGINS=y
13+
CT_MINGW_DIRECTX=y
14+
CT_MINGW_DDK=y
15+
CT_THREADS_POSIX=y
16+
CT_CC_LANG_CXX=y

0 commit comments

Comments
 (0)