so it turns out when building gcc 4.4.7 the first time, whether or not just using "make" still tries to bootstrap, DESPITE PASSING "--disable-bootstrap" TO GCC'S CONFIGURE SCRIPT, seems random. lovely.

nope! this is even dumber. it turns out gcc in general is just stupidly sensitive to any tweaks in the system's headers, even adding whitespace can cause all of libiberty (as packed with gcc 4.4.7) to be invalid. almost every single line, starting halfway in. it looks like a missed semicolon or bracket, but the 120-some lines directly above are fine, the three header files it processed are OK, no one's to blame but a random macro that worked for 40 other lines but suddenly not here.

god i hate gcc

the modded header files even built binutils, xz, gzip, tar, m4, bison, gmp, and more just fucking fine, they all work, autoconf test suites are actually reporting fewer issues with the modded system headers than stock, almost all of it is now C99 compliant with very limited exception.

but if you add just whitespace to the headers, gcc 2.95.x loses track of all its builtins, 3.2.x can build just fine, and 4.4.7 can't bootstrap itself because it loses the ability to read in stage1, even when bootstrapping is disabled (because it does a one-stage bootstrap for its support libraries regardless.)

can't switch to a more sane language either because rust requires llvm and cmake, and those need like gcc 6.x and glibc, which are a ways off.

"how did you make solaris 7 C99 compliant without rebuilding the entire OS from source?" Sun was following the draft versions incredibly closely, so all that was really missing were a couple minor tweaks to #define statements here and there and fabricating stdint.h, which is mostly just importing other headers anyway. The hardest part were values like WCHAR_MIN, but the _t counterpart usually existed somewhere already, and as such you can extrapolate those just fine.
i've just realized that i don't think xz actually needs 64MB of RAM to decompress. post-Tan xz still works in Solaris 7 to decompress -9evv tarballs with 16MB of memory.

i've been laboring for WEEKS under the assumption that gcc-4.4.7 actually checks for --disable-bootstrap because it's in the docs and it SAYS it checks for it in the ./configure script, but i've just checked and they only actually check for --enable-bootstrap and if it's not present they just default to "yeah probably bootstrap". They never... actually... check.

Do you think they'd take patches for this old of GCC? This is some real dumb shit right here.

ok no ACTUALLY what they did is instead of being --enable-bootstrap or --disable bootstrap, SOME MOTHERFUCKER banged out enough shell script to require someone to PASS IT AS --enable-bootstrap=no

that is NOT how that shit works, please cease to be

ok we're back to just... throwing GCC versions at it to see which ones we can build from 3.2 so the bootstrap works again, since 4.4.7-stage2 can't build 4.4.7-stage3 and i DO NOT KNOW WHY.

4.2.4 suddenly works fine, but cannot bootstrap 4.4.7, because 4.4.7-stage2 goes from "libiberty is just trashed" to "gmp went missing" and i'm not sure why it doesn't check the fucking system includes directory because it's literally already there, it strips off $CFLAGS before stage3 which breaks shit, once again.

goddammit.

Fuck it. Tcl/Tk works, even in 16 color mode.

ok so bootstrapping 4.3.6 or 4.4.7 with 4.2.4 leads to stage2 losing gmp.h, it suddenly can't find it because it alters the include folder list. not bootstrapping 4.3.6 works fine initially, but then it can't handle define statements at all. not bootstrapping 4.4.7 isn't even possible, it ignores all possible switches related to bootstrapping.

fuck right off, gcc.

"for example, you should be able to get any supported version running by slowly building every minor version, or just bootstrap instead!" - the docs of the only program where bootstrapping it takes weeks to debug

"gcc keeps losing track of includes by stage2 because it tosses out all cflags for stage2 onward of the mandatory bootstrap procedure"

at this point, fuck it, copy the entire system includes folder into the gcc folder. i don't care anymore. at this point i consider gcc an enemy combatant.

ok maybe installing to an NFS share causes issues when it's a modern Linux box that... cares about permissions.
it's been a while, but this shitass Solaris project is not dead. at all. i've managed to get TLS and SSL going on sol7, through gnutls, now that I have a box that can actually connect to the internet. next up, an attempt at SDL, for pygame purposes.
no, nvm, if you use mini-gmp for nettle it doesn't build SHIT and it spits out one of two libraries... and it's 8KB. nettle is a cryptographic library and it's gotta be a hell of a lot bigger than that.

I finally got GnuTLS running, and it was segfaulting instantly upon load. Why?

Solaris this old does not have a /dev/random equivalent. Anywhere. At all. There's a patch to add it for 2.5 and 2.6, but not for 2.7. Why they didn't include it in 2.7 as well, I don't know, but the 2.6 packages work on 2.7. Speed isn't great, but fuck it, it works. Now to figure out how the fuck to get certificates without needing recent python3 or openssl (this excludes every single update-ca-certificates type package. Yes, for every distro.)

Also, I got X11R6 running, and the drivers even give me 2D acceleration on this T43. It's nice to have more than 16 colors again.

what are the odds i'll get assistance with what appears to be busted configure flags on SDL2? https://github.com/libsdl-org/SDL/issues/13971
[SDL2] configure --disable-atomic ignored? · Issue #13971 · libsdl-org/SDL

(SDL2 2.32.8 attempting build on i386-pc-solaris2.7, GCC 4.3.6) Per the configure script, --enable-atomic is assumed by default, but "default=yes" implies it can be disabled. However, passing --dis...

GitHub
fuck it, after a patch to fix some problematic memcpy redefs we have SDL1. that'll do.
gcc's libstdc++.so is requiring several math functions for libm version "SUNW_1.1" but no libm packed with sol7 or SUNWspro fulfills that version number? A couple X11 libraries also need it, but they load fine. I don't know where the fuck it found these to start with, but I can't seem to turn off symbol versioning to fix it. What the FUCK do I do now?
what I do now is patch SDL2. They're detecting old Solaris versions as Solaris properly, but only newer versions of Solaris have the non-standard atomic.h header. sol7 doesn't have it... at all, so I have to manually comment out huge code blocks to get it to use the emulated atomic operations properly.

a couple complete asspulls to synthesize unsetenv and a few other things later, and we have SDL2 2.30.0. I can't test it, because everything that needs it requires cmake which is still busted because libstdc++ is still busted... but it compiled!

Speaking of, if you're gonna leave a check for setenv in your configure.ac because you can work around it, but you DON'T check for unsetenv, don't try to fucking use unsetenv!

The fun part about this is that this version of SDL2 has support for the PS5, so we can now consider Solaris 7 knowledgeable on the PS5. This almost-30 year old OS now shares code with the PS5. wonderful.
It turns out, C++ usually has separate headers for a reason. We have CMake.
cmake docs are lies. "LIBLZMA_FOUND added in 3.3" it's used to build 3.1, which requires 2.8.4 minimum.
i've been toying with the idea of pulling in something like gnulib as a large "libfixmyshit" since full-fat glibc is a nightmare of gcc macros and it's actually slick as shit once you figure out what's going on, in comparison to manually editing an entire fucking project...

ugh, the versioned symbols DO exist... in a custom table, and Solaris' linker gives up and returns the first file it sees when linking, so at COMPILE time libstdc++ is linked to /usr/lib/libm.so.1, but at RUNTIME it's pulling `$__OUTDIR/lib/libm.so.1`! (in this case `$__OUTDIR` is `/opt/newroot`)

# ldd -s /opt/newroot/lib/libstdc++.so

find library=libm.so.1; required by /opt/newroot/lib/libstdc++.so
search path=/usr/local/lib:/opt/newroot/lib:/usr/lib:/lib:/sbin/lib:/opt/SUNWspro/lib (LD_LIBRARY_PATH)
trying path=/usr/local/lib/libm.so.1
trying path=/opt/newroot/lib/libm.so.1
libm.so.1 => /opt/newroot/lib/libm.so.1
libm.so.1 (SUNW_1.1) => (version not found)
# mv /opt/newroot/lib/libm.so.1 /tmp
# sync
# LD_LIBRARY_PATH=/opt/newroot/lib:/usr/lib:/lib:/sbin/lib:/opt/SUNWspro/lib ldd -s /opt/newroot/lib/libstdc++.so

find library=libm.so.1; required by /opt/newroot/lib/libstdc++.so
search path=/opt/newroot/lib:/usr/lib:/lib:/sbin/lib:/opt/SUNWspro/lib (LD_LIBRARY_PATH)
trying path=/opt/newroot/lib/libm.so.1
trying path=/usr/lib/libm.so.1
libm.so.1 => /usr/lib/libm.so.1

i wish to retract my statement about gnulib being nice to use, i'm having to patch the m4 scripts because it won't get the goddamn hint that a header is incomplete if it sees it and builds fine with it.
i think the linker is cooked, gang
what the fuck, gcc?
how the fuck do you debug assembler errors from GCC, assuming a .S input? are the aline listings before or after preprocessing? the gcc and as docs don't specify, despite furious grepping

you know a package is completely hosed when you have to modify like twelve files to get CFLAGS to be respected, and it's especially bad when the CFLAGS need to be respected because they've somehow fucked up includes enough to require explicitly passing "-I/usr/include"

wouldn't it be fucking hilarious if that package was gcc-4.3?

Ah, yes: dd from coreutils-9.7 DOES WORK... unless status is enabled, at which point it will segfault as it's taking "jd" from... the formatted strings, I think? and just taking that literally, and then segfaulting shortly after when trying to compute numbers against string "jd", which I'm surprised doesn't work, as I figured you COULD, in fact, just do calculations against a string...

The fun part is that it works fine otherwise, so I've been compiling things normally and correctly with a busted dd the whole time.

with some help from a friend libffi-3.5.2 is BUILT but not TESTED because i'm not doing fucking dejagnu, it's so much extra shit to build to test a couple packages... let's see if python thinks it works.

figured out why libgnu.a becomes trashed due to __eprintf being referenced but hidden: binutils 2.15 poisons gcc 3.2, which then cascades ALL the way up to gcc-4.3.6 before problems actually show up, when symbols support being hidden suddenly. There's a bug and everything, which was wontfixed and forgotten about 20 FUCKING YEARS AGO, and 5 years before the bug actually trips in gcc on sol7! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19461

motherfuckers, all of them

19461 – hidden __eprintf referenced by DSO, gas+gld

The issue is more than this one bug, if you're dealing with this bug, this is how you fix it, as it starts at the very beginning of the non-Sun compiler stack:
- Don't use tgcware or sunfreeware packages. They're all poisoned in this way, and it causes issues compiling just about everything later down the line. Start with SUNWspro.
- Build binutils 2.13 before gcc 2.x, which is required for 3.x or higher anyway. SUNWspro will just barely suffice for this on Solaris 7.
- Build gcc 2.95.3, ENFORCE THE GNU BINUTILS. The docs say to use Solaris as+ld, this is a trap. Don't fall for it! Never use them unless there's strictly no other option.
- Build binutils 2.15, then gcc 3.2.3 (do not bootstrap.) Because gcc 2.95.3 isn't poisoned by the system linker, you'll be OK.
- As gcc 3.2.3 cannot be bootstrapped with 2.95.3 (despite that being the opposite of every doc in the universe about gcc being forced to bootstrap, gcc 2.95.3 is not capable of doing this) remove the GCC 2.x specific include dir in your prefix (3.2.3 won't do this itself) and immediately rebuild gcc 3.2.3 (with bootstrap-lean) to remove errant C++ behavior for later.
- Build binutils 2.17. 2.15 will build gcc 4.x and beyond, but this breaks libstdc++ permanently as it'll version symbols that do not exist. If "floor@@SUNW_1.1" symbol refs exist in a binary, you've hit this bug.
- Build gcc 4.2.4, disable bootstrap. (It will bootstrap anyway, but if you try to enable it, it'll break. This occurs with make 3.7 through 4.4, so it's a logic bug in gcc's autotools set.) As before, remove all 3.2.3-specific include directories (and $PREFIX/i386-pc-solaris2.7/assert.h, due to a CFLAGS bug in 4.2.4 through 4.6, and probably much further) and then immediately rebuild it with itself. (Again, disable bootstrap, it will anyway.)

At this point, if libstdc++.so has no references to __eprintf or floor@@SUNW_1.1, you're in the clear. More testing is needed to see if this persists through 4.6.x, the last versions with any measure of sol7 support, but i'll keep people posted.

"illegal instruction" oh boy, gcc 4.5.4 bootstrap isn't working again! how did i fix this last time?

`man /opt/SUNWspro/bin/cc`
"yes we have similar -O flags to GCC but no -OS or -Os"
ok, that's reasonable...

`-O1`
"WARNING: Passing '-1' to linker!"

so that was a fucking lie

i've gone ahead and rewritten 90% of my build system, and now I can build binutils-2.15 (kind of) but now gcc-3.2.3 is inconsistent on whether `ld` will SIGSEGV or not, and if it doesn't, tar-1.25 can't be built because it loses track of its own internal includes (alloca.h, part of libgnu), which it only tells me about at link time.

Nothing has changed in the env itself, I've got all kinds of debug output to make sure of that.

challenge to the gnu foundation: do literally anything other than override explicit instructions from the user in thirty separate places

$ cat sys-patch.sh

#Go To Jail For Your Linker Crimes
mkdir -p /usr/jail
mv /usr/ccs/bin/as /usr/jail/as.orig
mv /usr/ccs/bin/ld /usr/jail/ld.orig

this legitimately instantly fixed a hundred things because several GNU makefiles reset your PATH at some point and if you're trying to avoid default linker/etc, suddenly resetting the path tends to revert back to them, even with "LD=/very/specific/full/path/to/ld" and such.
ah yes, we can BUILD binutils-2.20.1, but if you EVER try to install it it eats shit on INSTALLING a static library. literally how
gdb be like "yeah we need to make this library. oh but we can't actually because the un-built library is missing sorry"
the mastodon web UI is Very Mad that I didn't add alt text to the image, but legitimately what would I add to it? There's no context I can further add with alt text to make it more descriptive, and polluting a TTS' output (or something like a Lynx TUI) with the full contents of the screenshot would probably be worse than adding no alt text...
@parzivalwolfram
Maybe just 'screenshot of gdb output'?

I've had friends suggest things during the duration of this project, some suggestions are helpful and some are very much not:

"Rebuild your scripts, they're ass and hard to maintain" - helpful, broke shit but needed done.

"You saw that one Unix book in that store, right? Buy it if it has the CD, i'll just give you the money." - Suspicious, but helpful, contained a lot of good hints and also seemingly lost versions of a lot of GNU software that I can bootstrap with suncc. archive.org listing soon.

"Just port glibc!" - trust me buddy, i've tried, it's not as easy as "add sysdefs lmao" like they make it out to be and they removed the ability to port it in like 2014

"Just port GCC <newest version>!" - god no could you imagine how fucking hard it would be to deal with the macro hell in there?

"Just use modern Linux" - not helpful, that's no fun.

"Use rust lmao" - not helpful, even taking it seriously I'd have to add full C98/C11/C++11 at minimum to build the vendored LLVM and if I could do that the issue would be over anyways.

"Build your own compiler equivalent to GCC <newest version>!" - i'm not smart enough to not fuck up the system headers, and you want me to do WHAT

i can't even build binutils-2.13.2.1 anymore, which came before GCC in general earlier.

i hate this shit dude it's rotting BEFORE MY EYES

it appears it's time once again.

Solaris 7 Pro Tip:
after installing XFree86 and getting it set up, use the following one-liner to get it to take over the display server:
`echo ":0 Local local_uid@console root /usr/X11R6/bin/X" > /usr/dt/config/Xservers && reboot`

(nowhere in the docs is this clear at all, and the docs lie in general.)

Perl, can you stop being a dick for five seconds? I have the build system set up specifically for a reason, obey my settings!
The answer is no. perl-5.38.0 is occasionally installing itself to $PREFIX/$PREFIX/ instead of $PREFIX/ and this is only happening after moving it up to before gcc 4.2.4 instead of after (the thing responsible for setting this data is a fucking *shell script* so why would that matter?)
uh oh perl, did you ignore the -ggdb flag?
are build success reports for this platform even helpful if I've had to patch both the program AND the tests? something like patching around MAP_ANON being missing and not being confident at all that it's correct, but it is working? I probably shouldn't submit those, right?
we have stdatomic. thank you to Jens Gustedt, who put together a libatomic I could understand enough to get working. https://gitlab.inria.fr/gustedt/stdatomic
Jens Gustedt / stdatomic · GitLab

Gitlab at Inria

GitLab
yes thank you gcc, "a != a"
Again? Again. Earlier, this time. This worked an hour ago, and now by the magic of "here's off_t" we've toasted wchar.h, which has never once needed a patch before. what
ah, yes, now CMake forgets that "file.c" is a C file, and "file2.cxx" is a CXX file. How did I fuck this up this badly, exactly?