Skip to content

Commit 92665aa

Browse files
authored
Merge pull request TermonyHQ#108 from hackeris/x86-64
support build for x86_64, works in Emulator of DevEco Studio
2 parents 0570129 + e8b290f commit 92665aa

73 files changed

Lines changed: 274 additions & 91 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/hnp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
- name: Build hnp
6565
shell: bash
6666
run: |
67-
USE_CCACHE=1 make -C build-hnp
67+
USE_CCACHE=1 OHOS_ARCH=aarch64 OHOS_ABI=arm64-v8a make -C build-hnp
6868
6969
- name: Upload hnp
7070
uses: actions/upload-artifact@v4

build-hnp/Makefile

Lines changed: 80 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
ifeq ($(OHOS_ARCH),aarch64)
12
PKGS=gettext \
23
bash \
34
binutils \
@@ -62,14 +63,81 @@ PKGS=gettext \
6263
libogg \
6364
libvorbis \
6465
ffmpeg
66+
else ifeq ($(OHOS_ARCH),x86_64)
67+
PKGS=gettext \
68+
bash \
69+
binutils \
70+
busybox \
71+
coremark \
72+
lz4 \
73+
make \
74+
ncurses \
75+
talloc \
76+
openssl \
77+
zstd \
78+
pcre2 \
79+
zlib \
80+
libarchive \
81+
proot \
82+
strace \
83+
tar \
84+
tree \
85+
vim \
86+
xxhash \
87+
libunistring \
88+
libidn2 \
89+
c-ares \
90+
curl \
91+
yyjson \
92+
fastfetch \
93+
sl \
94+
openssh \
95+
ncnn \
96+
readline \
97+
htop \
98+
vkpeak \
99+
libevent \
100+
tmux \
101+
fish \
102+
elf-loader \
103+
gmp \
104+
mpfr \
105+
mpc \
106+
gcc \
107+
expat \
108+
git \
109+
aria2 \
110+
xz \
111+
python \
112+
libusb \
113+
hdc \
114+
libffi \
115+
glib \
116+
qemu \
117+
qemu-vroot \
118+
libx264 \
119+
libx265 \
120+
libvpx \
121+
libsvt-av1 \
122+
libmp3-lame \
123+
libfdk-aac \
124+
libopus \
125+
libogg \
126+
libvorbis \
127+
ffmpeg
128+
else
129+
echo "Unsupported OHOS_ARCH=$(OHOS_ARCH)"
130+
exit 1
131+
endif
132+
65133
STAMP=$(patsubst %,%/.stamp,$(PKGS))
66134

67135
all: copy
68136

69137
copy: base.hnp
70-
rm -f ../entry/hnp/arm64-v8a/*.hnp
71-
cp $^ ../entry/hnp/arm64-v8a
72-
cp $^ ../entry/hnp/arm64-v8a/base-public.hnp
138+
rm -f ../entry/hnp/$(OHOS_ABI)/*.hnp
139+
cp $^ ../entry/hnp/$(OHOS_ABI)
140+
cp $^ ../entry/hnp/$(OHOS_ABI)/base-public.hnp
73141

74142
base.hnp: $(STAMP) utils/pbcopy utils/pbpaste utils/empty.a Makefile
75143
# reduce size
@@ -80,15 +148,15 @@ base.hnp: $(STAMP) utils/pbcopy utils/pbpaste utils/empty.a Makefile
80148
cp utils/pbcopy sysroot/bin
81149
cp utils/pbpaste sysroot/bin
82150
# let gcc work out of box
83-
mkdir -p sysroot/aarch64-unknown-linux-musl/lib
84-
cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/aarch64-linux-ohos/crt1.o sysroot/aarch64-unknown-linux-musl/lib/crt1.o
85-
cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/aarch64-linux-ohos/crti.o sysroot/aarch64-unknown-linux-musl/lib/crti.o
86-
cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/aarch64-linux-ohos/crtn.o sysroot/aarch64-unknown-linux-musl/lib/crtn.o
87-
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/clang_rt.crtbegin.o sysroot/aarch64-unknown-linux-musl/lib/crtbegin.o
88-
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/clang_rt.crtend.o sysroot/aarch64-unknown-linux-musl/lib/crtend.o
89-
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/libclang_rt.builtins.a sysroot/aarch64-unknown-linux-musl/lib/libgcc.a
90-
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/aarch64-linux-ohos/libclang_rt.builtins.a sysroot/aarch64-unknown-linux-musl/lib/libgcc_s.a
91-
cp utils/empty.a sysroot/aarch64-unknown-linux-musl/lib/libgcc_eh.a
151+
mkdir -p sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib
152+
cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/$(OHOS_ARCH)-linux-ohos/crt1.o sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/crt1.o
153+
cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/$(OHOS_ARCH)-linux-ohos/crti.o sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/crti.o
154+
cp $(OHOS_SDK_HOME)/native/sysroot/usr/lib/$(OHOS_ARCH)-linux-ohos/crtn.o sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/crtn.o
155+
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/$(OHOS_ARCH)-linux-ohos/clang_rt.crtbegin.o sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/crtbegin.o
156+
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/$(OHOS_ARCH)-linux-ohos/clang_rt.crtend.o sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/crtend.o
157+
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/$(OHOS_ARCH)-linux-ohos/libclang_rt.builtins.a sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/libgcc.a
158+
cp $(OHOS_SDK_HOME)/native/llvm/lib/clang/15.0.4/lib/$(OHOS_ARCH)-linux-ohos/libclang_rt.builtins.a sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/libgcc_s.a
159+
cp utils/empty.a sysroot/$(OHOS_ARCH)-unknown-linux-musl/lib/libgcc_eh.a
92160
# create hnp manually
93161
# $(OHOS_SDK_HOME)/toolchains/hnpcli pack -i sysroot -n base -v 1.0
94162
cp hnp.json sysroot

build-hnp/aria2/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include ../utils/Makefrag
33
SOURCE_URL = https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0.tar.gz
44
SOURCE_FILE = aria2-1.37.0.tar.gz
55
SOURCE_DIR = aria2-1.37.0
6-
CONFIG_ARGS = --prefix=$(PREFIX) --host aarch64-unknown-linux-musl --disable-nls --with-openssl --without-gnutls OPENSSL_CFLAGS="-D_FORTIFY_SOURCE=2" OPENSSL_LIBS="-lssl -lcrypto" --with-sysroot=$(OHOS_SDK_HOME)/native/sysroot --enable-libaria2 --with-ca-bundle=/etc/ssl/certs/cacert.pem CFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2 -O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib"
6+
CONFIG_ARGS = --prefix=$(PREFIX) --host $(OHOS_ARCH)-unknown-linux-musl --disable-nls --with-openssl --without-gnutls OPENSSL_CFLAGS="-D_FORTIFY_SOURCE=2" OPENSSL_LIBS="-lssl -lcrypto" --with-sysroot=$(OHOS_SDK_HOME)/native/sysroot --enable-libaria2 --with-ca-bundle=/etc/ssl/certs/cacert.pem CFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2 -O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2" LDFLAGS="-L$(shell pwd)/../sysroot/lib"
77

88
$(eval $(call define_autotools_package))

build-hnp/bash/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export CFLAGS_FOR_BUILD := -std=gnu17
66
SOURCE_URL = $(GNU_MIRROR)/gnu/bash/bash-5.3.tar.gz
77
SOURCE_FILE = bash-5.3.tar.gz
88
SOURCE_DIR = bash-5.3
9-
CONFIG_ARGS = --prefix=$(PREFIX) --host aarch64-unknown-linux-musl --without-bash-malloc --disable-nls
9+
CONFIG_ARGS = --prefix=$(PREFIX) --host $(OHOS_ARCH)-unknown-linux-musl --without-bash-malloc --disable-nls
1010

1111
$(eval $(call define_autotools_package))

build-hnp/binutils/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include ../utils/Makefrag
33
SOURCE_URL = $(GNU_MIRROR)/gnu/binutils/binutils-2.44.tar.xz
44
SOURCE_FILE = binutils-2.44.tar.xz
55
SOURCE_DIR = binutils-2.44
6-
CONFIG_ARGS = --prefix=$(PREFIX) --disable-static --enable-shared --host aarch64-unknown-linux-musl
6+
CONFIG_ARGS = --prefix=$(PREFIX) --disable-static --enable-shared --host $(OHOS_ARCH)-unknown-linux-musl
77

88
$(eval $(call define_autotools_package))

build-hnp/busybox/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ all: download/busybox-1.37.0.tar.bz2
2525
cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/if (setgid(gid))/\\/\\//" libbb/xfuncs_printf.c
2626
cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/setgid(rgid)/\\/\\//" libbb/appletlib.c
2727
cd temp/busybox-1.37.0 && /usr/bin/sed -i.bak "s/setuid(ruid)/\\/\\//" libbb/appletlib.c
28-
cd temp/busybox-1.37.0 && make -j $(shell nproc) CC=$(OHOS_SDK_HOME)/native/llvm/bin/aarch64-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar CFLAGS="-Wno-int-conversion" busybox_unstripped
28+
cd temp/busybox-1.37.0 && make -j $(shell nproc) CC=$(OHOS_SDK_HOME)/native/llvm/bin/$(OHOS_ARCH)-unknown-linux-ohos-clang AR=$(OHOS_SDK_HOME)/native/llvm/bin/llvm-ar CFLAGS="-Wno-int-conversion" busybox_unstripped
2929
$(OHOS_SDK_HOME)/native/llvm/bin/llvm-strip temp/busybox-1.37.0/busybox_unstripped
3030
mkdir -p ../sysroot/bin
3131
cp -v temp/busybox-1.37.0/busybox_unstripped ../sysroot/bin/busybox | tee file.lst

build-hnp/c-ares/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include ../utils/Makefrag
33
SOURCE_URL = https://github.com/c-ares/c-ares/releases/download/v1.34.5/c-ares-1.34.5.tar.gz
44
SOURCE_FILE = c-ares-1.34.5.tar.gz
55
SOURCE_DIR = c-ares-1.34.5
6-
CMAKE_ARGS = -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCARES_STATIC=OFF -DCARES_SHARED=ON -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_BUILD_TYPE=RelWithDebInfo
6+
CMAKE_ARGS = -DCMAKE_INSTALL_PREFIX=$(PREFIX) -DCARES_STATIC=OFF -DCARES_SHARED=ON -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_SYSTEM_PROCESSOR=$(OHOS_ARCH) -DCMAKE_BUILD_TYPE=RelWithDebInfo
77

88
$(eval $(call define_cmake_package))

build-hnp/curl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include ../utils/Makefrag
33
SOURCE_URL = https://github.com/curl/curl/releases/download/curl-8_14_1/curl-8.14.1.tar.xz
44
SOURCE_FILE = curl-8.14.1.tar.xz
55
SOURCE_DIR = curl-8.14.1
6-
CONFIG_ARGS = --prefix=$(PREFIX) --host aarch64-unknown-linux-musl --without-libssh --without-libssh2 --without-libpsl --with-libidn2 --enable-ares --without-nghttp2 --without-brotli --without-zstd --without-libgsasl --enable-shared --disable-static --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --disable-unix-sockets --with-ca-path=/etc/ssl/certs --with-ca-bundle=/etc/ssl/certs/cacert.pem --disable-http-auth-gssnegotiate --disable-mqtt --disable-nls --disable-proxy --enable-optimize --with-ssl CFLAGS="-O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2"
6+
CONFIG_ARGS = --prefix=$(PREFIX) --host $(OHOS_ARCH)-unknown-linux-musl --without-libssh --without-libssh2 --without-libpsl --with-libidn2 --enable-ares --without-nghttp2 --without-brotli --without-zstd --without-libgsasl --enable-shared --disable-static --disable-ldap --disable-ldaps --disable-rtsp --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-manual --disable-unix-sockets --with-ca-path=/etc/ssl/certs --with-ca-bundle=/etc/ssl/certs/cacert.pem --disable-http-auth-gssnegotiate --disable-mqtt --disable-nls --disable-proxy --enable-optimize --with-ssl CFLAGS="-O2 -g -pipe -fstack-protector-strong -fno-omit-frame-pointer" CPPFLAGS="-I$(shell pwd)/../sysroot/include -D_FORTIFY_SOURCE=2"
77

88
$(eval $(call define_autotools_package))

build-hnp/elf-loader/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ all: download/elf
55
mkdir -p temp build/bin
66
cd temp && cp -vr ../download/elf elf
77
cd temp/elf && git apply ../../jit.patch
8+
ifeq ($(OHOS_ARCH),aarch64)
89
cd temp/elf && make -C src ARCH=aarch64 CFLAGS="-ffreestanding -DELFCLASS=ELFCLASS64"
10+
else ifeq ($(OHOS_ARCH),x86_64)
11+
cd temp/elf && make -C src ARCH=amd64 CFLAGS="-ffreestanding -DELFCLASS=ELFCLASS64"
12+
else
13+
echo "Unsupported OHOS_ARCH=$(OHOS_ARCH)"
14+
exit 1
15+
endif
916
cp temp/elf/src/loader ./build/bin/
1017
mkdir -p ../sysroot
1118
cp -rv ./build/. ../sysroot | tee file.lst

build-hnp/expat/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ include ../utils/Makefrag
33
SOURCE_URL = https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz
44
SOURCE_FILE = expat-2.7.1.tar.xz
55
SOURCE_DIR = expat-2.7.1
6-
CONFIG_ARGS = --prefix=$(PREFIX) --disable-static --enable-shared --host aarch64-unknown-linux-musl
6+
CONFIG_ARGS = --prefix=$(PREFIX) --disable-static --enable-shared --host $(OHOS_ARCH)-unknown-linux-musl
77

88
$(eval $(call define_autotools_package))

0 commit comments

Comments
 (0)