Skip to content

Commit

Permalink
Merge pull request #11900 from JuliaLang/kf/forceelf
Browse files Browse the repository at this point in the history
Reset module triple and data layout before emitting an object file
  • Loading branch information
Keno committed Jun 28, 2015
2 parents a430892 + 4f642da commit 9579c1e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,9 +480,9 @@ void jl_dump_objfile(char *fname, int jit_model, const char *sysimg_data, size_t

PassManager PM;
#ifndef LLVM37
PM.add(new TargetLibraryInfo(Triple(jl_TargetMachine->getTargetTriple())));
PM.add(new TargetLibraryInfo(Triple(TM->getTargetTriple())));
#else
PM.add(new TargetLibraryInfoWrapperPass(Triple(jl_TargetMachine->getTargetTriple())));
PM.add(new TargetLibraryInfoWrapperPass(Triple(TM->getTargetTriple())));
#endif
#ifdef LLVM37
// No DataLayout pass needed anymore.
Expand Down Expand Up @@ -510,6 +510,11 @@ void jl_dump_objfile(char *fname, int jit_model, const char *sysimg_data, size_t
if (sysimg_data)
jl_sysimg_to_llvm(shadow_module, globalvars, sysimg_data, sysimg_len);
jl_gen_llvm_gv_array(shadow_module, globalvars);
// Reset the target triple to make sure it matches the new target machine
#ifdef LLVM37
shadow_module->setTargetTriple(TM->getTargetTriple().str());
shadow_module->setDataLayout(TM->getDataLayout()->getStringRepresentation());
#endif
PM.run(*shadow_module);
#else
if (sysimg_data)
Expand Down

0 comments on commit 9579c1e

Please sign in to comment.