Skip to content

Commit a3a45ce

Browse files
feat: 添加补丁
1 parent 616a132 commit a3a45ce

File tree

3 files changed

+186
-22
lines changed

3 files changed

+186
-22
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
outputs:
1616
app_version: ${{ steps.get-version.outputs.app_version }}
17+
app_build: ${{ steps.check-release.outputs.app_build }}
1718
steps:
1819
- uses: actions/checkout@v4
1920
- uses: docker/setup-buildx-action@v3
@@ -37,6 +38,7 @@ jobs:
3738
id: check-release
3839
run: |
3940
gh release view ${app_version} -R ${{ github.repository }} >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT
41+
gh release view ${app_version} -R ${{ github.repository }} | grep ${{ env.app_name }}-Debian-nw.tar.gz >/dev/null 2>&1 || echo "app_build=1" >> $GITHUB_OUTPUT
4042
env:
4143
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4244

@@ -62,25 +64,15 @@ jobs:
6264
build-binaries:
6365
runs-on: ubuntu-latest
6466
needs: check-binaries
67+
if: ${{ needs.check-binaries.outputs.app_build == '1' }}
6568
env:
6669
app_version: ${{ needs.check-binaries.outputs.app_version }}
6770
steps:
6871
- uses: actions/checkout@v4
69-
with:
70-
ref: ${{ env.app_version }}
71-
7272
- uses: docker/setup-qemu-action@v3
7373
- uses: docker/setup-buildx-action@v3
7474

75-
- name: Check Release
76-
id: create-binaries
77-
run: |
78-
gh release view ${{ env.app_version }} -R ${{ github.repository }} | grep ${{ env.app_name }}-x86_64 >/dev/null 2>&1 || echo "create=1" >> $GITHUB_OUTPUT
79-
env:
80-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81-
8275
- name: Cache Docker layers
83-
if : steps.create-binaries.outputs.create == '1'
8476
uses: actions/cache@v4
8577
with:
8678
path: /tmp/.buildx-cache
@@ -89,12 +81,10 @@ jobs:
8981
${{ runner.os }}-buildx-
9082
9183
- name: Build Binaries
92-
if : steps.create-binaries.outputs.create == '1'
9384
run: |
94-
docker buildx build --platform linux/loong64 -t ${{ env.app_name }}-debian-loong64:${{ env.app_version }} --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max debian --load
85+
docker buildx build --platform linux/loong64 --build-arg VERSION=${{ env.app_version }} -t ${{ env.app_name }}-debian-loong64:${{ env.app_version }} --cache-from=type=local,src=/tmp/.buildx-cache --cache-to=type=local,dest=/tmp/.buildx-cache-new,mode=max debian --load
9586
9687
- name: Upgrade Release
97-
if : steps.create-binaries.outputs.create == '1'
9888
run: |
9989
docker run --rm -v $(pwd)/dist:/dist ${{ env.app_name }}-debian-loong64:${{ env.app_version }}
10090
ls -al dist
@@ -103,7 +93,6 @@ jobs:
10393
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10494

10595
- name: Move cache
106-
if : steps.create-binaries.outputs.create == '1'
10796
run: |
10897
rm -rf /tmp/.buildx-cache
10998
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

debian/Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
FROM ghcr.io/loong64/debian:trixie-slim AS build-lat
22
ARG TARGETARCH
33

4-
# git ninja-build libssl-dev libc6 gcc g++ pkg-config libglib2.0-dev libdrm-dev lsb-release make python3-setuptools
54
ARG DEPENDENCIES=" \
65
ccache \
76
curl \
@@ -11,6 +10,7 @@ ARG DEPENDENCIES=" \
1110
libc6 \
1211
libdrm-dev \
1312
libglib2.0-dev \
13+
libkeyutils-dev \
1414
libssl-dev \
1515
lsb-release \
1616
make \
@@ -23,28 +23,31 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
2323
apt-get update \
2424
&& apt-get install -y ${DEPENDENCIES}
2525

26-
ARG VERSION=master
26+
ARG VERSION
2727
ARG WORKDIR=/opt/lat
2828

2929
WORKDIR ${WORKDIR}
3030

3131
RUN set -ex \
32-
&& git clone --depth=1 --recursive --branch ${VERSION} https://github.com/lat-opensource/lat ${WORKDIR} \
33-
&& curl -sSL "https://github.com/lat-opensource/lat/commit/27026fb60dc1707962539d8887ee4a9e4fb7d3ed.patch" | git apply
32+
&& git clone --depth=1 --recursive --branch master https://github.com/lat-opensource/lat ${WORKDIR}
3433

3534
ENV USE_CCACHE=1
35+
ADD lat_loong64.patch /opt/lat_loong64.patch
3636

3737
RUN --mount=type=cache,target=/root/.cache/ccache \
38-
cd latxbuild && ./build-release-nw.sh
38+
git apply /opt/lat_loong64.patch \
39+
&& sed -i 's@rm -rf@# rm -rf@g' latxbuild/build-release-nw.sh \
40+
&& cd latxbuild \
41+
&& ./build-release-nw.sh
3942

