]> git.lizzy.rs Git - rust.git/commitdiff
Extract librustc_back from librustc
authorBrian Anderson <banderson@mozilla.com>
Sat, 5 Jul 2014 02:41:54 +0000 (19:41 -0700)
committerBrian Anderson <banderson@mozilla.com>
Mon, 14 Jul 2014 19:27:07 +0000 (12:27 -0700)
22 files changed:
mk/crates.mk
src/librustc/back/abi.rs [deleted file]
src/librustc/back/archive.rs
src/librustc/back/arm.rs [deleted file]
src/librustc/back/link.rs
src/librustc/back/lto.rs
src/librustc/back/mips.rs [deleted file]
src/librustc/back/mipsel.rs [deleted file]
src/librustc/back/svh.rs [deleted file]
src/librustc/back/target_strs.rs [deleted file]
src/librustc/back/x86.rs [deleted file]
src/librustc/back/x86_64.rs [deleted file]
src/librustc/lib.rs
src/librustc_back/abi.rs [new file with mode: 0644]
src/librustc_back/arm.rs [new file with mode: 0644]
src/librustc_back/lib.rs [new file with mode: 0644]
src/librustc_back/mips.rs [new file with mode: 0644]
src/librustc_back/mipsel.rs [new file with mode: 0644]
src/librustc_back/svh.rs [new file with mode: 0644]
src/librustc_back/target_strs.rs [new file with mode: 0644]
src/librustc_back/x86.rs [new file with mode: 0644]
src/librustc_back/x86_64.rs [new file with mode: 0644]

index e565d3eb2b9402506e6ded6dd0d210f541e00ae9..c95576f6252aa3feca7b16ef2c458ec7de17f04e 100644 (file)
@@ -53,7 +53,8 @@ TARGET_CRATES := libc std green rustuv native flate arena glob term semver \
                  uuid serialize sync getopts collections num test time rand \
                  url log regex graphviz core rlibc alloc debug rustrt \
                  unicode
-HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros rustc_llvm
+HOST_CRATES := syntax rustc rustdoc fourcc hexfloat regex_macros fmt_macros \
+              rustc_llvm rustc_back
 CRATES := $(TARGET_CRATES) $(HOST_CRATES)
 TOOLS := compiletest rustdoc rustc
 
@@ -71,8 +72,9 @@ DEPS_rustuv := std native:uv native:uv_support
 DEPS_native := std
 DEPS_syntax := std term serialize log fmt_macros debug
 DEPS_rustc := syntax flate arena serialize getopts \
-              time log graphviz debug rustc_llvm
+              time log graphviz debug rustc_llvm rustc_back
 DEPS_rustc_llvm := native:rustllvm libc std
+DEPS_rustc_back := std syntax rustc_llvm flate log libc
 DEPS_rustdoc := rustc native:hoedown serialize getopts \
                 test time debug
 DEPS_flate := std native:miniz
diff --git a/src/librustc/back/abi.rs b/src/librustc/back/abi.rs
deleted file mode 100644 (file)
index c722beb..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2012 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.
-
-pub static box_field_refcnt: uint = 0u;
-pub static box_field_tydesc: uint = 1u;
-pub static box_field_body: uint = 4u;
-
-pub static tydesc_field_visit_glue: uint = 3u;
-
-// The two halves of a closure: code and environment.
-pub static fn_field_code: uint = 0u;
-pub static fn_field_box: uint = 1u;
-
-// The two fields of a trait object/trait instance: vtable and box.
-// The vtable contains the type descriptor as first element.
-pub static trt_field_vtable: uint = 0u;
-pub static trt_field_box: uint = 1u;
-
-pub static vec_elt_fill: uint = 0u;
-
-pub static vec_elt_alloc: uint = 1u;
-
-pub static vec_elt_elems: uint = 2u;
-
-pub static slice_elt_base: uint = 0u;
-pub static slice_elt_len: uint = 1u;
index 4d921fb97dc503f0fe205f43e55ad2d48a5fe777..8acb610db3f597419a2f309dbe27c39442912b9e 100644 (file)
 
 //! A helper class for dealing with static archives
 
-use back::link::{get_ar_prog};
+use super::link::{get_ar_prog};
 use driver::session::Session;
 use metadata::filesearch;
-use lib::llvm::{ArchiveRef, llvm};
+use llvm::{ArchiveRef, llvm};
 
 use libc;
 use std::io::process::{Command, ProcessOutput};
diff --git a/src/librustc/back/arm.rs b/src/librustc/back/arm.rs
deleted file mode 100644 (file)
index 7a7d248..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright 2012 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 back::target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
-    let cc_args = if target_triple.as_slice().contains("thumb") {
-        vec!("-mthumb".to_string())
-    } else {
-        vec!("-marm".to_string())
-    };
-    return target_strs::t {
-        module_asm: "".to_string(),
-
-        data_layout: match target_os {
-          abi::OsMacos => {
-            "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".to_string()
-          }
-
-          abi::OsiOS => {
-            "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".to_string()
-          }
-
-          abi::OsWin32 => {
-            "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".to_string()
-          }
-
-          abi::OsLinux => {
-            "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".to_string()
-          }
-
-          abi::OsAndroid => {
-            "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".to_string()
-          }
-
-          abi::OsFreebsd => {
-            "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".to_string()
-          }
-        },
-
-        target_triple: target_triple,
-
-        cc_args: cc_args,
-    };
-}
index a1df360a11b8e2878fd43ca3c33240e828fa7488..2112e8d822d38c2deabdb3be92fa1ea02923b8c8 100644 (file)
@@ -8,16 +8,15 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::archive::{Archive, METADATA_FILENAME};
-use back::rpath;
-use back::svh::Svh;
+use super::archive::{Archive, METADATA_FILENAME};
+use super::rpath;
+use super::svh::Svh;
 use driver::driver::{CrateTranslation, OutputFilenames, Input, FileInput};
 use driver::config::NoDebugInfo;
 use driver::session::Session;
 use driver::config;
-use lib::llvm::llvm;
-use lib::llvm::ModuleRef;
-use lib;
+use llvm;
+use llvm::ModuleRef;
 use metadata::common::LinkMeta;
 use metadata::{encoder, cstore, filesearch, csearch, loader, creader};
 use middle::trans::context::CrateContext;
