Skip to content
Open
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
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
codegen_ssa_L4Bender_exporting_symbols_unimplemented = exporting symbols not implemented yet for L4Bender

codegen_ssa_aarch64_softfloat_neon = enabling the `neon` target feature on the current target is unsound due to ABI issues

codegen_ssa_add_native_library = failed to add native library {$library_path}: {$error}
Expand Down
126 changes: 0 additions & 126 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ pub(crate) fn get_linker<'a>(
// to the linker args construction.
assert!(cmd.get_args().is_empty() || sess.target.abi == Abi::Uwp);
match flavor {
LinkerFlavor::Unix(Cc::No) if sess.target.os == Os::L4Re => {
Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>
}
LinkerFlavor::Unix(Cc::No) if sess.target.os == Os::Aix => {
Box::new(AixLinker::new(cmd, sess)) as Box<dyn Linker>
}
Expand Down Expand Up @@ -280,7 +277,6 @@ generate_arg_methods! {
MsvcLinker<'_>
EmLinker<'_>
WasmLd<'_>
L4Bender<'_>
AixLinker<'_>
LlbcLinker<'_>
PtxLinker<'_>
Expand Down Expand Up @@ -1475,128 +1471,6 @@ impl<'a> WasmLd<'a> {
}
}

/// Linker shepherd script for L4Re (Fiasco)
struct L4Bender<'a> {
cmd: Command,
sess: &'a Session,
hinted_static: bool,
}

impl<'a> Linker for L4Bender<'a> {
fn cmd(&mut self) -> &mut Command {
&mut self.cmd
}

fn set_output_kind(
&mut self,
_output_kind: LinkOutputKind,
_crate_type: CrateType,
_out_filename: &Path,
) {
}

fn link_staticlib_by_name(&mut self, name: &str, _verbatim: bool, whole_archive: bool) {
self.hint_static();
if !whole_archive {
self.link_arg(format!("-PC{name}"));
} else {
self.link_arg("--whole-archive")
.link_or_cc_arg(format!("-l{name}"))
.link_arg("--no-whole-archive");
}
}

fn link_staticlib_by_path(&mut self, path: &Path, whole_archive: bool) {
self.hint_static();
if !whole_archive {
self.link_or_cc_arg(path);
} else {
self.link_arg("--whole-archive").link_or_cc_arg(path).link_arg("--no-whole-archive");
}
}

fn full_relro(&mut self) {
self.link_args(&["-z", "relro", "-z", "now"]);
}

fn partial_relro(&mut self) {
self.link_args(&["-z", "relro"]);
}

fn no_relro(&mut self) {
self.link_args(&["-z", "norelro"]);
}

fn gc_sections(&mut self, keep_metadata: bool) {
if !keep_metadata {
self.link_arg("--gc-sections");
}
}

fn optimize(&mut self) {
// GNU-style linkers support optimization with -O. GNU ld doesn't
// need a numeric argument, but other linkers do.
if self.sess.opts.optimize == config::OptLevel::More
|| self.sess.opts.optimize == config::OptLevel::Aggressive
{
self.link_arg("-O1");
}
}

fn pgo_gen(&mut self) {}

fn debuginfo(&mut self, strip: Strip, _: &[PathBuf]) {
match strip {
Strip::None => {}
Strip::Debuginfo => {
self.link_arg("--strip-debug");
}
Strip::Symbols => {
self.link_arg("--strip-all");
}
}
}

fn no_default_libraries(&mut self) {
self.cc_arg("-nostdlib");
}

fn export_symbols(&mut self, _: &Path, _: CrateType, _: &[(String, SymbolExportKind)]) {
// ToDo, not implemented, copy from GCC
self.sess.dcx().emit_warn(errors::L4BenderExportingSymbolsUnimplemented);
}

fn windows_subsystem(&mut self, subsystem: WindowsSubsystemKind) {
let subsystem = subsystem.as_str();
self.link_arg(&format!("--subsystem {subsystem}"));
}

fn reset_per_library_state(&mut self) {
self.hint_static(); // Reset to default before returning the composed command line.
}

fn linker_plugin_lto(&mut self) {}

fn control_flow_guard(&mut self) {}

fn ehcont_guard(&mut self) {}

fn no_crt_objects(&mut self) {}
}

