Skip to content

Commit bfb4be2

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 bfb4be2

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

external_deps/build.sh

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ 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+
NACLRUNTIME_BASEURL='https://api.github.com/repos/DaemonEngine/native_client/zipball'
4142
NCURSES_BASEURL='https://ftpmirror.gnu.org/gnu/ncurses'
4243
WASISDK_BASEURL='https://github.com/WebAssembly/wasi-sdk/releases'
4344
WASMTIME_BASEURL='https://github.com/bytecodealliance/wasmtime/releases'
@@ -60,6 +61,7 @@ VORBIS_VERSION=1.3.7
6061
OPUS_VERSION=1.4
6162
OPUSFILE_VERSION=0.12
6263
NACLSDK_VERSION=44.0.2403.155
64+
NACLRUNTIME_REVISION=2aea5fcfce504862a825920fcaea1a8426afbd6f
6365
NCURSES_VERSION=6.2
6466
WASISDK_VERSION=16.0
6567
WASMTIME_VERSION=2.0.2
@@ -790,9 +792,15 @@ build_naclsdk() {
790792

791793
"${download_only}" && return
792794

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

@@ -816,7 +824,11 @@ build_naclsdk() {
816824
cp pepper_*"/tools/sel_ldr_x86_64.exe" "${PREFIX}/nacl_loader-amd64.exe"
817825
cp pepper_*"/tools/irt_core_x86_64.nexe" "${PREFIX}/irt_core-amd64.nexe"
818826
;;
819-
linux-amd64-*|linux-i686-*)
827+
linux-amd64-*)
828+
# Fix permissions on a few files which deny access to non-owner
829+
chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe"
830+
;;
831+
linux-i686-*)
820832
cp pepper_*"/tools/nacl_helper_bootstrap_${NACLSDK_ARCH}" "${PREFIX}/nacl_helper_bootstrap"
821833
# Fix permissions on a few files which deny access to non-owner
822834
chmod 644 "${PREFIX}/irt_core-${DAEMON_ARCH}.nexe"
@@ -843,6 +855,31 @@ build_naclsdk() {
843855
esac
844856
}
845857

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

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'
1157+
base_linux_amd64_default_packages='naclsdk naclruntime'
1158+
all_linux_amd64_default_packages='zlib gmp nettle curl sdl2 glew png jpeg webp openal ogg vorbis opus opusfile naclsdk naclruntime'
11221159

11231160
base_linux_i686_default_packages="${base_linux_amd64_default_packages}"
11241161
all_linux_i686_default_packages="${all_linux_amd64_default_packages}"
@@ -1224,6 +1261,7 @@ fi
12241261

12251262
# Enable parallel build
12261263
export MAKEFLAGS="-j`nproc 2> /dev/null || sysctl -n hw.ncpu 2> /dev/null || echo 1`"
1264+
export SCONSFLAGS="${MAKEFLAGS}"
12271265

12281266
# Setup platform
12291267
platform="${1}"; shift

0 commit comments

Comments
 (0)