Skip to content

Commit

Permalink
Don't emit metadata unless compiling -shared.
Browse files Browse the repository at this point in the history
  • Loading branch information
graydon committed Apr 29, 2011
1 parent c39a95d commit 7b95b5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/comp/middle/metadata.rs
Expand Up @@ -235,9 +235,9 @@ mod Encode {
}


// Returns a Plain Old LLVM String, *without* the trailing zero byte.
// Returns a Plain Old LLVM String.
fn C_postr(str s) -> ValueRef {
ret llvm.LLVMConstString(_str.buf(s), _str.byte_len(s) - 1u, False);
ret llvm.LLVMConstString(_str.buf(s), _str.byte_len(s), False);
}


Expand Down Expand Up @@ -674,8 +674,11 @@ fn encode_metadata(@trans.crate_ctxt cx, @ast.crate crate)
ret C_postr(string_w.get_str());
}

fn write_metadata(@trans.crate_ctxt cx, @ast.crate crate) {
auto llmeta = encode_metadata(cx, crate);
fn write_metadata(@trans.crate_ctxt cx, bool shared, @ast.crate crate) {
auto llmeta = C_postr("");
if (shared) {
llmeta = encode_metadata(cx, crate);
}

auto llconst = trans.C_struct(vec(llmeta));
auto llglobal = llvm.LLVMAddGlobal(cx.llmod, trans.val_ty(llconst),
Expand Down
2 changes: 1 addition & 1 deletion src/comp/middle/trans.rs
Expand Up @@ -7747,7 +7747,7 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx,
}

// Translate the metadata.
middle.metadata.write_metadata(cx.ccx, crate);
middle.metadata.write_metadata(cx.ccx, shared, crate);

run_passes(llmod, optimize, verify, save_temps, output, ot);
}
Expand Down

0 comments on commit 7b95b5c

Please sign in to comment.