diff options
| author | comex <comexk@gmail.com> | 2014-01-28 00:05:33 -0500 |
|---|---|---|
| committer | comex <comexk@gmail.com> | 2014-01-28 00:05:33 -0500 |
| commit | ea7b20d8f279ea8c63b9a4b8e9129fce0e3c2b5d (patch) | |
| tree | 4da18db71394fcd2a3e2092e8f8282594083e429 /src/librustc/middle/trans | |
| parent | 760ddb3081acb038ff3c6bcc918bfa293dfc5acd (diff) | |
| download | rust-ea7b20d8f279ea8c63b9a4b8e9129fce0e3c2b5d.tar.gz rust-ea7b20d8f279ea8c63b9a4b8e9129fce0e3c2b5d.zip | |
Add appropriate LLVM module flags for debug info.
Set "Dwarf Version" to 2 on OS X to avoid toolchain incompatibility, and set "Debug Info Version" to prevent debug info from being stripped from bitcode. Fixes #11352.
Diffstat (limited to 'src/librustc/middle/trans')
| -rw-r--r-- | src/librustc/middle/trans/debuginfo.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index c4fdc895670..42f069e2705 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -149,7 +149,7 @@ use std::ptr; use std::sync::atomics; use std::vec; use syntax::codemap::{Span, Pos}; -use syntax::{ast, codemap, ast_util, ast_map, opt_vec}; +use syntax::{abi, ast, codemap, ast_util, ast_map, opt_vec}; use syntax::parse::token; use syntax::parse::token::special_idents; @@ -263,6 +263,20 @@ pub fn finalize(cx: @CrateContext) { unsafe { llvm::LLVMDIBuilderFinalize(DIB(cx)); llvm::LLVMDIBuilderDispose(DIB(cx)); + // Debuginfo generation in LLVM by default uses a higher + // version of dwarf than OS X currently understands. We can + // instruct LLVM to emit an older version of dwarf, however, + // for OS X to understand. For more info see #11352 + // This can be overridden using --llvm-opts -dwarf-version,N. + if cx.sess.targ_cfg.os == abi::OsMacos { + "Dwarf Version".with_c_str( + |s| llvm::LLVMRustAddModuleFlag(cx.llmod, s, 2)); + } + + // Prevent bitcode readers from deleting the debug info. + "Debug Info Version".with_c_str( + |s| llvm::LLVMRustAddModuleFlag(cx.llmod, s, + llvm::LLVMRustDebugMetadataVersion)); }; } |
