s-macke / jor1k

Online OR1K Emulator running Linux
http://jor1k.com
BSD 2-Clause "Simplified" License
1.74k stars 199 forks source link

Allow jor1k use other linux distros #137

Open sr229 opened 6 years ago

sr229 commented 6 years ago

Main Rationale behind this is the copy/v86 project.

A number of Linux distros and some OSes can run OpenRISC, and it would make sense if:

Considering how this project stacks up with other emulators, its fair we also give such feature since it'll promote a sense of customizability on the end user

elixx commented 5 years ago

I have been trying to bootstrap a basic system using buildroot and openADK (and just plain 'raw'), but haven't had much success. Seconding this; perhaps just an easy way to build a 9p filesystem and kernel to boot.

s-macke commented 5 years ago

Unfortunately it is not easy to build for OpenRISC. I don't know of any distros supporting OpenRISC. Please let me know if this changed.

I am using my own scripts (www.jor1k.com/or1k-toolchain.tar.bz2) to build for the emulator. The kernel is patched to work flawless. Also I use my own code to generate my 9p specific file system. I don't see an easy method to support other distros out of the box. However when you have a sysroot filesystem it is pretty easy to build the 9p filesystem for jor1k. Just look at the fs2xml.c file in the tools directory.

sr229 commented 5 years ago

hey @s-macke, GCC supports OpenRISC compiling now on GCC9, which should allow you to compile any distro for OpenRISC.

elixx commented 5 years ago

I've managed to do the binfmt + QEMU bit, and unbzip2 the existing jor1k filesystem and chroot into it, and attempting to build software that way, with a bit more horsepower, but I generally either run into missing header files for some of the installed (or sometimes missing) libraries, or otherwise odd segfaults (probably QEMU issues there).

I think I may have created a system with https://openadk.org/ which claims to support OR1k, but am not certain the usage with fs2xml to bring in a new sysroot and kernel. I also run into some compilation issues with fs2xml on my main dev VM for this, probably something simple on my part:

$ gcc -lbz2 -o fs2xml fs2xml.c

/usr/bin/ld: /tmp/ccbsQtfm.o: in function `decompress':
fs2xml.c:(.text+0x4e7): undefined reference to `BZ2_bzopen'
/usr/bin/ld: fs2xml.c:(.text+0x540): undefined reference to `BZ2_bzread'
/usr/bin/ld: fs2xml.c:(.text+0x555): undefined reference to `BZ2_bzclose'
collect2: error: ld returned 1 exit status

I've also built the gcc toolchain separately for cross compilation, fwiw, but am not sure where to go with that without a rootfs with headers to chroot into:

┌─[elixx@ubufoo] - [/opt/toolchains/or1k-elf/bin] - [2019-05-31 05:52:34]
└─[1] <> ./or1k-elf-c++ -v
Using built-in specs.
COLLECT_GCC=./or1k-elf-c++
COLLECT_LTO_WRAPPER=/opt/toolchains/or1k-elf/libexec/gcc/or1k-elf/9.0.0/lto-wrapper
Target: or1k-elf
Configured with: ../gcc/configure --target=or1k-elf --prefix=/opt/toolchains/or1k-elf/ --enable-languages=c,c++ --disable-shared --disable-libssp --with-newlib
Thread model: single
gcc version 9.0.0 20181109 (experimental) (GCC)

I'm no stranger to chasing down dependencies to get manual compilations off the ground -- I used to run Slackware in the 90's ;) -- but seem to keep running into missing headers when trying to get (for example) w3m or NetHack compiled -- even natively within the emulator.

andrakis commented 5 years ago

Hello, I've been using a version of GCC that matches the version that jor1k uses - it's statically compiled for x86_64 and runs on a current (13.10+) ubuntu. https://github.com/andrakis/openrisc-toolchain

I mirrored this tool chain because it is difficult to track down, but I've not run into issues compiling large C++ projects with it. (My own project using the POCO library cross compiles fine.)

You may have some more luck using this version of the GCC suite, I did. I myself ran into problems getting the cross compiler setup and working on jor1k, particularly in that any difference in version meant I had to compile statically or the C runtime would be incorrect and my program would not run.