emulators/qemu-user-static: revive as a copy of qemu-user-static-devel

This is effectively the 3.1 update of qemu-user-static. The main feature of
the update to 3.1 is RISC-V support, contributed by Embecosm.

PR:		243906
Approved by:	koobs (mentor)
This commit is contained in:
Kyle Evans 2020-04-26 15:57:12 +00:00
parent d66dbec320
commit 79afda803f
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=533075
9 changed files with 350 additions and 1 deletions

1
MOVED
View file

@ -14551,4 +14551,3 @@ emulators/qemu30|emulators/qemu31|2020-04-21|Has expired: No longer maintained b
editors/nano-devel||2020-04-23|Removed: Obsolete now, use editors/nano instead
devel/py-liblarch||2020-04-25|Removed: uses deprecated version of python; no consumers left
sysutils/DTraceToolkit|sysutils/dtrace-toolkit|2020-04-26|Renamed to match the package name
emulators/qemu-user-static||2020-04-25|Slave port being replaced by a copy of qemu-user-static-devel

View file

@ -110,6 +110,7 @@
SUBDIR += qemu-devel
SUBDIR += qemu-powernv
SUBDIR += qemu-sbruno
SUBDIR += qemu-user-static
SUBDIR += qemu-user-static-devel
SUBDIR += qemu-utils
SUBDIR += qemu31

View file

@ -20,6 +20,9 @@ USES= bison compiler:c11 gmake perl5 pkgconfig python:2.7,build
USE_PERL5= build
MAKE_ENV+= BSD_MAKE="${MAKE}" V=1
DEPRECATED= Port will be removed in favor of emulators/qemu
EXPIRATION_DATE= 2020-10-01
ONLY_FOR_ARCHS= amd64 powerpc powerpc64 # XXX someone wants to debug sparc64 hosts?
BROKEN_i386= aarch64 system target is currently broken for i386 hosts, disable for now while dealing with upstream

View file

