Hacker News new | past | comments | ask | show | jobs | submit login
The tale of "-mrtd" in GCC and Clang (m680x0.github.io)
85 points by cbmuser on May 7, 2023 | hide | past | favorite | 19 comments



GCC 1.21 (released in May 1988) had -mrtd for m68k, but it didn't support i386 yet:

https://gcc.gnu.org/pub/gcc/old-releases/gcc-1/gcc-1.21.tar....


I didn’t know they put pre-VCS GCC on their own server. Thanks for pointing out!


Even though rcs and sccs were in every Unix distro and some other competitors existed their use was not common back then.

Rich Pixley deserves all the credit for getting gnu sources into source control, specifically CVS which at the time was the latest hotness (it was not yet client server; that was added later by IIRC Ian Taylor after some unfortunate incidents).

John and I placed some absurd hoops that needed to be jumped through in order for source control to be adopted, all of which Rich wisely just ignored.


This story was uncovered while working on the M68k backend in LLVM.

If you think that LLVM having an M68k is a great idea, please consider supporting the development via OpenCollective or Patreon:

- https://opencollective.com/m68k-llvm-dev

- https://www.patreon.com/m68k_llvm


> Alternatively I can directly ask some of the early GCC contributors. Unfortunately I’m not sure whether their emails are still reachable or even worse, whether they are still with us.

Last I checked, rms himself is still alive and answering emails. He might be a good place to start.


[flagged]


I'm not a fan of him, but he responds relatively quick to emails, so maybe he still has access to some old copies of gcc source code.


Why?


[flagged]


The man eats his own toenails. C'mon bro.


I mean yeah, but that's not bad enough to warrant such a response.

It's not like he's deranged or unsafe to speak to.


[flagged]


If you’re studying history you talk to everyone regardless of their beliefs. You’d be better off just ignoring crap like that entirely.


I'm not trans but I have some mates who are so that side of things matters to me. Here's his position on trans stuff https://web.archive.org/web/20210324062919/https://www.stall...

It's not one I agree or disagree with but it looks perfectly reasonable. My suspicion is you didn't read any of it and just spouted off on first impressions.

I'd be a lot happier if opinionated HN commenters would be a little slower about getting offended on other people's behalf.


Discussed on HN back then:

https://news.ycombinator.com/item?id=26558348 (146 comments)


As someone growing up writing assembler on the M68k-based Amiga, reading about the rtd instruction was mildly shocking. Learning it was 68010 and later calmed me down, phew.

Edit: spelling.


I re-used the 68k engine from an amiga emulator once. I only encountered one bug: the RTD instruction wasn't implemented correctly.


I remember the RTD instruction. In classic macOS 7 it's employed by code that uses the Pascal calling convention.


The reason why it was generally not used in C was probably that in pre-ANSI C, prototypes were optional, calling conventions were enforced loosely, and even in functions that were not officially variadic, sometimes trailing arguments were omitted deliberately or accidentally.


Prototypes did not exist in original K&R. Even function declarations (without prototypes/parameter lists) were still optional in C89 (“ANSI C”), only C99 disallowed calling undeclared functions. To this day, GCC accepts call to undeclared functions by default. Generally, the ABIs GCC supports are carefully constructed to support such usage in many historically important cases (such as calling functions declared in <unistd.h>, many of which use the default int return type, too).

The K&R legacy is likely the reason for the caller-pops-arguments convention, but there was also a time where it was deemed more efficient because you could combine multiple stack adjustments.

There's also a neat trick I learned from LuaJIT: if you store the stack pointer in a callee-saved register before the call and restore it afterwards, it works with both conventions.


Ah yes you're right. I had forgotten just how primitive declarations in K&R C were; I thought parameter names were allowed.

In addition to caller-pops-arguments, I also remember that arguments used to be pushed on the stack in right to left order, so the callee had a fixed offset to the first argument, no matter how many arguments were provided.


That is how it worked on MS-DOS as well, the enter/leave instruction pairs for x86 had a similar purpose.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: