mirror of
https://github.com/vlang/v.git
synced 2025-09-13 14:32:26 +03:00
examples: add minimal_c_like_program_using_puts.v showing how to produce a much smaller executable on Linux, using clang, mold and sstrip.
This commit is contained in:
parent
70db1499b8
commit
4a8b3151b9
1 changed files with 14 additions and 0 deletions
14
examples/minimal_c_like_program_using_puts.v
Normal file
14
examples/minimal_c_like_program_using_puts.v
Normal file
|
@ -0,0 +1,14 @@
|
|||
module no_main
|
||||
|
||||
// Compile with:
|
||||
// v -cc clang -prod -gc none -cflags '-s -fuse-ld=mold' -o hw examples/minimal_c_like_program_using_puts.v && ll hw && sstrip -z hw && ll hw
|
||||
// With clang-10, on Ubuntu 20.04, it produces an executable with a size of 2331 bytes, after stripping.
|
||||
// Note: the above uses sstrip 2.1 (from https://git.sr.ht/~breadbox/ELFkickers) and mold 2.32.0 (from https://github.com/rui314/mold).
|
||||
|
||||
fn C.puts(const_msg &char) int
|
||||
|
||||
@[export: 'main']
|
||||
fn hello() int {
|
||||
C.puts(c'Hello world')
|
||||
return 0
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue