pub enum LibraryPath {
CargoArtifact(PathBuf),
External(PathBuf),
}
Expand description
Represents a path added to the library search path.
We need to keep track of requests to add search paths within the cargo build directory
separately from paths outside of Cargo. The reason is that we want to give precedence to linking
against libraries within the Cargo build directory even if a similar library exists in the
system (e.g. crate A adds /usr/lib
to the search path and then a later build of crate B adds
target/debug/...
to satisfy its request to link against the library B that it built, but B is
also found in /usr/lib
).
There’s some nuance here because we want to preserve relative order of paths of the same type. For example, if the build process would in declaration order emit the following linker line:
-L/usr/lib -Ltarget/debug/build/crate1/libs -L/lib -Ltarget/debug/build/crate2/libs)
we want the linker to actually receive:
-Ltarget/debug/build/crate1/libs -Ltarget/debug/build/crate2/libs) -L/usr/lib -L/lib
so that the library search paths within the crate artifacts directory come first but retain relative ordering while the system library paths come after while still retaining relative ordering among them; ordering is the order they are emitted within the build process, not lexicographic order.
WARNING: Even though this type implements PartialOrd + Ord, this is a lexicographic ordering. The linker line will require an explicit sorting algorithm. PartialOrd + Ord is derived because BuildOutput requires it but that ordering is different from the one for the linker search path, at least today. It may be worth reconsidering & perhaps it’s ok if BuildOutput doesn’t have a lexicographic ordering for the library_paths? I’m not sure the consequence of that.
Variants§
CargoArtifact(PathBuf)
The path is pointing within the output folder of the crate and takes priority over external paths when passed to the linker.
External(PathBuf)
The path is pointing outside of the crate’s build location. The linker will always
receive such paths after CargoArtifact
.
Implementations§
Source§impl LibraryPath
impl LibraryPath
Trait Implementations§
Source§impl AsRef<PathBuf> for LibraryPath
impl AsRef<PathBuf> for LibraryPath
Source§impl Clone for LibraryPath
impl Clone for LibraryPath
Source§fn clone(&self) -> LibraryPath
fn clone(&self) -> LibraryPath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for LibraryPath
impl Debug for LibraryPath
Source§impl Hash for LibraryPath
impl Hash for LibraryPath
Source§impl Ord for LibraryPath
impl Ord for LibraryPath
Source§fn cmp(&self, other: &LibraryPath) -> Ordering
fn cmp(&self, other: &LibraryPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for LibraryPath
impl PartialEq for LibraryPath
Source§impl PartialOrd for LibraryPath
impl PartialOrd for LibraryPath
impl Eq for LibraryPath
impl StructuralPartialEq for LibraryPath
Auto Trait Implementations§
impl Freeze for LibraryPath
impl RefUnwindSafe for LibraryPath
impl Send for LibraryPath
impl Sync for LibraryPath
impl Unpin for LibraryPath
impl UnwindSafe for LibraryPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes
Size for each variant:
CargoArtifact
: 24 bytesExternal
: 24 bytes