Struct rustc_target::spec::TargetOptions
source · pub struct TargetOptions {Show 114 fields
pub is_builtin: bool,
pub endian: Endian,
pub c_int_width: Cow<'static, str>,
pub os: Cow<'static, str>,
pub env: Cow<'static, str>,
pub abi: Cow<'static, str>,
pub vendor: Cow<'static, str>,
pub linker: Option<Cow<'static, str>>,
pub linker_flavor: LinkerFlavor,
linker_flavor_json: LinkerFlavorCli,
lld_flavor_json: LldFlavor,
linker_is_gnu_json: bool,
pub pre_link_objects: CrtObjects,
pub post_link_objects: CrtObjects,
pub pre_link_objects_self_contained: CrtObjects,
pub post_link_objects_self_contained: CrtObjects,
pub link_self_contained: LinkSelfContainedDefault,
pub pre_link_args: LinkArgs,
pre_link_args_json: LinkArgsCli,
pub late_link_args: LinkArgs,
late_link_args_json: LinkArgsCli,
pub late_link_args_dynamic: LinkArgs,
late_link_args_dynamic_json: LinkArgsCli,
pub late_link_args_static: LinkArgs,
late_link_args_static_json: LinkArgsCli,
pub post_link_args: LinkArgs,
post_link_args_json: LinkArgsCli,
pub link_script: Option<Cow<'static, str>>,
pub link_env: Cow<'static, [(Cow<'static, str>, Cow<'static, str>)]>,
pub link_env_remove: Cow<'static, [Cow<'static, str>]>,
pub asm_args: Cow<'static, [Cow<'static, str>]>,
pub cpu: Cow<'static, str>,
pub features: Cow<'static, str>,
pub direct_access_external_data: Option<bool>,
pub dynamic_linking: bool,
pub dll_tls_export: bool,
pub only_cdylib: bool,
pub executables: bool,
pub relocation_model: RelocModel,
pub code_model: Option<CodeModel>,
pub tls_model: TlsModel,
pub disable_redzone: bool,
pub frame_pointer: FramePointer,
pub function_sections: bool,
pub dll_prefix: Cow<'static, str>,
pub dll_suffix: Cow<'static, str>,
pub exe_suffix: Cow<'static, str>,
pub staticlib_prefix: Cow<'static, str>,
pub staticlib_suffix: Cow<'static, str>,
pub families: Cow<'static, [Cow<'static, str>]>,
pub abi_return_struct_as_int: bool,
pub is_like_aix: bool,
pub is_like_osx: bool,
pub is_like_solaris: bool,
pub is_like_windows: bool,
pub is_like_msvc: bool,
pub is_like_wasm: bool,
pub is_like_android: bool,
pub default_dwarf_version: u32,
pub allows_weak_linkage: bool,
pub has_rpath: bool,
pub no_default_libraries: bool,
pub position_independent_executables: bool,
pub static_position_independent_executables: bool,
pub plt_by_default: bool,
pub relro_level: RelroLevel,
pub archive_format: Cow<'static, str>,
pub allow_asm: bool,
pub main_needs_argc_argv: bool,
pub has_thread_local: bool,
pub obj_is_bitcode: bool,
pub forces_embed_bitcode: bool,
pub bitcode_llvm_cmdline: Cow<'static, str>,
pub min_atomic_width: Option<u64>,
pub max_atomic_width: Option<u64>,
pub atomic_cas: bool,
pub panic_strategy: PanicStrategy,
pub crt_static_allows_dylibs: bool,
pub crt_static_default: bool,
pub crt_static_respected: bool,
pub stack_probes: StackProbeType,
pub min_global_align: Option<u64>,
pub default_codegen_units: Option<u64>,
pub default_codegen_backend: Option<Cow<'static, str>>,
pub trap_unreachable: bool,
pub requires_lto: bool,
pub singlethread: bool,
pub no_builtins: bool,
pub default_hidden_visibility: bool,
pub emit_debug_gdb_scripts: bool,
pub requires_uwtable: bool,
pub default_uwtable: bool,
pub simd_types_indirect: bool,
pub limit_rdylib_exports: bool,
pub override_export_symbols: Option<Cow<'static, [Cow<'static, str>]>>,
pub merge_functions: MergeFunctions,
pub mcount: Cow<'static, str>,
pub llvm_mcount_intrinsic: Option<Cow<'static, str>>,
pub llvm_abiname: Cow<'static, str>,
pub relax_elf_relocations: bool,
pub llvm_args: Cow<'static, [Cow<'static, str>]>,
pub use_ctors_section: bool,
pub eh_frame_header: bool,
pub has_thumb_interworking: bool,
pub debuginfo_kind: DebuginfoKind,
pub split_debuginfo: SplitDebuginfo,
pub supported_split_debuginfo: Cow<'static, [SplitDebuginfo]>,
pub supported_sanitizers: SanitizerSet,
pub c_enum_min_bits: Option<u64>,
pub generate_arange_section: bool,
pub supports_stack_protector: bool,
pub entry_name: Cow<'static, str>,
pub entry_abi: Conv,
pub supports_xray: bool,
}
Expand description
Optional aspects of a target specification.
This has an implementation of Default
, see each field for what the default is. In general,
these try to take “minimal defaults” that don’t assume anything about the runtime they run in.
TargetOptions
as a separate structure is mostly an implementation detail of Target
construction, all its fields logically belong to Target
and available from Target
through Deref
impls.
Fields§
§is_builtin: bool
Whether the target is built-in or loaded from a custom target specification.
endian: Endian
Used as the target_endian
cfg
variable. Defaults to little endian.
c_int_width: Cow<'static, str>
Width of c_int type. Defaults to “32”.
os: Cow<'static, str>
OS name to use for conditional compilation (target_os
). Defaults to “none”.
“none” implies a bare metal target without std
library.
A couple of targets having std
also use “unknown” as an os
value,
but they are exceptions.
env: Cow<'static, str>
Environment name to use for conditional compilation (target_env
). Defaults to “”.
abi: Cow<'static, str>
ABI name to distinguish multiple ABIs on the same OS and architecture. For instance, "eabi"
or "eabihf"
. Defaults to “”.
vendor: Cow<'static, str>
Vendor name to use for conditional compilation (target_vendor
). Defaults to “unknown”.
linker: Option<Cow<'static, str>>
Linker to invoke
linker_flavor: LinkerFlavor
Default linker flavor used if -C linker-flavor
or -C linker
are not passed
on the command line. Defaults to LinkerFlavor::Gnu(Cc::Yes, Lld::No)
.
linker_flavor_json: LinkerFlavorCli
§lld_flavor_json: LldFlavor
§linker_is_gnu_json: bool
§pre_link_objects: CrtObjects
Objects to link before and after all other object code.
post_link_objects: CrtObjects
§pre_link_objects_self_contained: CrtObjects
Same as (pre|post)_link_objects
, but when self-contained linking mode is enabled.
post_link_objects_self_contained: CrtObjects
§link_self_contained: LinkSelfContainedDefault
Behavior for the self-contained linking mode: inferred for some targets, or explicitly enabled (in bulk, or with individual components).
pre_link_args: LinkArgs
Linker arguments that are passed before any user-defined libraries.
pre_link_args_json: LinkArgsCli
§late_link_args: LinkArgs
Linker arguments that are unconditionally passed after any user-defined but before post-link objects. Standard platform libraries that should be always be linked to, usually go here.
late_link_args_json: LinkArgsCli
§late_link_args_dynamic: LinkArgs
Linker arguments used in addition to late_link_args
if at least one
Rust dependency is dynamically linked.
late_link_args_dynamic_json: LinkArgsCli
§late_link_args_static: LinkArgs
Linker arguments used in addition to late_link_args
if all Rust
dependencies are statically linked.
late_link_args_static_json: LinkArgsCli
§post_link_args: LinkArgs
Linker arguments that are unconditionally passed after any user-defined libraries.
post_link_args_json: LinkArgsCli
§link_script: Option<Cow<'static, str>>
Optional link script applied to dylib
and executable
crate types.
This is a string containing the script, not a path. Can only be applied
to linkers where linker flavor matches LinkerFlavor::Gnu(..)
.
link_env: Cow<'static, [(Cow<'static, str>, Cow<'static, str>)]>
Environment variables to be set for the linker invocation.
link_env_remove: Cow<'static, [Cow<'static, str>]>
Environment variables to be removed for the linker invocation.
asm_args: Cow<'static, [Cow<'static, str>]>
Extra arguments to pass to the external assembler (when used)
cpu: Cow<'static, str>
Default CPU to pass to LLVM. Corresponds to llc -mcpu=$cpu
. Defaults
to “generic”.
features: Cow<'static, str>
Default target features to pass to LLVM. These features will always be
passed, and cannot be disabled even via -C
. Corresponds to llc -mattr=$features
.
direct_access_external_data: Option<bool>
Direct or use GOT indirect to reference external data symbols
dynamic_linking: bool
Whether dynamic linking is available on this target. Defaults to false.
dll_tls_export: bool
Whether dynamic linking can export TLS globals. Defaults to true.
only_cdylib: bool
If dynamic linking is available, whether only cdylibs are supported.
executables: bool
Whether executables are available on this target. Defaults to true.
relocation_model: RelocModel
Relocation model to use in object file. Corresponds to llc -relocation-model=$relocation_model
. Defaults to Pic
.
code_model: Option<CodeModel>
Code model to use. Corresponds to llc -code-model=$code_model
.
Defaults to None
which means “inherited from the base LLVM target”.
tls_model: TlsModel
TLS model to use. Options are “global-dynamic” (default), “local-dynamic”, “initial-exec” and “local-exec”. This is similar to the -ftls-model option in GCC/Clang.
disable_redzone: bool
Do not emit code that uses the “red zone”, if the ABI has one. Defaults to false.
frame_pointer: FramePointer
Frame pointer mode for this target. Defaults to MayOmit
.
function_sections: bool
Emit each function in its own section. Defaults to true.
dll_prefix: Cow<'static, str>
String to prepend to the name of every dynamic library. Defaults to “lib”.
dll_suffix: Cow<'static, str>
String to append to the name of every dynamic library. Defaults to “.so”.
exe_suffix: Cow<'static, str>
String to append to the name of every executable.
staticlib_prefix: Cow<'static, str>
String to prepend to the name of every static library. Defaults to “lib”.
staticlib_suffix: Cow<'static, str>
String to append to the name of every static library. Defaults to “.a”.
families: Cow<'static, [Cow<'static, str>]>
Values of the target_family
cfg set for this target.
Common options are: “unix”, “windows”. Defaults to no families.
See https://doc.rust-lang.org/reference/conditional-compilation.html#target_family.
abi_return_struct_as_int: bool
Whether the target toolchain’s ABI supports returning small structs as an integer.
is_like_aix: bool
Whether the target toolchain is like AIX’s. Linker options on AIX are special and it uses XCOFF as binary format. Defaults to false.
is_like_osx: bool
Whether the target toolchain is like macOS’s. Only useful for compiling against iOS/macOS,
in particular running dsymutil and some other stuff like -dead_strip
. Defaults to false.
Also indiates whether to use Apple-specific ABI changes, such as extending function
parameters to 32-bits.
is_like_solaris: bool
Whether the target toolchain is like Solaris’s. Only useful for compiling against Illumos/Solaris, as they have a different set of linker flags. Defaults to false.
is_like_windows: bool
Whether the target is like Windows. This is a combination of several more specific properties represented as a single flag:
- The target uses a Windows ABI,
- uses PE/COFF as a format for object code,
- uses Windows-style dllexport/dllimport for shared libraries,
- uses import libraries and .def files for symbol exports,
- executables support setting a subsystem.
is_like_msvc: bool
Whether the target is like MSVC. This is a combination of several more specific properties represented as a single flag:
- The target has all the properties from
is_like_windows
(for in-tree targets “is_like_msvc ⇒ is_like_windows” is ensured by a unit test), - has some MSVC-specific Windows ABI properties,
- uses a link.exe-like linker,
- uses CodeView/PDB for debuginfo and natvis for its visualization,
- uses SEH-based unwinding,
- supports control flow guard mechanism.
is_like_wasm: bool
Whether a target toolchain is like WASM.
is_like_android: bool
Whether a target toolchain is like Android, implying a Linux kernel and a Bionic libc
default_dwarf_version: u32
Default supported version of DWARF on this platform. Useful because some platforms (osx, bsd) only want up to DWARF2.
allows_weak_linkage: bool
The MinGW toolchain has a known issue that prevents it from correctly handling COFF object files with more than 215 sections. Since each weak symbol needs its own COMDAT section, weak linkage implies a large number sections that easily exceeds the given limit for larger codebases. Consequently we want a way to disallow weak linkage on some platforms.
has_rpath: bool
Whether the linker support rpaths or not. Defaults to false.
no_default_libraries: bool
Whether to disable linking to the default libraries, typically corresponds
to -nodefaultlibs
. Defaults to true.
position_independent_executables: bool
Dynamically linked executables can be compiled as position independent if the default relocation model of position independent code is not changed. This is a requirement to take advantage of ASLR, as otherwise the functions in the executable are not randomized and can be used during an exploit of a vulnerability in any code.
static_position_independent_executables: bool
Executables that are both statically linked and position-independent are supported.
plt_by_default: bool
Determines if the target always requires using the PLT for indirect
library calls or not. This controls the default value of the -Z plt
flag.
relro_level: RelroLevel
Either partial, full, or off. Full RELRO makes the dynamic linker resolve all symbols at startup and marks the GOT read-only before starting the program, preventing overwriting the GOT.
archive_format: Cow<'static, str>
Format that archives should be emitted in. This affects whether we use LLVM to assemble an archive or fall back to the system linker, and currently only “gnu” is used to fall into LLVM. Unknown strings cause the system linker to be used.
allow_asm: bool
Is asm!() allowed? Defaults to true.
main_needs_argc_argv: bool
Whether the runtime startup code requires the main
function be passed
argc
and argv
values.
has_thread_local: bool
Flag indicating whether #thread_local is available for this target.
obj_is_bitcode: bool
This is mainly for easy compatibility with emscripten. If we give emcc .o files that are actually .bc files it will ‘just work’.
forces_embed_bitcode: bool
Whether the target requires that emitted object code includes bitcode.
bitcode_llvm_cmdline: Cow<'static, str>
Content of the LLVM cmdline section associated with embedded bitcode.
min_atomic_width: Option<u64>
Don’t use this field; instead use the .min_atomic_width()
method.
max_atomic_width: Option<u64>
Don’t use this field; instead use the .max_atomic_width()
method.
atomic_cas: bool
Whether the target supports atomic CAS operations natively
panic_strategy: PanicStrategy
Panic strategy: “unwind” or “abort”
crt_static_allows_dylibs: bool
Whether or not linking dylibs to a static CRT is allowed.
crt_static_default: bool
Whether or not the CRT is statically linked by default.
crt_static_respected: bool
Whether or not crt-static is respected by the compiler (or is a no-op).
stack_probes: StackProbeType
The implementation of stack probes to use.
min_global_align: Option<u64>
The minimum alignment for global symbols.
default_codegen_units: Option<u64>
Default number of codegen units to use in debug mode
default_codegen_backend: Option<Cow<'static, str>>
Default codegen backend used for this target. Defaults to None
.
If None
, then CFG_DEFAULT_CODEGEN_BACKEND
environmental variable captured when
compiling rustc
will be used instead (or llvm if it is not set).
N.B. when using the compiler, backend can always be overridden with -Zcodegen-backend
.
This was added by WaffleLapkin in #116793. The motivation is a rustc fork that requires a custom codegen backend for a particular target.
trap_unreachable: bool
Whether to generate trap instructions in places where optimization would otherwise produce control flow that falls through into unrelated memory.
requires_lto: bool
This target requires everything to be compiled with LTO to emit a final executable, aka there is no native linker for this target.
singlethread: bool
This target has no support for threads.
no_builtins: bool
Whether library functions call lowering/optimization is disabled in LLVM for this target unconditionally.
The default visibility for symbols in this target should be “hidden” rather than “default”.
This value typically shouldn’t be accessed directly, but through
the rustc_session::Session::default_hidden_visibility
method, which
allows rustc
users to override this setting using cmdline flags.
emit_debug_gdb_scripts: bool
Whether a .debug_gdb_scripts section will be added to the output object file
requires_uwtable: bool
Whether or not to unconditionally uwtable
attributes on functions,
typically because the platform needs to unwind for things like stack
unwinders.
default_uwtable: bool
Whether or not to emit uwtable
attributes on functions if -C force-unwind-tables
is not specified and uwtable
is not required on this target.
simd_types_indirect: bool
Whether or not SIMD types are passed by reference in the Rust ABI,
typically required if a target can be compiled with a mixed set of
target features. This is true
by default, and false
for targets like
wasm32 where the whole program either has simd or not.
limit_rdylib_exports: bool
Pass a list of symbol which should be exported in the dylib to the linker.
override_export_symbols: Option<Cow<'static, [Cow<'static, str>]>>
If set, have the linker export exactly these symbols, instead of using the usual logic to figure this out from the crate itself.
merge_functions: MergeFunctions
Determines how or whether the MergeFunctions LLVM pass should run for this target. Either “disabled”, “trampolines”, or “aliases”. The MergeFunctions pass is generally useful, but some targets may need to opt out. The default is “aliases”.
Workaround for: https://github.com/rust-lang/rust/issues/57356
mcount: Cow<'static, str>
Use platform dependent mcount function
llvm_mcount_intrinsic: Option<Cow<'static, str>>
Use LLVM intrinsic for mcount function name
llvm_abiname: Cow<'static, str>
LLVM ABI name, corresponds to the ‘-mabi’ parameter available in multilib C compilers
relax_elf_relocations: bool
Whether or not RelaxElfRelocation flag will be passed to the linker
llvm_args: Cow<'static, [Cow<'static, str>]>
Additional arguments to pass to LLVM, similar to the -C llvm-args
codegen option.
use_ctors_section: bool
Whether to use legacy .ctors initialization hooks rather than .init_array. Defaults to false (uses .init_array).
eh_frame_header: bool
Whether the linker is instructed to add a GNU_EH_FRAME
ELF header
used to locate unwinding information is passed
(only has effect if the linker is ld
-like).
has_thumb_interworking: bool
Is true if the target is an ARM architecture using thumb v1 which allows for thumb and arm interworking.
debuginfo_kind: DebuginfoKind
Which kind of debuginfo is used by this target?
split_debuginfo: SplitDebuginfo
How to handle split debug information, if at all. Specifying None
has
target-specific meaning.
supported_split_debuginfo: Cow<'static, [SplitDebuginfo]>
Which kinds of split debuginfo are supported by the target?
supported_sanitizers: SanitizerSet
The sanitizers supported by this target
Note that the support here is at a codegen level. If the machine code with sanitizer enabled can generated on this target, but the necessary supporting libraries are not distributed with the target, the sanitizer should still appear in this list for the target.
c_enum_min_bits: Option<u64>
Minimum number of bits in #[repr(C)] enum. Defaults to the size of c_int
generate_arange_section: bool
Whether or not the DWARF .debug_aranges
section should be generated.
supports_stack_protector: bool
Whether the target supports stack canary checks. true
by default,
since this is most common among tier 1 and tier 2 targets.
entry_name: Cow<'static, str>
The name of entry function. Default value is “main”
entry_abi: Conv
The ABI of entry function.
Default value is Conv::C
, i.e. C call convention
supports_xray: bool
Whether the target supports XRay instrumentation.
Implementations§
source§impl TargetOptions
impl TargetOptions
fn link_args(flavor: LinkerFlavor, args: &[&'static str]) -> LinkArgs
fn add_pre_link_args(&mut self, flavor: LinkerFlavor, args: &[&'static str])
fn update_from_cli(&mut self)
fn update_to_cli(&mut self)
Trait Implementations§
source§impl Clone for TargetOptions
impl Clone for TargetOptions
source§fn clone(&self) -> TargetOptions
fn clone(&self) -> TargetOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TargetOptions
impl Debug for TargetOptions
source§impl Default for TargetOptions
impl Default for TargetOptions
source§fn default() -> TargetOptions
fn default() -> TargetOptions
Creates a set of “sane defaults” for any target. This is still incomplete, and if used for compilation, will certainly not work.
source§impl PartialEq for TargetOptions
impl PartialEq for TargetOptions
impl StructuralPartialEq for TargetOptions
Auto Trait Implementations§
impl Freeze for TargetOptions
impl RefUnwindSafe for TargetOptions
impl Send for TargetOptions
impl Sync for TargetOptions
impl Unpin for TargetOptions
impl UnwindSafe for TargetOptions
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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 moresource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
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: 1184 bytes