noisify makes shared libraries static.
The tool writes native relocatable objects and indexed static archives. The final native linker handles ordinary code, read-only data, writable data, TLS, and unwind sections.
Use noisify to distribute a C++ implementation as a static library with a C interface. Consumers link the archive
with their compatible native C toolchain and use the original C header. The producer can bundle its required C++
runtime code beforehand; noisify keeps suitable implementation symbols private while exposing the selected API.
Typical applications include:
- Shipping a C++ library to C applications without making consumers choose the producer's C++ compiler frontend.
- Incorporating a prebuilt shared library when its original objects or a static build are unavailable.
- Distributing library code statically when shipping a separate shared-library file is undesirable.
Inputs must contain the metadata required by the relevant backend. Runtime libraries left external by the producer remain link dependencies. The resulting object still targets the original platform ABI and processor architecture.
| Platform | Architectures | Input | Object output | Archive output |
|---|---|---|---|---|
| Linux | x86_64, AArch64 |
ELF64 .so |
ELF64 ET_REL .o |
System V indexed .a |
| OS X | x86_64, arm64 (Apple Silicon) |
Mach-O64 .dylib |
Mach-O64 MH_OBJECT .o |
Darwin indexed .a |
All supported inputs are little-endian. Output uses the input's native format, architecture, and ABI; conversion
does not translate Linux code into OS X code. Universal OS X inputs produce one selected architecture per invocation.
Use --arch arm64 or --arch x86_64 to select a slice; the default selects the native or sole supported slice.
Supported compilers are GNU G++ and LLVM Clang++ for Linux, and Apple Clang++ for OS X. The compiler and linker combinations tested locally are:
| Architecture | Compiler versions tested | Producer and consumer linker |
|---|---|---|
| Linux x86-64 | G++ 12.2.0, Clang++ 14.0.6 |
GNU ld.bfd 2.40 |
| Linux AArch64 | G++ 14.2.0, Clang++ 19.1.7 |
GNU ld.bfd 2.44 |
| OS X arm64 and x86-64 | Apple Clang++ 21.0.0 |
Apple ld 1267 |
The Linux x86-64 tests ran under QEMU; Linux AArch64 and OS X arm64 tests ran natively. OS X x86-64 also links and
executes on the local Apple Silicon host. Linux Clang++ is tested with libstdc++; OS X uses libc++.
LLVM lld, other compiler versions, and other architectures have not been validated.
Build the .so with -Wl,--emit-relocs,--no-relax, retaining section headers and symbol tables.
noisify emits separate native sections, whose relative placement can change during the final static link.
--emit-relocs preserves the references that need adjustment when, for example, code and data move by different
amounts. References within a section remain valid when that section moves intact. The current backend requires
retained link-time relocations; it does not infer discarded references from machine code.
The --no-relax requirement is temporary. Producer linker relaxation can rewrite instruction sequences so that
retained relocations alone no longer describe how to reconstruct them. This restriction can be removed as those
sequences gain support. Compiler optimization remains available, and the final consumer link can relax normally.
Build the .dylib with -Wl,-no_fixup_chains and an install name under /usr/lib/ or
/System/Library/. Apple ld then emits version 2 split-segment references, which describe references between
sections. The install name is only producer metadata; the file does not need to be installed in that directory.
The initial backend uses split-segment references and legacy dyld bind/rebase opcodes. It supports ordinary C++ code,
data, native TLS, constructors, destructors, and exception metadata. Chained fixups, arm64e, Objective-C runtime
metadata, and unsupported reference patterns are rejected. Inputs missing the required metadata are rejected.
Python 3.9 or later. The producer and consumer use their normal native compilers and linkers.
The converter has no runtime dependencies beyond Python's standard library.
Install from GitHub (requires Git):
python3 -m pip install git+https://github.com/excitoon/noisify.gitOr install from a local checkout:
python3 -m pip install .
noisify --helpFor development, use python3 -m pip install -e .. Running python3 -m noisify from the checkout also works.
On Linux, build the input with either g++ or clang++:
mkdir -p build
g++ -std=c++17 -O2 -fPIC -shared examples/library.cpp \
-static-libstdc++ -static-libgcc \
-Wl,--emit-relocs,--no-relax \
-o build/libdemo.so
noisify convert build/libdemo.so -o build/libdemo.a \
--name demo --export demo_parse --export demo_next --lifecycle explicit
cc examples/client.c -Iexamples -Ibuild build/libdemo.a -pthread -o build/demo
./build/demoThe example prints 42 1 2. Public symbols are selected by the converter's --export options.
The producer statically includes its C++ standard library and unwinder in this example. If the input imports a shared
C++ runtime instead, the required implementation must still be supplied at the final link. Conversion does not fetch
or automatically include dependency libraries. The consumer need not use the producer's C++ compiler frontend.
On OS X:
mkdir -p build
clang++ -std=c++17 -O2 -dynamiclib examples/library.cpp \
-Wl,-install_name,/usr/lib/libdemo.dylib,-no_fixup_chains \
-o build/libdemo.dylib
noisify convert build/libdemo.dylib -o build/libdemo.a \
--name demo --export demo_parse --export demo_next --lifecycle explicit
clang examples/client.c -Iexamples -Ibuild build/libdemo.a -lc++ -o build/demo
./build/demoThis example leaves the system C++ runtime external, so the C consumer links -lc++.
The resulting executable uses the converted code without loading the input .dylib.
noisify inspect path/to/library.so
noisify convert path/to/library.so -o build/library.a \
--export public_function --export public_data \
--init library_start --cleanup library_stop --lifecycle explicitPublic exports are an explicit allowlist. --exports-file accepts one name per line, with optional # comments.
Original API names and their C types remain unchanged; use the original C header for those declarations. The generated
lifecycle functions default to NAME_init and NAME_cleanup, selected with --name.
Choose output .o for a relocatable object or .a for an indexed archive containing that object.
Conversion also produces a sibling .h with lifecycle declarations and a .json manifest.
Existing outputs are protected unless --force is supplied. An input file is never overwritten by an output or sidecar.
Protected publication requires a filesystem with hard-link support. A late collision can leave complete outputs
already published by that invocation; competing files are preserved.
With --lifecycle explicit, call the generated initializer before using the original API or its exported data.
Initialization returns 0 on success. Cleanup is terminal and idempotent. Serialize lifecycle calls, finish active
API calls, and join library workers before cleanup; reinitialization after cleanup is unsupported.
The argument-free initializer passes 0 and null pointers to original constructors that accept process arguments.
The default auto mode uses ordinary ELF initialization/finalization arrays on Linux. On OS X, a native initializer
registers cleanup with atexit before running the original constructors. The generated entry points are native code
in normal executable sections, with native linker relocations.
Each original constructor receives the initializer arguments supplied by the platform in auto mode.
Destructor registration uses the input's original runtime implementation. On glibc, __cxa_atexit and
__cxa_finalize are libc interfaces and do not themselves require libstdc++. Native TLS and thread-exit handling
remain the responsibility of the normal platform runtime.
On OS X, destructor registrations use a private module token, and explicit cleanup calls __cxa_finalize for it.
Imported atexit calls register against the same token, so explicit cleanup also runs those callbacks in reverse
registration order. Automatic process-exit handling does not run callbacks a second time.
Generated runtime calls use the platform runtime independently of private implementation symbols. Original source
registrations retain their matching runtime finalizer. A used private __cxa_atexit requires a private
__cxa_finalize.
Selected public C symbols remain global. Suitable implementation and bundled-runtime symbols become local to the output object. Existing allocator code is preserved. The library author defines allocation ownership and must catch exceptions inside the C API; the converter does not enforce exception containment.
Native relocations allow the final linker to lay out sections and handle TLS normally. ELF GOT/PLT entries are regenerated; the initial Mach-O backend retains private stubs and pointer cells, with imports bound at the final link. Original exception metadata participates in the final executable's native unwind tables, including reconstructed Mach-O compact unwind records.
Internal definitions bind privately. ELF interposition and GNU unique coalescing across the original DSO boundary are not preserved. Loader-module introspection, ELF filters, local IFUNC resolvers, and unsupported relocation patterns require additional support or rejection. This is a prototype, not a claim of arbitrary binary equivalence.
The initial version preserves section contents and does not split functions or remove unused code within sections. Localizing symbols reduces public-symbol exposure; it does not by itself remove their code. The final linker can discard unused sections where ordinary section-level garbage collection permits it.
Converted functions execute their original native instructions. Position-independent addressing, existing indirect calls, and private Mach-O stubs can remain; conversion does not necessarily eliminate their overhead. ELF final links can optimize some references through normal linker relaxation. There is no general speedup or slowdown guarantee; benchmark the resulting executable with the intended workload.
Converting a library changes its binary format, not its license. Check the input library, every dependency bundled into it, and the consuming application's license. A C API and private symbols do not remove licensing obligations.
For distributing a statically linked application with proprietary application code:
| Input library license | Static redistribution |
|---|---|
MIT, BSD-2-Clause, BSD-3-Clause, ISC |
Generally permitted; retain required notices. |
| Apache-2.0 | Permitted; preserve required license, attribution, NOTICE, and change notices. |
| MPL-2.0 | Permitted; make covered source files and changes available under MPL and provide notices. |
LGPL-2.1, LGPL-3.0 |
Conditional; supply required source and relinking materials. |
GPL-2.0, GPL-3.0 |
Needs a suitable linking exception or separate permission. |
| AGPL-3.0 | Needs additional permission; network-source rules also apply. |
| Proprietary license | Only if your agreement permits conversion and static redistribution. |
The permissive-license summaries follow MIT, BSD-2-Clause, BSD-3-Clause, and ISC.
For LGPL static linking, the usual compliance route supplies the required library source, including changes, and application object files or source plus the materials needed to relink with a modified library. Preserve the required notices and license copies, and permit the modification and debugging reverse engineering required by the license. LGPL-3.0 can also require Installation Information. Providing only the converted library archive supplies neither the library's corresponding source nor the consuming application's relinking materials. See LGPL-2.1 section 6 and LGPL-3.0 section 4.
GPL libraries can be used when the distributed combined program complies with the applicable GPL, including its
corresponding-source requirements; constituent modules may retain compatible licenses.
See GPL-2.0 and GPL-3.0. Proprietary distribution requires an applicable exception
or separate permission.
For modified AGPL-3.0 programs that support remote network interaction, section 13 additionally requires a source
offer to remote users, potentially even without distributing a binary. Check exact license versions, any
or-later options, and exceptions when combining libraries.
Bundled runtime code needs its own check. The GCC Runtime Library Exception can permit
proprietary applications using covered libstdc++ and libgcc code when its Independent Modules and Eligible
Compilation Process conditions hold. It is not an exception for arbitrary GPL libraries. Current upstream
libc++ licensing is Apache-2.0 with LLVM exceptions; older versions and vendor-supplied binaries
can have different terms. Preserve the notices and meet the actual components' redistribution conditions.
These are practical summaries of input-license conditions, not a legal compatibility determination for a particular release. Successful conversion establishes no redistribution permission; review the actual licenses and agreements.
python3 -m unittest discover -vThe suite uses unittest, temporary directories, and the installed native toolchain for integration tests.
The compiler matrix covers GCC/G++ and Clang/Clang++ on Linux x86-64 and AArch64, and Apple Clang on OS X.
Parser checks do not require a compiler; unavailable native integration environments are reported as skips.
Linux validation passed the original 54 tests on each target. The expanded suite also covers native Mach-O objects,
Darwin archives, universal input selection, and C++ cleanup. Integration checks include C-only final links, native TLS,
internal exceptions, lifecycle calls, empty-PATH conversion, ordinary section permissions, and indexed archives.
GitHub Actions runs the suite on native Linux and OS X runners for both architectures, with the minimum and current
Python versions where available. It also checks installation and builds wheel/source distributions. A vVERSION tag
matching the package version prepares a draft GitHub Release with both packages and checksums; publishing is manual.
- ELF relocation specification
- C++ construction and destruction ABI
- GNU linker relocation retention
- Apple dyld sources
MIT.