4 ms·
> Performance isn't that important in most cases. Optimizing for storage space is…better?
by doublepg23 4y ago
> Performance isn't that important in most cases.
Optimizing for storage space is…better?
- vidarh 4y agoSince they say "scripts", note that tcc supports being invoked in the shebang line. E.g. #!/usr/bin/tcc -run You can do that with gcc/clang too (e.g. #if 0, #endif to wrap a block of shell script to compile the current file and execute the result) but a primary value of tcc is that it compiles fast. On a more philosophical note, the suckless approach is to optimise for simplicity not storage. It's perfectly valid to disagree with that of course, but if simplicitly of the system as a whole is a consideration gcc and clang doesn't really fit.
- LukeShu 4y agoYou can only sort of do that with gcc/clang. The #if 0 trick relies on funny behavior that is in a few common shells. When you try to execve(2) a script without a proper #! shebang, the kernel will return ENOEXEC. Bash will check for ENOEXEC then check a few heuristics to see if it looks like a text file, and if it does, then it will try to run it as a shell script. This means that your script will work when run from a shell, but won't work when exec()ed from a non-shell program, which is a weird foot-gun.
- vidarh 4y agoThat makes sense. When I checked the tcc command line I was mildly surprised to see you could do the #if 0 hack at all, so not surprised to hear it has severe limitations.