Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Latest commit

 

History

History
25 lines (19 loc) · 648 Bytes

README.md

File metadata and controls

25 lines (19 loc) · 648 Bytes

c_dependency_example

rustc

# Compile C code with `-flto`
clang ./src/clib.c -flto=thin -c -o ./clib.o -O2
# Create a static library from the C code
ar crus ./libxyz.a ./clib.o

# Invoke `rustc` with the additional arguments
rustc -Clinker-plugin-lto -L. -Copt-level=2 -Clinker=clang -Clink-arg=-fuse-ld=lld ./src/main.rs

cargo

# Compile C code with `-flto`
clang ./src/clib.c -flto=thin -c -o ./clib.o -O2
# Create a static library from the C code
ar crus ./libxyz.a ./clib.o

# Set the linking arguments via RUSTFLAGS
RUSTFLAGS="-Clinker-plugin-lto -Clinker=clang -Clink-arg=-fuse-ld=lld" cargo build --release