Choosing the correct compiler version
jfondren
julian.fondren at gmail.com
Tue Jul 19 23:19:28 UTC 2022
On Tuesday, 19 July 2022 at 15:33:59 UTC, Alexander Zhirov wrote:
> On Tuesday, 19 July 2022 at 15:28:44 UTC, Alexander Zhirov
> wrote:
>> I'm trying to install dmd with my hands in order to build ldc2
>> from the sources, but I can't:
>
> I need to build a compiler under x32 in order to compile a
> program for the same machine.
>
> ```sh
> dmd2/src/dmd# make -f posix.mak
> posix.mak:42: ===== DEPRECATION NOTICE =====
> posix.mak:43: ===== DEPRECATION: posix.mak is deprecated.
> Please use src/build.d instead.
> posix.mak:44: ==============================
> dmd -of../generated/build -g build.d
> dmd: /lib/libc.so.6: version `GLIBC_2.28' not found (required
> by dmd)
> posix.mak:111: recipe for target '../generated/build' failed
> make: *** [../generated/build] Error 1
> ```
You can find the release archive linked from
https://dlang.org/download.html , after clicking 'Download' by
dmd. It's at http://downloads.dlang.org/
You can then go through old versions and, by trial, find one
that's old enough to work on your machine, which you can then use
to a newer dmd:
for x in dmd druntime phobos; do git clone
https://github.com/dlang/$x; done
export HOST_DMD=path/to/bin32/dmd
( cd dmd; make -f posix.mak ) # etc.
Finding an old version that works on your machine will be very
easy, but for example the random 2016 build that I grabbed was
also too old to build dmd master, so you want to prefer a newer
build that still works. It's not necessary to build dmd master
though: in the worst case, you should be able check out interim
releases (look at 'git tag --list', then 'git checkout v2.094.0'
for example), build those, then used them to build a newer
release.
This is all of course a massive PITA, which any extremely nice
person could make less of a pain by cataloguing useful versions
on the D wiki or by providing their own "good enough to compile
master" builds for old architectures. Another option is to get
newer glibc onto this system (not installing it, just making it
available for dmd. use LD_LIBRARY_PATH).
An option that's technically possible but probably even more of a
pain than what I've just described is using another machine to
cross-compile static 32-bit D binaries that will then work on
this machine. I've tried this and run into pretty unpleasant
limitations, but I have a guide anyway at
https://d.minimaltype.com/index.cgi/wiki?name=statically-linked+binaries , which you can supplement with https://wiki.dlang.org/Cross-compiling_with_LDC to get a 32-bit result. For that matter 'ldc2 -mtriple i686-linux-musl file.d' might be made to work, but I've no idea how to supply the toolchains that it expects.
Speaking of toolchains, it might be possible to use a modern
server with a modern dmd with an ancient glibc:
https://www.lordaro.co.uk/posts/2018-08-26-compiling-glibc.html
More information about the Digitalmars-d-learn
mailing list