@@ -55,7 +54,7 @@ pub enum OutputType {
 
 pub fn llvm_err(sess: &Session, msg: String) -> ! {
     unsafe {
-        let cstr = llvm::LLVMRustGetLastError();
+        let cstr = llvm::llvm::LLVMRustGetLastError();
         if cstr == ptr::null() {
             sess.fatal(msg.as_slice());
         } else {
@@ -70,14 +69,14 @@ pub fn llvm_err(sess: &Session, msg: String) -> ! {
 
 pub fn write_output_file(
         sess: &Session,
-        target: lib::llvm::TargetMachineRef,
-        pm: lib::llvm::PassManagerRef,
+        target: llvm::TargetMachineRef,
+        pm: llvm::PassManagerRef,
         m: ModuleRef,
         output: &Path,
-        file_type: lib::llvm::FileType) {
+        file_type: llvm::FileType) {
     unsafe {
         output.with_c_str(|output| {
-            let result = llvm::LLVMRustWriteOutputFile(
+            let result = llvm::llvm::LLVMRustWriteOutputFile(
                     target, pm, m, output, file_type);
             if !result {
                 llvm_err(sess, "could not write output".to_string());
@@ -88,18 +87,17 @@ pub fn write_output_file(
 
 pub mod write {
 
-    use back::lto;
-    use back::link::{write_output_file, OutputType};
-    use back::link::{OutputTypeAssembly, OutputTypeBitcode};
-    use back::link::{OutputTypeExe, OutputTypeLlvmAssembly};
-    use back::link::{OutputTypeObject};
+    use super::super::lto;
+    use super::{write_output_file, OutputType};
+    use super::{OutputTypeAssembly, OutputTypeBitcode};
+    use super::{OutputTypeExe, OutputTypeLlvmAssembly};
+    use super::{OutputTypeObject};
     use driver::driver::{CrateTranslation, OutputFilenames};
     use driver::config::NoDebugInfo;
     use driver::session::Session;
     use driver::config;
-    use lib::llvm::llvm;
-    use lib::llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
-    use lib;
+    use llvm;
+    use llvm::{ModuleRef, TargetMachineRef, PassManagerRef};
     use util::common::time;
     use syntax::abi;
 
@@ -147,15 +145,15 @@ pub fn run_passes(sess: &Session,
 
             if sess.opts.cg.save_temps {
                 output.with_extension("no-opt.bc").with_c_str(|buf| {
-                    llvm::LLVMWriteBitcodeToFile(llmod, buf);
+                    llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
                 })
             }
 
             let opt_level = match sess.opts.optimize {
-              config::No => lib::llvm::CodeGenLevelNone,
-              config::Less => lib::llvm::CodeGenLevelLess,
-              config::Default => lib::llvm::CodeGenLevelDefault,
-              config::Aggressive => lib::llvm::CodeGenLevelAggressive,
+              config::No => llvm::CodeGenLevelNone,
+              config::Less => llvm::CodeGenLevelLess,
+              config::Default => llvm::CodeGenLevelDefault,
+              config::Aggressive => llvm::CodeGenLevelAggressive,
             };
             let use_softfp = sess.opts.cg.soft_float;
 
@@ -172,10 +170,10 @@ pub fn run_passes(sess: &Session,
             let fdata_sections = ffunction_sections;
 
             let reloc_model = match sess.opts.cg.relocation_model.as_slice() {
-                "pic" => lib::llvm::RelocPIC,
-                "static" => lib::llvm::RelocStatic,
-                "default" => lib::llvm::RelocDefault,
-                "dynamic-no-pic" => lib::llvm::RelocDynamicNoPic,
+                "pic" => llvm::RelocPIC,
+                "static" => llvm::RelocStatic,
+                "default" => llvm::RelocDefault,
+                "dynamic-no-pic" => llvm::RelocDynamicNoPic,
                 _ => {
                     sess.err(format!("{} is not a valid relocation mode",
                                      sess.opts
@@ -193,9 +191,9 @@ pub fn run_passes(sess: &Session,
                          .with_c_str(|t| {
                 sess.opts.cg.target_cpu.as_slice().with_c_str(|cpu| {
                     target_feature(sess).with_c_str(|features| {
-                        llvm::LLVMRustCreateTargetMachine(
+                        llvm::llvm::LLVMRustCreateTargetMachine(
                             t, cpu, features,
-                            lib::llvm::CodeModelDefault,
+                            llvm::CodeModelDefault,
                             reloc_model,
                             opt_level,
                             true /* EnableSegstk */,
@@ -212,26 +210,26 @@ pub fn run_passes(sess: &Session,
             // does, and are by populated by LLVM's default PassManagerBuilder.
             // Each manager has a different set of passes, but they also share
             // some common passes.
-            let fpm = llvm::LLVMCreateFunctionPassManagerForModule(llmod);
-            let mpm = llvm::LLVMCreatePassManager();
+            let fpm = llvm::llvm::LLVMCreateFunctionPassManagerForModule(llmod);
+            let mpm = llvm::llvm::LLVMCreatePassManager();
 
             // If we're verifying or linting, add them to the function pass
             // manager.
             let addpass = |pass: &str| {
-                pass.as_slice().with_c_str(|s| llvm::LLVMRustAddPass(fpm, s))
+                pass.as_slice().with_c_str(|s| llvm::llvm::LLVMRustAddPass(fpm, s))
             };
             if !sess.no_verify() { assert!(addpass("verify")); }
 
             if !sess.opts.cg.no_prepopulate_passes {
-                llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
-                llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
+                llvm::llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
+                llvm::llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
                 populate_llvm_passes(fpm, mpm, llmod, opt_level,
                                      trans.no_builtins);
             }
 
             for pass in sess.opts.cg.passes.iter() {
                 pass.as_slice().with_c_str(|s| {
-                    if !llvm::LLVMRustAddPass(mpm, s) {
+                    if !llvm::llvm::LLVMRustAddPass(mpm, s) {
                         sess.warn(format!("unknown pass {}, ignoring",
                                           *pass).as_slice());
                     }
@@ -240,13 +238,13 @@ pub fn run_passes(sess: &Session,
 
             // Finally, run the actual optimization passes
             time(sess.time_passes(), "llvm function passes", (), |()|
-                 llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
+                 llvm::llvm::LLVMRustRunFunctionPassManager(fpm, llmod));
             time(sess.time_passes(), "llvm module passes", (), |()|
-                 llvm::LLVMRunPassManager(mpm, llmod));
+                 llvm::llvm::LLVMRunPassManager(mpm, llmod));
 
             // Deallocate managers that we're now done with
-            llvm::LLVMDisposePassManager(fpm);
-            llvm::LLVMDisposePassManager(mpm);
+            llvm::llvm::LLVMDisposePassManager(fpm);
+            llvm::llvm::LLVMDisposePassManager(mpm);
 
             // Emit the bytecode if we're either saving our temporaries or
             // emitting an rlib. Whenever an rlib is created, the bytecode is
@@ -255,7 +253,7 @@ pub fn run_passes(sess: &Session,
                (sess.crate_types.borrow().contains(&config::CrateTypeRlib) &&
                 sess.opts.output_types.contains(&OutputTypeExe)) {
                 output.temp_path(OutputTypeBitcode).with_c_str(|buf| {
-                    llvm::LLVMWriteBitcodeToFile(llmod, buf);
+                    llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
                 })
             }
 
@@ -265,7 +263,7 @@ pub fn run_passes(sess: &Session,
 
                 if sess.opts.cg.save_temps {
                     output.with_extension("lto.bc").with_c_str(|buf| {
-                        llvm::LLVMWriteBitcodeToFile(llmod, buf);
+                        llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
                     })
                 }
             }
@@ -281,11 +279,11 @@ pub fn run_passes(sess: &Session,
             fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
                             no_builtins: bool, f: |PassManagerRef|) {
                 unsafe {
-                    let cpm = llvm::LLVMCreatePassManager();
-                    llvm::LLVMRustAddAnalysisPasses(tm, cpm, llmod);
-                    llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
+                    let cpm = llvm::llvm::LLVMCreatePassManager();
+                    llvm::llvm::LLVMRustAddAnalysisPasses(tm, cpm, llmod);
+                    llvm::llvm::LLVMRustAddLibraryInfo(cpm, llmod, no_builtins);
                     f(cpm);
-                    llvm::LLVMDisposePassManager(cpm);
+                    llvm::llvm::LLVMDisposePassManager(cpm);
                 }
             }
 
@@ -296,13 +294,13 @@ fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
                 match *output_type {
                     OutputTypeBitcode => {
                         path.with_c_str(|buf| {
-                            llvm::LLVMWriteBitcodeToFile(llmod, buf);
+                            llvm::llvm::LLVMWriteBitcodeToFile(llmod, buf);
                         })
                     }
                     OutputTypeLlvmAssembly => {
                         path.with_c_str(|output| {
                             with_codegen(tm, llmod, trans.no_builtins, |cpm| {
-                                llvm::LLVMRustPrintModule(cpm, llmod, output);
+                                llvm::llvm::LLVMRustPrintModule(cpm, llmod, output);
                             })
                         })
                     }
@@ -320,7 +318,7 @@ fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
                         };
                         with_codegen(tm, llmod, trans.no_builtins, |cpm| {
                             write_output_file(sess, tm, cpm, llmod, &path,
-                                            lib::llvm::AssemblyFile);
+                                            llvm::AssemblyFile);
                         });
                     }
                     OutputTypeObject => {
@@ -338,7 +336,7 @@ fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
                     Some(ref path) => {
                         with_codegen(tm, llmod, trans.no_builtins, |cpm| {
                             write_output_file(sess, tm, cpm, llmod, path,
-                                            lib::llvm::ObjectFile);
+                                            llvm::ObjectFile);
                         });
                     }
                     None => {}
@@ -350,16 +348,16 @@ fn with_codegen(tm: TargetMachineRef, llmod: ModuleRef,
                                         .with_extension("metadata.o");
                         write_output_file(sess, tm, cpm,
                                         trans.metadata_module, &out,
-                                        lib::llvm::ObjectFile);
+                                        llvm::ObjectFile);
                     })
                 }
             });
 
-            llvm::LLVMRustDisposeTargetMachine(tm);
-            llvm::LLVMDisposeModule(trans.metadata_module);
-            llvm::LLVMDisposeModule(llmod);
-            llvm::LLVMContextDispose(llcx);
-            if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
+            llvm::llvm::LLVMRustDisposeTargetMachine(tm);
+            llvm::llvm::LLVMDisposeModule(trans.metadata_module);
+            llvm::llvm::LLVMDisposeModule(llmod);
+            llvm::llvm::LLVMContextDispose(llcx);
+            if sess.time_llvm_passes() { llvm::llvm::LLVMRustPrintPassTimings(); }
         }
     }
 
@@ -426,69 +424,69 @@ unsafe fn configure_llvm(sess: &Session) {
         }
 
         INIT.doit(|| {
-            llvm::LLVMInitializePasses();
+            llvm::llvm::LLVMInitializePasses();
 
             // Only initialize the platforms supported by Rust here, because
             // using --llvm-root will have multiple platforms that rustllvm
             // doesn't actually link to and it's pointless to put target info
             // into the registry that Rust cannot generate machine code for.
-            llvm::LLVMInitializeX86TargetInfo();
-            llvm::LLVMInitializeX86Target();
-            llvm::LLVMInitializeX86TargetMC();
-            llvm::LLVMInitializeX86AsmPrinter();
-            llvm::LLVMInitializeX86AsmParser();
-
-            llvm::LLVMInitializeARMTargetInfo();
-            llvm::LLVMInitializeARMTarget();
-            llvm::LLVMInitializeARMTargetMC();
-            llvm::LLVMInitializeARMAsmPrinter();
-            llvm::LLVMInitializeARMAsmParser();
-
-            llvm::LLVMInitializeMipsTargetInfo();
-            llvm::LLVMInitializeMipsTarget();
-            llvm::LLVMInitializeMipsTargetMC();
-            llvm::LLVMInitializeMipsAsmPrinter();
-            llvm::LLVMInitializeMipsAsmParser();
-
-            llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
+            llvm::llvm::LLVMInitializeX86TargetInfo();
+            llvm::llvm::LLVMInitializeX86Target();
+            llvm::llvm::LLVMInitializeX86TargetMC();
+            llvm::llvm::LLVMInitializeX86AsmPrinter();
+            llvm::llvm::LLVMInitializeX86AsmParser();
+
+            llvm::llvm::LLVMInitializeARMTargetInfo();
+            llvm::llvm::LLVMInitializeARMTarget();
+            llvm::llvm::LLVMInitializeARMTargetMC();
+            llvm::llvm::LLVMInitializeARMAsmPrinter();
+            llvm::llvm::LLVMInitializeARMAsmParser();
+
+            llvm::llvm::LLVMInitializeMipsTargetInfo();
+            llvm::llvm::LLVMInitializeMipsTarget();
+            llvm::llvm::LLVMInitializeMipsTargetMC();
+            llvm::llvm::LLVMInitializeMipsAsmPrinter();
+            llvm::llvm::LLVMInitializeMipsAsmParser();
+
+            llvm::llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
                                          llvm_args.as_ptr());
         });
     }
 
-    unsafe fn populate_llvm_passes(fpm: lib::llvm::PassManagerRef,
-                                   mpm: lib::llvm::PassManagerRef,
+    unsafe fn populate_llvm_passes(fpm: llvm::PassManagerRef,
+                                   mpm: llvm::PassManagerRef,
                                    llmod: ModuleRef,
-                                   opt: lib::llvm::CodeGenOptLevel,
+                                   opt: llvm::CodeGenOptLevel,
                                    no_builtins: bool) {
         // Create the PassManagerBuilder for LLVM. We configure it with
         // reasonable defaults and prepare it to actually populate the pass
         // manager.
-        let builder = llvm::LLVMPassManagerBuilderCreate();
+        let builder = llvm::llvm::LLVMPassManagerBuilderCreate();
         match opt {
-            lib::llvm::CodeGenLevelNone => {
+            llvm::CodeGenLevelNone => {
                 // Don't add lifetime intrinsics at O0
-                llvm::LLVMRustAddAlwaysInlinePass(builder, false);
+                llvm::llvm::LLVMRustAddAlwaysInlinePass(builder, false);
             }
-            lib::llvm::CodeGenLevelLess => {
-                llvm::LLVMRustAddAlwaysInlinePass(builder, true);
+            llvm::CodeGenLevelLess => {
+                llvm::llvm::LLVMRustAddAlwaysInlinePass(builder, true);
             }
             // numeric values copied from clang
-            lib::llvm::CodeGenLevelDefault => {
-                llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
+            llvm::CodeGenLevelDefault => {
+                llvm::llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
                                                                     225);
             }
-            lib::llvm::CodeGenLevelAggressive => {
-                llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
+            llvm::CodeGenLevelAggressive => {
+                llvm::llvm::LLVMPassManagerBuilderUseInlinerWithThreshold(builder,
                                                                     275);
             }
         }
-        llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt as c_uint);
-        llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, no_builtins);
+        llvm::llvm::LLVMPassManagerBuilderSetOptLevel(builder, opt as c_uint);
+        llvm::llvm::LLVMRustAddBuilderLibraryInfo(builder, llmod, no_builtins);
 
         // Use the builder to populate the function/module pass managers.
-        llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
-        llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
-        llvm::LLVMPassManagerBuilderDispose(builder);
+        llvm::llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(builder, fpm);
+        llvm::llvm::LLVMPassManagerBuilderPopulateModulePassManager(builder, mpm);
+        llvm::llvm::LLVMPassManagerBuilderDispose(builder);
     }
 }
 
@@ -611,7 +609,7 @@ pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
                        name: String) -> LinkMeta {
     let r = LinkMeta {
         crate_name: name,
-        crate_hash: Svh::calculate(sess, krate),
+        crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
     };
     info!("{}", r);
     return r;
index b9ae9530f8e1c3291aa4a15be0393484b844b0e5..cf163cdbb637cc70bda7321a6f3f52646e256c39 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use back::archive::ArchiveRO;
-use back::link;
+use super::archive::ArchiveRO;
+use super::link;
 use driver::session;
 use driver::config;
-use lib::llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
+use llvm::{ModuleRef, TargetMachineRef, llvm, True, False};
 use metadata::cstore;
 use util::common::time;
 
diff --git a/src/librustc/back/mips.rs b/src/librustc/back/mips.rs
deleted file mode 100644 (file)
index 8f3da03..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2012 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 back::target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
-    return target_strs::t {
-        module_asm: "".to_string(),
-
-        data_layout: match target_os {
-          abi::OsMacos => {
-            "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".to_string()
-          }
-
-          abi::OsiOS => {
-            "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".to_string()
-          }
-
-          abi::OsWin32 => {
-            "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".to_string()
-          }
-
-          abi::OsLinux => {
-            "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".to_string()
-          }
-
-          abi::OsAndroid => {
-            "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".to_string()
-          }
-
-          abi::OsFreebsd => {
-            "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".to_string()
-          }
-        },
-
-        target_triple: target_triple,
-
-        cc_args: Vec::new(),
-    };
-}
diff --git a/src/librustc/back/mipsel.rs b/src/librustc/back/mipsel.rs
deleted file mode 100644 (file)
index c2c48a4..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// Copyright 2012 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 back::target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
-    return target_strs::t {
-        module_asm: "".to_string(),
-
-        data_layout: match target_os {
-          abi::OsMacos => {
-            "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".to_string()
-          }
-
-          abi::OsiOS => {
-            "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".to_string()
-          }
-
-          abi::OsWin32 => {
-            "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".to_string()
-          }
-
-          abi::OsLinux => {
-            "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".to_string()
-          }
-
-          abi::OsAndroid => {
-            "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".to_string()
-          }
-
-          abi::OsFreebsd => {
-            "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".to_string()
-          }
-        },
-
-        target_triple: target_triple,
-
-        cc_args: Vec::new(),
-    };
-}
diff --git a/src/librustc/back/svh.rs b/src/librustc/back/svh.rs
deleted file mode 100644 (file)
index 324ed3b..0000000
+++ /dev/null
@@ -1,514 +0,0 @@
-// Copyright 2012-2014 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.
-
-//! Calculation and management of a Strict Version Hash for crates
-//!
-//! # Today's ABI problem
-//!
-//! In today's implementation of rustc, it is incredibly difficult to achieve
-//! forward binary compatibility without resorting to C-like interfaces. Within
-//! rust code itself, abi details such as symbol names suffer from a variety of
-//! unrelated factors to code changing such as the "def id drift" problem. This
-//! ends up yielding confusing error messages about metadata mismatches and
-//! such.
-//!
-//! The core of this problem is when an upstream dependency changes and
-//! downstream dependents are not recompiled. This causes compile errors because
-//! the upstream crate's metadata has changed but the downstream crates are
-//! still referencing the older crate's metadata.
-//!
-//! This problem exists for many reasons, the primary of which is that rust does
-//! not currently support forwards ABI compatibility (in place upgrades of a
-//! crate).
-//!
-//! # SVH and how it alleviates the problem
-//!
-//! With all of this knowledge on hand, this module contains the implementation
-//! of a notion of a "Strict Version Hash" for a crate. This is essentially a
-//! hash of all contents of a crate which can somehow be exposed to downstream
-//! crates.
-//!
-//! This hash is currently calculated by just hashing the AST, but this is
-//! obviously wrong (doc changes should not result in an incompatible ABI).
-//! Implementation-wise, this is required at this moment in time.
-//!
-//! By encoding this strict version hash into all crate's metadata, stale crates
-//! can be detected immediately and error'd about by rustc itself.
-//!
-//! # Relevant links
-//!
-//! Original issue: https://github.com/rust-lang/rust/issues/10207
-
-use std::fmt;
-use std::hash::Hash;
-use std::hash::sip::SipState;
-use std::iter::range_step;
-use syntax::ast;
-use syntax::visit;
-
-use driver::session::Session;
-
-#[deriving(Clone, PartialEq)]
-pub struct Svh {
-    hash: String,
-}
-
-impl Svh {
-    pub fn new(hash: &str) -> Svh {
-        assert!(hash.len() == 16);
-        Svh { hash: hash.to_string() }
-    }
-
-    pub fn as_str<'a>(&'a self) -> &'a str {
-        self.hash.as_slice()
-    }
-
-    pub fn calculate(sess: &Session, krate: &ast::Crate) -> Svh {
-        // FIXME (#14132): This is better than it used to be, but it still not
-        // ideal. We now attempt to hash only the relevant portions of the
-        // Crate AST as well as the top-level crate attributes. (However,
-        // the hashing of the crate attributes should be double-checked
-        // to ensure it is not incorporating implementation artifacts into
-        // the hash that are not otherwise visible.)
-
-        // FIXME: this should use SHA1, not SipHash. SipHash is not built to
-        //        avoid collisions.
-        let mut state = SipState::new();
-
-        for data in sess.opts.cg.metadata.iter() {
-            data.hash(&mut state);
-        }
-
-        {
-            let mut visit = svh_visitor::make(&mut state);
-            visit::walk_crate(&mut visit, krate, ());
-        }
-
-        // FIXME (#14132): This hash is still sensitive to e.g. the
-        // spans of the crate Attributes and their underlying
-        // MetaItems; we should make ContentHashable impl for those
-        // types and then use hash_content.  But, since all crate
-        // attributes should appear near beginning of the file, it is
-        // not such a big deal to be sensitive to their spans for now.
-        //
-        // We hash only the MetaItems instead of the entire Attribute
-        // to avoid hashing the AttrId
-        for attr in krate.attrs.iter() {
-            attr.node.value.hash(&mut state);
-        }
-
-        let hash = state.result();
-        return Svh {
-            hash: range_step(0u, 64u, 4u).map(|i| hex(hash >> i)).collect()
-        };
-
-        fn hex(b: u64) -> char {
-            let b = (b & 0xf) as u8;
-            let b = match b {
-                0 .. 9 => '0' as u8 + b,
-                _ => 'a' as u8 + b - 10,
-            };
-            b as char
-        }
-    }
-}
-
-impl fmt::Show for Svh {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        f.pad(self.as_str())
-    }
-}
-
-// FIXME (#14132): Even this SVH computation still has implementation
-// artifacts: namely, the order of item declaration will affect the
-// hash computation, but for many kinds of items the order of
-// declaration should be irrelevant to the ABI.
-
-mod svh_visitor {
-    use syntax::ast;
-    use syntax::ast::*;
-    use syntax::codemap::Span;
-    use syntax::parse::token;
-    use syntax::print::pprust;
-    use syntax::visit;
-    use syntax::visit::{Visitor, FnKind};
-
-    use std::hash::Hash;
-    use std::hash::sip::SipState;
-
-    pub struct StrictVersionHashVisitor<'a> {
-        pub st: &'a mut SipState,
-    }
-
-    pub fn make<'a>(st: &'a mut SipState) -> StrictVersionHashVisitor<'a> {
-        StrictVersionHashVisitor { st: st }
-    }
-
-    // To off-load the bulk of the hash-computation on deriving(Hash),
-    // we define a set of enums corresponding to the content that our
-    // crate visitor will encounter as it traverses the ast.
-    //
-    // The important invariant is that all of the Saw*Component enums
-    // do not carry any Spans, Names, or Idents.
-    //
-    // Not carrying any Names/Idents is the important fix for problem
-    // noted on PR #13948: using the ident.name as the basis for a
-    // hash leads to unstable SVH, because ident.name is just an index
-    // into intern table (i.e. essentially a random address), not
-    // computed from the name content.
-    //
-    // With the below enums, the SVH computation is not sensitive to
-    // artifacts of how rustc was invoked nor of how the source code
-    // was laid out.  (Or at least it is *less* sensitive.)
-
-    // This enum represents the different potential bits of code the
-    // visitor could encounter that could affect the ABI for the crate,
-    // and assigns each a distinct tag to feed into the hash computation.
-    #[deriving(Hash)]
-    enum SawAbiComponent<'a> {
-
-        // FIXME (#14132): should we include (some function of)
-        // ident.ctxt as well?
-        SawIdent(token::InternedString),
-        SawStructDef(token::InternedString),
-
-        SawLifetimeRef(token::InternedString),
-        SawLifetimeDecl(token::InternedString),
-
-        SawMod,
-        SawViewItem,
-        SawForeignItem,
-        SawItem,
-        SawDecl,
-        SawTy,
-        SawGenerics,
-        SawFn,
-        SawTyMethod,
-        SawTraitMethod,
-        SawStructField,
-        SawVariant,
-        SawExplicitSelf,
-        SawPath,
-        SawOptLifetimeRef,
-        SawBlock,
-        SawPat,
-        SawLocal,
-        SawArm,
-        SawExpr(SawExprComponent<'a>),
-        SawStmt(SawStmtComponent),
-    }
-
-    /// SawExprComponent carries all of the information that we want
-    /// to include in the hash that *won't* be covered by the
-    /// subsequent recursive traversal of the expression's
-    /// substructure by the visitor.
-    ///
-    /// We know every Expr_ variant is covered by a variant because
-    /// `fn saw_expr` maps each to some case below.  Ensuring that
-    /// each variant carries an appropriate payload has to be verified
-    /// by hand.
-    ///
-    /// (However, getting that *exactly* right is not so important
-    /// because the SVH is just a developer convenience; there is no
-    /// guarantee of collision-freedom, hash collisions are just
-    /// (hopefully) unlikely.)
-    #[deriving(Hash)]
-    pub enum SawExprComponent<'a> {
-
-        SawExprLoop(Option<token::InternedString>),
-        SawExprField(token::InternedString),
-        SawExprBreak(Option<token::InternedString>),
-        SawExprAgain(Option<token::InternedString>),
-
-        SawExprVstore,
-        SawExprBox,
-        SawExprVec,
-        SawExprCall,
-        SawExprMethodCall,
-        SawExprTup,
-        SawExprBinary(ast::BinOp),
-        SawExprUnary(ast::UnOp),
-        SawExprLit(ast::Lit_),
-        SawExprCast,
-        SawExprIf,
-        SawExprWhile,
-        SawExprMatch,
-        SawExprFnBlock,
-        SawExprProc,
-        SawExprBlock,
-        SawExprAssign,
-        SawExprAssignOp(ast::BinOp),
-        SawExprIndex,
-        SawExprPath,
-        SawExprAddrOf(ast::Mutability),
-        SawExprRet,
-        SawExprInlineAsm(&'a ast::InlineAsm),
-        SawExprStruct,
-        SawExprRepeat,
-        SawExprParen,
-    }
-
-    fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
-        match *node {
-            ExprVstore(..)           => SawExprVstore,
-            ExprBox(..)              => SawExprBox,
-            ExprVec(..)              => SawExprVec,
-            ExprCall(..)             => SawExprCall,
-            ExprMethodCall(..)       => SawExprMethodCall,
-            ExprTup(..)              => SawExprTup,
-            ExprBinary(op, _, _)     => SawExprBinary(op),
-            ExprUnary(op, _)         => SawExprUnary(op),
-            ExprLit(lit)             => SawExprLit(lit.node.clone()),
-            ExprCast(..)             => SawExprCast,
-            ExprIf(..)               => SawExprIf,
-            ExprWhile(..)            => SawExprWhile,
-            ExprLoop(_, id)          => SawExprLoop(id.map(content)),
-            ExprMatch(..)            => SawExprMatch,
-            ExprFnBlock(..)          => SawExprFnBlock,
-            ExprProc(..)             => SawExprProc,
-            ExprBlock(..)            => SawExprBlock,
-            ExprAssign(..)           => SawExprAssign,
-            ExprAssignOp(op, _, _)   => SawExprAssignOp(op),
-            ExprField(_, id, _)      => SawExprField(content(id.node)),
-            ExprIndex(..)            => SawExprIndex,
-            ExprPath(..)             => SawExprPath,
-            ExprAddrOf(m, _)         => SawExprAddrOf(m),
-            ExprBreak(id)            => SawExprBreak(id.map(content)),
-            ExprAgain(id)            => SawExprAgain(id.map(content)),
-            ExprRet(..)              => SawExprRet,
-            ExprInlineAsm(ref asm)   => SawExprInlineAsm(asm),
-            ExprStruct(..)           => SawExprStruct,
-            ExprRepeat(..)           => SawExprRepeat,
-            ExprParen(..)            => SawExprParen,
-
-            // just syntactic artifacts, expanded away by time of SVH.
-            ExprForLoop(..)          => unreachable!(),
-            ExprMac(..)              => unreachable!(),
-        }
-    }
-
-    /// SawStmtComponent is analogous to SawExprComponent, but for statements.
-    #[deriving(Hash)]
-    pub enum SawStmtComponent {
-        SawStmtDecl,
-        SawStmtExpr,
-        SawStmtSemi,
-    }
-
-    fn saw_stmt(node: &Stmt_) -> SawStmtComponent {
-        match *node {
-            StmtDecl(..) => SawStmtDecl,
-            StmtExpr(..) => SawStmtExpr,
-            StmtSemi(..) => SawStmtSemi,
-            StmtMac(..)  => unreachable!(),
-        }
-    }
-
-    // Ad-hoc overloading between Ident and Name to their intern table lookups.
-    trait InternKey { fn get_content(self) -> token::InternedString; }
-    impl InternKey for Ident {
-        fn get_content(self) -> token::InternedString { token::get_ident(self) }
-    }
-    impl InternKey for Name {
-        fn get_content(self) -> token::InternedString { token::get_name(self) }
-    }
-    fn content<K:InternKey>(k: K) -> token::InternedString { k.get_content() }
-
-    // local short-hand eases writing signatures of syntax::visit mod.
-    type E = ();
-
-    impl<'a> Visitor<E> for StrictVersionHashVisitor<'a> {
-
-        fn visit_mac(&mut self, macro: &Mac, e: E) {
-            // macro invocations, namely macro_rules definitions,
-            // *can* appear as items, even in the expanded crate AST.
-
-            if macro_name(macro).get() == "macro_rules" {
-                // Pretty-printing definition to a string strips out
-                // surface artifacts (currently), such as the span
-                // information, yielding a content-based hash.
-
-                // FIXME (#14132): building temporary string is
-                // expensive; a direct content-based hash on token
-                // trees might be faster. Implementing this is far
-                // easier in short term.
-                let macro_defn_as_string =
-                    pprust::to_string(|pp_state| pp_state.print_mac(macro));
-                macro_defn_as_string.hash(self.st);
-            } else {
-                // It is not possible to observe any kind of macro
-                // invocation at this stage except `macro_rules!`.
-                fail!("reached macro somehow: {}",
-                      pprust::to_string(|pp_state| pp_state.print_mac(macro)));
-            }
-
-            visit::walk_mac(self, macro, e);
-
-            fn macro_name(macro: &Mac) -> token::InternedString {
-                match &macro.node {
-                    &MacInvocTT(ref path, ref _tts, ref _stx_ctxt) => {
-                        let s = path.segments.as_slice();
-                        assert_eq!(s.len(), 1);
-                        content(s[0].identifier)
-                    }
-                }
-            }
-        }
-
-        fn visit_struct_def(&mut self, s: &StructDef, ident: Ident,
-                            g: &Generics, _: NodeId, e: E) {
-            SawStructDef(content(ident)).hash(self.st);
-            visit::walk_generics(self, g, e.clone());
-            visit::walk_struct_def(self, s, e)
-        }
-
-        fn visit_variant(&mut self, v: &Variant, g: &Generics, e: E) {
-            SawVariant.hash(self.st);
-            // walk_variant does not call walk_generics, so do it here.
-            visit::walk_generics(self, g, e.clone());
-            visit::walk_variant(self, v, g, e)
-        }
-
-        fn visit_opt_lifetime_ref(&mut self, _: Span, l: &Option<Lifetime>, env: E) {
-            SawOptLifetimeRef.hash(self.st);
-            // (This is a strange method in the visitor trait, in that
-            // it does not expose a walk function to do the subroutine
-            // calls.)
-            match *l {
-                Some(ref l) => self.visit_lifetime_ref(l, env),
-                None => ()
-            }
-        }
-
-        // All of the remaining methods just record (in the hash
-        // SipState) that the visitor saw that particular variant
-        // (with its payload), and continue walking as the default
-        // visitor would.
-        //
-        // Some of the implementations have some notes as to how one
-        // might try to make their SVH computation less discerning
-        // (e.g. by incorporating reachability analysis).  But
-        // currently all of their implementations are uniform and
-        // uninteresting.
-        //
-        // (If you edit a method such that it deviates from the
-        // pattern, please move that method up above this comment.)
-
-        fn visit_ident(&mut self, _: Span, ident: Ident, _: E) {
-            SawIdent(content(ident)).hash(self.st);
-        }
-
-        fn visit_lifetime_ref(&mut self, l: &Lifetime, _: E) {
-            SawLifetimeRef(content(l.name)).hash(self.st);
-        }
-
-        fn visit_lifetime_decl(&mut self, l: &Lifetime, _: E) {
-            SawLifetimeDecl(content(l.name)).hash(self.st);
-        }
-
-        // We do recursively walk the bodies of functions/methods
-        // (rather than omitting their bodies from the hash) since
-        // monomorphization and cross-crate inlining generally implies
-        // that a change to a crate body will require downstream
-        // crates to be recompiled.
-        fn visit_expr(&mut self, ex: &Expr, e: E) {
-            SawExpr(saw_expr(&ex.node)).hash(self.st); visit::walk_expr(self, ex, e)
-        }
-
-        fn visit_stmt(&mut self, s: &Stmt, e: E) {
-            SawStmt(saw_stmt(&s.node)).hash(self.st); visit::walk_stmt(self, s, e)
-        }
-
-        fn visit_view_item(&mut self, i: &ViewItem, e: E) {
-            // Two kinds of view items can affect the ABI for a crate:
-            // exported `pub use` view items (since that may expose
-            // items that downstream crates can call), and `use
-            // foo::Trait`, since changing that may affect method
-            // resolution.
-            //
-            // The simplest approach to handling both of the above is
-            // just to adopt the same simple-minded (fine-grained)
-            // hash that I am deploying elsewhere here.
-            SawViewItem.hash(self.st); visit::walk_view_item(self, i, e)
-        }
-
-        fn visit_foreign_item(&mut self, i: &ForeignItem, e: E) {
-            // FIXME (#14132) ideally we would incorporate privacy (or
-            // perhaps reachability) somewhere here, so foreign items
-            // that do not leak into downstream crates would not be
-            // part of the ABI.
-            SawForeignItem.hash(self.st); visit::walk_foreign_item(self, i, e)
-        }
-
-        fn visit_item(&mut self, i: &Item, e: E) {
-            // FIXME (#14132) ideally would incorporate reachability
-            // analysis somewhere here, so items that never leak into
-            // downstream crates (e.g. via monomorphisation or
-            // inlining) would not be part of the ABI.
-            SawItem.hash(self.st); visit::walk_item(self, i, e)
-        }
-
-        fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId, e: E) {
-            SawMod.hash(self.st); visit::walk_mod(self, m, e)
-        }
-
-        fn visit_decl(&mut self, d: &Decl, e: E) {
-            SawDecl.hash(self.st); visit::walk_decl(self, d, e)
-        }
-
-        fn visit_ty(&mut self, t: &Ty, e: E) {
-            SawTy.hash(self.st); visit::walk_ty(self, t, e)
-        }
-
-        fn visit_generics(&mut self, g: &Generics, e: E) {
-            SawGenerics.hash(self.st); visit::walk_generics(self, g, e)
-        }
-
-        fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId, e: E) {
-            SawFn.hash(self.st); visit::walk_fn(self, fk, fd, b, s, e)
-        }
-
-        fn visit_ty_method(&mut self, t: &TypeMethod, e: E) {
-            SawTyMethod.hash(self.st); visit::walk_ty_method(self, t, e)
-        }
-
-        fn visit_trait_method(&mut self, t: &TraitMethod, e: E) {
-            SawTraitMethod.hash(self.st); visit::walk_trait_method(self, t, e)
-        }
-
-        fn visit_struct_field(&mut self, s: &StructField, e: E) {
-            SawStructField.hash(self.st); visit::walk_struct_field(self, s, e)
-        }
-
-        fn visit_explicit_self(&mut self, es: &ExplicitSelf, e: E) {
-            SawExplicitSelf.hash(self.st); visit::walk_explicit_self(self, es, e)
-        }
-
-        fn visit_path(&mut self, path: &Path, _: ast::NodeId, e: E) {
-            SawPath.hash(self.st); visit::walk_path(self, path, e)
-        }
-
-        fn visit_block(&mut self, b: &Block, e: E) {
-            SawBlock.hash(self.st); visit::walk_block(self, b, e)
-        }
-
-        fn visit_pat(&mut self, p: &Pat, e: E) {
-            SawPat.hash(self.st); visit::walk_pat(self, p, e)
-        }
-
-        fn visit_local(&mut self, l: &Local, e: E) {
-            SawLocal.hash(self.st); visit::walk_local(self, l, e)
-        }
-
-        fn visit_arm(&mut self, a: &Arm, e: E) {
-            SawArm.hash(self.st); visit::walk_arm(self, a, e)
-        }
-    }
-}
diff --git a/src/librustc/back/target_strs.rs b/src/librustc/back/target_strs.rs
deleted file mode 100644 (file)
index 7928f3d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2012 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.
-
-#![allow(non_camel_case_types)]
-
-pub struct t {
-    pub module_asm: String,
-    pub data_layout: String,
-    pub target_triple: String,
-    pub cc_args: Vec<String> ,
-}
diff --git a/src/librustc/back/x86.rs b/src/librustc/back/x86.rs
deleted file mode 100644 (file)
index d2dac03..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2012 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 back::target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os)
-                       -> target_strs::t {
-    return target_strs::t {
-        module_asm: "".to_string(),
-
-        data_layout: match target_os {
-          abi::OsMacos => {
-            "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
-                -i32:32:32-i64:32:64\
-                -f32:32:32-f64:32:64-v64:64:64\
-                -v128:128:128-a0:0:64-f80:128:128\
-                -n8:16:32".to_string()
-          }
-
-          abi::OsiOS => {
-            "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
-                -i32:32:32-i64:32:64\
-                -f32:32:32-f64:32:64-v64:64:64\
-                -v128:128:128-a0:0:64-f80:128:128\
-                -n8:16:32".to_string()
-          }
-
-          abi::OsWin32 => {
-            "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string()
-          }
-
-          abi::OsLinux => {
-            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
-          }
-          abi::OsAndroid => {
-            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
-          }
-
-          abi::OsFreebsd => {
-            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
-          }
-        },
-
-        target_triple: target_triple,
-
-        cc_args: vec!("-m32".to_string()),
-    };
-}
diff --git a/src/librustc/back/x86_64.rs b/src/librustc/back/x86_64.rs
deleted file mode 100644 (file)
index c2eae18..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2012 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 back::target_strs;
-use syntax::abi;
-
-pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
-    return target_strs::t {
-        module_asm: "".to_string(),
-
-        data_layout: match target_os {
-          abi::OsMacos => {
-            "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".to_string()
-          }
-
-          abi::OsiOS => {
-            "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".to_string()
-          }
-
-          abi::OsWin32 => {
-            // FIXME: Test this. Copied from linux (#2398)
-            "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".to_string()
-          }
-
-          abi::OsLinux => {
-            "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".to_string()
-          }
-          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-\
-                s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
-          }
-
-          abi::OsFreebsd => {
-            "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".to_string()
-          }
-        },
-
-        target_triple: target_triple,
-
-        cc_args: vec!("-m64".to_string()),
-    };
-}
index 7da3ae0208714f3694c7b31e7eb909cdd4309492..65124ceff1dbbb0beafb41ff838cdbbb14a05c8a 100644 (file)
@@ -42,6 +42,7 @@
 extern crate graphviz;
 extern crate libc;
 extern crate llvm = "rustc_llvm";
+extern crate rustc_back = "rustc_back";
 extern crate serialize;
 extern crate time;
 #[phase(plugin, link)] extern crate log;
 
 mod diagnostics;
 
+pub mod back {
+    pub use rustc_back::abi;
+    pub use rustc_back::arm;
+    pub use rustc_back::mips;
+    pub use rustc_back::mipsel;
+    pub use rustc_back::svh;
+    pub use rustc_back::target_strs;
+    pub use rustc_back::x86;
+    pub use rustc_back::x86_64;
+
+    pub mod archive;
+    pub mod link;
+    pub mod lto;
+    pub mod rpath;
+
+}
+>>>>>>> Extract librustc_back from librustc
+
 pub mod middle {
     pub mod def;
     pub mod trans;
@@ -97,21 +116,6 @@ pub mod front {
     pub mod show_span;
 }
 
-pub mod back {
-    pub mod abi;
-    pub mod archive;
-    pub mod arm;
-    pub mod link;
-    pub mod lto;
-    pub mod mips;
-    pub mod mipsel;
-    pub mod rpath;
-    pub mod svh;
-    pub mod target_strs;
-    pub mod x86;
-    pub mod x86_64;
-}
-
 pub mod metadata;
 
 pub mod driver;
diff --git a/src/librustc_back/abi.rs b/src/librustc_back/abi.rs
new file mode 100644 (file)
index 0000000..c722beb
--- /dev/null
@@ -0,0 +1,33 @@
+// Copyright 2012 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.
+
+pub static box_field_refcnt: uint = 0u;
+pub static box_field_tydesc: uint = 1u;
+pub static box_field_body: uint = 4u;
+
+pub static tydesc_field_visit_glue: uint = 3u;
+
+// The two halves of a closure: code and environment.
+pub static fn_field_code: uint = 0u;
+pub static fn_field_box: uint = 1u;
+
+// The two fields of a trait object/trait instance: vtable and box.
+// The vtable contains the type descriptor as first element.
+pub static trt_field_vtable: uint = 0u;
+pub static trt_field_box: uint = 1u;
+
+pub static vec_elt_fill: uint = 0u;
+
+pub static vec_elt_alloc: uint = 1u;
+
+pub static vec_elt_elems: uint = 2u;
+
+pub static slice_elt_base: uint = 0u;
+pub static slice_elt_len: uint = 1u;
diff --git a/src/librustc_back/arm.rs b/src/librustc_back/arm.rs
new file mode 100644 (file)
index 0000000..a073036
--- /dev/null
@@ -0,0 +1,77 @@
+// Copyright 2012 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 target_strs;
+use syntax::abi;
+
+pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
+    let cc_args = if target_triple.as_slice().contains("thumb") {
+        vec!("-mthumb".to_string())
+    } else {
+        vec!("-marm".to_string())
+    };
+    return target_strs::t {
+        module_asm: "".to_string(),
+
+        data_layout: match target_os {
+          abi::OsMacos => {
+            "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".to_string()
+          }
+
+          abi::OsiOS => {
+            "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".to_string()
+          }
+
+          abi::OsWin32 => {
+            "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".to_string()
+          }
+
+          abi::OsLinux => {
+            "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".to_string()
+          }
+
+          abi::OsAndroid => {
+            "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".to_string()
+          }
+
+          abi::OsFreebsd => {
+            "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".to_string()
+          }
+        },
+
+        target_triple: target_triple,
+
+        cc_args: cc_args,
+    };
+}
diff --git a/src/librustc_back/lib.rs b/src/librustc_back/lib.rs
new file mode 100644 (file)
index 0000000..5334c49
--- /dev/null
@@ -0,0 +1,39 @@
+// Copyright 2012-2013 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.
+
+#![crate_id = "rustc_back#0.11.0-pre"]
+#![crate_name = "rustc_back"]
+#![experimental]
+#![comment = "The Rust compiler backend"]
+#![license = "MIT/ASL2"]
+#![crate_type = "dylib"]
+#![crate_type = "rlib"]
+#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
+      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
+      html_root_url = "http://doc.rust-lang.org/")]
+
+#![feature(globs)]
+#![feature(phase)]
+#![allow(unused_attribute)] // NOTE: remove after stage0
+
+#[phase(plugin, link)]
+extern crate log;
+extern crate syntax;
+extern crate libc;
+extern crate flate;
+
+pub mod abi;
+pub mod arm;
+pub mod mips;
+pub mod mipsel;
+pub mod svh;
+pub mod target_strs;
+pub mod x86;
+pub mod x86_64;
diff --git a/src/librustc_back/mips.rs b/src/librustc_back/mips.rs
new file mode 100644 (file)
index 0000000..4176d0e
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright 2012 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 target_strs;
+use syntax::abi;
+
+pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
+    return target_strs::t {
+        module_asm: "".to_string(),
+
+        data_layout: match target_os {
+          abi::OsMacos => {
+            "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".to_string()
+          }
+
+          abi::OsiOS => {
+            "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".to_string()
+          }
+
+          abi::OsWin32 => {
+            "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".to_string()
+          }
+
+          abi::OsLinux => {
+            "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".to_string()
+          }
+
+          abi::OsAndroid => {
+            "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".to_string()
+          }
+
+          abi::OsFreebsd => {
+            "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".to_string()
+          }
+        },
+
+        target_triple: target_triple,
+
+        cc_args: Vec::new(),
+    };
+}
diff --git a/src/librustc_back/mipsel.rs b/src/librustc_back/mipsel.rs
new file mode 100644 (file)
index 0000000..d3ea9d3
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright 2012 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 target_strs;
+use syntax::abi;
+
+pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
+    return target_strs::t {
+        module_asm: "".to_string(),
+
+        data_layout: match target_os {
+          abi::OsMacos => {
+            "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".to_string()
+          }
+
+          abi::OsiOS => {
+            "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".to_string()
+          }
+
+          abi::OsWin32 => {
+            "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".to_string()
+          }
+
+          abi::OsLinux => {
+            "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".to_string()
+          }
+
+          abi::OsAndroid => {
+            "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".to_string()
+          }
+
+          abi::OsFreebsd => {
+            "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".to_string()
+          }
+        },
+
+        target_triple: target_triple,
+
+        cc_args: Vec::new(),
+    };
+}
diff --git a/src/librustc_back/svh.rs b/src/librustc_back/svh.rs
new file mode 100644 (file)
index 0000000..66bc8c7
--- /dev/null
@@ -0,0 +1,512 @@
+// Copyright 2012-2014 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.
+
+//! Calculation and management of a Strict Version Hash for crates
+//!
+//! # Today's ABI problem
+//!
+//! In today's implementation of rustc, it is incredibly difficult to achieve
+//! forward binary compatibility without resorting to C-like interfaces. Within
+//! rust code itself, abi details such as symbol names suffer from a variety of
+//! unrelated factors to code changing such as the "def id drift" problem. This
+//! ends up yielding confusing error messages about metadata mismatches and
+//! such.
+//!
+//! The core of this problem is when an upstream dependency changes and
+//! downstream dependents are not recompiled. This causes compile errors because
+//! the upstream crate's metadata has changed but the downstream crates are
+//! still referencing the older crate's metadata.
+//!
+//! This problem exists for many reasons, the primary of which is that rust does
+//! not currently support forwards ABI compatibility (in place upgrades of a
+//! crate).
+//!
+//! # SVH and how it alleviates the problem
+//!
+//! With all of this knowledge on hand, this module contains the implementation
+//! of a notion of a "Strict Version Hash" for a crate. This is essentially a
+//! hash of all contents of a crate which can somehow be exposed to downstream
+//! crates.
+//!
+//! This hash is currently calculated by just hashing the AST, but this is
+//! obviously wrong (doc changes should not result in an incompatible ABI).
+//! Implementation-wise, this is required at this moment in time.
+//!
+//! By encoding this strict version hash into all crate's metadata, stale crates
+//! can be detected immediately and error'd about by rustc itself.
+//!
+//! # Relevant links
+//!
+//! Original issue: https://github.com/rust-lang/rust/issues/10207
+
+use std::fmt;
+use std::hash::Hash;
+use std::hash::sip::SipState;
+use std::iter::range_step;
+use syntax::ast;
+use syntax::visit;
+
+#[deriving(Clone, PartialEq)]
+pub struct Svh {
+    hash: String,
+}
+
+impl Svh {
+    pub fn new(hash: &str) -> Svh {
+        assert!(hash.len() == 16);
+        Svh { hash: hash.to_string() }
+    }
+
+    pub fn as_str<'a>(&'a self) -> &'a str {
+        self.hash.as_slice()
+    }
+
+    pub fn calculate(metadata: &Vec<String>, krate: &ast::Crate) -> Svh {
+        // FIXME (#14132): This is better than it used to be, but it still not
+        // ideal. We now attempt to hash only the relevant portions of the
+        // Crate AST as well as the top-level crate attributes. (However,
+        // the hashing of the crate attributes should be double-checked
+        // to ensure it is not incorporating implementation artifacts into
+        // the hash that are not otherwise visible.)
+
+        // FIXME: this should use SHA1, not SipHash. SipHash is not built to
+        //        avoid collisions.
+        let mut state = SipState::new();
+
+        for data in metadata.iter() {
+            data.hash(&mut state);
+        }
+
+        {
+            let mut visit = svh_visitor::make(&mut state);
+            visit::walk_crate(&mut visit, krate, ());
+        }
+
+        // FIXME (#14132): This hash is still sensitive to e.g. the
+        // spans of the crate Attributes and their underlying
+        // MetaItems; we should make ContentHashable impl for those
+        // types and then use hash_content.  But, since all crate
+        // attributes should appear near beginning of the file, it is
+        // not such a big deal to be sensitive to their spans for now.
+        //
+        // We hash only the MetaItems instead of the entire Attribute
+        // to avoid hashing the AttrId
+        for attr in krate.attrs.iter() {
+            attr.node.value.hash(&mut state);
+        }
+
+        let hash = state.result();
+        return Svh {
+            hash: range_step(0u, 64u, 4u).map(|i| hex(hash >> i)).collect()
+        };
+
+        fn hex(b: u64) -> char {
+            let b = (b & 0xf) as u8;
+            let b = match b {
+                0 .. 9 => '0' as u8 + b,
+                _ => 'a' as u8 + b - 10,
+            };
+            b as char
+        }
+    }
+}
+
+impl fmt::Show for Svh {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.pad(self.as_str())
+    }
+}
+
+// FIXME (#14132): Even this SVH computation still has implementation
+// artifacts: namely, the order of item declaration will affect the
+// hash computation, but for many kinds of items the order of
+// declaration should be irrelevant to the ABI.
+
+mod svh_visitor {
+    use syntax::ast;
+    use syntax::ast::*;
+    use syntax::codemap::Span;
+    use syntax::parse::token;
+    use syntax::print::pprust;
+    use syntax::visit;
+    use syntax::visit::{Visitor, FnKind};
+
+    use std::hash::Hash;
+    use std::hash::sip::SipState;
+
+    pub struct StrictVersionHashVisitor<'a> {
+        pub st: &'a mut SipState,
+    }
+
+    pub fn make<'a>(st: &'a mut SipState) -> StrictVersionHashVisitor<'a> {
+        StrictVersionHashVisitor { st: st }
+    }
+
+    // To off-load the bulk of the hash-computation on deriving(Hash),
+    // we define a set of enums corresponding to the content that our
+    // crate visitor will encounter as it traverses the ast.
+    //
+    // The important invariant is that all of the Saw*Component enums
+    // do not carry any Spans, Names, or Idents.
+    //
+    // Not carrying any Names/Idents is the important fix for problem
+    // noted on PR #13948: using the ident.name as the basis for a
+    // hash leads to unstable SVH, because ident.name is just an index
+    // into intern table (i.e. essentially a random address), not
+    // computed from the name content.
+    //
+    // With the below enums, the SVH computation is not sensitive to
+    // artifacts of how rustc was invoked nor of how the source code
+    // was laid out.  (Or at least it is *less* sensitive.)
+
+    // This enum represents the different potential bits of code the
+    // visitor could encounter that could affect the ABI for the crate,
+    // and assigns each a distinct tag to feed into the hash computation.
+    #[deriving(Hash)]
+    enum SawAbiComponent<'a> {
+
+        // FIXME (#14132): should we include (some function of)
+        // ident.ctxt as well?
+        SawIdent(token::InternedString),
+        SawStructDef(token::InternedString),
+
+        SawLifetimeRef(token::InternedString),
+        SawLifetimeDecl(token::InternedString),
+
+        SawMod,
+        SawViewItem,
+        SawForeignItem,
+        SawItem,
+        SawDecl,
+        SawTy,
+        SawGenerics,
+        SawFn,
+        SawTyMethod,
+        SawTraitMethod,
+        SawStructField,
+        SawVariant,
+        SawExplicitSelf,
+        SawPath,
+        SawOptLifetimeRef,
+        SawBlock,
+        SawPat,
+        SawLocal,
+        SawArm,
+        SawExpr(SawExprComponent<'a>),
+        SawStmt(SawStmtComponent),
+    }
+
+    /// SawExprComponent carries all of the information that we want
+    /// to include in the hash that *won't* be covered by the
+    /// subsequent recursive traversal of the expression's
+    /// substructure by the visitor.
+    ///
+    /// We know every Expr_ variant is covered by a variant because
+    /// `fn saw_expr` maps each to some case below.  Ensuring that
+    /// each variant carries an appropriate payload has to be verified
+    /// by hand.
+    ///
+    /// (However, getting that *exactly* right is not so important
+    /// because the SVH is just a developer convenience; there is no
+    /// guarantee of collision-freedom, hash collisions are just
+    /// (hopefully) unlikely.)
+    #[deriving(Hash)]
+    pub enum SawExprComponent<'a> {
+
+        SawExprLoop(Option<token::InternedString>),
+        SawExprField(token::InternedString),
+        SawExprBreak(Option<token::InternedString>),
+        SawExprAgain(Option<token::InternedString>),
+
+        SawExprVstore,
+        SawExprBox,
+        SawExprVec,
+        SawExprCall,
+        SawExprMethodCall,
+        SawExprTup,
+        SawExprBinary(ast::BinOp),
+        SawExprUnary(ast::UnOp),
+        SawExprLit(ast::Lit_),
+        SawExprCast,
+        SawExprIf,
+        SawExprWhile,
+        SawExprMatch,
+        SawExprFnBlock,
+        SawExprProc,
+        SawExprBlock,
+        SawExprAssign,
+        SawExprAssignOp(ast::BinOp),
+        SawExprIndex,
+        SawExprPath,
+        SawExprAddrOf(ast::Mutability),
+        SawExprRet,
+        SawExprInlineAsm(&'a ast::InlineAsm),
+        SawExprStruct,
+        SawExprRepeat,
+        SawExprParen,
+    }
+
+    fn saw_expr<'a>(node: &'a Expr_) -> SawExprComponent<'a> {
+        match *node {
+            ExprVstore(..)           => SawExprVstore,
+            ExprBox(..)              => SawExprBox,
+            ExprVec(..)              => SawExprVec,
+            ExprCall(..)             => SawExprCall,
+            ExprMethodCall(..)       => SawExprMethodCall,
+            ExprTup(..)              => SawExprTup,
+            ExprBinary(op, _, _)     => SawExprBinary(op),
+            ExprUnary(op, _)         => SawExprUnary(op),
+            ExprLit(lit)             => SawExprLit(lit.node.clone()),
+            ExprCast(..)             => SawExprCast,
+            ExprIf(..)               => SawExprIf,
+            ExprWhile(..)            => SawExprWhile,
+            ExprLoop(_, id)          => SawExprLoop(id.map(content)),
+            ExprMatch(..)            => SawExprMatch,
+            ExprFnBlock(..)          => SawExprFnBlock,
+            ExprProc(..)             => SawExprProc,
+            ExprBlock(..)            => SawExprBlock,
+            ExprAssign(..)           => SawExprAssign,
+            ExprAssignOp(op, _, _)   => SawExprAssignOp(op),
+            ExprField(_, id, _)      => SawExprField(content(id.node)),
+            ExprIndex(..)            => SawExprIndex,
+            ExprPath(..)             => SawExprPath,
+            ExprAddrOf(m, _)         => SawExprAddrOf(m),
+            ExprBreak(id)            => SawExprBreak(id.map(content)),
+            ExprAgain(id)            => SawExprAgain(id.map(content)),
+            ExprRet(..)              => SawExprRet,
+            ExprInlineAsm(ref asm)   => SawExprInlineAsm(asm),
+            ExprStruct(..)           => SawExprStruct,
+            ExprRepeat(..)           => SawExprRepeat,
+            ExprParen(..)            => SawExprParen,
+
+            // just syntactic artifacts, expanded away by time of SVH.
+            ExprForLoop(..)          => unreachable!(),
+            ExprMac(..)              => unreachable!(),
+        }
+    }
+
+    /// SawStmtComponent is analogous to SawExprComponent, but for statements.
+    #[deriving(Hash)]
+    pub enum SawStmtComponent {
+        SawStmtDecl,
+        SawStmtExpr,
+        SawStmtSemi,
+    }
+
+    fn saw_stmt(node: &Stmt_) -> SawStmtComponent {
+        match *node {
+            StmtDecl(..) => SawStmtDecl,
+            StmtExpr(..) => SawStmtExpr,
+            StmtSemi(..) => SawStmtSemi,
+            StmtMac(..)  => unreachable!(),
+        }
+    }
+
+    // Ad-hoc overloading between Ident and Name to their intern table lookups.
+    trait InternKey { fn get_content(self) -> token::InternedString; }
+    impl InternKey for Ident {
+        fn get_content(self) -> token::InternedString { token::get_ident(self) }
+    }
+    impl InternKey for Name {
+        fn get_content(self) -> token::InternedString { token::get_name(self) }
+    }
+    fn content<K:InternKey>(k: K) -> token::InternedString { k.get_content() }
+
+    // local short-hand eases writing signatures of syntax::visit mod.
+    type E = ();
+
+    impl<'a> Visitor<E> for StrictVersionHashVisitor<'a> {
+
+        fn visit_mac(&mut self, macro: &Mac, e: E) {
+            // macro invocations, namely macro_rules definitions,
+            // *can* appear as items, even in the expanded crate AST.
+
+            if macro_name(macro).get() == "macro_rules" {
+                // Pretty-printing definition to a string strips out
+                // surface artifacts (currently), such as the span
+                // information, yielding a content-based hash.
+
+                // FIXME (#14132): building temporary string is
+                // expensive; a direct content-based hash on token
+                // trees might be faster. Implementing this is far
+                // easier in short term.
+                let macro_defn_as_string =
+                    pprust::to_string(|pp_state| pp_state.print_mac(macro));
+                macro_defn_as_string.hash(self.st);
+            } else {
+                // It is not possible to observe any kind of macro
+                // invocation at this stage except `macro_rules!`.
+                fail!("reached macro somehow: {}",
+                      pprust::to_string(|pp_state| pp_state.print_mac(macro)));
+            }
+
+            visit::walk_mac(self, macro, e);
+
+            fn macro_name(macro: &Mac) -> token::InternedString {
+                match &macro.node {
+                    &MacInvocTT(ref path, ref _tts, ref _stx_ctxt) => {
+                        let s = path.segments.as_slice();
+                        assert_eq!(s.len(), 1);
+                        content(s[0].identifier)
+                    }
+                }
+            }
+        }
+
+        fn visit_struct_def(&mut self, s: &StructDef, ident: Ident,
+                            g: &Generics, _: NodeId, e: E) {
+            SawStructDef(content(ident)).hash(self.st);
+            visit::walk_generics(self, g, e.clone());
+            visit::walk_struct_def(self, s, e)
+        }
+
+        fn visit_variant(&mut self, v: &Variant, g: &Generics, e: E) {
+            SawVariant.hash(self.st);
+            // walk_variant does not call walk_generics, so do it here.
+            visit::walk_generics(self, g, e.clone());
+            visit::walk_variant(self, v, g, e)
+        }
+
+        fn visit_opt_lifetime_ref(&mut self, _: Span, l: &Option<Lifetime>, env: E) {
+            SawOptLifetimeRef.hash(self.st);
+            // (This is a strange method in the visitor trait, in that
+            // it does not expose a walk function to do the subroutine
+            // calls.)
+            match *l {
+                Some(ref l) => self.visit_lifetime_ref(l, env),
+                None => ()
+            }
+        }
+
+        // All of the remaining methods just record (in the hash
+        // SipState) that the visitor saw that particular variant
+        // (with its payload), and continue walking as the default
+        // visitor would.
+        //
+        // Some of the implementations have some notes as to how one
+        // might try to make their SVH computation less discerning
+        // (e.g. by incorporating reachability analysis).  But
+        // currently all of their implementations are uniform and
+        // uninteresting.
+        //
+        // (If you edit a method such that it deviates from the
+        // pattern, please move that method up above this comment.)
+
+        fn visit_ident(&mut self, _: Span, ident: Ident, _: E) {
+            SawIdent(content(ident)).hash(self.st);
+        }
+
+        fn visit_lifetime_ref(&mut self, l: &Lifetime, _: E) {
+            SawLifetimeRef(content(l.name)).hash(self.st);
+        }
+
+        fn visit_lifetime_decl(&mut self, l: &Lifetime, _: E) {
+            SawLifetimeDecl(content(l.name)).hash(self.st);
+        }
+
+        // We do recursively walk the bodies of functions/methods
+        // (rather than omitting their bodies from the hash) since
+        // monomorphization and cross-crate inlining generally implies
+        // that a change to a crate body will require downstream
+        // crates to be recompiled.
+        fn visit_expr(&mut self, ex: &Expr, e: E) {
+            SawExpr(saw_expr(&ex.node)).hash(self.st); visit::walk_expr(self, ex, e)
+        }
+
+        fn visit_stmt(&mut self, s: &Stmt, e: E) {
+            SawStmt(saw_stmt(&s.node)).hash(self.st); visit::walk_stmt(self, s, e)
+        }
+
+        fn visit_view_item(&mut self, i: &ViewItem, e: E) {
+            // Two kinds of view items can affect the ABI for a crate:
+            // exported `pub use` view items (since that may expose
+            // items that downstream crates can call), and `use
+            // foo::Trait`, since changing that may affect method
+            // resolution.
+            //
+            // The simplest approach to handling both of the above is
+            // just to adopt the same simple-minded (fine-grained)
+            // hash that I am deploying elsewhere here.
+            SawViewItem.hash(self.st); visit::walk_view_item(self, i, e)
+        }
+
+        fn visit_foreign_item(&mut self, i: &ForeignItem, e: E) {
+            // FIXME (#14132) ideally we would incorporate privacy (or
+            // perhaps reachability) somewhere here, so foreign items
+            // that do not leak into downstream crates would not be
+            // part of the ABI.
+            SawForeignItem.hash(self.st); visit::walk_foreign_item(self, i, e)
+        }
+
+        fn visit_item(&mut self, i: &Item, e: E) {
+            // FIXME (#14132) ideally would incorporate reachability
+            // analysis somewhere here, so items that never leak into
+            // downstream crates (e.g. via monomorphisation or
+            // inlining) would not be part of the ABI.
+            SawItem.hash(self.st); visit::walk_item(self, i, e)
+        }
+
+        fn visit_mod(&mut self, m: &Mod, _s: Span, _n: NodeId, e: E) {
+            SawMod.hash(self.st); visit::walk_mod(self, m, e)
+        }
+
+        fn visit_decl(&mut self, d: &Decl, e: E) {
+            SawDecl.hash(self.st); visit::walk_decl(self, d, e)
+        }
+
+        fn visit_ty(&mut self, t: &Ty, e: E) {
+            SawTy.hash(self.st); visit::walk_ty(self, t, e)
+        }
+
+        fn visit_generics(&mut self, g: &Generics, e: E) {
+            SawGenerics.hash(self.st); visit::walk_generics(self, g, e)
+        }
+
+        fn visit_fn(&mut self, fk: &FnKind, fd: &FnDecl, b: &Block, s: Span, _: NodeId, e: E) {
+            SawFn.hash(self.st); visit::walk_fn(self, fk, fd, b, s, e)
+        }
+
+        fn visit_ty_method(&mut self, t: &TypeMethod, e: E) {
+            SawTyMethod.hash(self.st); visit::walk_ty_method(self, t, e)
+        }
+
+        fn visit_trait_method(&mut self, t: &TraitMethod, e: E) {
+            SawTraitMethod.hash(self.st); visit::walk_trait_method(self, t, e)
+        }
+
+        fn visit_struct_field(&mut self, s: &StructField, e: E) {
+            SawStructField.hash(self.st); visit::walk_struct_field(self, s, e)
+        }
+
+        fn visit_explicit_self(&mut self, es: &ExplicitSelf, e: E) {
+            SawExplicitSelf.hash(self.st); visit::walk_explicit_self(self, es, e)
+        }
+
+        fn visit_path(&mut self, path: &Path, _: ast::NodeId, e: E) {
+            SawPath.hash(self.st); visit::walk_path(self, path, e)
+        }
+
+        fn visit_block(&mut self, b: &Block, e: E) {
+            SawBlock.hash(self.st); visit::walk_block(self, b, e)
+        }
+
+        fn visit_pat(&mut self, p: &Pat, e: E) {
+            SawPat.hash(self.st); visit::walk_pat(self, p, e)
+        }
+
+        fn visit_local(&mut self, l: &Local, e: E) {
+            SawLocal.hash(self.st); visit::walk_local(self, l, e)
+        }
+
+        fn visit_arm(&mut self, a: &Arm, e: E) {
+            SawArm.hash(self.st); visit::walk_arm(self, a, e)
+        }
+    }
+}
diff --git a/src/librustc_back/target_strs.rs b/src/librustc_back/target_strs.rs
new file mode 100644 (file)
index 0000000..7928f3d
--- /dev/null
@@ -0,0 +1,18 @@
+// Copyright 2012 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.
+
+#![allow(non_camel_case_types)]
+
+pub struct t {
+    pub module_asm: String,
+    pub data_layout: String,
+    pub target_triple: String,
+    pub cc_args: Vec<String> ,
+}
diff --git a/src/librustc_back/x86.rs b/src/librustc_back/x86.rs
new file mode 100644 (file)
index 0000000..b4d67bc
--- /dev/null
@@ -0,0 +1,57 @@
+// Copyright 2012 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 target_strs;
+use syntax::abi;
+
+pub fn get_target_strs(target_triple: String, target_os: abi::Os)
+                       -> target_strs::t {
+    return target_strs::t {
+        module_asm: "".to_string(),
+
+        data_layout: match target_os {
+          abi::OsMacos => {
+            "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
+                -i32:32:32-i64:32:64\
+                -f32:32:32-f64:32:64-v64:64:64\
+                -v128:128:128-a0:0:64-f80:128:128\
+                -n8:16:32".to_string()
+          }
+
+          abi::OsiOS => {
+            "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16\
+                -i32:32:32-i64:32:64\
+                -f32:32:32-f64:32:64-v64:64:64\
+                -v128:128:128-a0:0:64-f80:128:128\
+                -n8:16:32".to_string()
+          }
+
+          abi::OsWin32 => {
+            "e-p:32:32-f64:64:64-i64:64:64-f80:32:32-n8:16:32".to_string()
+          }
+
+          abi::OsLinux => {
+            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
+          }
+          abi::OsAndroid => {
+            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
+          }
+
+          abi::OsFreebsd => {
+            "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32".to_string()
+          }
+        },
+
+        target_triple: target_triple,
+
+        cc_args: vec!("-m32".to_string()),
+    };
+}
diff --git a/src/librustc_back/x86_64.rs b/src/librustc_back/x86_64.rs
new file mode 100644 (file)
index 0000000..70807ed
--- /dev/null
@@ -0,0 +1,61 @@
+// Copyright 2012 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 target_strs;
+use syntax::abi;
+
+pub fn get_target_strs(target_triple: String, target_os: abi::Os) -> target_strs::t {
+    return target_strs::t {
+        module_asm: "".to_string(),
+
+        data_layout: match target_os {
+          abi::OsMacos => {
+            "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".to_string()
+          }
+
+          abi::OsiOS => {
+            "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".to_string()
+          }
+
+          abi::OsWin32 => {
+            // FIXME: Test this. Copied from linux (#2398)
+            "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".to_string()
+          }
+
+          abi::OsLinux => {
+            "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".to_string()
+          }
+          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-\
+                s0:64:64-f80:128:128-n8:16:32:64-S128".to_string()
+          }
+
+          abi::OsFreebsd => {
+            "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".to_string()
+          }
+        },
+
+        target_triple: target_triple,
+
+        cc_args: vec!("-m64".to_string()),
+    };
+}