Skip to content

Commit

Permalink
Add in support for running a cross-shell directly in qemu (bug 807936…
Browse files Browse the repository at this point in the history
…, r=ted)
  • Loading branch information
Marty Rosenberg committed Nov 15, 2012
1 parent 5cb2973 commit 544dc37
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
24 changes: 24 additions & 0 deletions build/qemu-wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# this script creates a wrapper shell script for an executable. The idea is the actual executable cannot be
# executed natively (it was cross compiled), but we want to run tests natively. Running this script
# as part of the compilation process will move the non-native executable to a new location, and replace it
# with a script that will run it under qemu.
while [[ -n $1 ]]; do
case $1 in
--qemu) QEMU="$2"; shift 2;;
--libdir) LIBDIR="$2"; shift 2;;
--ld) LD="$2"; shift 2;;
*) exe="$1"; shift;;
esac
done
if [[ -z $LIBDIR ]]; then
echo "You need to specify a directory for the cross libraries when you configure the shell"
echo "You can do this with --with-cross-lib="
exit 1
fi
LD=${LD:-$LIBDIR/ld-linux.so.3}
mv $exe $exe.target
# Just hardcode the path to the executable. It'll be pretty obvious if it is doing the wrong thing.

echo $'#!/bin/bash\n' $QEMU -E LD_LIBRARY_PATH="${LIBDIR}" "$LD" "$(readlink -f "$exe.target")" '"$@"' >"$exe"
chmod +x $exe
24 changes: 24 additions & 0 deletions js/src/build/qemu-wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# this script creates a wrapper shell script for an executable. The idea is the actual executable cannot be
# executed natively (it was cross compiled), but we want to run tests natively. Running this script
# as part of the compilation process will move the non-native executable to a new location, and replace it
# with a script that will run it under qemu.
while [[ -n $1 ]]; do
case $1 in
--qemu) QEMU="$2"; shift 2;;
--libdir) LIBDIR="$2"; shift 2;;
--ld) LD="$2"; shift 2;;
*) exe="$1"; shift;;
esac
done
if [[ -z $LIBDIR ]]; then
echo "You need to specify a directory for the cross libraries when you configure the shell"
echo "You can do this with --with-cross-lib="
exit 1
fi
LD=${LD:-$LIBDIR/ld-linux.so.3}
mv $exe $exe.target
# Just hardcode the path to the executable. It'll be pretty obvious if it is doing the wrong thing.

echo $'#!/bin/bash\n' $QEMU -E LD_LIBRARY_PATH="${LIBDIR}" "$LD" "$(readlink -f "$exe.target")" '"$@"' >"$exe"
chmod +x $exe
15 changes: 15 additions & 0 deletions js/src/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -4136,6 +4136,21 @@ if test "$MOZ_DEBUG" -o "$NS_TRACE_MALLOC"; then
MOZ_COMPONENTS_VERSION_SCRIPT_LDFLAGS=
fi

dnl ========================================================
dnl =
dnl = Options for generating the shell as a script
dnl =
dnl ========================================================

MOZ_ARG_WITH_STRING(qemu-exe,
[ --with-qemu-exe=path Use path as an arm emulator on host platforms],
QEMU_EXE=$withval)
AC_SUBST(QEMU_EXE)
MOZ_ARG_WITH_STRING(cross-lib,
[ --with-cross-lib=dir Use dir as the location for arm libraries],
CROSS_LIB=$withval,
CROSS_LIB=/usr/$target)
AC_SUBST(CROSS_LIB)
dnl ========================================================
dnl =
dnl = Maintainer debug option (no --enable equivalent)
Expand Down
4 changes: 4 additions & 0 deletions js/src/jsapi-tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ LIBS = $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX) $(NSPR_LIBS) $(MOZ_ZLI

LOCAL_INCLUDES += -I$(topsrcdir) -I..

ifdef QEMU_EXE
MOZ_POST_PROGRAM_COMMAND = $(topsrcdir)/build/qemu-wrap --qemu $(QEMU_EXE) --libdir $(CROSS_LIB)
endif

include $(topsrcdir)/config/rules.mk

check::
Expand Down
4 changes: 4 additions & 0 deletions js/src/shell/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ DARWIN_EXE_LDFLAGS += -pagezero_size 10000 -image_base 100000000
endif
endif

ifdef QEMU_EXE
MOZ_POST_PROGRAM_COMMAND = $(topsrcdir)/build/qemu-wrap --qemu $(QEMU_EXE) --libdir $(CROSS_LIB)
endif

include $(topsrcdir)/config/rules.mk

ifdef MOZ_SHARK
Expand Down

0 comments on commit 544dc37

Please sign in to comment.