Install i686-pc-msdosdjgpp
michaeljhkim opened this issue · 19 comments
So I tried to install this like specified, but it only installs the i586 version. I need the i686 version, and there are no instructions on how to do that.
There is an arch pkg build, but I can't get access to it because I am on fedora. Is there anything I could do?
Thank you.
You’ll need to modify https://github.com/andrewwutw/build-djgpp/blob/master/script/12.1.0
So I just need to change i586 to i686?
Pretty much. I'll run through this effort right now to validate it.
On Fedora 36 using my 7 year old Dell Precision 3420, Xeon E3-1245 v5 3.5GHz, 64GB DDR4, Kingston 240GB M.2 SSD a full build takes about 30 minutes. Not quite finished though. The djlsr205 build is configured for an MTUNE
of i586 and therefore expects a i586-pc-msdosdjgpp-*
set of tools. I'll need to workaround it later this weekend. Probably need to look at patch/patch-djlsr205.txt
or write a new patch/sed into script/12.1.0-i686
.
Note, the build-djgpp script could be improved w.r.t. parallelism. It's currently set to be single threaded within build-djgpp while all the tools support multi-threaded compilation. Only the last step does a make j=4
(which I think should be -j=4
).
build-djgpp also seems to build with debugging turned on, which is fair, tbh. Slower builds, larger binaries, potentially slower cross-compiler binaries is the result. I think you can remove -g
from CFLAGS
or set it to something other than -O2 -g
. -Os
or -O3
might be all you need. The resulting cross-compilers will run a bit faster. I like to wrap manual builds with the time
utility (time -p
below) to understand developer cycle latency. You can remove that from my instructions.
# sudo dnf install g++ gcc unzip bison flex make texinfo patch zlib-devel curl wget perl-File-Compare automake
# sed 's/i586/i686/g' script/12.1.0 >script/12.1.0-i686
# chmod -v 755 script/12.1.0-i686
# DJGPP_PREFIX=`pwd` time -p bash build-djgpp.sh 12.1.0-i686
I'll get back to this tonight or tomorrow evening.
Alright.....got it. A bit of hacky sed
patch to djlsr. djlsr is built with expectations of -mtune=i586
/-mcpu=i586
/-march=i386
. I didn't feel like untangling that. There might be some reason to do it besides the widest possible compatibility. Look at patching djlsr205/src/{gcc-l.opt,gcc.opt,gpp.opt,makefile.cfg,dxe/makefile.dxe}
if you really want to make it i686. Total build time on my old box is a bit over 33 minutes without patching in calls to nproc
to scale out the make -j
parameter.
Steps reproduce on Fedora 36.
# sudo dnf install g++ gcc unzip bison flex make texinfo patch zlib-devel curl wget perl-File-Compare automake
# sed -e 's/i586/i686/g' -e 's:"Building DXE tools.":"Building DXE tools." ; for Z in src/{makefile.def,dxe/makefile.dxe} ; do ( sed "s/i586/i686/g" $Z > $Z-i686 ; mv -v $Z{-i686,} ) ; done :g' script/12.1.0 >script/12.1.0-i686
# chmod -v 755 script/12.1.0-i686
# sed -e 's/i586/i686/g' setenv/setenv >setenv/setenv-i686 && mv -v setenv/setenv{-i686,}
# DJGPP_PREFIX=`pwd`/i686 time -p bash build-djgpp.sh 12.1.0-i686
Bottom of build log:
gcc -O2 -Wall -DDXE_LD=\"i686-pc-msdosdjgpp-ld\" -DDXE_CC=\"i686-pc-msdosdjgpp-gcc\" -DDXE_AR=\"i686-pc-msdosdjgpp-ar\" -DDXE_AS=\"i686-pc-msdosdjgpp-as\" dxe3gen.c -o dxe3gen
ln -s dxe3gen dxegen
gcc -O2 -Wall dxe3res.c -o dxe3res
#make -C mkdoc
#make -C libc
#make -C debug
#make -C djasm
#make -C stub
#make -C dxe
#make -C libemu
#make -C libm
#make -C utils
#make -C docs
#-make -C ../zoneinfo/src
make -f makempty
i686-pc-msdosdjgpp-gcc -pipe ... -c empty.s
i686-pc-msdosdjgpp-ar rv ../lib/libg.a empty.o
i686-pc-msdosdjgpp-ar: creating ../lib/libg.a
a - empty.o
i686-pc-msdosdjgpp-ar rv ../lib/libpc.a empty.o
i686-pc-msdosdjgpp-ar: creating ../lib/libpc.a
a - empty.o
Copy setenv script
Testing DJGPP.
Use DJGPP to build a test C program.
Use DJGPP to build a test C++ program.
build-djgpp.sh done.
real 1992.70
user 1730.22
sys 251.08
Cross compiler bits: (91M)
> ls -lak i686/bin/
total 92648
drwxr-xr-x. 1 lps lps 1382 Mar 25 23:18 .
drwxr-xr-x. 1 lps lps 350 Mar 25 22:45 ..
-rwxr-xr-x. 1 lps lps 3206496 Mar 25 22:47 i686-pc-msdosdjgpp-addr2line
-rwxr-xr-x. 2 lps lps 3364560 Mar 25 22:47 i686-pc-msdosdjgpp-ar
-rwxr-xr-x. 2 lps lps 5427152 Mar 25 22:47 i686-pc-msdosdjgpp-as
-rwxr-xr-x. 2 lps lps 1269280 Mar 25 23:18 i686-pc-msdosdjgpp-c++
-rwxr-xr-x. 1 lps lps 3162480 Mar 25 22:47 i686-pc-msdosdjgpp-c++filt
-rwxr-xr-x. 1 lps lps 1265184 Mar 25 23:18 i686-pc-msdosdjgpp-cpp
-rwxr-xr-x. 1 lps lps 97408 Mar 25 22:47 i686-pc-msdosdjgpp-elfedit
-rwxr-xr-x. 2 lps lps 1269280 Mar 25 23:18 i686-pc-msdosdjgpp-g++
-rwxr-xr-x. 2 lps lps 1265184 Mar 25 23:18 i686-pc-msdosdjgpp-gcc
-rwxr-xr-x. 2 lps lps 1265184 Mar 25 23:18 i686-pc-msdosdjgpp-gcc-12.1.0
-rwxr-xr-x. 1 lps lps 35888 Mar 25 23:18 i686-pc-msdosdjgpp-gcc-ar
-rwxr-xr-x. 1 lps lps 35888 Mar 25 23:18 i686-pc-msdosdjgpp-gcc-nm
-rwxr-xr-x. 1 lps lps 35888 Mar 25 23:18 i686-pc-msdosdjgpp-gcc-ranlib
-rwxr-xr-x. 1 lps lps 766728 Mar 25 23:18 i686-pc-msdosdjgpp-gcov
-rwxr-xr-x. 1 lps lps 578144 Mar 25 23:18 i686-pc-msdosdjgpp-gcov-dump
-rwxr-xr-x. 1 lps lps 602816 Mar 25 23:18 i686-pc-msdosdjgpp-gcov-tool
-rwxr-xr-x. 1 lps lps 3733216 Mar 25 22:47 i686-pc-msdosdjgpp-gprof
-rwxr-xr-x. 4 lps lps 4402600 Mar 25 22:47 i686-pc-msdosdjgpp-ld
-rwxr-xr-x. 4 lps lps 4402600 Mar 25 22:47 i686-pc-msdosdjgpp-ld.bfd
-rwxr-xr-x. 1 lps lps 29702904 Mar 25 23:18 i686-pc-msdosdjgpp-lto-dump
-rwxr-xr-x. 2 lps lps 3244200 Mar 25 22:47 i686-pc-msdosdjgpp-nm
-rwxr-xr-x. 2 lps lps 4175952 Mar 25 22:47 i686-pc-msdosdjgpp-objcopy
-rwxr-xr-x. 2 lps lps 5926496 Mar 25 22:47 i686-pc-msdosdjgpp-objdump
-rwxr-xr-x. 2 lps lps 3364552 Mar 25 22:47 i686-pc-msdosdjgpp-ranlib
-rwxr-xr-x. 2 lps lps 1659096 Mar 25 22:47 i686-pc-msdosdjgpp-readelf
-rwxr-xr-x. 1 lps lps 3196360 Mar 25 22:47 i686-pc-msdosdjgpp-size
-rwxr-xr-x. 1 lps lps 3192120 Mar 25 22:47 i686-pc-msdosdjgpp-strings
-rwxr-xr-x. 2 lps lps 4175984 Mar 25 22:47 i686-pc-msdosdjgpp-strip
DOS cross-built binaries: (56M)
> ls -lak i686-pc-msdosdjgpp/bin/
total 56844
drwxr-xr-x. 1 lps lps 256 Mar 25 23:18 .
drwxr-xr-x. 1 lps lps 34 Mar 25 22:08 ..
-rwxr-xr-x. 1 lps lps 3206496 Mar 25 23:18 addr2line
-rwxr-xr-x. 2 lps lps 3364560 Mar 25 22:47 ar
-rwxr-xr-x. 2 lps lps 5427152 Mar 25 22:47 as
-rwxr-xr-x. 1 lps lps 1269280 Mar 25 23:18 c++
-rwxr-xr-x. 1 lps lps 3162480 Mar 25 23:18 c++filt
-rwxr-xr-x. 1 lps lps 1265184 Mar 25 23:18 cpp
-rwxr-xr-x. 1 lps lps 43104 Mar 25 23:18 dxe3gen
-rwxr-xr-x. 1 lps lps 26096 Mar 25 23:18 dxe3res
-rwxr-xr-x. 1 lps lps 43104 Mar 25 23:18 dxegen
-rwxr-xr-x. 1 lps lps 25520 Mar 25 23:18 exe2coff
-rwxr-xr-x. 1 lps lps 1269280 Mar 25 23:18 g++
-rwxr-xr-x. 1 lps lps 1265184 Mar 25 23:18 gcc
-rwxr-xr-x. 4 lps lps 4402600 Mar 25 22:47 ld
-rwxr-xr-x. 4 lps lps 4402600 Mar 25 22:47 ld.bfd
-rwxr-xr-x. 2 lps lps 3244200 Mar 25 22:47 nm
-rwxr-xr-x. 2 lps lps 4175952 Mar 25 22:47 objcopy
-rwxr-xr-x. 2 lps lps 5926496 Mar 25 22:47 objdump
-rwxr-xr-x. 2 lps lps 3364552 Mar 25 22:47 ranlib
-rwxr-xr-x. 2 lps lps 1659096 Mar 25 22:47 readelf
-rwxr-xr-x. 1 lps lps 3196360 Mar 25 23:18 size
-rwxr-xr-x. 1 lps lps 3192120 Mar 25 23:18 strings
-rwxr-xr-x. 2 lps lps 4175984 Mar 25 22:47 strip
-rwxr-xr-x. 1 lps lps 26712 Mar 25 22:47 stubedit
-rwxr-xr-x. 1 lps lps 30504 Mar 25 22:47 stubify
DOS cross-built libc: (1.4M)
> ls -lak i686/i686-pc-msdosdjgpp/lib/
total 1356
drwxr-xr-x. 1 lps lps 156 Mar 25 22:47 .
drwxr-xr-x. 1 lps lps 34 Mar 25 22:08 ..
-rw-r--r--. 1 lps lps 4516 Oct 17 2015 crt0.o
-rw-r--r--. 1 lps lps 2720 May 10 2015 djgpp.djl
-rw-r--r--. 1 lps lps 628 Mar 25 22:47 dxe.ld
-rw-r--r--. 1 lps lps 4558 Oct 17 2015 gcrt0.o
drwxr-xr-x. 1 lps lps 132 Mar 25 22:47 ldscripts
-rw-r--r--. 1 lps lps 999320 Oct 18 2015 libc.a
-rw-r--r--. 1 lps lps 45298 Oct 18 2015 libdbg.a
-rw-r--r--. 1 lps lps 58804 Oct 18 2015 libemu.a
-rw-r--r--. 1 lps lps 482 Oct 18 2015 libg.a
-rw-r--r--. 1 lps lps 245346 Oct 18 2015 libm.a
-rw-r--r--. 1 lps lps 482 Oct 18 2015 libpc.a
@lpsantil thank you for the patch! I'm trying to add it to Nixpkgs now
Why i686? All it does is set the default value for -march=
, and then the target libraries are built with that. I would suggest using i386 instead for improved compatibility.
I'm trying to replicate a tricky project that requires it
I'm not seeing anything that requires i686-compiled target libraries - only hardcoded compiler names, which is just bad practice. If you want to avoid patching the makefiles, symlinks would work too.
I think there's some benefit to MMX (which means i586 over i386) but agreed I don't see a strong i686 need. Once I have a working build I'll be able to experiment / benchmark removing it (and other odd choices in this project).
@lpsantil i'm using your method to compile under msys2 but it always block at this error:
../../gnu/gcc-12.20/gcc/system.h:782:30: error: expected identifier before string constant
782 | #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
| ^~~~~~~~
../../gnu/gcc-12.20/gcc/system.h:782:30: error: expected ',' or '...' before string constant
../../gnu/gcc-12.20/gcc/system.h:782:30: error: expected identifier before string constant
782 | #define abort() fancy_abort (__FILE__, __LINE__, __FUNCTION__)
| ^~~~~~~~
../../gnu/gcc-12.20/gcc/system.h:782:30: error: expected ',' or '...' before string constant
make[2]: *** [Makefile:1143: diagnostic-color.o] Error 1
under WSL2 (Ubuntu) it works fine but the problem is that under ubuntu it makes the binaries for linux and i need binaries for windows instead. How to solve this? Thank you!
I just happened to have stood up a Windows box last night. So I might be able to help.
Just to be clear. All of the build-djgpp
scripts will build cross compilers toolchain from the the native
system to i586-pc-msdosdjgpp
. So if you use WSL, you'll get a Linux toolchain (which will also work under WSL). If you use mingw/msys2, you'll get a Windows toolchain.
That said, there's already pre-built Windows i586-pc-msdosdjgpp
toolchain at (https://github.com/andrewwutw/build-djgpp/releases) built with mingw. If you need an i686
version, then my steps should work with mingw or msys2. I'll test that out a little later today.
@lpsantil yes i already testing your steps. Now i'm trying something, maybe i've found a similar issue in this code:
i've adapted the build script with this modification: let's see if it will build correctly. I will report back
I notice you're also using a new gcc version, 12.20 vs. 12.1.0 I used earlier this year. That might require other tweaks.
I can confirm that with that modification i successfully built version 12.20 under msys2 mingw32
That's great to hear. And if you're opposed to invoking perl, sed should be able to do the job as well. Something like
# sed -e 's/^#define abort/\/\/#define abort/' `pwd`/gnu/gcc-12.*/system.h > `pwd`/gnu/gcc-12.*/system.h.tmp && mv -v `pwd`/gnu/gcc-12.*/system.h{.tmp,}
before build-djgpp.sh (though my paths will be wrong here).
I also don't understand why the toolchain is called i586-pc-...
. IMHO it should be i386-pc-...
. The fact that it can build for i586 or i686 is just a minor variation of the executable, which should be specified via -march=
flags, not hardcoded into the toolchain. If somebody really needs the toolchain to be called after the -march=
setting, just write scripts with the wished name which call the i386-pc-...
toolchain with the proper flags.
At least w/arch x86 (<amd64), the gcc convention seems to be to identify the highest ISA supported by the toolchain.
Oops, my mistake, I thought mingw-w64 was i386- for 32bit, but it's i686- ...you are right, sorry!