Create a generic AVR target: avr-none

This commit removes the `avr-unknown-gnu-atmega328` target and replaces
it with a more generic `avr-none` variant that must be specialized with
the `-C target-cpu` flag (e.g. `-C target-cpu=atmega328p`).
This commit is contained in:
Patryk Wychowaniec 2024-10-13 14:58:44 +02:00
parent ed49386d3a
commit 78ddabf31d
No known key found for this signature in database
GPG key ID: F62547D075E09767
19 changed files with 156 additions and 60 deletions

View file

@ -153,6 +153,7 @@ pub(crate) fn get_linker<'a>(
hinted_static: None,
is_ld: cc == Cc::No,
is_gnu: flavor.is_gnu(),
uses_lld: flavor.uses_lld(),
}) as Box<dyn Linker>,
LinkerFlavor::Msvc(..) => Box::new(MsvcLinker { cmd, sess }) as Box<dyn Linker>,
LinkerFlavor::EmCc => Box::new(EmLinker { cmd, sess }) as Box<dyn Linker>,
@ -361,6 +362,7 @@ struct GccLinker<'a> {
// Link as ld
is_ld: bool,
is_gnu: bool,
uses_lld: bool,
}
impl<'a> GccLinker<'a> {
@ -552,6 +554,7 @@ impl<'a> Linker for GccLinker<'a> {
self.link_args(&["--entry", "_initialize"]);
}
}
// VxWorks compiler driver introduced `--static-crt` flag specifically for rustc,
// it switches linking for libc and similar system libraries to static without using
// any `#[link]` attributes in the `libc` crate, see #72782 for details.
@ -567,6 +570,15 @@ impl<'a> Linker for GccLinker<'a> {
{
self.cc_arg("--static-crt");
}
// avr-none doesn't have default ISA, users must specify which specific
// CPU (well, microcontroller) they are targetting using `-Ctarget-cpu`.
//
// Currently this makes sense only when using avr-gcc as a linker, since
// it brings a couple of hand-written important intrinsics from libgcc.
if self.sess.target.arch == "avr" && !self.uses_lld {
self.verbatim_arg(format!("-mmcu={}", self.target_cpu));
}
}
fn link_dylib_by_name(&mut self, name: &str, verbatim: bool, as_needed: bool) {