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.