Documentation ¶
Overview ¶
patchpkg patches packages to fix common linker errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // SystemLibSearchPaths match the system library paths for common Linux // distributions. SystemLibSearchPaths = []string{ "/lib*/*-linux-gnu", "/lib*", "/var/lib*/*/lib*", } // EnvLibrarySearchPath matches the paths in the LIBRARY_PATH // environment variable. EnvLibrarySearchPath = filepath.SplitList(os.Getenv("LIBRARY_PATH")) // EnvLDLibrarySearchPath matches the paths in the LD_LIBRARY_PATH // environment variable. EnvLDLibrarySearchPath = filepath.SplitList(os.Getenv("LD_LIBRARY_PATH")) // CUDALibSearchPaths match the common installation directories for CUDA // libraries. CUDALibSearchPaths = []string{ "/opt/cuda/lib*", "/opt/nvidia/lib*", "/usr/local/cuda/lib*", "/usr/local/nvidia/lib*", "/lib*/nvidia", "/lib*/cuda", "/usr/lib*/nvidia", "/usr/lib*/cuda", "/usr/local/lib*", "/usr/local/lib*/nvidia", "/usr/local/lib*/cuda", } )
Functions ¶
func FindSharedLibrary ¶
func FindSharedLibrary(name string, searchPath ...string) iter.Seq[SharedLibrary]
FindSharedLibrary searches the directories in searchPath for a shared library. It yields any libraries in the search path directories that have name as a prefix. For example, "libcuda.so" will match "libcuda.so", "libcuda.so.1", and "libcuda.so.550.107.02". The underlying file is only valid for a single iteration, after which it is closed.
The search path may contain filepath.Glob patterns. See SystemLibSearchPaths for some predefined search paths. If name is an absolute path, then FindSharedLibrary opens it directly and doesn't perform any searching.
Types ¶
type DerivationBuilder ¶
type DerivationBuilder struct { // Out is the output directory that will contain the built derivation. // If empty it defaults to $out, which is typically set by Nix. Out string // Glibc is an optional store path to an alternative glibc version. If // it's set, the builder will patch ELF binaries to use its shared // libraries and dynamic linker. Glibc string // Gcc is an optional store path to an alternative gcc version. If // it's set, the builder will patch ELF binaries to use its shared // libraries (such as libstdc++.so). Gcc string RestoreRefs bool // contains filtered or unexported fields }
DerivationBuilder patches an existing package.
func NewDerivationBuilder ¶
func NewDerivationBuilder() (*DerivationBuilder, error)
NewDerivationBuilder initializes a new DerivationBuilder from the current Nix build environment.
type SharedLibrary ¶
type SharedLibrary struct { // is typically a symlink pointing to Soname. The build-time linker // looks for this name by default. LinkerName string // It usually includes a version number suffix (libfoo.so.1). Other ELF // binaries that depend on this library typically specify this name in // the DT_NEEDED field. Soname string // library code. It is typically the soname plus a minor version and // release number (libfoo.so.1.0.0). RealName string }
SharedLibrary describes an ELF shared library (object).
Note that the various name fields document the common naming and versioning conventions, but it is possible for a library to deviate from them.
For an introduction to Linux shared libraries, see https://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
func OpenSharedLibrary ¶
func OpenSharedLibrary(name string) (SharedLibrary, error)
OpenSharedLibrary opens a shared library file. Unlike with ld, name must be an exact path. To search for a library in the usual locations, use FindSharedLibrary instead.
func (SharedLibrary) CopyAndLink ¶
func (lib SharedLibrary) CopyAndLink(dir string) error
CopyAndLink copies the shared library to dir and creates the LinkerName and Soname symlinks for it. It creates dir if it doesn't already exist.
func (SharedLibrary) LogValue ¶
func (lib SharedLibrary) LogValue() slog.Value