88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- extern crate rustc_trans_utils;
12-
1311use super :: archive:: { ArchiveBuilder , ArchiveConfig } ;
1412use super :: linker:: Linker ;
1513use super :: command:: Command ;
@@ -27,7 +25,6 @@ use {CrateTranslation, CrateInfo};
2725use rustc:: util:: common:: time;
2826use rustc:: util:: fs:: fix_windows_verbatim_for_gcc;
2927use rustc:: hir:: def_id:: CrateNum ;
30- use rustc:: hir:: svh:: Svh ;
3128use rustc_back:: tempdir:: TempDir ;
3229use rustc_back:: { PanicStrategy , RelroLevel } ;
3330use context:: get_reloc_model;
@@ -88,9 +85,9 @@ pub const RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET: usize =
8885pub const RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET : usize =
8986 RLIB_BYTECODE_OBJECT_V1_DATASIZE_OFFSET + 8 ;
9087
91- pub use self :: rustc_trans_utils:: link:: { find_crate_name, filename_for_input,
92- default_output_for_target , invalid_output_for_target ,
93- build_link_meta } ;
88+ pub use rustc_trans_utils:: link:: { find_crate_name, filename_for_input, default_output_for_target ,
89+ invalid_output_for_target , build_link_meta , out_filename ,
90+ check_file_is_writeable } ;
9491
9592// The third parameter is for env vars, used on windows to set up the
9693// path for MSVC to find its DLLs, and gcc to find its bundled
@@ -218,13 +215,6 @@ pub fn link_binary(sess: &Session,
218215 out_filenames
219216}
220217
221- fn is_writeable ( p : & Path ) -> bool {
222- match p. metadata ( ) {
223- Err ( ..) => true ,
224- Ok ( m) => !m. permissions ( ) . readonly ( )
225- }
226- }
227-
228218fn filename_for_metadata ( sess : & Session , crate_name : & str , outputs : & OutputFilenames ) -> PathBuf {
229219 let out_filename = outputs. single_output_file . clone ( )
230220 . unwrap_or ( outputs
@@ -288,32 +278,6 @@ pub fn ignored_for_lto(info: &CrateInfo, cnum: CrateNum) -> bool {
288278 info. is_no_builtins . contains ( & cnum) || info. compiler_builtins == Some ( cnum)
289279}
290280
291- fn out_filename ( sess : & Session ,
292- crate_type : config:: CrateType ,
293- outputs : & OutputFilenames ,
294- crate_name : & str )
295- -> PathBuf {
296- let default_filename = filename_for_input ( sess, crate_type, crate_name, outputs) ;
297- let out_filename = outputs. outputs . get ( & OutputType :: Exe )
298- . and_then ( |s| s. to_owned ( ) )
299- . or_else ( || outputs. single_output_file . clone ( ) )
300- . unwrap_or ( default_filename) ;
301-
302- check_file_is_writeable ( & out_filename, sess) ;
303-
304- out_filename
305- }
306-
307- // Make sure files are writeable. Mac, FreeBSD, and Windows system linkers
308- // check this already -- however, the Linux linker will happily overwrite a
309- // read-only file. We should be consistent.
310- fn check_file_is_writeable ( file : & Path , sess : & Session ) {
311- if !is_writeable ( file) {
312- sess. fatal ( & format ! ( "output file {} is not writeable -- check its \
313- permissions", file. display( ) ) ) ;
314- }
315- }
316-
317281fn link_binary_output ( sess : & Session ,
318282 trans : & CrateTranslation ,
319283 crate_type : config:: CrateType ,
0 commit comments