Skip to content
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

RFC: Add OsUnknown as a target operating system #12841

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/librustc/back/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
"-v64:64:64-v128:64:128" +
"-a0:0:64-n32"
}

abi::OsUnknown => {
~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" +
"-v64:64:64-v128:64:128" +
"-a0:0:64-n32"
}
},

target_triple: target_triple,
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,8 @@ pub fn filename_for_input(sess: &Session, crate_type: session::CrateType,
abi::OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
abi::OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
abi::OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
abi::OsUnknown =>
sess.fatal("output dylib not available with unknown OS"),
};
out_filename.with_filename(format!("{}{}{}", prefix, libname, suffix))
}
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/back/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
"-v64:64:64-v128:64:128" +
"-a0:0:64-n32"
}

abi::OsUnknown => {
~"e-p:32:32:32" +
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64" +
"-f32:32:32-f64:64:64" +
"-v64:64:64-v128:64:128" +
"-a0:0:64-n32"
}
},

target_triple: target_triple,
Expand Down
11 changes: 8 additions & 3 deletions src/librustc/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ fn not_win32(os: abi::Os) -> bool {
os != abi::OsWin32
}

fn not_unknown(os: abi::Os) -> bool {
os != abi::OsUnknown
}

pub fn get_rpath_flags(sess: session::Session, out_filename: &Path) -> Vec<~str> {
let os = sess.targ_cfg.os;

// No rpath on windows
if os == abi::OsWin32 {
// No rpath on windows or unknown
if os == abi::OsWin32 || os == abi::OsUnknown {
return Vec::new();
}

Expand Down Expand Up @@ -127,13 +131,14 @@ pub fn get_rpath_relative_to_output(os: abi::Os,
use std::os;

assert!(not_win32(os));
assert!(not_unknown(os));

// Mac doesn't appear to support $ORIGIN
let prefix = match os {
abi::OsAndroid | abi::OsLinux | abi::OsFreebsd
=> "$ORIGIN",
abi::OsMacos => "@loader_path",
abi::OsWin32 => unreachable!()
abi::OsWin32 | abi::OsUnknown => unreachable!()
};

let mut lib = os::make_absolute(lib);
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/back/x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,18 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
abi::OsLinux => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
}

abi::OsAndroid => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
}

abi::OsFreebsd => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
}

abi::OsUnknown => {
~"e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32"
}
},

target_triple: target_triple,
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/back/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128"
}

abi::OsAndroid => {
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
Expand All @@ -50,6 +51,12 @@ pub fn get_target_strs(target_triple: ~str, target_os: abi::Os) -> target_strs::
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128"
}

abi::OsUnknown => {
~"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"+
"f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-"+
"s0:64:64-f80:128:128-n8:16:32:64-S128"
}
},

target_triple: target_triple,
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub fn default_configuration(sess: Session) ->
abi::OsLinux => InternedString::new("linux"),
abi::OsAndroid => InternedString::new("android"),
abi::OsFreebsd => InternedString::new("freebsd"),
abi::OsUnknown => InternedString::new("unknown"),
};

// ARM is bi-endian, however using NDK seems to default
Expand Down Expand Up @@ -696,7 +697,8 @@ static os_names : &'static [(&'static str, abi::Os)] = &'static [
("darwin", abi::OsMacos),
("android", abi::OsAndroid),
("linux", abi::OsLinux),
("freebsd", abi::OsFreebsd)];
("freebsd", abi::OsFreebsd),
("unknown", abi::OsUnknown)];

pub fn get_arch(triple: &str) -> Option<abi::Architecture> {
for &(arch, abi) in architecture_abis.iter() {
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,11 @@ pub fn collect_crate_types(session: &Session,
} else {
None
}
}).filter(|a| {
// Filter out dylib attrs in the create for unknown os
session.targ_cfg.os != abi::OsUnknown || *a != CrateTypeDylib
});

base.extend(&mut iter);
if base.len() == 0 {
base.push(CrateTypeExecutable);
Expand All @@ -529,6 +533,7 @@ pub fn sess_os_to_meta_os(os: abi::Os) -> metadata::loader::Os {
abi::OsLinux => loader::OsLinux,
abi::OsAndroid => loader::OsAndroid,
abi::OsMacos => loader::OsMacos,
abi::OsFreebsd => loader::OsFreebsd
abi::OsFreebsd => loader::OsFreebsd,
abi::OsUnknown => loader::OsUnknown
}
}
12 changes: 8 additions & 4 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use std::c_str::ToCStr;
use std::cast;
use std::cmp;
use std::io;
use std::os::consts::{macos, freebsd, linux, android, win32};
use std::os::consts::{macos, freebsd, linux, android, win32, unknown};
use std::str;
use std::vec;
use std::vec_ng::Vec;
Expand All @@ -42,7 +42,8 @@ pub enum Os {
OsWin32,
OsLinux,
OsAndroid,
OsFreebsd
OsFreebsd,
OsUnknown
}

pub struct Context<'a> {
Expand Down Expand Up @@ -348,6 +349,7 @@ impl<'a> Context<'a> {
OsLinux => (linux::DLL_PREFIX, linux::DLL_SUFFIX),
OsAndroid => (android::DLL_PREFIX, android::DLL_SUFFIX),
OsFreebsd => (freebsd::DLL_PREFIX, freebsd::DLL_SUFFIX),
OsUnknown => (unknown::DLL_PREFIX, unknown::DLL_SUFFIX),
}
}
}
Expand Down Expand Up @@ -460,7 +462,8 @@ pub fn meta_section_name(os: Os) -> &'static str {
OsWin32 => ".note.rustc",
OsLinux => ".note.rustc",
OsAndroid => ".note.rustc",
OsFreebsd => ".note.rustc"
OsFreebsd => ".note.rustc",
OsUnknown => ".note.rustc"
}
}

Expand All @@ -470,7 +473,8 @@ pub fn read_meta_section_name(os: Os) -> &'static str {
OsWin32 => ".note.rustc",
OsLinux => ".note.rustc",
OsAndroid => ".note.rustc",
OsFreebsd => ".note.rustc"
OsFreebsd => ".note.rustc",
OsUnknown => ".note.rustc"
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/libstd/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,9 @@ pub mod consts {
#[cfg(target_os = "win32")]
pub use os::consts::win32::*;

#[cfg(target_os = "unknown")]
pub use os::consts::unknown::*;

#[cfg(target_arch = "x86")]
pub use os::consts::x86::*;

Expand Down Expand Up @@ -1370,6 +1373,15 @@ pub mod consts {
pub static EXE_EXTENSION: &'static str = "exe";
}

pub mod unknown {
pub static SYSNAME: &'static str = "unknown";
pub static DLL_PREFIX: &'static str = "";
pub static DLL_SUFFIX: &'static str = "";
pub static DLL_EXTENSION: &'static str = "";
pub static EXE_SUFFIX: &'static str = "";
pub static EXE_EXTENSION: &'static str = "";
}


pub mod x86 {
pub static ARCH: &'static str = "x86";
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::vec_ng::Vec;
use std::fmt::Show;

#[deriving(Eq)]
pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, }
pub enum Os { OsWin32, OsMacos, OsLinux, OsAndroid, OsFreebsd, OsUnknown, }

#[deriving(Eq, Hash)]
pub enum Abi {
Expand Down