pub enum Item {
File(PathBuf),
Library(String),
Linker(String),
}Expand description
One input to the link, in the position the user wrote it.
Link order is semantic: an archive is searched for what is undefined at the moment the linker reaches it, so a library named before the object that needs it contributes nothing. That is why this is one ordered list rather than a list of objects and a list of libraries, which is a shape that cannot represent what the user typed.
Variants§
File(PathBuf)
A file, which is an object this compilation produced or one named on the command line.
Library(String)
-l<name>, which the linker resolves against the search path.
Linker(String)
One word from -Wl, or -Xlinker, handed to the linker where the user wrote it.
Here for the reason the other two are. A great many of the linker’s options are a bracket
around the files after them, so an option moved away from what it brackets means something
else or nothing at all: --whole-archive takes every member of every archive after it
whether anything referenced it or not, --start-group searches the archives after it again
until nothing more comes out, and -Bstatic picks which half of a library that ships both
is wanted.