Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
rust-lang/rust
0xAX/rust
12234/rust
4414/rust
APTy/rust
Acidburn0zzz/rust-lang
AerialX/rust
Alinuxfriend/rust
Arreth/rust
CNXTEoEorg/rust
DanielJCampbell/rust
DiamondLovesYou/rust
EllieAdam/rust
Epictetus/rust
GulajavaMinistudio/rust
JamesLinus/rust
MabezDev/rust-xtensa
Manishearth/rust
Nashenas88/rust
NickPepper/rust
P1start/rust
Raul630/rust
SONNYROBOT/rust
Tengfei1010/rust
XAMPPRocky/rust
XiangQingW/rust
Yoric/rust
Zoxc/rust
abossard/rust
alanfalloon/rust
alex/rust
alexcrichton/rust
alexrp/rust
alistra/rust
anasazi/rust
apoelstra/rust
arkaitzj/rust
atris/rust
avr-rust/rust
bendotc/rust
benjaminjackman/rust
berkus/rust
bjadamson/rust
bklooste/rust
blorf/rust-on-gpu
brianloveswords/rust
brson/rust
caiges/rust
catamorphism/rust
cavedweller/rust
charliesome/rust
chengky/rust
chirag08/rust
chmodawk/rust
chrisdew/rust
cjfrisz/rust
crabtw/rust
csae1152/rust
da-x/rust
dbp/rust
delewit/rust
dobkeratops/rust
dojotech/rust
drhodes/rust
driax/rust
eddyb/rust
eholk/rust
ehsan/rust
elliottslaughter/rust
elly/rust
erickt/rust
erikrose/rust
espadrine/rust
eter360/rust
funkill/rust
fzzzy/rust
gilescope/rust
glaubitz/rust
gmfawcett/rust
gordonlw/rust
grahame/rust
graydon/rust
green-panther/rust
gwillen/rust
harnoor992/rust
ids1024/rust
ischeinkman/libnx-rs-std
j-clark/rust
jamorton/rust
janus/rust
jdm/rust
jeanpuga/rust
jensnockert/rust
jld/rust
joelgarciajr84/rust
johnterickson/rust
jorendorff/rust
jrgold/rust
jruderman/rust
jwatt/rust
jwilberding/rust
jwise/rust
jyasskin/rust
kevina/rust
killerswan/rust
kleimkuhler/rust
kosslab-kr/rust
kumasento/rust
levonlloyd/rust
lht/rust
liigo/rust
liufeigit/rust
lkuper/rust
logie17/rust
lunarpulse/rust
macressler/rust
masondesu/rust
matricks/rust
mbrubeck/rust
mcandre/rust
megakorre/rust
mhenes/rust
michaelwoerister/rust
milkowski/rust
miselin/rust
mitsuhiko/rust
mmeyerho/rust
mneumann/rust
mounir34/rust
mpark/rust
mrmonday/rust
mujiatong/rust
muyayo/rust
nathanielherman/rust
nbaksalyar/rust
nbp/rust
nielx/rust
nikomatsakis/rust
nrc/rust
oyiptong/rust
ozzie00/rust
pcwalton/rust
pkarvou/rust
poiru/rust
pwoolcoc/rust
rbancroft/rust
redox-os/rust
reuben/rust
robyoung/rust
rozbb/rust
rpearl/rust
rtanglao/rust
rust-highfive/rust
rustlang/rust
rusty-horizon/horizon-nx-std
rwaldron/rust
samgiles/rust
sarojaba/rust-doc-korean
sayrer/rust
sdeniskos/rust
semarie/rust
sferik/rust
shepmaster/rust
shinglyu/rust
shinta42/rust
sigma318/rust
smaeul/rust
songshaodong/rust
stereotype441/rust
steveklabnik/rust
strangeglyph/rust
sunlightboy/rust
tbu-/rust
tclfs/rust
tedhorst/rust
tfviv79/rust
thomaslee/rust
tohava/rust
tomaka/rust
toshok/rust
tromey/rust
trulliandloeb/rust
tshakah/rust
uasi/rust
vadimcn/rust
varkor/rust
vendula/rust
vhbit/rust
vy12021/rust
waywardmonkeys/rust
webea/rust
wesj/rust
whtoo/rust
williamw520/rust
wilsonk/rust
withoutboats/rust
yamidevs/rust
yodalee/rust
ysbaddaden/rust
zhaobr/rust
Nothing to show
base: master
Choose a Head Repository
rust-lang/rust
0xAX/rust
12234/rust
4414/rust
APTy/rust
Acidburn0zzz/rust-lang
AerialX/rust
Alinuxfriend/rust
Arreth/rust
CNXTEoEorg/rust
DanielJCampbell/rust
DiamondLovesYou/rust
EllieAdam/rust
Epictetus/rust
GulajavaMinistudio/rust
JamesLinus/rust
MabezDev/rust-xtensa
Manishearth/rust
Nashenas88/rust
NickPepper/rust
P1start/rust
Raul630/rust
SONNYROBOT/rust
Tengfei1010/rust
XAMPPRocky/rust
XiangQingW/rust
Yoric/rust
Zoxc/rust
abossard/rust
alanfalloon/rust
alex/rust
alexcrichton/rust
alexrp/rust
alistra/rust
anasazi/rust
apoelstra/rust
arkaitzj/rust
atris/rust
avr-rust/rust
bendotc/rust
benjaminjackman/rust
berkus/rust
bjadamson/rust
bklooste/rust
blorf/rust-on-gpu
brianloveswords/rust
brson/rust
caiges/rust
catamorphism/rust
cavedweller/rust
charliesome/rust
chengky/rust
chirag08/rust
chmodawk/rust
chrisdew/rust
cjfrisz/rust
crabtw/rust
csae1152/rust
da-x/rust
dbp/rust
delewit/rust
dobkeratops/rust
dojotech/rust
drhodes/rust
driax/rust
eddyb/rust
eholk/rust
ehsan/rust
elliottslaughter/rust
elly/rust
erickt/rust
erikrose/rust
espadrine/rust
eter360/rust
funkill/rust
fzzzy/rust
gilescope/rust
glaubitz/rust
gmfawcett/rust
gordonlw/rust
grahame/rust
graydon/rust
green-panther/rust
gwillen/rust
harnoor992/rust
ids1024/rust
ischeinkman/libnx-rs-std
j-clark/rust
jamorton/rust
janus/rust
jdm/rust
jeanpuga/rust
jensnockert/rust
jld/rust
joelgarciajr84/rust
johnterickson/rust
jorendorff/rust
jrgold/rust
jruderman/rust
jwatt/rust
jwilberding/rust
jwise/rust
jyasskin/rust
kevina/rust
killerswan/rust
kleimkuhler/rust
kosslab-kr/rust
kumasento/rust
levonlloyd/rust
lht/rust
liigo/rust
liufeigit/rust
lkuper/rust
logie17/rust
lunarpulse/rust
macressler/rust
masondesu/rust
matricks/rust
mbrubeck/rust
mcandre/rust
megakorre/rust
mhenes/rust
michaelwoerister/rust
milkowski/rust
miselin/rust
mitsuhiko/rust
mmeyerho/rust
mneumann/rust
mounir34/rust
mpark/rust
mrmonday/rust
mujiatong/rust
muyayo/rust
nathanielherman/rust
nbaksalyar/rust
nbp/rust
nielx/rust
nikomatsakis/rust
nrc/rust
oyiptong/rust
ozzie00/rust
pcwalton/rust
pkarvou/rust
poiru/rust
pwoolcoc/rust
rbancroft/rust
redox-os/rust
reuben/rust
robyoung/rust
rozbb/rust
rpearl/rust
rtanglao/rust
rust-highfive/rust
rustlang/rust
rusty-horizon/horizon-nx-std
rwaldron/rust
samgiles/rust
sarojaba/rust-doc-korean
sayrer/rust
sdeniskos/rust
semarie/rust
sferik/rust
shepmaster/rust
shinglyu/rust
shinta42/rust
sigma318/rust
smaeul/rust
songshaodong/rust
stereotype441/rust
steveklabnik/rust
strangeglyph/rust
sunlightboy/rust
tbu-/rust
tclfs/rust
tedhorst/rust
tfviv79/rust
thomaslee/rust
tohava/rust
tomaka/rust
toshok/rust
tromey/rust
trulliandloeb/rust
tshakah/rust
uasi/rust
vadimcn/rust
varkor/rust
vendula/rust
vhbit/rust
vy12021/rust
waywardmonkeys/rust
webea/rust
wesj/rust
whtoo/rust
williamw520/rust
wilsonk/rust
withoutboats/rust
yamidevs/rust
yodalee/rust
ysbaddaden/rust
zhaobr/rust
Nothing to show
compare: redox
Checking mergeability… Don’t worry, you can still create the pull request.
  • 12 commits
  • 17 files changed
  • 0 commit comments
  • 4 contributors