impl<'a> L4Bender<'a> {
fn new(cmd: Command, sess: &'a Session) -> L4Bender<'a> {
L4Bender { cmd, sess, hinted_static: false }
}

fn hint_static(&mut self) {
if !self.hinted_static {
self.link_or_cc_arg("-static");
self.hinted_static = true;
}
}
}

/// Linker for AIX.
struct AixLinker<'a> {
cmd: Command,
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ pub(crate) struct Ld64UnimplementedModifier;
#[diag(codegen_ssa_linker_unsupported_modifier)]
pub(crate) struct LinkerUnsupportedModifier;

#[derive(Diagnostic)]
#[diag(codegen_ssa_L4Bender_exporting_symbols_unimplemented)]
pub(crate) struct L4BenderExportingSymbolsUnimplemented;

#[derive(Diagnostic)]
#[diag(codegen_ssa_no_natvis_directory)]
pub(crate) struct NoNatvisDirectory {
Expand Down
55 changes: 50 additions & 5 deletions compiler/rustc_target/src/spec/base/l4re.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,59 @@
use crate::spec::{Cc, Env, LinkerFlavor, Os, PanicStrategy, RelocModel, TargetOptions, cvs};
use crate::spec::{
Cc, Env, LinkOutputKind, LinkSelfContainedComponents, LinkSelfContainedDefault, LinkerFlavor,
Os, PanicStrategy, TargetOptions, add_link_args, crt_objects, cvs,
};

pub(crate) fn opts() -> TargetOptions {
// add ld- and cc-style args
macro_rules! prepare_args {
($($val:expr),+) => {{
let ld_args = &[$($val),+];
let cc_args = &[$(concat!("-Wl,", $val)),+];

let mut ret = TargetOptions::link_args(LinkerFlavor::Unix(Cc::No), ld_args);
add_link_args(&mut ret, LinkerFlavor::Unix(Cc::Yes), cc_args);
ret
}};
}

let pre_link_args = prepare_args!("-nostdlib", "-dynamic-linker=rom/libld-l4.so");

let late_link_args = prepare_args!("-lc", "-lgcc_eh");

let pre_link_objects_self_contained = crt_objects::new(&[
(LinkOutputKind::StaticNoPicExe, &["crt1.o", "crti.o", "crtbeginT.o"]),
(LinkOutputKind::StaticPicExe, &["crt1.p.o", "crti.o", "crtbegin.o"]),
(LinkOutputKind::DynamicNoPicExe, &["crt1.o", "crti.o", "crtbegin.o"]),
(LinkOutputKind::DynamicPicExe, &["crt1.s.o", "crti.o", "crtbeginS.o"]),
(LinkOutputKind::DynamicDylib, &["crti.s.o", "crtbeginS.o"]),
(LinkOutputKind::StaticDylib, &["crti.s.o", "crtbeginS.o"]),
]);

let post_link_objects_self_contained = crt_objects::new(&[
(LinkOutputKind::StaticNoPicExe, &["crtendT.o", "crtn.o"]),
(LinkOutputKind::StaticPicExe, &["crtend.o", "crtn.o"]),
(LinkOutputKind::DynamicNoPicExe, &["crtend.o", "crtn.o"]),
(LinkOutputKind::DynamicPicExe, &["crtendS.o", "crtn.o"]),
(LinkOutputKind::DynamicDylib, &["crtendS.o", "crtn.s.o"]),
(LinkOutputKind::StaticDylib, &["crtendS.o", "crtn.s.o"]),
]);

TargetOptions {
os: Os::L4Re,
env: Env::Uclibc,
linker_flavor: LinkerFlavor::Unix(Cc::No),
panic_strategy: PanicStrategy::Abort,
linker: Some("l4-bender".into()),
families: cvs!["unix"],
relocation_model: RelocModel::Static,
panic_strategy: PanicStrategy::Abort,
linker_flavor: LinkerFlavor::Unix(Cc::No),
dynamic_linking: true,
position_independent_executables: true,
has_thread_local: true,
pre_link_args,
late_link_args,
pre_link_objects_self_contained,
post_link_objects_self_contained,
link_self_contained: LinkSelfContainedDefault::WithComponents(
LinkSelfContainedComponents::LIBC | LinkSelfContainedComponents::CRT_OBJECTS,
),
..Default::default()
}
}
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,6 +1559,7 @@ supported_targets! {

("avr-none", avr_none),

("aarch64-unknown-l4re-uclibc", aarch64_unknown_l4re_uclibc),
("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),

("aarch64-unknown-redox", aarch64_unknown_redox),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut base = base::l4re::opts();

let extra_link_args = &["-zmax-page-size=0x1000", "-zcommon-page-size=0x1000"];
base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), extra_link_args);
base.add_pre_link_args(LinkerFlavor::Unix(Cc::No), extra_link_args);

Target {
llvm_target: "aarch64-unknown-l4re-uclibc".into(),
metadata: crate::spec::TargetMetadata {
description: Some("Arm64 L4Re".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: Arch::AArch64,
options: TargetOptions {
features: "+v8a".into(),
mcount: "__mcount".into(),
max_atomic_width: Some(128),
..base
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::spec::{Arch, PanicStrategy, Target, TargetMetadata, base};
use crate::spec::{Arch, Cc, LinkerFlavor, Target, TargetMetadata, base};

pub(crate) fn target() -> Target {
let mut base = base::l4re::opts();
base.cpu = "x86-64".into();
base.plt_by_default = false;
base.max_atomic_width = Some(64);
base.panic_strategy = PanicStrategy::Abort;
let extra_link_args = &["-zmax-page-size=0x1000", "-zcommon-page-size=0x1000"];
base.add_pre_link_args(LinkerFlavor::Unix(Cc::Yes), extra_link_args);
base.add_pre_link_args(LinkerFlavor::Unix(Cc::No), extra_link_args);

Target {
llvm_target: "x86_64-unknown-l4re-gnu".into(),
Expand Down
4 changes: 2 additions & 2 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.178"
version = "0.2.179"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
checksum = "c5a2d376baa530d1238d133232d15e239abad80d05838b4b59354e5268af431f"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down
5 changes: 0 additions & 5 deletions library/panic_unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ cfg_select! {
#[path = "hermit.rs"]
mod imp;
}
target_os = "l4re" => {
// L4Re is unix family but does not yet support unwinding.
#[path = "dummy.rs"]
mod imp;
}
any(
all(target_family = "windows", target_env = "gnu"),
target_os = "psp",
Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
addr2line = { version = "0.25.0", optional = true, default-features = false }

[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
libc = { version = "0.2.178", default-features = false, features = [
libc = { version = "0.2.179", default-features = false, features = [
'rustc-dep-of-std',
], public = true }

Expand Down
1 change: 1 addition & 0 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
all(target_os = "wasi", target_env = "p1"),
target_os = "xous",
target_os = "trusty",
target_os = "l4re",
))
))]
mod tests;
Expand Down
1 change: 1 addition & 0 deletions library/std/src/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
target_env = "sgx",
target_os = "xous",
target_os = "trusty",
target_os = "l4re",
))
))]
mod tests;
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mod raw;
mod owned;

// Implementations for `AsRawFd` etc. for network types.
#[cfg(not(target_os = "trusty"))]
#[cfg(not(any(target_os = "trusty", target_os = "l4re")))]
mod net;

#[cfg(test)]
Expand Down
Loading
Loading