@ -0,0 +1,90 @@
# $FreeBSD$
PORTNAME= qemu
PORTVERSION= 3.1.0
CATEGORIES= emulators
PKGNAMESUFFIX= -user-static
DIST_SUBDIR= qemu/${PORTVERSION}
MAINTAINER= emulation@FreeBSD.org
COMMENT= QEMU CPU Emulator (github bsd-user branch)
LICENSE= GPLv2
LICENSE_FILE= ${WRKSRC}/COPYING
ONLY_FOR_ARCHS= amd64 powerpc powerpc64
CONFLICTS_INSTALL= qemu-user-static-devel-[0-9]*
USES= bison compiler:c11 gmake perl5 pkgconfig python:build
USE_GITHUB= yes
GH_TUPLE= seanbruno:qemu-bsd-user:e21442a \
qemu:keycodemapdb:10739aa:keycodemapdb/ui/keycodemapdb
HAS_CONFIGURE= yes
USE_PERL5= build
MAKE_ENV+= BSD_MAKE="${MAKE}" V=1
USE_RC_SUBR= qemu_user_static
SUB_LIST= NAME=qemu_user_static
# When static linking we have a build dependency on libglib-2.0.a, otherwise
# we use glib20 in the usual way (shared-lib runtime dependency).
BUILD_DEPENDS+= ${LOCALBASE}/lib/libglib-2.0.a:devel/glib20
.include <bsd.port.pre.mk>
CONFIGURE_ARGS+= --localstatedir=/var
CONFIGURE_ARGS+= --extra-ldflags=-L${LOCALBASE}/lib
CONFIGURE_ARGS+= --extra-cflags=-I${LOCALBASE}/include
CONFIGURE_ARGS+= --disable-libssh2
QEMU_TARGETS= i386-bsd-user sparc-bsd-user arm-bsd-user mips-bsd-user mipsel-bsd-user ppc-bsd-user
.if ${ARCH} == "amd64" || ${ARCH} == "powerpc64"
QEMU_TARGETS+= x86_64-bsd-user riscv64-bsd-user sparc64-bsd-user mips64-bsd-user mips64el-bsd-user ppc64-bsd-user aarch64-bsd-user
PLIST_SUB+= 64BIT=""
.else
PLIST_SUB+= 64BIT="@comment "
.endif
CONFIGURE_ARGS+= --target-list=${QEMU_TARGETS:ts,}
WITHOUT_CPU_CFLAGS=yes #to avoid problems with register allocation
CFLAGS:= ${CFLAGS:C/-fno-tree-vrp//}
CFLAGS+= -Wno-address-of-packed-member
CFLAGS+= -D_WANT_SEMUN
CONFIGURE_ARGS+= --prefix=${PREFIX} --cc=${CC} --enable-docs \
--disable-linux-user --disable-linux-aio \
--disable-kvm --disable-xen \
--smbd=${LOCALBASE}/sbin/smbd \
--enable-debug \
--enable-debug-info \
--static \
--python=${PYTHON_CMD} \
--disable-sdl --disable-gtk --disable-vte --disable-gnutls --disable-vnc \
--disable-curl --disable-opengl --disable-usb-redir --disable-pcap \
--disable-docs --disable-tools --disable-system --disable-guest-agent \
--extra-cflags=-I${WRKSRC}\ -I${LOCALBASE}/include\ -DPREFIX=\\\"\"${PREFIX}\\\"\"
QEMU_ARCH= ${ARCH:C/amd64/x86_64/:C/powerpc/ppc/}
MAKE_ARGS+= ARCH=${QEMU_ARCH}
post-patch:
@${REINPLACE_CMD} -E \
-e "s|^(CFLAGS=).*|\1${CFLAGS} -fno-strict-aliasing|" \
-e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \
${WRKSRC}/Makefile.target
@${REINPLACE_CMD} -E \
-e "s|^(CFLAGS=).*|\1${CFLAGS} -fno-strict-aliasing -I.|" \
-e "s|^(LDFLAGS=).*|\1${LDFLAGS}|" \
${WRKSRC}/Makefile
post-install:
@${MV} ${STAGEDIR}${PREFIX}/etc/rc.d ${WRKDIR}
@${RM} -r ${STAGEDIR}${PREFIX}/etc
@${MKDIR} ${STAGEDIR}${PREFIX}/etc
@${MV} ${WRKDIR}/rc.d ${STAGEDIR}${PREFIX}/etc
@${RM} -r ${STAGEDIR}${PREFIX}/man
@${RM} -r ${STAGEDIR}${DATADIR}
@${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/qemu-*
@(cd ${STAGEDIR}${PREFIX}/bin && \
for i in qemu-*; do ${MV} -i $$i $$i-static; done)
.include <bsd.port.post.mk>

View file

@ -0,0 +1,5 @@
TIMESTAMP = 1576119784
SHA256 (qemu/3.1.0/seanbruno-qemu-bsd-user-3.1.0-e21442a_GH0.tar.gz) = 8396a53fbf6f46f89327bc0b747aca928dc21916f67952f938f6c527ccab8cfd
SIZE (qemu/3.1.0/seanbruno-qemu-bsd-user-3.1.0-e21442a_GH0.tar.gz) = 16902208
SHA256 (qemu/3.1.0/qemu-keycodemapdb-10739aa_GH0.tar.gz) = ae43fb1e2b07b78be88a7882306b6e71383eb77472a35d7d78fed21e345d134a
SIZE (qemu/3.1.0/qemu-keycodemapdb-10739aa_GH0.tar.gz) = 47895

View file

@ -0,0 +1,52 @@
--- configure.orig 2019-12-12 02:59:17 UTC
+++ configure
@@ -5954,27 +5954,30 @@ if ( [ "$linux_user" = yes ] || [ "$bsd_user" = yes ]
cat > $TMPC <<EOF
int main(void) { return 0; }
EOF
- textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
+ textseg_ldflags="-Wl,--image-base=$textseg_addr"
if ! compile_prog "" "$textseg_ldflags"; then
- # In case ld does not support -Ttext-segment, edit the default linker
- # script via sed to set the .text start addr. This is needed on FreeBSD
- # at least.
- if ! $ld --verbose >/dev/null 2>&1; then
- error_exit \
- "We need to link the QEMU user mode binaries at a" \
- "specific text address. Unfortunately your linker" \
- "doesn't support either the -Ttext-segment option or" \
- "printing the default linker script with --verbose." \
- "If you don't want the user mode binaries, pass the" \
- "--disable-user option to configure."
- fi
+ textseg_ldflags="-Wl,-Ttext-segment=$textseg_addr"
+ if ! compile_prog "" "$textseg_ldflags"; then
+ # In case ld does not support -Ttext-segment, edit the default linker
+ # script via sed to set the .text start addr. This is needed on FreeBSD
+ # at least.
+ if ! $ld --verbose >/dev/null 2>&1; then
+ error_exit \
+ "We need to link the QEMU user mode binaries at a" \
+ "specific text address. Unfortunately your linker" \
+ "doesn't support either the -Ttext-segment option or" \
+ "printing the default linker script with --verbose." \
+ "If you don't want the user mode binaries, pass the" \
+ "--disable-user option to configure."
+ fi
- $ld --verbose | sed \
- -e '1,/==================================================/d' \
- -e '/==================================================/,$d' \
- -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
- -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
- textseg_ldflags="-Wl,-T../config-host.ld"
+ $ld --verbose | sed \
+ -e '1,/==================================================/d' \
+ -e '/==================================================/,$d' \
+ -e "s/[.] = [0-9a-fx]* [+] SIZEOF_HEADERS/. = $textseg_addr + SIZEOF_HEADERS/" \
+ -e "s/__executable_start = [0-9a-fx]*/__executable_start = $textseg_addr/" > config-host.ld
+ textseg_ldflags="-Wl,-T../config-host.ld"
+ fi
fi
fi
fi

View file

@ -0,0 +1,164 @@
#!/bin/sh
#
# $FreeBSD$
#
# PROVIDE: %%NAME%%
# REQUIRE: LOGIN
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf to enable `%%NAME%%':
#
# %%NAME%%_enable="YES"
#
. /etc/rc.subr
name=%%NAME%%
rcvar=%%NAME%%_enable
# read configuration and set defaults
load_rc_config "$name"
: ${%%NAME%%_enable:="NO"}
BINMISCCTL=/usr/sbin/binmiscctl
QEMU_DIR=%%PREFIX%%/bin
QEMU_PREFIX=qemu-
QEMU_SUFFIX=-static
start_cmd=%%NAME%%_start
stop_cmd=%%NAME%%_stop
extra_commands=list
list_cmd="${BINMISCCTL} list"
%%NAME%%_start()
{
# register arm interpreter styled 'arm'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}arm${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add arm --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register armv6 interpreter styled 'arm'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}arm${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add armv6 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register armv7 interpreter styled 'arm'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}arm${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add armv7 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register aarch64 interpreter styled 'aarch64'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}aarch64${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add aarch64 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register mips interpreter styled 'mips'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}mips${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add mips --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register mipsle interpreter styled 'mipsel'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}mipsel${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add mipsel --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register mips64 interpreter styled 'mips64'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}mips64${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add mips64 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register powerpc interpreter styled 'ppc'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}ppc${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add powerpc --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register powerpc64 interpreter styled 'ppc64'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}ppc64${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add powerpc64 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x15" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register riscv64 interpreter styled 'riscv64'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}riscv64${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add riscv64 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
# register sparc64 interpreter styled 'sparc64'
interpreter=${QEMU_DIR}/${QEMU_PREFIX}sparc64${QEMU_SUFFIX}
if [ -x "${interpreter}" ]; then
${BINMISCCTL} add sparc64 --interpreter "${interpreter}" \
--magic "\x7f\x45\x4c\x46\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2b" \
--mask "\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff" \
--size 20 --set-enabled
else
echo "$0: interpreter ${interpreter} not found, cannot register."
fi
}
%%NAME%%_stop()
{
${BINMISCCTL} remove arm
${BINMISCCTL} remove armv6
${BINMISCCTL} remove armv7
${BINMISCCTL} remove aarch64
${BINMISCCTL} remove mips
${BINMISCCTL} remove mips64
${BINMISCCTL} remove mipsel
${BINMISCCTL} remove powerpc
${BINMISCCTL} remove powerpc64
${BINMISCCTL} remove riscv64
${BINMISCCTL} remove sparc64
}
run_rc_command "$1"

View file

@ -0,0 +1,22 @@
QEMU is a FAST! processor emulator using dynamic translation to achieve
good emulation speed.
QEMU has two operating modes:
* Full system emulation. In this mode, QEMU emulates a full system
(for example a PC), including a processor and various peripherials.
It can be used to launch different Operating Systems without rebooting
the PC or to debug system code.
* User mode emulation (Linux host only). In this mode, QEMU can launch
Linux processes compiled for one CPU on another CPU. It can be used to
launch the Wine Windows API emulator or to ease cross-compilation and
cross-debugging.
As QEMU requires no host kernel patches to run, it is very safe and easy to use.
This port builds static bsd-user targets named like qemu-mips-static. While
still being experimental, people have already built many armv6/mips/mips64 ports
using these and, e.g., poudriere. Some notes are also here:
http://wiki.freebsd.org/QemuUserModeHowTo
WWW: http://wiki.qemu.org/Main_Page

View file

@ -0,0 +1,13 @@
%%64BIT%%bin/qemu-aarch64-static
bin/qemu-arm-static
bin/qemu-i386-static
bin/qemu-mips-static
%%64BIT%%bin/qemu-mips64-static
%%64BIT%%bin/qemu-mips64el-static
bin/qemu-mipsel-static
bin/qemu-ppc-static
%%64BIT%%bin/qemu-ppc64-static
%%64BIT%%bin/qemu-riscv64-static
bin/qemu-sparc-static
%%64BIT%%bin/qemu-sparc64-static
%%64BIT%%bin/qemu-x86_64-static