diff --git a/src/librustc/back/rpath.rs b/src/librustc/back/rpath.rs index ce79bea5cee7d..8c0aa494d6f80 100644 --- a/src/librustc/back/rpath.rs +++ b/src/librustc/back/rpath.rs @@ -133,7 +133,7 @@ pub fn get_rpath_relative_to_output(os: abi::Os, } pub fn get_install_prefix_rpath(sysroot: &Path, target_triple: &str) -> ~str { - let install_prefix = env!("CFG_PREFIX"); + let install_prefix = option_env!("CFG_PREFIX").expect("CFG_PREFIX"); let tlib = filesearch::relative_target_lib_path(sysroot, target_triple); let mut path = Path::new(install_prefix); @@ -171,7 +171,7 @@ mod test { fn test_prefix_rpath() { let sysroot = filesearch::get_or_default_sysroot(); let res = get_install_prefix_rpath(&sysroot, "triple"); - let mut d = Path::new(env!("CFG_PREFIX")); + let mut d = Path::new((option_env!("CFG_PREFIX")).expect("CFG_PREFIX")); d.push("lib"); d.push(filesearch::rustlibdir()); d.push("triple/lib"); diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index e4ace2a2b9594..62ecacd2c3a7a 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -802,7 +802,8 @@ pub fn host_triple() -> &'static str { // Instead of grabbing the host triple (for the current host), we grab (at // compile time) the target triple that this rustc is built with and // calling that (at runtime) the host triple. - env!("CFG_COMPILER_HOST_TRIPLE") + (option_env!("CFG_COMPILER_HOST_TRIPLE")). + expect("CFG_COMPILER_HOST_TRIPLE") } pub fn build_session_options(matches: &getopts::Matches) -> session::Options { diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 0c7d36e0dbedf..6d7c4291fa463 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -984,7 +984,8 @@ fn compile_unit_metadata(cx: &CrateContext) { }; debug!("compile_unit_metadata: {:?}", compile_unit_name); - let producer = format!("rustc version {}", env!("CFG_VERSION")); + let producer = format!("rustc version {}", + (option_env!("CFG_VERSION")).expect("CFG_VERSION")); compile_unit_name.with_ref(|compile_unit_name| { work_dir.as_vec().with_c_str(|work_dir| {