4043
FROM ghcr.io/loong64/debian:trixie-slim
4144
ARG TARGETARCH
4245

4346
WORKDIR /opt/dist
4447

45-
COPY --from=build-lat /opt/lat/lat-Debian-nw /opt/dist/lat-Debian-nw
48+
COPY --from=build-lat /opt/lat/lat-Debian-nw.tar.gz /opt/dist/
4649

47-
RUN tar -czf lat-Debian-nw.tar.gz lat-Debian-nw
50+
RUN sha256sum lat-Debian-nw.tar.gz > lat-Debian-nw.tar.gz.sha256sum
4851

4952
VOLUME /dist
5053

debian/lat_loong64.patch

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c
2+
index 6750da5..2e16f0f 100644
3+
--- a/accel/tcg/translate-all.c
4+
+++ b/accel/tcg/translate-all.c
5+
@@ -4607,6 +4607,7 @@ int shared_private_interpret(siginfo_t *info, ucontext_t *uc)
6+
*(int64_t *)(mem_addr + 24) = UC_GET_LASX(&extctx, fd, 3, int64_t);
7+
goto end;
8+
#endif
9+
+#ifndef CONFIG_LOONGARCH_NEW_WORLD
10+
case 0xc0:
11+
if (inst & (1<<21)) {
12+
/*VLDREPL.W*/
13+
@@ -4634,6 +4635,7 @@ int shared_private_interpret(siginfo_t *info, ucontext_t *uc)
14+
*((int8_t *)&UC_FREG(uc)[fd].__val32[i] + 3) = *(int8_t *)mem_addr;
15+
}
16+
goto end;
17+
+#endif
18+
case 0xb8: /* LDL.W */
19+
case 0xb9: /* LDR.W */
20+
case 0xba: /* LDL.D */
21+
diff --git a/include/loongarch-extcontext.h b/include/loongarch-extcontext.h
22+
index 461345e..3a6ae91 100644
23+
--- a/include/loongarch-extcontext.h
24+
+++ b/include/loongarch-extcontext.h
25+
@@ -5,6 +5,8 @@
26+
*/
27+
#ifndef LOONGARCH_EXTCONTEXT_H
28+
#define LOONGARCH_EXTCONTEXT_H
29+
+#include "config-host.h"
30+
+
31+
#if defined(CONFIG_LOONGARCH_NEW_WORLD) && defined(__loongarch__)
32+
#include "qemu/osdep.h"
33+
#include "asm/sigcontext.h"
34+
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
35+
index db088ce..8612c75 100644
36+
--- a/include/qemu/osdep.h
37+
+++ b/include/qemu/osdep.h
38+
@@ -27,15 +27,22 @@
39+
#ifndef QEMU_OSDEP_H
40+
#define QEMU_OSDEP_H
41+
42+
+#include "config-host.h"
43+
+
44+
/* arch dependent signal context retriev macros */
45+
#if defined(__mips__)
46+
#define UC_GR(uc) ((uc)->uc_mcontext.gregs)
47+
#define UC_PC(uc) ((uc)->uc_mcontext.pc)
48+
#elif defined(__loongarch__)
49+
+#ifdef CONFIG_LOONGARCH_NEW_WORLD
50+
#define UC_GR(uc) ((uc)->uc_mcontext.__gregs)
51+
#define UC_PC(uc) ((uc)->uc_mcontext.__pc)
52+
-#define UC_FREG(uc) ((uc)->uc_mcontext.__fpregs)
53+
-#define UC_FCSR(uc) ((uc)->uc_mcontext.__fcsr)
54+
+#else
55+
+ #define UC_GR(uc) ((uc)->uc_mcontext.sc_regs)
56+
+ #define UC_PC(uc) ((uc)->uc_mcontext.sc_pc)
57+
+ #define UC_FREG(uc) ((uc)->uc_mcontext.__fpregs)
58+
+ #define UC_FCSR(uc) ((uc)->uc_mcontext.__fcsr)
59+
+#endif
60+
#else
61+
#error "unknown arch"
62+
#endif
63+
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
64+
index 76ae0b5..a46f6f6 100644
65+
--- a/linux-user/syscall_defs.h
66+
+++ b/linux-user/syscall_defs.h
67+
@@ -1527,8 +1527,15 @@ struct target_winsize {
68+
#include "termbits.h"
69+
70+
#define HUGETLB_FLAG_ENCODE_SHIFT 26
71+
+
72+
+#ifndef MAP_HUGE_2MB
73+
#define MAP_HUGE_2MB (21 << HUGETLB_FLAG_ENCODE_SHIFT)
74+
+#endif
75+
+
76+
+#ifndef MAP_HUGE_1GB
77+
#define MAP_HUGE_1GB (30 << HUGETLB_FLAG_ENCODE_SHIFT)
78+
+#endif
79+
+
80+
#define LEGACY_MAP_MASK (TARGET_MAP_SHARED \
81+
| TARGET_MAP_PRIVATE \
82+
| TARGET_MAP_FIXED \
83+
diff --git a/meson.build b/meson.build
84+
index a30002f..074aa3a 100644
85+
--- a/meson.build
86+
+++ b/meson.build
87+
@@ -17,9 +17,9 @@ cc = meson.get_compiler('c')
88+
config_host = keyval.load(meson.current_build_dir() / 'config-host.mak')
89+
enable_static = 'CONFIG_STATIC' in config_host
90+
91+
-latx_version_h = vcs_tag(command : ['git', 'describe'],
92+
+latx_version_h = vcs_tag(command : ['cat', 'VERSION'],
93+
fallback : 'unknown',
94+
- input : 'linux-user/latx-version.h.in',
95+
+ input : 'linux-user/latx-version.h.in',
96+
output :'latx-version.h')
97+
# Allow both shared and static libraries unless --enable-static
98+
static_kwargs = enable_static ? {'static': true} : {}
99+
@@ -206,7 +206,10 @@ config_host_data.set('CONFIG_MALLOC_TRIM', has_malloc_trim)
100+
lsb_release = find_program('lsb_release', required: false)
101+
if lsb_release.found()
102+
lsb_release_output = run_command('lsb_release', '-si').stdout().strip()
103+
- if lsb_release_output == 'Loongnix'
104+
+ if lsb_release_output == 'Debian'
105+
+ config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
106+
+ config_host_data.set('IS_DEBIAN', 'true')
107+
+ elif lsb_release_output == 'Loongnix'
108+
config_host_data.set('HAVE_DRM_H', cc.has_header('libdrm/drm.h'))
109+
config_host_data.set('IS_LOONGNIX', 'true')
110+
elif lsb_release_output == 'Arch'
111+
diff --git a/target/i386/latx/context/myalign.c b/target/i386/latx/context/myalign.c
112+
index 62698d0..3695113 100644
113+
--- a/target/i386/latx/context/myalign.c
114+
+++ b/target/i386/latx/context/myalign.c
115+
@@ -1,3 +1,4 @@
116+
+#include "config-host.h"
117+
#include "lsenv.h"
118+
#include "myalign.h"
119+
#include "elfloader.h"
120+
diff --git a/target/i386/latx/context/wrappedlibc.c b/target/i386/latx/context/wrappedlibc.c
121+
index 3cfe2ac..fa5b70c 100644
122+
--- a/target/i386/latx/context/wrappedlibc.c
123+
+++ b/target/i386/latx/context/wrappedlibc.c
124+
@@ -1,3 +1,4 @@
125+
+#include "config-host.h"
126+
#define _LARGEFILE_SOURCE 1
127+
#define _FILE_OFFSET_BITS 64
128+
#include <stdlib.h>
129+
diff --git a/target/i386/latx/include/generated/wrappedlibctypes.h b/target/i386/latx/include/generated/wrappedlibctypes.h
130+
index 88c1867..92258aa 100644
131+
--- a/target/i386/latx/include/generated/wrappedlibctypes.h
132+
+++ b/target/i386/latx/include/generated/wrappedlibctypes.h
133+
@@ -4,6 +4,8 @@
134+
#ifndef __wrappedlibcTYPES_H_
135+
#define __wrappedlibcTYPES_H_
136+
137+
+#include "config-host.h"
138+
+
139+
#ifndef LIBNAME
140+
#error You should only #include this file inside a wrapped*.c file
141+
#endif
142+
diff --git a/target/i386/latx/include/library_list.h b/target/i386/latx/include/library_list.h
143+
index f14793f..01638dd 100755
144+
--- a/target/i386/latx/include/library_list.h
145+
+++ b/target/i386/latx/include/library_list.h
146+
@@ -2,6 +2,8 @@
147+
#error Nope
148+
#endif
149+
150+
+#include "config-host.h"
151+
+
152+
GO("libEGL.so.1", libegl)
153+
#ifndef CONFIG_LOONGARCH_NEW_WORLD
154+
GO("libdl.so.2", libdl)
155+
diff --git a/target/i386/latx/include/wrappedlibc_private.h b/target/i386/latx/include/wrappedlibc_private.h
156+
index 2b63178..f836a95 100644
157+
--- a/target/i386/latx/include/wrappedlibc_private.h
158+
+++ b/target/i386/latx/include/wrappedlibc_private.h
159+
@@ -1,3 +1,4 @@
160+
+#include "config-host.h"
161+
#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA) && defined(GOS))
162+
#error Meh...
163+
#endif
164+
diff --git a/target/i386/latx/latx-config.c b/target/i386/latx/latx-config.c
165+
index 5a6d98f..aadcc68 100644
166+
--- a/target/i386/latx/latx-config.c
167+
+++ b/target/i386/latx/latx-config.c
168+
@@ -1,3 +1,4 @@
169+
+#include "config-host.h"
170+
#include "common.h"
171+
#include "diStorm/distorm.h"
172+
#include "ir1.h"

0 commit comments

Comments
 (0)