diff options
| author | Rafael Ávila de Espíndola <[email protected]> | 2011-04-18 10:02:34 -0400 |
|---|---|---|
| committer | Rafael Ávila de Espíndola <[email protected]> | 2011-04-18 10:02:52 -0400 |
| commit | f12998e5d7a4409d2bf748a671c345a79085213e (patch) | |
| tree | e8ae174f5e6bf1c8c7c87b18d807684d1b126358 /src/comp | |
| parent | Make log the log level configurable per module (diff) | |
| download | rust-f12998e5d7a4409d2bf748a671c345a79085213e.tar.xz rust-f12998e5d7a4409d2bf748a671c345a79085213e.zip | |
Add a -c option.
Diffstat (limited to 'src/comp')
| -rw-r--r-- | src/comp/driver/rustc.rs | 2 | ||||
| -rw-r--r-- | src/comp/lib/llvm.rs | 6 | ||||
| -rw-r--r-- | src/comp/middle/trans.rs | 30 |
3 files changed, 32 insertions, 6 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index afa2a9bb..db069279 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -168,6 +168,8 @@ impure fn main(vec[str] args) { ot = trans.output_type_none; } else if (_str.eq(arg, "-S")) { ot = trans.output_type_assembly; + } else if (_str.eq(arg, "-c")) { + ot = trans.output_type_object; } else if (_str.eq(arg, "-o")) { if (i+1u < len) { output_file = some(args.(i+1u)); diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 8d0910d5..3c40a583 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -815,8 +815,10 @@ native mod llvm = llvm_lib { fn LLVMRustCreateMemoryBufferWithContentsOfFile(sbuf Path) -> MemoryBufferRef; - fn LLVMRustWriteAssembly(PassManagerRef PM, ModuleRef M, - sbuf Triple, sbuf Output); + /* FIXME: The FileType is an enum.*/ + fn LLVMRustWriteOutputFile(PassManagerRef PM, ModuleRef M, + sbuf Triple, sbuf Output, + int FileType); /** Returns a string describing the last error caused by an LLVMRust* call. */ diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index ac2ceff5..db27a823 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -6754,6 +6754,17 @@ tag output_type { output_type_none; output_type_bitcode; output_type_assembly; + output_type_object; +} + +fn is_object_or_assembly(output_type ot) -> bool { + if (ot == output_type_assembly) { + ret true; + } + if (ot == output_type_object) { + ret true; + } + ret false; } fn run_passes(ModuleRef llmod, bool opt, str output, @@ -6823,10 +6834,21 @@ fn run_passes(ModuleRef llmod, bool opt, str output, } llvm.LLVMAddVerifierPass(pm.llpm); - if (ot == output_type_assembly) { - llvm.LLVMRustWriteAssembly(pm.llpm, llmod, - _str.buf(x86.get_target_triple()), - _str.buf(output)); + if (is_object_or_assembly(ot)) { + let int LLVMAssemblyFile = 0; + let int LLVMObjectFile = 1; + let int LLVMNullFile = 2; + auto FileType; + if (ot == output_type_object) { + FileType = LLVMObjectFile; + } else { + FileType = LLVMAssemblyFile; + } + + llvm.LLVMRustWriteOutputFile(pm.llpm, llmod, + _str.buf(x86.get_target_triple()), + _str.buf(output), + FileType); ret; } |