Dynamic load deferred.
ExternalLibrary provider trait
Platform spec article
ExternalLibrary provider trait
Spec standingStandard
-
Link-time FFI
Context
Decision
v0.3 maps Extern libraries to link-time providers.
Consequences
C ABI profile.
Verification anchors
Foreign-library import tests.
-
Closed providers
Context
Plugin security.
Decision
v0.3 closed provider registry; plugins deferred.
Consequences
Tier-1 hosts only.
Verification anchors
CLI provider list.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Purpose
Section titled “Purpose”Extern contracts carry a logical Library name (for example "libc", "pthread"). Linkers need concrete flags (-lc, -lpthread, framework paths). The ExternalLibrary trait abstracts that mapping so the CLI can support multiple providers over time.
Trait contract (normative Rust shape)
Section titled “Trait contract (normative Rust shape)”/// Resolves a logical library name from Beskid `Extern` metadata to linker inputs.pub trait ExternalLibrary: Send + Sync { /// Stable provider id (for example `"c-posix"`, `"msvc"` Proposed). fn id(&self) -> &'static str;
/// Target triple or host key this provider supports. fn host_key(&self) -> &str;
/// Map logical name to linker arguments (for example `["-lc"]`). fn resolve_link_args(&self, logical: &str) -> Result<Vec<String>, LibraryResolveError>;
/// Optional: search paths to pass the linker when the logical name is a path. fn resolve_search_paths(&self, logical: &str) -> Vec<std::path::PathBuf>;}Provider registry (v0.3)
Section titled “Provider registry (v0.3)”The reference CLI must ship at least one provider:
| Provider id | Host | Logical names |
|---|---|---|
c-posix | Linux / macOS tier-1 | libc, libpthread, libm, paths to .so / .dylib |
msvc / WinAPI providers are Proposed and out of scope for stdlib Standard (platform tier matrix).
Extension
Section titled “Extension”Future providers (Rust rlib, Swift, etc.) must implement ExternalLibrary without changing Beskid source syntax—only manifest/link metadata and CLI selection.
Errors
Section titled “Errors”LibraryResolveError must surface as CLI diagnostics with the logical name, provider id, and host key so authors can fix Project.proj link entries.
Verification anchors
Section titled “Verification anchors”- Trait + closed registry implementation:
compiler/crates/beskid_analysis/src/external_library/(trait_def.rs,providers.rs,registry.rs). - Closed provider list:
compiler/crates/beskid_analysis/src/external_library/registry.rs::default_registryshipsc-posix(+posixalias) only; per ADRD-TOOL-FLI-0002. - C / POSIX mapping table:
compiler/crates/beskid_analysis/src/external_library/providers.rs::C_POSIX_LOGICAL_NAMES(e.g.c -> -lc,m -> -lm,pthread -> -lpthread); canonicalization stripslibprefix and.so/.dylib/.asuffixes. - Tests:
external_library::providers::testsandexternal_library::registry::tests(in-tree unit tests). End-to-end coverage incompiler/crates/beskid_tests/src/cli/import_lib.rs.