Open QianNangong opened 3 years ago
This kind of thing is not currently supported — we use bare metal with OS/2 here (and/or VMs). Although it's doable per se. The EMX toolchain belongs to LIBC that lives here https://github.com/bitwiseworks/libc (look for release-tools
target in the main Makefile).
But I bet adding Linux support there will need some work (mostly to deal with path differences).
Thanks for your reply! I wonder if I can help.
Sure, why not, you are welcome! I would just start with trying it out (check out the source tree and try to build).
Steps as I see it are:
1.- Extract the existing OS/2 binaries into a Linux folder (will be needed for EMX includes and libc)
2.- Compile GCC for Linux host with EMX target (I got this to work but as I skipped pass 1 it just stopped complaining about emxload.h
not found :woman_shrugging:, and only after removing -Zstack and -Zhigh-mem parameters in emx target, as these are host options used when compiling GCC itself under OS/2)
3.- Compile libc
What I'm not sure is if I need to compile binutils or not.
I'm far from an expert in compiling GCC. But will try this weekend.
Potential problem, on OS/2 GCC outputs aout object files which are usually converted to OMF and then linked. So GCC would need to be configured to output aout, emxomf and friends complied on Linux and use the OpenWatcom linker, wlink to link the OMF object files into OS/2 binaries. OpenWatcom does sorta support Linux currently (no shared libraries) so a wlink Linux binary should exist. Eventually GCC would also need patching to support all the -Z host operations. Easiest might be to use the OS/2 GCC source and compile that on Linux. Also might look at the 2ine project, sorta like WINE for OS/2 binaries, https://virtuallyfun.com/wordpress/2018/02/23/2ine-the-os-2-emulator/ where he successfully ran the EMX build of GCC 2.5.8 on Linux.
Got binutils to compile without ld using the following:
CFLAGS="-g -O2 -DEMX=1" ../binutils-os2/configure --target=i386-pc-os2-emx --prefix=/opt/emx --enable-ld=no
and after patching two places where the code was expecting to be running in host==emx: binutils-emx.patch.zip
ld fails to configure with the following very unhelpful message:
config.status:1551: cd . && sed -e '/# am--include-marker/d' Makefile | make -f - am--depfiles
make[2]: Entering directory '/home/claunia/build-binutils/ld'
/tmp/GmMzokQ3:3074: .deps/emmo.Pc: No such file or directory
make[2]: *** No rule to make target '.deps/emmo.Pc'. Stop.
make[2]: Leaving directory '/home/claunia/build-binutils/ld'
config.status:1556: $? = 2
config.status:1560: error: in `/home/claunia/build-binutils/ld':
config.status:1562: error: Something went wrong bootstrapping makefile fragments
for automatic dependency tracking. Try re-running configure with the
'--disable-dependency-tracking' option to at least be able to build
the package (albeit without support for automatic dependency tracking).
See `config.log' for more details
Ok I got all in https://bitwiseworks/binutils-os2 compile except for ld, then got gcc-os2 to compile stage1 removing some expectations that host is EMX if target is EMX, but I cannot compile libc because, well, there's not even a makefile, it's a REXX script :D, and without that I cannot get the emx*
tools so no stage2 :thinking:
@claunia good progress :) but LIBC expected by GCC is not part of binutils-os2. It's a separate project, see https://github.com/bitwiseworks/libc. All EMX tools you need to compile OS/2 programs with GCC are part of that project too (directories starting with emx
in https://github.com/bitwiseworks/libc/tree/master/src/emx/src). You should try to build those from there.
Well, you can always install REXX, probably Regina Rexx, or translate the Rexx cmds to sh or even manually. IIRC the scripts mostly set up the environment and create OMF versions of the aout libs. Some such as dllar.cmd have already been converted to sh, though I forget where the sh file can be downloaded from, wxwidgets? there's also https://github.com/komh/kdllar You are also going to need kbuild to build. http://trac.netlabs.org/kbuild or perhaps your package manager may have it, its most famous use/requirement is building VirtualBox.
The hard part is likely bootstrapping, needing emxomf to convert the aout libs to OMF and such to build emxomf. Perhaps first build on OS/2 to do those things, or manually build.
@claunia good progress :) but LIBC expected by GCC is not part of binutils-os2. It's a separate project, see https://github.com/bitwiseworks/libc. All EMX tools you need to compile OS/2 programs with GCC are part of that project too (directories starting with
emx
in https://github.com/bitwiseworks/libc/tree/master/src/emx/src). You should try to build those from there.
that is where I tried to build them. I did not have time to look at it yesterday neither will have time today.
Also neozeed is helping me on this (he ported EMX 0.8 to cross compile from Windows), so let's see what do we get.
I'll copy my patches later on, but they are not correct. I do know know if there's a way to detect host vs target when making GCC stage 1 so I just removed all suppositions (and fixed spawnvp
calls), so my changes make GCC-OS/2 compilable on Linux and at the same time makes it non-compilable on OS/2 and this is unacceptable :disappointed:
@claunia ok I see. You don't need REXX to build stuff there. Just look at regular makefiles (starting from Makefile in the root).
How can I build an emx toolchain for OS/2 on Linux or some Unix variants?