3 ms·
Something that has boggled my mind everytime I tried out Freepascal is its link time. This is something that I feel tends to get glanced over in Nim or D circl
by fayten 6y ago
Something that has boggled my mind everytime I tried out Freepascal is its link time. This is something that I feel tends to get glanced over in Nim or D circles.
Both advertise fast compilation, and they do compile quickly, but my experience with even 5-10k loc projects with those languages start to see some time sunk into the linker, even with Gold. This will inevitably lead to the change-execute cycle taking 1-3 seconds, while I have had no issue with substantially larger fpc code bases compiling and running in milliseconds.
For Rust and C++ devs a change-execute cycle sub 10 seconds is incredibly enticing. However, fpc has ruined me for what fast compilation really means. It also makes me really wish Nim had stuck to fpc as a backend.
I know very little about what is actually going on behind the scenes here. If anyone has any info about pascals compilation as well as linkers in general I would love to know more.
- thijsvandien 6y agoIt's funny you should say that, because to me FPC feels very slow. Delphi got me spoiled. Especially the older versions build (quite literally) in a blink.
- fayten 6y agoI'm not sure if it's good form to reply to yourself here, but I did find this: https://lwn.net/Articles/276782/ https://lwn.net/Articles/276782/. It appears to be a 20 part series from a(the?) Gold developer on Linkers. I checked HN and it looks like there is an old discussion here: https://news.ycombinator.com/item?id=9597406 https://news.ycombinator.com/item?id=9597406 So, I'll probably give this a read when I find time. Hopefully someone else will find it useful as well.
- cb321 6y agoCompiling an echo "hello world" module in Nim from scratch to a fully linked executable can be under 200 milliseconds on modern hardware with the TinyC/tcc backend. tcc has its own assembler and ELF linker built in to get that speed. I don't know much about fpc/free Pascal, but maybe it also does very little optimization of generated code and has its own assembler/linker. It think these are the Big Three things for a fast compile. To get a fast edit/compile/test workflow I just set up my default backend to be tcc and automatically switch to gcc if "-d:release" or "-d:danger" is given on the compile line { really I abbreviate that to "-d:r" :-) } This makes it easy to develop quickly and then switch right over to quick timing tests. Nim also has an interpreter whose startup is more like 100 ms, but which is limited to only what its virtual machine target (also used for compile-time computation) supports.
- pjmlp 6y agoThis is the main reason why Go compilation times, while very welcomed, fail to impress me. Turbo Pascal has spoiled me in 1990's hardware.
- tekknolagi 6y agoThe guy who wrote lld is working on a new, faster linker here: https://github.com/rui314/mold https://github.com/rui314/mold
- fayten 6y agoI like the sounds of this; thank you for sharing!