Skip to content

Win32 => Windows #16435

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

Closed
wants to merge 4 commits 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
15 changes: 10 additions & 5 deletions src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ use header::TestProps;
use header;
use procsrv;
use util::logv;
#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
use util;

use std::io::File;
Expand Down Expand Up @@ -816,7 +817,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
format!("{}:{}:", testfile.display(), ee.line)
}).collect::<Vec<String> >();

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
fn to_lower( s : &str ) -> String {
let i = s.chars();
let c : Vec<char> = i.map( |c| {
Expand All @@ -829,7 +831,8 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
String::from_chars(c.as_slice())
}

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
fn prefix_matches( line : &str, prefix : &str ) -> bool {
to_lower(line).as_slice().starts_with(to_lower(prefix).as_slice())
}
Expand Down Expand Up @@ -1246,14 +1249,16 @@ fn make_cmdline(_libpath: &str, prog: &str, args: &[String]) -> String {
format!("{} {}", prog, args.connect(" "))
}

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
fn make_cmdline(libpath: &str, prog: &str, args: &[String]) -> String {
format!("{} {} {}", lib_path_cmd_prefix(libpath), prog, args.connect(" "))
}

// Build the LD_LIBRARY_PATH variable as it would be seen on the command line
// for diagnostic purposes
#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
fn lib_path_cmd_prefix(path: &str) -> String {
format!("{}=\"{}\"", util::lib_path_env_var(), util::make_new_path(path))
}
Expand Down
17 changes: 11 additions & 6 deletions src/compiletest/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@

use common::Config;

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
use std::os::getenv;

/// Conversion table from triple OS name to Rust SYSNAME
static OS_TABLE: &'static [(&'static str, &'static str)] = &[
("mingw32", "win32"),
("win32", "win32"),
("mingw32", "windows"),
("win32", "windows"),
("windows", "windows"),
("darwin", "macos"),
("android", "android"),
("linux", "linux"),
Expand All @@ -33,7 +35,8 @@ pub fn get_os(triple: &str) -> &'static str {
fail!("Cannot determine OS from triple");
}

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub fn make_new_path(path: &str) -> String {

// Windows just uses PATH as the library search path, so we have to
Expand All @@ -46,10 +49,12 @@ pub fn make_new_path(path: &str) -> String {
}
}

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub fn lib_path_env_var() -> &'static str { "PATH" }

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub fn path_div() -> &'static str { ";" }

pub fn logv(config: &Config, s: String) {
Expand Down
4 changes: 3 additions & 1 deletion src/etc/mklldeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ def run(args):
elif 'android' in os:
os = 'android'
elif 'win' in os or 'mingw' in os:
os = 'win32'
os = 'windows'
cfg = [
"target_arch = \"" + arch + "\"",
"target_os = \"" + os + "\"",
]

f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
if os == "windows": # NOTE: Remove after snapshot
f.write("#[cfg(stage0, target_arch = \"%s\", target_os = \"win32\")]\n" % (arch,))

version = run([llconfig, '--version']).strip()

Expand Down
21 changes: 14 additions & 7 deletions src/liblibc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,8 @@ pub mod types {
}
}

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub mod os {
pub mod common {
pub mod posix01 {
Expand Down Expand Up @@ -1803,7 +1804,8 @@ pub mod consts {
// Consts tend to vary per OS so we pull their definitions out
// into this module.

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub mod os {
pub mod c95 {
use types::os::arch::c95::{c_int, c_uint};
Expand Down Expand Up @@ -3887,7 +3889,8 @@ pub mod funcs {
// so be careful when trying to write portable code; it won't always work
// with the same POSIX functions and types as other platforms.

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub mod posix88 {
pub mod stat_ {
use types::os::common::posix01::{stat, utimbuf};
Expand Down Expand Up @@ -4316,7 +4319,8 @@ pub mod funcs {
}
}

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub mod posix01 {
pub mod stat_ {
}
Expand All @@ -4332,7 +4336,8 @@ pub mod funcs {
}


#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
#[cfg(target_os = "linux")]
#[cfg(target_os = "android")]
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -4470,7 +4475,8 @@ pub mod funcs {
}


#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub mod bsd44 {
}

Expand All @@ -4496,7 +4502,8 @@ pub mod funcs {
}


#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
pub mod extra {

pub mod kernel32 {
Expand Down
3 changes: 2 additions & 1 deletion src/libnative/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ pub mod file;
#[path = "timer_unix.rs"]
pub mod timer;

#[cfg(target_os = "win32")]
#[cfg(target_os = "windows")]
#[cfg(stage0, target_os = "win32")] // NOTE: Remove after snapshot
#[path = "timer_win32.rs"]
pub mod timer;

Expand Down
14 changes: 7 additions & 7 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub mod write {
// OSX has -dead_strip, which doesn't rely on ffunction_sections
// FIXME(#13846) this should be enabled for windows
let ffunction_sections = sess.targ_cfg.os != abi::OsMacos &&
sess.targ_cfg.os != abi::OsWin32;
sess.targ_cfg.os != abi::OsWindows;
let fdata_sections = ffunction_sections;

let reloc_model = match sess.opts.cg.relocation_model.as_slice() {
Expand Down Expand Up @@ -858,7 +858,7 @@ pub fn get_cc_prog(sess: &Session) -> String {
// instead of hard-coded gcc.
// For win32, there is no cc command, so we add a condition to make it use gcc.
match sess.targ_cfg.os {
abi::OsWin32 => "gcc",
abi::OsWindows => "gcc",
_ => "cc",
}.to_string()
}
Expand Down Expand Up @@ -954,7 +954,7 @@ pub fn filename_for_input(sess: &Session,
}
config::CrateTypeDylib => {
let (prefix, suffix) = match sess.targ_cfg.os {
abi::OsWin32 => (loader::WIN32_DLL_PREFIX, loader::WIN32_DLL_SUFFIX),
abi::OsWindows => (loader::WIN32_DLL_PREFIX, loader::WIN32_DLL_SUFFIX),
abi::OsMacos => (loader::MACOS_DLL_PREFIX, loader::MACOS_DLL_SUFFIX),
abi::OsLinux => (loader::LINUX_DLL_PREFIX, loader::LINUX_DLL_SUFFIX),
abi::OsAndroid => (loader::ANDROID_DLL_PREFIX, loader::ANDROID_DLL_SUFFIX),
Expand All @@ -972,7 +972,7 @@ pub fn filename_for_input(sess: &Session,
}
config::CrateTypeExecutable => {
match sess.targ_cfg.os {
abi::OsWin32 => out_filename.with_extension("exe"),
abi::OsWindows => out_filename.with_extension("exe"),
abi::OsMacos |
abi::OsLinux |
abi::OsAndroid |
Expand Down Expand Up @@ -1388,7 +1388,7 @@ fn link_args(cmd: &mut Command,
// subset we wanted.
//
// FIXME(#11937) we should invoke the system linker directly
if sess.targ_cfg.os != abi::OsWin32 {
if sess.targ_cfg.os != abi::OsWindows {
cmd.arg("-nodefaultlibs");
}

Expand Down Expand Up @@ -1440,7 +1440,7 @@ fn link_args(cmd: &mut Command,
cmd.arg("-Wl,-dead_strip");
}

if sess.targ_cfg.os == abi::OsWin32 {
if sess.targ_cfg.os == abi::OsWindows {
// Make sure that we link to the dynamic libgcc, otherwise cross-module
// DWARF stack unwinding will not work.
// This behavior may be overridden by --link-args "-static-libgcc"
Expand Down Expand Up @@ -1715,7 +1715,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,

// Converts a library file-stem into a cc -l argument
fn unlib<'a>(config: &config::Config, stem: &'a [u8]) -> &'a [u8] {
if stem.starts_with("lib".as_bytes()) && config.os != abi::OsWin32 {
if stem.starts_with("lib".as_bytes()) && config.os != abi::OsWindows {
stem.tailn(3)
} else {
stem
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/driver/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ pub fn default_lib_output() -> CrateType {

pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
let tos = match sess.targ_cfg.os {
abi::OsWin32 => InternedString::new("win32"),
abi::OsWindows => InternedString::new("windows"),
abi::OsMacos => InternedString::new("macos"),
abi::OsLinux => InternedString::new("linux"),
abi::OsAndroid => InternedString::new("android"),
Expand All @@ -410,7 +410,7 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
};

let fam = match sess.targ_cfg.os {
abi::OsWin32 => InternedString::new("windows"),
abi::OsWindows => InternedString::new("windows"),
_ => InternedString::new("unix")
};

Expand Down Expand Up @@ -452,8 +452,9 @@ pub fn get_os(triple: &str) -> Option<abi::Os> {
None
}
static os_names : &'static [(&'static str, abi::Os)] = &[
("mingw32", abi::OsWin32),
("win32", abi::OsWin32),
("mingw32", abi::OsWindows),
("win32", abi::OsWindows),
("windows", abi::OsWindows),
("darwin", abi::OsMacos),
("android", abi::OsAndroid),
("linux", abi::OsLinux),
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ impl<'a> Context<'a> {
// dynamic libraries
fn dylibname(&self) -> Option<(&'static str, &'static str)> {
match self.os {
abi::OsWin32 => Some((WIN32_DLL_PREFIX, WIN32_DLL_SUFFIX)),
abi::OsWindows => Some((WIN32_DLL_PREFIX, WIN32_DLL_SUFFIX)),
abi::OsMacos => Some((MACOS_DLL_PREFIX, MACOS_DLL_SUFFIX)),
abi::OsLinux => Some((LINUX_DLL_PREFIX, LINUX_DLL_SUFFIX)),
abi::OsAndroid => Some((ANDROID_DLL_PREFIX, ANDROID_DLL_SUFFIX)),
Expand Down Expand Up @@ -824,7 +824,7 @@ pub fn meta_section_name(os: abi::Os) -> Option<&'static str> {
match os {
abi::OsMacos => Some("__DATA,__note.rustc"),
abi::OsiOS => Some("__DATA,__note.rustc"),
abi::OsWin32 => Some(".note.rustc"),
abi::OsWindows => Some(".note.rustc"),
abi::OsLinux => Some(".note.rustc"),
abi::OsAndroid => Some(".note.rustc"),
abi::OsFreebsd => Some(".note.rustc"),
Expand All @@ -836,7 +836,7 @@ pub fn read_meta_section_name(os: abi::Os) -> &'static str {
match os {
abi::OsMacos => "__note.rustc",
abi::OsiOS => unreachable!(),
abi::OsWin32 => ".note.rustc",
abi::OsWindows => ".note.rustc",
abi::OsLinux => ".note.rustc",
abi::OsAndroid => ".note.rustc",
abi::OsFreebsd => ".note.rustc",
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/cabi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use middle::trans::cabi_arm;
use middle::trans::cabi_mips;
use middle::trans::type_::Type;
use syntax::abi::{X86, X86_64, Arm, Mips, Mipsel};
use syntax::abi::{OsWin32};
use syntax::abi::{OsWindows};

#[deriving(Clone, PartialEq)]
pub enum ArgKind {
Expand Down Expand Up @@ -110,7 +110,7 @@ pub fn compute_abi_info(ccx: &CrateContext,
match ccx.sess().targ_cfg.arch {
X86 => cabi_x86::compute_abi_info(ccx, atys, rty, ret_def),
X86_64 =>
if ccx.sess().targ_cfg.os == OsWin32 {
if ccx.sess().targ_cfg.os == OsWindows {
cabi_x86_win64::compute_abi_info(ccx, atys, rty, ret_def)
} else {
cabi_x86_64::compute_abi_info(ccx, atys, rty, ret_def)
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/cabi_x86.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.


use syntax::abi::{OsWin32, OsMacos, OsiOS};
use syntax::abi::{OsWindows, OsMacos, OsiOS};
use llvm::*;
use super::cabi::*;
use super::common::*;
Expand All @@ -36,7 +36,7 @@ pub fn compute_abi_info(ccx: &CrateContext,

enum Strategy { RetValue(Type), RetPointer }
let strategy = match ccx.sess().targ_cfg.os {
OsWin32 | OsMacos | OsiOS => {
OsWindows | OsMacos | OsiOS => {
match llsize_of_alloc(ccx, rty) {
1 => RetValue(Type::i8(ccx)),
2 => RetValue(Type::i16(ccx)),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
pub fn find_library(name: &str, os: abi::Os, search_paths: &[Path],
handler: &ErrorHandler) -> Path {
let (osprefix, osext) = match os {
abi::OsWin32 => ("", "lib"), _ => ("lib", "a"),
abi::OsWindows => ("", "lib"), _ => ("lib", "a"),
};
// On Windows, static libraries sometimes show up as libfoo.a and other
// times show up as foo.lib
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
-a0:0:64-n32".to_string()
}

abi::OsWin32 => {
abi::OsWindows => {
"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\
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/mips.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
-a0:0:64-n32".to_string()
}

abi::OsWin32 => {
abi::OsWindows => {
"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\
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/mipsel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs
-a0:0:64-n32".to_string()
}

abi::OsWin32 => {
abi::OsWindows => {
"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\
Expand Down
Loading