Skip to content

Latest commit

 

History

History
53 lines (36 loc) · 1.89 KB

File metadata and controls

53 lines (36 loc) · 1.89 KB

Languages: English | 简体中文 | 繁體中文 | 日本語 | 한국어 | Français | Deutsch | Español | Italiano | Русский | العربية

← NeverC Examples

Linux Fully-Static Binary Example

A self-contained, statically-linked Linux executable built with NeverC. The output binary has zero runtime dependencies — runs on any Linux system without shared libraries.

NeverC bundles a Linux sysroot (Ubuntu 22.04, glibc 2.35) in runtime/linux/, so a single invocation handles preprocessing, compilation, optimization (auto-LTO), and linking via the built-in linker.

Build

From the repo (default target: x86_64-linux-gnu):

cd examples/linux-static
neverc make          # debug: -g (default on the first build)
neverc make release  # release: -O2 --strip
neverc make debug    # switch back to debug

The Makefile persists PROFILE, so later neverc make keeps the same debug/release selection. Release uses NeverC's integrated --strip: debug metadata and unneeded static symbol names are removed while loader/dynamic ABI names that the binary still needs are preserved. See Release builds.

Build for AArch64:

neverc make TARGET=aarch64-linux-gnu

Manual build (without Make)

neverc --target=x86_64-linux-gnu -Wall -static -lm -o static-demo main.c

Verify static linking

file static-demo           # "statically linked"
ldd static-demo            # "not a dynamic executable"

What it does

  • Reports system info (pointer size, architecture)
  • Math functions: sqrt, sin, cos, pow, log, exp
  • String operations: snprintf, strdup, sorting
  • Dynamic memory: malloc/free across 10 sizes