klcc(1)

✨ klcc(1) β€” bestie edition ✨

okay so. you found your way to klcc(1), the manual page for klcc, and honestly? you're in the right place. the author is H. Peter Anvin and this little tool is about to make compiling against klibc feel like a vibe. let's get into it. πŸŽ€


🌸 NAME 🌸

klcc β€” compile a program against klibc


πŸ¦‹ SYNOPSIS πŸ¦‹

klcc [gcc options] [-o outfile] infile...

πŸ’… DESCRIPTION πŸ’…

so klcc is basically a wrapper around gcc(1) and ld(1) β€” like, it takes your stuff, compiles it, links it, and does the whole thing against the klibc tiny C library. it supports most gcc options, so you don't have to relearn everything. slay. πŸ”₯

now here's the part where it's not like gcc, and this is important bestie: unlike gcc, klcc compiles with optimization on by default. yes, by default. and the optimization level it uses depends on whether or not you specified -g, because klcc frequently uses options in the normal case which makes debugging impossible. 😭 so like, the debugger and the optimizer are beefing, basically.

therefore β€” write this down β€” compile without -g, -O, -f or -m option to use the default optimization level. that's the move. this will generally result in the smallest binaries. πŸ‘‘

you may want to use -s when linking, however.

and if you want to compile with zero optimization whatsoever, use -O0. but heads up: this may not work depending on the version of gcc used. πŸ™ˆ so, y'know, lowkey risky.

  • -nostdinc β€” allows to turn off klibc include files. like, if you don't want them, this is how you say no. πŸ’…

use the -shared or -static option to compile for and link against shared or static klibc. pick your fighter. ⭐

⚠️ note that shared klibc only supports running against the exact same klibc binary as the binary was linked with. not a similar one, not a cousin of it, the exact same one. iykyk. so don't be out here swapping klibc binaries and acting surprised, fr fr. πŸ’€

and in addition to standard gcc options, klcc supports options of the form -print-klibc-option, which prints the corresponding klibc configuration option. cute little introspection moment. ✨


πŸ‘‘ AUTHOR πŸ‘‘

Written by H. Peter Anvin <hpa@zytor.com>. legend behavior, honestly.


Copyright Β© 2005 H. Peter Anvin - All Rights Reserved

okay so this next part is the legal bit and we do not skip it, because it's real and it matters. here it is, verbatim energy:

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


πŸ’– SEE ALSO πŸ’–

  • gcc(1) β€” the other one. you'll be seeing a lot of each other. 🫢

and that's the whole page, bestie. this manual page comes to you from klibc, dated 1 March 2005 β€” yes, 2005, she's vintage and she still eats. πŸ’œ 🧚 go compile something iconic. ✨