4 ms·
Back when compiler warnings possibly cost extra processing time to generate, it was possible to make gcc compile the craziest things. After much experimentatio
by smokel 3y ago
Back when compiler warnings possibly cost extra processing time to generate, it was possible to make gcc compile the craziest things.
After much experimentation, it turned out that the smallest program that would compile and run was only 5 bytes long:
main;
- LoganDark 3y ago> make gcc compile the craziest things In languages like Haskell you can just make 2+2=5: https://codegolf.stackexchange.com/a/28794 https://codegolf.stackexchange.com/a/28794
- extraduder_ire 3y agoI still get a segmentation fault out of that when I run it. I think there's flags you can use to get the linker to not complain about missing main if you give gcc an empty file. The craziest thing I got gcc (the AVR version, specifically) to compile for real purposes was a preprocessor macro that spit out tens of thousands of asm blocks with memory barriers and nop (do nothing) instructions with "PORTB = 1;" in the middle and "PORTB = 0" at the end. I needed it to bitbang out a clock signal to read an RFID tag on poorly documented hardware. (fun fact: the clock the cpu uses on an arduino uno is considerably worse and less accurate than the one that's on the board for the USB chip.)
- SomeoneFromCA 3y agoMust be the internal RC clock? it sucks.
- extraduder_ire 3y agoNope, it's an external one at 16mhz. I think the internal one on the chip can only get up to 8mhz, and is accurate to about +-5% It's enough to work for most things. Only annoying thing is, if you use the ICSP header to set the clock to external, you need a working clock to even use ICSP. (the 328pb falls back to the internal clock in this case)
- leblancfg 3y agoWelp that's a nerd snipe if I ever had one. Will report back once my bruteforce hack finishes crunching away.
- smokel 3y agoPlease do, I'm eager to find out how long it takes to compile and run 4,294,967,296 small C files on modern hardware ;)
- leblancfg 3y agoI was able to feed stdin to `gcc` instead of all that IO, which considerably sped it up and spread over 5 cores. But ultimately I gave up after the third time my computer crashed. I was at length 4 by that point, next step would have been to throttle the CPU usage.