striplibs

command
v1.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Command striplibs removes from wgpu-native's prebuilt static libraries the sections that cgo refuses to link since Go 1.27.4 (#24).

Go 1.27.4 checks every library a #cgo LDFLAGS names, and refuses it when an object inside carries LLVM bitcode (.llvmbc and .llvmcmd in ELF and COFF, the __LLVM segment in Mach-O) or a COFF .drectve directive it does not allow. Every libs-* slice trips the first: the Rust standard library ships precompiled with embedded bitcode, so a staticlib carries it whatever flags wgpu-native is built with. The Windows GNU slices also trip the second: rustc writes an -exclude-symbols: directive for each symbol a DLL must not re-export, and Go refuses any whose value contains "..", which Rust's legacy symbol mangling uses for "::".

Neither is needed to link: the bitcode is only read for cross-language LTO, and -exclude-symbols: only matters when the library is linked into a DLL. So striplibs removes the bitcode sections, drops the refused -exclude-symbols: directives and keeps the rest, and then checks its own result.

Usage:

go run ./cmd/striplibs [-objcopy llvm-objcopy] lib.a...

Each library is rewritten in place. ELF and Mach-O archives go through llvm-objcopy whole. COFF archives are rewritten member by member, because llvm-objcopy cannot process an archive holding short import members (the windows-link crate puts some in), and extracting and re-archiving loses members that share a name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL