Skip to content

Commit bc09529

Browse files
committed
external_deps: rebuild nacl_loader for Linux amd64
Add the naclruntime target to external_deps/build.sh. It builds nacl_loader and nacl_helper_bootstrap. This uses our version of the native_client repository with a hacked build script that lets us build native binaries without Chromium tools. The build brings two dependencies: LLVM and SCons. Fixes #1504 (NaCl crash handling doesn't work with recent Linux kernels.)
1 parent 06a1171 commit bc09529

File tree

1 file changed

+43
-4
lines changed

1 file changed

+43
-4
lines changed

external_deps/build.sh

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ OPUS_BASEURL='https://downloads.xiph.org/releases/opus'
3838
OPUSFILE_BASEURL='https://downloads.xiph.org/releases/opus'
3939
# No index.
4040
NACLSDK_BASEURL='https://storage.googleapis.com/nativeclient-mirror/nacl/nacl_sdk'
41+
# No index.
42+
NACLRUNTIME_BASEURL='https://api.github.com/repos/DaemonEngine/native_client/zipball'
4143
NCURSES_BASEURL='https://ftpmirror.gnu.org/gnu/ncurses'
4244
WASISDK_BASEURL='https://github.com/WebAssembly/wasi-sdk/releases'
4345
WASMTIME_BASEURL='https://github.com/bytecodealliance/wasmtime/releases'
@@ -60,6 +62,7 @@ VORBIS_VERSION=1.3.7
6062
OPUS_VERSION=1.4
6163
OPUSFILE_VERSION=0.12
6264
NACLSDK_VERSION=44.0.2403.155
65+
NACLRUNTIME_REVISION=2aea5fcfce504862a825920fcaea1a8426afbd6f
6366
NCURSES_VERSION=6.2
6467
WASISDK_VERSION=16.0
6568
WASMTIME_VERSION=2.0.2
@@ -790,9 +793,15 @@ build_naclsdk() {
790793

791794
"${download_only}" && return
792795

793-
cp pepper_*"/tools/sel_ldr_${NACLSDK_ARCH}${EXE}" "${PREFIX}/nacl_loader${EXE}"
794796
cp pepper_*"/tools/irt_core_${NACLSDK_ARCH}.nexe" "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe"
795797
case "${PLATFORM}" in
798+
linux-amd64-*)
799+
;; # Get sel_ldr from naclruntime package
800+
*)
801+
cp pepper_*"/tools/sel_ldr_${NACLSDK_ARCH}${EXE}" "${PREFIX}/nacl_loader${EXE}"
802+
;;
803+
esac
804+
case "${PLATFORM}" in
796805
windows-i686-*|*-amd64-*)
797806
cp pepper_*"/toolchain/${NACLSDK_PLATFORM}_x86_newlib/bin/x86_64-nacl-gdb${EXE}" "${PREFIX}/nacl-gdb${EXE}"
798807

@@ -816,7 +825,11 @@ build_naclsdk() {
816825
cp pepper_*"/tools/sel_ldr_x86_64.exe" "${PREFIX}/nacl_loader-amd64.exe"
817826
cp pepper_*"/tools/irt_core_x86_64.nexe" "${PREFIX}/irt_core-amd64.nexe"
818827
;;
819-
linux-amd64-*|linux-i686-*)
828+
linux-amd64-*)
829+
# Fix permissions on a few files which deny access to non-owner
830+
chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe"
831+
;;
832+
linux-i686-*)
820833
cp pepper_*"/tools/nacl_helper_bootstrap_${NACLSDK_ARCH}" "${PREFIX}/nacl_helper_bootstrap"
821834
# Fix permissions on a few files which deny access to non-owner
822835
chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe"
@@ -843,6 +856,31 @@ build_naclsdk() {
843856
esac
844857
}
845858

859+
# Only builds nacl_loader and nacl_helper_bootstrap for now, not IRT.
860+
build_naclruntime() {
861+
case "${PLATFORM}" in
862+
linux-amd64-*)
863+
local NACL_ARCH=x86-64
864+
;;
865+
*)
866+
log error 'Unsupported platform for naclruntime'
867+
;;
868+
esac
869+
870+
local dir_name="DaemonEngine-native_client-${NACLRUNTIME_REVISION:0:7}"
871+
local archive_name="native_client-${NACLRUNTIME_REVISION}.zip"
872+
873+
download_extract naclruntime "${archive_name}" \
874+
"{$NACLRUNTIME_BASEURL}/${NACLRUNTIME_REVISION}"
875+
876+
"${download_only}" && return
877+
878+
cd "${dir_name}"
879+
scons --mode=opt-linux "platform=${NACL_ARCH}" werror=0 sysinfo=0 sel_ldr
880+
cp "scons-out/opt-linux-${NACL_ARCH}/staging/nacl_helper_bootstrap" "${PREFIX}/nacl_helper_bootstrap"
881+
cp "scons-out/opt-linux-${NACL_ARCH}/staging/sel_ldr" "${PREFIX}/nacl_loader"
882+
}
883+
846884
# The import libraries generated by MinGW seem to have issues, so we use LLVM's version instead.
847885
# So LLVM must be installed, e.g. 'sudo apt install llvm'
848886
build_genlib() {
@@ -1117,8 +1155,8 @@ all_windows_i686_mingw_packages="${base_windows_amd64_mingw_packages}"
11171155
base_macos_amd64_default_packages='pkgconfig nasm gmp nettle sdl2 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk'
11181156
all_macos_amd64_default_packages="${base_macos_amd64_default_packages}"
11191157

1120-
base_linux_amd64_default_packages='naclsdk'
1121-
all_linux_amd64_default_packages='zlib gmp nettle curl sdl2 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk'
1158+
base_linux_amd64_default_packages='naclsdk naclruntime'
1159+
all_linux_amd64_default_packages='zlib gmp nettle curl sdl2 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime'
11221160

11231161
base_linux_i686_default_packages="${base_linux_amd64_default_packages}"
11241162
all_linux_i686_default_packages="${all_linux_amd64_default_packages}"
@@ -1224,6 +1262,7 @@ fi
12241262

12251263
# Enable parallel build
12261264
export MAKEFLAGS="-j`nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1`"
1265+
export SCONSFLAGS="${MAKEFLAGS}"
12271266

12281267
# Setup platform
12291268
platform="${1}"; shift

0 commit comments

Comments
 (0)