Skip to content

Instantly share code, notes, and snippets.

@dillera
Last active December 6, 2021 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dillera/51a53e68150cb74749a69807c1de364d to your computer and use it in GitHub Desktop.
Save dillera/51a53e68150cb74749a69807c1de364d to your computer and use it in GitHub Desktop.
Building irix QEMU on Ubuntu 20 LTS
5.11.0-40-generic #44~20.04.2-Ubuntu
gh repo clone sgidevnet/qemu-irix
sudo apt-get install build-essential zlib1g-dev pkg-config libglib2.0-dev \
binutils-dev libboost-all-dev autoconf libtool libssl-dev libpixman-1-dev \
python3-pip python-capstone python libncurses-dev libgcrypt-dev \
libcurl4-gnutls-dev libbz2-dev liblzo2-dev libsnappy-dev libxml2-dev libsdl2-dev \
nettle-dev gnutls-bin libxml2 flex bison
cd qemu-irix
[copy patches to local dir]
cat <<EOF > ./patch_configure.patch
diff --git a/configure b/configure
index b091b82cb3..6632d05fc7 100755
--- a/configure
+++ b/configure
@@ -5139,7 +5139,7 @@ fi
sem_timedwait=no
cat > $TMPC << EOF
#include <semaphore.h>
-int main(void) { return sem_timedwait(0, 0); }
+int main(void) { sem_t s; struct timespec t = {0}; return sem_timedwait(&s, &t); }
EOF
if compile_prog "" "" ; then
sem_timedwait=yes
EOF
cat <<EOF > ./patch_sockets.patch
diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c
index 9705051690..4322652428 100644
--- a/util/qemu-sockets.c
+++ b/util/qemu-sockets.c
@@ -877,7 +877,7 @@ static int unix_listen_saddr(UnixSocketAddress *saddr,
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
- strncpy(un.sun_path, path, sizeof(un.sun_path));
+ strncpy(un.sun_path, path, sizeof(un.sun_path) - 1);
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
error_setg_errno(errp, errno, "Failed to bind socket to %s", path);
@@ -922,7 +922,7 @@ static int unix_connect_saddr(UnixSocketAddress *saddr, Error **errp)
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
- strncpy(un.sun_path, saddr->path, sizeof(un.sun_path));
+ strncpy(un.sun_path, saddr->path, sizeof(un.sun_path) - 1);
/* connect to peer */
do {
EOF
patch configure ./patch_configure.patch
patch util/qemu-sockets.c patch_sockets.patch
export CFLAGS="-Wno-deprecated-declarations -Wno-error"
make clean
./configure --target-list=irix-linux-user,irixn32-linux-user,irix64-linux-user,solaris-linux-user
make
sudo make install
cd ~/
wget https://sgi-irix.s3.amazonaws.com/irix-6.5/full-installs/irix-6522.tar.7z
sudo apt install p7zip
p7zip -d ./irix-6522.tar.7z
# Get RSE and get patched libdicl from vladv
wget https://github.com/sgidevnet/sgug-rse/releases/download/v0.0.7beta/sgug-rse-selfhoster-0.0.7beta.tar.gz
wget https://misc.bitops.com/llvm-rpms/libdicl-0.1.so.0.0.0.gz
sudo groupadd -u 31310 sgug
sudo useradd -u 31310 sgug
sudo mkdir -p /opt/sgugbuild
sudo tar xf irix-6522-2.tar -C /opt/sgugbuild/
sudo tar zxf sgug-rse-selfhoster-0.0.7beta.tar.gz -C /opt/sgugbuild/usr
sudo su -
echo "sgug::31310:31310::/usr/people/sgug:/usr/sgug/bin/bash" >> /opt/sgugbuild/etc/passwd
echo "sgug::31310:sgug" >> /opt/sgugbuild/etc/group
exit
cd irix-qemu
sudo chroot --userspec=sgug:sgug /opt/sgugbuild/usr
* need to do: libdictl
* test sugshell
notes here :
https://hackmd.io/leeW9yR6Qbii4UjpLo3Enw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment