Skip to main content

LinkOptions

Struct LinkOptions 

Source
pub struct LinkOptions {
Show 23 fields pub use_ld: Option<String>, pub search: Vec<PathBuf>, pub prefixes: Vec<PathBuf>, pub sysroot: Option<PathBuf>, pub cache: Option<PathBuf>, pub usr: Option<PathBuf>, pub is_static: bool, pub shared: bool, pub pie: Option<bool>, pub no_stdlib: bool, pub no_startfiles: bool, pub no_defaultlibs: bool, pub export_dynamic: bool, pub strip: bool, pub gui: bool, pub unicode: bool, pub no_builtins_lib: bool, pub pinned: Option<TargetTuple>, pub profile: bool, pub fast_math: bool, pub daz_ftz: Option<bool>, pub relocatable: bool, pub os_version: Option<Version>,
}
Expand description

What the command line said about linking.

Kept apart from Options because none of it reaches the compilation. A flag here changes what the linker is told and changes nothing about the object files handed to it, which is why -lm on a -c line is a note rather than an error.

Fields§

§use_ld: Option<String>

-fuse-ld=<name>, which names a linker rather than a path to one.

§search: Vec<PathBuf>

-L<dir>, in order, because the linker takes the first library it finds.

§prefixes: Vec<PathBuf>

-B<prefix>, which is where to look for the linker before looking on the path.

§sysroot: Option<PathBuf>

--sysroot=<dir>, which prefixes the directories this looks in.

§cache: Option<PathBuf>

Where the generated sysroots are, which is crate::cache::dir on a real command line.

None is a caller that was not given one, which outside a test is nothing, and then there is no cross link line and a foreign target is refused the way it was before there was one. It is a field rather than a call inside this module because a link line that read the environment could only be tested on a machine whose environment said the right thing.

§usr: Option<PathBuf>

Where a distribution’s cross packages put the tree for another architecture, which is /usr on a real command line.

Debian and Ubuntu install libc6-dev-arm64-cross and its friends as /usr/<multiarch>/include and /usr/<multiarch>/lib, and gcc’s own files for that target under /usr/lib/gcc-cross/<multiarch>. distro_cross reads it. A field for the reason LinkOptions::cache is one, and None in a test is a machine with no such packages.

§is_static: bool

-static.

§shared: bool

-shared.

§pie: Option<bool>

-pie or -no-pie, and the platform’s default when neither was written.

§no_stdlib: bool

-nostdlib, which is -nostartfiles and -nodefaultlibs together.

§no_startfiles: bool

-nostartfiles.

§no_defaultlibs: bool

-nodefaultlibs.

§export_dynamic: bool

-rdynamic, which puts every symbol in the dynamic table so a program can look itself up.

§strip: bool

-s, which drops the symbol table.

§gui: bool

-mwindows rather than -mconsole, whichever came last. Only a Windows line reads it.

§unicode: bool

-municode, which only a Windows line reads.

§no_builtins_lib: bool

-fno-builtins-lib, which leaves our own runtime off the line so that the machine’s libgcc answers for everything instead.

§pinned: Option<TargetTuple>

The whole ten field target when --target= spelled one, which is where a pinned libc release is.

None is a command line that named no target at all, and then there is nothing pinned and this machine is the target. A Triple has room for an architecture, an OS and an environment and nowhere to put a release, so the release arrives here instead of there, and cross_sysroot reads it for both of the things it decides: whether this is a cross link and which directory under the cache it is against.

§profile: bool

-pg, which changes the link as well as the code.

The counts a profiled program keeps have to be started before main runs and written out after it returns, and what does both is a start file of its own. So a build that compiles with the flag and links without it produces a program that calls the hook on every function and never writes a profile.

§fast_math: bool

Whether -Ofast, -ffast-math or -funsafe-math-optimizations was in force at the end of the command line, which links crtfastmath.o into anything that is not a shared object.

That file is a constructor which sets flush to zero and denormals are zero before main, so the mode is the process’s rather than the unit’s, and it is the half of fast math the compiler cannot give from inside a function.

§daz_ftz: Option<bool>

-mdaz-ftz or -mno-daz-ftz, which decides the same file outright and for a shared object as well.

§relocatable: bool

-r, which joins objects into one bigger object rather than into something that runs.

Kbuild builds every directory into a built-in.o this way. The result is still an input to a later link, so it takes no startup files, no libraries and nothing about how it will be loaded, which is what gcc leaves off the line when it sees the flag.

§os_version: Option<Version>

The deployment target on an Apple platform, from -mmacosx-version-min= and its friends or from the tuple, which ld64 is told in -platform_version and checks every object against.

None is the platform’s default, the same one the object writer puts in LC_BUILD_VERSION, so that the two agree when neither was told anything.

Trait Implementations§

Source§

impl Clone for LinkOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LinkOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LinkOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for LinkOptions

Source§

impl PartialEq for LinkOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LinkOptions

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.