Add support for the rumprun unikernel

For most parts, rumprun currently looks like NetBSD, as they share the same
libc and drivers. However, being a unikernel, rumprun does not support
process management, signals or virtual memory, so related functions
might fail at runtime. Stack guards are disabled exactly for this reason.

Code for rumprun is always cross-compiled, it uses always static
linking and needs a custom linker.
This commit is contained in:
Sebastian Wicki 2015-09-21 19:16:24 +02:00
parent 6645ca1a85
commit c099cfab06
9 changed files with 85 additions and 6 deletions

View file

@ -24,6 +24,7 @@
html_playground_url = "https://play.rust-lang.org/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![cfg_attr(test, feature(test))]
#![feature(cfg_target_vendor)]
//! Bindings for the C standard library and other platform libraries
//!
@ -143,7 +144,10 @@ pub use funcs::bsd43::*;
// On NaCl, these libraries are static. Thus it would be a Bad Idea to link them
// in when creating a test crate.
#[cfg(not(any(windows, target_env = "musl", all(target_os = "nacl", test))))]
#[cfg(not(any(windows,
target_env = "musl",
all(target_os = "nacl", test),
all(target_os = "netbsd", target_vendor = "rumprun"))))]
#[link(name = "c")]
#[link(name = "m")]
extern {}

View file

@ -411,6 +411,7 @@ impl Target {
x86_64_unknown_bitrig,
x86_64_unknown_openbsd,
x86_64_unknown_netbsd,
x86_64_rumprun_netbsd,
x86_64_apple_darwin,
i686_apple_darwin,

View file

@ -0,0 +1,35 @@
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use target::Target;
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.pre_link_args.push("-m64".to_string());
base.linker = "x86_64-rumprun-netbsd-gcc".to_string();
base.ar = "x86_64-rumprun-netbsd-ar".to_string();
base.dynamic_linking = false;
base.has_rpath = false;
base.position_independent_executables = false;
base.disable_redzone = true;
base.no_default_libraries = false;
Target {
llvm_target: "x86_64-rumprun-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
arch: "x86_64".to_string(),
target_os: "netbsd".to_string(),
target_env: "".to_string(),
target_vendor: "rumprun".to_string(),
options: base,
}
}

View file

@ -204,6 +204,7 @@
#![feature(associated_consts)]
#![feature(borrow_state)]
#![feature(box_syntax)]
#![feature(cfg_target_vendor)]
#![feature(char_from_unchecked)]
#![feature(char_internals)]
#![feature(clone_from_slice)]

View file

@ -108,10 +108,18 @@ extern {}
#[link(name = "unwind", kind = "static")]
extern {}
#[cfg(any(target_os = "android", target_os = "netbsd", target_os = "openbsd"))]
#[cfg(any(target_os = "android", target_os = "openbsd"))]
#[link(name = "gcc")]
extern {}
#[cfg(all(target_os = "netbsd", not(target_vendor = "rumprun")))]
#[link(name = "gcc")]
extern {}
#[cfg(all(target_os = "netbsd", target_vendor = "rumprun"))]
#[link(name = "unwind")]
extern {}
#[cfg(target_os = "dragonfly")]
#[link(name = "gcc_pic")]
extern {}

View file

@ -34,7 +34,7 @@ impl Drop for Handler {
#[cfg(any(target_os = "linux",
target_os = "macos",
target_os = "bitrig",
target_os = "netbsd",
all(target_os = "netbsd", not(target_vendor = "rumprun")),
target_os = "openbsd"))]
mod imp {
use super::Handler;
@ -143,7 +143,7 @@ mod imp {
#[cfg(not(any(target_os = "linux",
target_os = "macos",
target_os = "bitrig",
target_os = "netbsd",
all(target_os = "netbsd", not(target_vendor = "rumprun")),
target_os = "openbsd")))]
mod imp {
use ptr;

View file

@ -174,7 +174,7 @@ impl Drop for Thread {
#[cfg(all(not(target_os = "linux"),
not(target_os = "macos"),
not(target_os = "bitrig"),
not(target_os = "netbsd"),
not(all(target_os = "netbsd", not(target_vendor = "rumprun"))),
not(target_os = "openbsd")))]
pub mod guard {
pub unsafe fn current() -> Option<usize> { None }
@ -185,7 +185,7 @@ pub mod guard {
#[cfg(any(target_os = "linux",
target_os = "macos",
target_os = "bitrig",
target_os = "netbsd",
all(target_os = "netbsd", not(target_vendor = "rumprun")),
target_os = "openbsd"))]
#[allow(unused_imports)]
pub mod guard {