Commits on Nov 08, 2018
Interpret shebangs on redox
This is no longer handled on the kernel side
Commits on Nov 10, 2018
Commits on Nov 12, 2018
Commits on Jan 06, 2019
Commits on Feb 27, 2019
Introduce a target family for Redox
The Redox base target spec located within the rustc source did not
specify a 'target_family' attribute. However, the x86_64 specific target
spec located within the redox source did.

Now AArch64 could have done something similar but unfortunately can't
since there are rust compiler mods needed to support Redox on AArch64
which imply that any AArch64 target spec file in the Redox source shall
be ignored in favour of the target spec within the rustc source.

The target_family attribute is eventually translated into an environment
variable called CARGO_CFG_TARGET_FAMILY whose presence can be tested by
software built with the compiler generated from the target spec.

Some crates expect this variable to contain something failing which they
crash. Eg onig_sys within rust-onig. Since the Redox base target spec in
the rustc source doesn't specify target_family for AArch64, such crates
don't build.

The solution is to introduce target_family in the Redox base
target spec within the rustc source so both x86_64 and AArch64 have it
defined by default. It is set to "redox".

"unix" would perhaps be more preferable but using that breaks the rustc
build which starts making incorrect assumptions about the support libs
that Redox has.
Merge branch 'aarch64' into 'redox'
Rustc support for Redox on AArch64

