-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add initial support for m68k #88321
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
Add initial support for m68k #88321
Changes from all commits
0ad0d30
df7ad3a
5805591
9d177f8
33088b9
0e4e0ce
13b029d
5e56778
fa27d50
2cef5d8
c99d365
5d22b1a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,6 +76,7 @@ fn main() { | |
"aarch64", | ||
"amdgpu", | ||
"avr", | ||
"m68k", | ||
"mips", | ||
"powerpc", | ||
"systemz", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::abi::call::{ArgAbi, FnAbi}; | ||
|
||
fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) { | ||
if ret.layout.is_aggregate() { | ||
ret.make_indirect(); | ||
} else { | ||
ret.extend_integer_width_to(32); | ||
} | ||
} | ||
|
||
fn classify_arg<Ty>(arg: &mut ArgAbi<'_, Ty>) { | ||
if arg.layout.is_aggregate() { | ||
arg.make_indirect_byval(); | ||
} else { | ||
arg.extend_integer_width_to(32); | ||
} | ||
} | ||
|
||
pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) { | ||
if !fn_abi.ret.is_ignore() { | ||
classify_ret(&mut fn_abi.ret); | ||
} | ||
|
||
for arg in &mut fn_abi.args { | ||
if arg.is_ignore() { | ||
continue; | ||
} | ||
classify_arg(arg); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::abi::Endian; | ||
use crate::spec::{Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
let mut base = super::linux_base::opts(); | ||
base.max_atomic_width = Some(32); | ||
|
||
Target { | ||
llvm_target: "m68k-unknown-linux-gnu".to_string(), | ||
pointer_width: 32, | ||
data_layout: "E-m:e-p:32:16:32-i8:8:8-i16:16:16-i32:16:32-n8:16:32-a:0:16-S16".to_string(), | ||
arch: "m68k".to_string(), | ||
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".to_string(), ..base }, | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
FROM ubuntu:20.04 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
g++ \ | ||
make \ | ||
file \ | ||
curl \ | ||
ca-certificates \ | ||
python2.7 \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is python2.7 really needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably not. I wrote this Docker file over a year ago when the CI was still using an older version of Ubuntu. I will verify that the issue and send in a follow-up PR to drop Thanks for spotting this. |
||
git \ | ||
cmake \ | ||
sudo \ | ||
gdb \ | ||
xz-utils \ | ||
g++-m68k-linux-gnu \ | ||
libssl-dev \ | ||
pkg-config | ||
|
||
|
||
COPY scripts/sccache.sh /scripts/ | ||
RUN sh /scripts/sccache.sh | ||
|
||
ENV HOSTS=m68k-unknown-linux-gnu | ||
|
||
ENV RUST_CONFIGURE_ARGS --host=$HOSTS --enable-extended | ||
ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $HOSTS |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# m68k-unknown-linux-gnu | ||
|
||
**Tier: 3** | ||
|
||
Motorola 680x0 Linux | ||
|
||
## Designated Developers | ||
|
||
* [@glaubitz](https://github.com/glaubitz) | ||
* [@ricky26](https://github.com/ricky26) | ||
|
||
## Requirements | ||
|
||
This target requires a Linux/m68k build environment for cross-compilation which | ||
is available on Debian and Debian-based systems, openSUSE and other distributions. | ||
|
||
On Debian, it should be sufficient to install a g++ cross-compiler for the m68k | ||
architecture which will automatically pull in additional dependencies such as | ||
the glibc cross development package: | ||
|
||
```text | ||
# apt install g++-m68k-linux-gnu | ||
``` | ||
|
||
Binaries can be run using QEMU user emulation. On Debian-based systems, it should be | ||
sufficient to install the package `qemu-user-static` to be able to run simple static | ||
binaries: | ||
|
||
```text | ||
# apt install qemu-user-static | ||
``` | ||
|
||
To run more complex programs, it will be necessary to set up a Debian/m68k chroot with | ||
the help of the command `debootstrap`: | ||
|
||
```text | ||
# apt install debootstrap debian-ports-archive-keyring | ||
# debootstrap --keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg --arch=m68k unstable debian-68k http://ftp.ports.debian.org/debian-ports | ||
``` | ||
|
||
This chroot can then seamlessly entered using the normal `chroot` command thanks to | ||
QEMU user emulation: | ||
|
||
```text | ||
# chroot /path/to/debian-68k | ||
``` | ||
|
||
To get started with native builds, which are currently untested, a native Debian/m68k | ||
system can be installed either on real hardware such as 68k-based Commodore Amiga or | ||
Atari systems or emulated environments such as QEMU version 4.2 or newer or ARAnyM. | ||
|
||
ISO images for installation are provided by the Debian Ports team and can be obtained | ||
from the Debian CD image server available at: | ||
|
||
[https://cdimage.debian.org/cdimage/ports/current](https://cdimage.debian.org/cdimage/ports/current/) | ||
|
||
Documentation for Debian/m68k is available on the Debian Wiki at: | ||
|
||
[https://wiki.debian.org/M68k](https://wiki.debian.org/M68k) | ||
|
||
Support is available either through the `debian-68k` mailing list: | ||
|
||
[https://lists.debian.org/debian-68k/](https://lists.debian.org/debian-68k/) | ||
|
||
or the `#debian-68k` IRC channel on OFTC network. | ||
|
||
## Building | ||
|
||
The codegen for this target should be built by default. However, core and std | ||
are currently missing but are being worked on and should become available in | ||
the near future. | ||
|
||
## Cross-compilation | ||
|
||
This target can be cross-compiled from a standard Debian or Debian-based, openSUSE or any | ||
other distribution which has a basic m68k cross-toolchain available. | ||
|
||
## Testing | ||
|
||
Currently there is no support to run the rustc test suite for this target. | ||
|
||
## Building Rust programs | ||
|
||
Rust programs can be built for that target: | ||
|
||
```text | ||
rustc --target m68k-unknown-linux-gnu your-code.rs | ||
``` | ||
|
||
Very simple progams can be run using the `qemu-m68k-static` program: | ||
|
||
```text | ||
$ qemu-m68k-static your-code | ||
``` | ||
|
||
For more complex applications, a chroot or native (emulated) Debian/m68k system are required | ||
for testing. |
Uh oh!
There was an error while loading. Please reload this page.