Skip to content

rustc_target: Flip the default for TargetOptions::executables to true #98622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/aarch64_unknown_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+strict-align,+neon,+fp-armv8".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(128),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+strict-align,-neon,-fp-armv8".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(128),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/apple_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ pub fn opts(os: &'static str) -> TargetOptions {
function_sections: false,
dynamic_linking: true,
linker_is_gnu: false,
executables: true,
families: cvs!["unix"],
is_like_osx: true,
default_dwarf_version: 2,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/apple_sdk_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
abi: target_abi(arch).into(),
cpu: target_cpu(arch).into(),
dynamic_linking: false,
executables: true,
link_env_remove: link_env_remove(arch),
has_thread_local: false,
..super::apple_base::opts(os)
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armebv7r_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
abi: "eabi".into(),
endian: Endian::Big,
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armebv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
abi: "eabihf".into(),
endian: Endian::Big,
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv6k_nintendo_3ds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn target() -> Target {
abi: "eabihf".into(),
linker_flavor: LinkerFlavor::Gcc,
cpu: "mpcore".into(),
executables: true,
families: cvs!["unix"],
linker: Some("arm-none-eabi-gcc".into()),
relocation_model: RelocModel::Static,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7a_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+v7,+thumb2,+soft-float,-neon,+strict-align".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7a_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
features: "+v7,+vfp3,-d32,+thumb2,-neon,+strict-align".into(),
executables: true,
relocation_model: RelocModel::Static,
disable_redzone: true,
max_atomic_width: Some(64),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7r_none_eabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabi".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/armv7r_none_eabihf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub fn target() -> Target {
options: TargetOptions {
abi: "eabihf".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/avr_gnu_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub fn target(target_cpu: &'static str, mmcu: &'static str) -> Target {
exe_suffix: ".elf".into(),

linker: Some("avr-gcc".into()),
executables: true,
eh_frame_header: false,
pre_link_args: TargetOptions::link_args(LinkerFlavor::Gcc, &[mmcu]),
late_link_args: TargetOptions::link_args(LinkerFlavor::Gcc, &["-lgcc"]),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/bpf_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn opts(endian: Endian) -> TargetOptions {
endian,
linker_flavor: LinkerFlavor::BpfLinker,
atomic_cas: false,
executables: true,
dynamic_linking: true,
no_builtins: true,
panic_strategy: PanicStrategy::Abort,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/dragonfly_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "dragonfly".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/freebsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "freebsd".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/fuchsia_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub fn opts() -> TargetOptions {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
pre_link_args,
pre_link_objects: crt_objects::new(&[
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/haiku_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "haiku".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
relro_level: RelroLevel::Full,
..Default::default()
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/hermit_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub fn opts() -> TargetOptions {
os: "hermit".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
linker: Some("rust-lld".into()),
executables: true,
has_thread_local: true,
pre_link_args,
panic_strategy: PanicStrategy::Abort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub fn target() -> Target {
base.has_rpath = true;
base.linker_is_gnu = false;
base.dynamic_linking = true;
base.executables = true;

base.c_enum_min_bits = 8;

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/illumos_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "illumos".into(),
dynamic_linking: true,
executables: true,
has_rpath: true,
families: cvs!["unix"],
is_like_solaris: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/l4re_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub fn opts() -> TargetOptions {
os: "l4re".into(),
env: "uclibc".into(),
linker_flavor: LinkerFlavor::L4Bender,
executables: true,
panic_strategy: PanicStrategy::Abort,
linker: Some("l4-bender".into()),
linker_is_gnu: false,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/linux_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "linux".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/mipsel_sony_psp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub fn target() -> Target {
vendor: "sony".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
cpu: "mips2".into(),
executables: true,
linker: Some("rust-lld".into()),
relocation_model: RelocModel::Static,

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/mipsel_unknown_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub fn target() -> Target {
cpu: "mips32r2".into(),
features: "+mips32r2,+soft-float,+noabicalls".into(),
max_atomic_width: Some(32),
executables: true,
linker: Some("rust-lld".into()),
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
Expand Down
5 changes: 2 additions & 3 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1212,8 +1212,7 @@ pub struct TargetOptions {
pub dynamic_linking: bool,
/// If dynamic linking is available, whether only cdylibs are supported.
pub only_cdylib: bool,
/// Whether executables are available on this target. iOS, for example, only allows static
/// libraries. Defaults to false.
/// Whether executables are available on this target. Defaults to true.
pub executables: bool,
/// Relocation model to use in object file. Corresponds to `llc
/// -relocation-model=$relocation_model`. Defaults to `Pic`.
Expand Down Expand Up @@ -1520,7 +1519,7 @@ impl Default for TargetOptions {
features: "".into(),
dynamic_linking: false,
only_cdylib: false,
executables: false,
executables: true,
relocation_model: RelocModel::Pic,
code_model: None,
tls_model: TlsModel::GeneralDynamic,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/msp430_none_elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub fn target() -> Target {

options: TargetOptions {
c_int_width: "16".into(),
executables: true,

// The LLVM backend currently can't generate object files. To
// workaround this LLVM generates assembly files which then we feed
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/msvc_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub fn opts() -> TargetOptions {

TargetOptions {
linker_flavor: LinkerFlavor::Msvc,
executables: true,
is_like_windows: true,
is_like_msvc: true,
lld_flavor: LldFlavor::Link,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/netbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "netbsd".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
no_default_libraries: false,
has_rpath: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/nvptx64_nvidia_cuda.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn target() -> Target {

// Needed to use `dylib` and `bin` crate types and the linker.
dynamic_linking: true,
executables: true,

// Avoid using dylib because it contain metadata not supported
// by LLVM NVPTX backend.
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/openbsd_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "openbsd".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
abi_return_struct_as_int: true,
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/redox_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub fn opts() -> TargetOptions {
os: "redox".into(),
env: "relibc".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
position_independent_executables: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(0),
atomic_cas: false,
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub fn target() -> Target {
max_atomic_width: Some(0),
atomic_cas: false,
features: "+m".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub fn target() -> Target {
cpu: "generic-rv32".into(),
max_atomic_width: Some(32),
features: "+m,+a,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
..Default::default()
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/riscv32imc_esp_espidf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pub fn target() -> Target {
atomic_cas: true,

features: "+m,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub fn target() -> Target {
max_atomic_width: Some(0),
atomic_cas: false,
features: "+m,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
emit_debug_gdb_scripts: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub fn target() -> Target {
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
features: "+m,+a,+f,+d,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
code_model: Some(CodeModel::Medium),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ pub fn target() -> Target {
cpu: "generic-rv64".into(),
max_atomic_width: Some(64),
features: "+m,+a,+c".into(),
executables: true,
panic_strategy: PanicStrategy::Abort,
relocation_model: RelocModel::Static,
code_model: Some(CodeModel::Medium),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/solaris_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
os: "solaris".into(),
dynamic_linking: true,
executables: true,
has_rpath: true,
families: cvs!["unix"],
is_like_solaris: true,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/solid_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pub fn opts(kernel: &str) -> TargetOptions {
TargetOptions {
os: format!("solid_{}", kernel).into(),
vendor: "kmc".into(),
executables: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @kawadakk
Is this intentional?
The target specifies a linker, but doesn't specify support for executables or dynamic libraries, so the linker is never used, which is weird.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's intentional. This target requires an external toolchain (linker + post-processor + runtime libraries) to build functional executables or dynamic libraries.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, what?

That's not the impression I had when that target was first approved?

What is the license on that toolchain?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This target requires an external toolchain (linker + post-processor + runtime libraries) to build functional executables or dynamic libraries.

That's true for majority of our targets though, linker/libc/startup objects are typically not shipped with Rust toolchain.
rustc just calls the linker and passes libraries to it by name and expects them to be there.
Although I'm not sure what the post-processor step means for this target.

Copy link
Contributor

@kawadakk kawadakk Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the license on that toolchain?

There's a supported proprietary toolchain (C compiler, linker, etc.) with enhanced functionalities, though it can be substituted by a publicly-available one, such as GNU Arm Embedded Toolchain, to build functional application binaries. ("external" might have given off a wrong connotation.)

The primary deployment mode of this target's operating system is as a library OS. The application binary is built as a static library, which can be done entirely by FOSS components as explained above. Other modes may be possible in the future, and we'd like to leave the executables option for those for now.

Although I'm not sure what the post-processor step means for this target.

Some dynamic executable formats in this operating system use non-standard formats that require post-link conversion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, keeping executables: false for these targets.

frame_pointer: FramePointer::NonLeaf,
has_thread_local: true,
..Default::default()
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/thumb_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ pub fn opts() -> TargetOptions {
// See rust-lang/rfcs#1645 for a discussion about these defaults
TargetOptions {
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
// In most cases, LLD is good enough
linker: Some("rust-lld".into()),
// Because these devices have very little resources having an unwinder is too onerous so we
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/vxworks_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ pub fn opts() -> TargetOptions {
linker: Some("wr-c++".into()),
exe_suffix: ".vxe".into(),
dynamic_linking: true,
executables: true,
families: cvs!["unix"],
has_rpath: true,
has_thread_local: true,
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_target/src/spec/wasm_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ pub fn options() -> TargetOptions {
dynamic_linking: true,
only_cdylib: true,

// This means we'll just embed a `#[start]` function in the wasm module
executables: true,

// relatively self-explanatory!
exe_suffix: ".wasm".into(),
dll_prefix: "".into(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/windows_gnu_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ pub fn opts() -> TargetOptions {
function_sections: false,
linker: Some("gcc".into()),
dynamic_linking: true,
executables: true,
dll_prefix: "".into(),
dll_suffix: ".dll".into(),
exe_suffix: ".exe".into(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/windows_gnullvm_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ pub fn opts() -> TargetOptions {
abi: "llvm".into(),
linker: Some("clang".into()),
dynamic_linking: true,
executables: true,
dll_prefix: "".into(),
dll_suffix: ".dll".into(),
exe_suffix: ".exe".into(),
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_target/src/spec/windows_uwp_gnu_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub fn opts() -> TargetOptions {
TargetOptions {
abi: "uwp".into(),
vendor: "uwp".into(),
executables: false,
limit_rdylib_exports: false,
late_link_args,
late_link_args_dynamic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ pub fn target() -> Target {
vendor: "fortanix".into(),
abi: "fortanix".into(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
executables: true,
linker: Some("rust-lld".into()),
max_atomic_width: Some(64),
cpu: "x86-64".into(),
Expand Down
Loading