See merge request redox-os/rust!18
@@ -1,13 +1,13 @@
[submodule "src/llvm"]
path = src/llvm
url = https://github.com/rust-lang/llvm.git
branch = master
url = https://gitlab.redox-os.org/redox-os/llvm.git
branch = aarch64
[submodule "src/rust-installer"]
path = src/tools/rust-installer
url = https://github.com/rust-lang/rust-installer.git
[submodule "src/liblibc"]
path = src/liblibc
url = https://github.com/rust-lang/libc.git
url = https://gitlab.redox-os.org/redox-os/liblibc.git
[submodule "src/doc/nomicon"]
path = src/doc/nomicon
url = https://github.com/rust-lang-nursery/nomicon.git
@@ -0,0 +1,30 @@
// Copyright 2016 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 spec::{LinkerFlavor, Target, TargetResult};

pub fn target() -> TargetResult {
let mut base = super::redox_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
llvm_target: "aarch64-unknown-redox".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
target_c_int_width: "32".to_string(),
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
arch: "aarch64".to_string(),
target_os: "redox".to_string(),
target_env: "".to_string(),
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}
@@ -363,6 +363,7 @@ supported_targets! {

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

("aarch64-unknown-redox", aarch64_unknown_redox),
("x86_64-unknown-redox", x86_64_unknown_redox),

("i386-apple-ios", i386_apple_ios),
@@ -33,7 +33,7 @@ pub fn opts() -> TargetOptions {
relocation_model: "static".to_string(),
disable_redzone: true,
eliminate_frame_pointer: false,
target_family: None,
target_family: Some("redox".to_string()),
linker_is_gnu: true,
has_elf_tls: true,
.. Default::default()
@@ -193,6 +193,10 @@ pub enum Prefix<'a> {
/// Prefix `C:` for the given disk drive.
#[stable(feature = "rust1", since = "1.0.0")]
Disk(#[stable(feature = "rust1", since = "1.0.0")] u8),

/// Scheme `file:` used on Redox
#[stable(feature = "rust1", since = "1.0.0")]
Scheme(#[stable(feature = "rust1", since = "1.0.0")] &'a OsStr),
}

impl<'a> Prefix<'a> {
@@ -223,6 +227,7 @@ impl<'a> Prefix<'a> {
},
DeviceNS(x) => 4 + os_str_len(x),
Disk(_) => 2,
Scheme(x) => 1 + os_str_len(x),
}

}
@@ -324,11 +329,6 @@ unsafe fn u8_slice_as_os_str(s: &[u8]) -> &OsStr {
&*(s as *const [u8] as *const OsStr)
}

// Detect scheme on Redox
fn has_redox_scheme(s: &[u8]) -> bool {
cfg!(target_os = "redox") && s.split(|b| *b == b'/').next().unwrap_or(b"").contains(&b':')
}

////////////////////////////////////////////////////////////////////////////////
// Cross-platform, iterator-independent parsing
////////////////////////////////////////////////////////////////////////////////
@@ -1811,12 +1811,7 @@ impl Path {
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn is_absolute(&self) -> bool {
if cfg!(target_os = "redox") {
// FIXME: Allow Redox prefixes
self.has_root() || has_redox_scheme(self.as_u8_slice())
} else {
self.has_root() && (cfg!(unix) || self.prefix().is_some())
}
self.has_root() && (cfg!(unix) || self.prefix().is_some())
}

/// Returns `true` if the `Path` is relative, i.e. not absolute.
@@ -2219,8 +2214,7 @@ impl Path {
Components {
path: self.as_u8_slice(),
prefix,
has_physical_root: has_physical_root(self.as_u8_slice(), prefix) ||
has_redox_scheme(self.as_u8_slice()),
has_physical_root: has_physical_root(self.as_u8_slice(), prefix),
front: State::Prefix,
back: State::Body,
}
@@ -75,6 +75,29 @@ pub fn cvt(result: Result<usize, syscall::Error>) -> io::Result<usize> {
result.map_err(|err| io::Error::from_raw_os_error(err.errno))
}

#[doc(hidden)]
pub trait IsMinusOne {
fn is_minus_one(&self) -> bool;
}

macro_rules! impl_is_minus_one {
($($t:ident)*) => ($(impl IsMinusOne for $t {
fn is_minus_one(&self) -> bool {
*self == -1
}
})*)
}

impl_is_minus_one! { i8 i16 i32 i64 isize }

pub fn cvt_libc<T: IsMinusOne>(t: T) -> io::Result<T> {
if t.is_minus_one() {
Err(io::Error::last_os_error())
} else {
Ok(t)
}
}

/// On Redox, use an illegal instruction to abort
pub unsafe fn abort_internal() -> ! {
::core::intrinsics::abort();
@@ -12,10 +12,12 @@

#![allow(unused_imports)] // lots of cfg code here

use libc::{self, c_char};

use os::unix::prelude::*;

use error::Error as StdError;
use ffi::{OsString, OsStr};
use ffi::{CStr, CString, OsStr, OsString};
use fmt;
use io::{self, Read, Write};
use iter;
@@ -27,7 +29,7 @@ use ptr;
use slice;
use str;
use sys_common::mutex::Mutex;
use sys::{cvt, fd, syscall};
use sys::{cvt, cvt_libc, fd, syscall};
use vec;

extern {
@@ -129,6 +131,8 @@ pub fn current_exe() -> io::Result<PathBuf> {
Ok(PathBuf::from(path))
}

pub static ENV_LOCK: Mutex = Mutex::new();

pub struct Env {
iter: vec::IntoIter<(OsString, OsString)>,
_dont_send_or_sync_me: PhantomData<*mut ()>,
@@ -140,52 +144,92 @@ impl Iterator for Env {
fn size_hint(&self) -> (usize, Option<usize>) { self.iter.size_hint() }
}

pub unsafe fn environ() -> *mut *const *const c_char {
extern { static mut environ: *const *const c_char; }
&mut environ
}

/// Returns a vector of (variable, value) byte-vector pairs for all the
/// environment variables of the current process.
pub fn env() -> Env {
let mut variables: Vec<(OsString, OsString)> = Vec::new();
if let Ok(mut file) = ::fs::File::open("env:") {
let mut string = String::new();
if file.read_to_string(&mut string).is_ok() {
for line in string.lines() {
let mut parts = line.splitn(2, '=');
if let Some(name) = parts.next() {
let value = parts.next().unwrap_or("");
variables.push((OsString::from(name.to_string()),
OsString::from(value.to_string())));
}
unsafe {
let _guard = ENV_LOCK.lock();
let mut environ = *environ();
if environ == ptr::null() {
panic!("os::env() failure getting env string from OS: {}",
io::Error::last_os_error());
}
let mut result = Vec::new();
while *environ != ptr::null() {
if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) {
result.push(key_value);
}
environ = environ.offset(1);
}
return Env {
iter: result.into_iter(),
_dont_send_or_sync_me: PhantomData,
}
}
Env { iter: variables.into_iter(), _dont_send_or_sync_me: PhantomData }

fn parse(input: &[u8]) -> Option<(OsString, OsString)> {
// Strategy (copied from glibc): Variable name and value are separated
// by an ASCII equals sign '='. Since a variable name must not be
// empty, allow variable names starting with an equals sign. Skip all
// malformed lines.
if input.is_empty() {
return None;
}
let pos = memchr::memchr(b'=', &input[1..]).map(|p| p + 1);
pos.map(|p| (
OsStringExt::from_vec(input[..p].to_vec()),
OsStringExt::from_vec(input[p+1..].to_vec()),
))
}
}

pub fn getenv(key: &OsStr) -> io::Result<Option<OsString>> {
if ! key.is_empty() {
if let Ok(mut file) = ::fs::File::open(&("env:".to_owned() + key.to_str().unwrap())) {
let mut string = String::new();
file.read_to_string(&mut string)?;
Ok(Some(OsString::from(string)))
pub fn getenv(k: &OsStr) -> io::Result<Option<OsString>> {
// environment variables with a nul byte can't be set, so their value is
// always None as well
let k = CString::new(k.as_bytes())?;
unsafe {
let _guard = ENV_LOCK.lock();
let s = libc::getenv(k.as_ptr()) as *const libc::c_char;
let ret = if s.is_null() {
None
} else {
Ok(None)
}
} else {
Ok(None)
Some(OsStringExt::from_vec(CStr::from_ptr(s).to_bytes().to_vec()))
};
Ok(ret)
}
}

pub fn setenv(key: &OsStr, value: &OsStr) -> io::Result<()> {
if ! key.is_empty() {
let mut file = ::fs::File::create(&("env:".to_owned() + key.to_str().unwrap()))?;
file.write_all(value.as_bytes())?;
file.set_len(value.len() as u64)?;
pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> {
extern "C" {
fn setenv(name: *const c_char, val: *const c_char,
overwrite: libc::c_int) -> libc::c_int;
}

let k = CString::new(k.as_bytes())?;
let v = CString::new(v.as_bytes())?;

unsafe {
let _guard = ENV_LOCK.lock();
cvt_libc(setenv(k.as_ptr(), v.as_ptr(), 1)).map(|_| ())
}
Ok(())
}

pub fn unsetenv(key: &OsStr) -> io::Result<()> {
::fs::remove_file(&("env:".to_owned() + key.to_str().unwrap()))?;
Ok(())
pub fn unsetenv(n: &OsStr) -> io::Result<()> {
extern "C" {
fn unsetenv(name: *const c_char) -> libc::c_int;
}

let nbuf = CString::new(n.as_bytes())?;

unsafe {
let _guard = ENV_LOCK.lock();
cvt_libc(unsetenv(nbuf.as_ptr())).map(|_| ())
}
}

pub fn page_size() -> usize {
@@ -23,10 +23,9 @@ pub fn is_verbatim_sep(b: u8) -> bool {

pub fn parse_prefix(path: &OsStr) -> Option<Prefix> {
if let Some(path_str) = path.to_str() {
if let Some(_i) = path_str.find(':') {
if let Some(i) = path_str.find(':') {
// FIXME: Redox specific prefix
// Some(Prefix::Verbatim(OsStr::new(&path_str[..i])))
None
Some(Prefix::Scheme(OsStr::new(&path_str[..i])))
} else {
None
}
Oops, something went wrong.

No commit comments for this range

You can’t perform that action at this time.