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

6
configure vendored
View file

@ -1295,6 +1295,12 @@ $ pacman -R cmake && pacman -S mingw-w64-x86_64-cmake
putvar CFG_MSVC_LIB_PATH_${bits}
;;
*-rumprun-netbsd)
step_msg "targeting rumprun-netbsd, disabling jemalloc"
CFG_DISABLE_JEMALLOC=1
putvar CFG_DISABLE_JEMALLOC
;;
*)
;;
esac

View file

@ -0,0 +1,24 @@
# x86_64-rumprun-netbsd configuration
CROSS_PREFIX_x86_64-rumprun-netbsd=x86_64-rumprun-netbsd-
CC_x86_64-rumprun-netbsd=gcc
CXX_x86_64-rumprun-netbsd=g++
CPP_x86_64-rumprun-netbsd=gcc -E
AR_x86_64-rumprun-netbsd=ar
CFG_INSTALL_ONLY_RLIB_x86_64-rumprun-netbsd = 1
CFG_LIB_NAME_x86_64-rumprun-netbsd=lib$(1).so
CFG_STATIC_LIB_NAME_x86_64-rumprun-netbsd=lib$(1).a
CFG_LIB_GLOB_x86_64-rumprun-netbsd=lib$(1)-*.so
CFG_JEMALLOC_CFLAGS_x86_64-rumprun-netbsd := -m64
CFG_GCCISH_CFLAGS_x86_64-rumprun-netbsd := -Wall -Werror -g -fPIC -m64
CFG_GCCISH_CXXFLAGS_x86_64-rumprun-netbsd :=
CFG_GCCISH_LINK_FLAGS_x86_64-rumprun-netbsd :=
CFG_GCCISH_DEF_FLAG_x86_64-rumprun-netbsd :=
CFG_LLC_FLAGS_x86_64-rumprun-netbsd :=
CFG_INSTALL_NAME_x86_64-rumprun-netbsd =
CFG_EXE_SUFFIX_x86_64-rumprun-netbsd =
CFG_WINDOWSY_x86_64-rumprun-netbsd :=
CFG_UNIXY_x86_64-rumprun-netbsd := 1
CFG_LDPATH_x86_64-rumprun-netbsd :=
CFG_RUN_x86_64-rumprun-netbsd=$(2)
CFG_RUN_TARG_x86_64-rumprun-netbsd=$(call CFG_RUN_x86_64-rumprun-netbsd,,$(2))
CFG_GNU_TRIPLE_x86_64-rumprun-netbsd := x86_64-rumprun-netbsd

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 @@
// 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 @@ macro_rules! load_specific {
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 @@ pub enum _Unwind_Context {}
#[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 @@ fn drop(&mut self) {
#[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 @@ pub unsafe fn drop_handler(handler: &mut Handler) {
#[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 @@ fn drop(&mut self) {
#[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 unsafe fn init() -> Option<usize> { None }
#[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 {