Misc. Build Options
-
-llvm-features=<features>Control LLVM target features used when generating machine code. These are architecture-specific capabilities, such as instruction set extensions, not Go language features or build tags.Pass a comma-separated list without spaces. Use
+nameto enable a feature and-nameto disable it. For example, when building for an x86-64 CPU that supports AVX2:GOOS=linux GOARCH=amd64 tinygo build -llvm-features=+avx2 -o app .TinyGo appends these settings to the selected target’s
featureslist. LLVM also derives defaults from the selected CPU. Normally the target defaults are sufficient; changing them can produce code that will not run on the intended hardware or WebAssembly engine.Available feature names depend on the target architecture and LLVM version. To list them, install LLVM and use its
llvm-asandllctools:llvm-as < /dev/null | llc -march=arm -mattr=helpReplace
armwith the LLVM architecture, such asaarch64,x86,riscv32, orwasm32. The output lists CPUs and features with brief descriptions. Use the LLVM version reported bytinygo versionto get a matching list. These tools are not required for normal TinyGo builds and may need to be installed separately.See LLVM’s
llcdocumentation for more about target features. -
-no-debugDisable outputting debug symbols. This can be useful for WebAssembly, as there is no debugger for .wasm files yet and .wasm files are generally served directly. Avoiding debug symbols can have a big impact on generated binary size, reducing them by more than half. This is not necessary on microcontrollers because debugging symbols are not flashed to the microcontroller. Additionally, you will need it when you usetinygo gdb. In general, it is recommended to include debug symbols unless you have a good reason not to. Note: while there is some support for debug symbols, only line numbers have been implemented so far. That means single-stepping and stacktraces work just fine, but no variables can be inspected. -
-sizePrint size (none,short, orfull) of the output (linked) binary. Note that the calculated size includes RAM reserved for the stack.-
none(default) Print nothing. -
shortPrint size statistics, roughly like what thesizebinutils program would print but with useful flash and RAM columns:code data bss | flash ram 5780 144 2132 | 5924 2276 -
fullTry to determine per package how much space is used. Note that these calculations are merely guesses and can sometimes be way off due to various reasons like inlining:code rodata data bss | flash ram | package 876 0 4 0 | 880 4 | (bootstrap) 38 0 0 0 | 38 0 | device/arm 0 0 0 66 | 0 66 | machine 2994 440 124 0 | 3558 124 | main 948 127 4 1 | 1079 5 | runtime 4856 567 132 67 | 5555 199 | (sum) 5780 - 144 2132 | 5924 2276 | (all)
-
-
-print-allocs=<regex>Print heap allocations in the program and why they happen. You can use-print-allocs=.if you want to see all heap allocations in the program. You can also match the function name, for example you can use-print-allocs=strconvto print heap allocations that contain thestrconvsubstring (which includes all functions from the strconv standard library package).