@@ -2682,30 +2682,35 @@ static jl_cgval_t convert_julia_type(jl_codectx_t &ctx, const jl_cgval_t &v, jl_
2682
2682
return jl_cgval_t (v, typ, new_tindex);
2683
2683
}
2684
2684
2685
- std::unique_ptr<Module> jl_create_llvm_module (StringRef name, LLVMContext &context, const DataLayout &DL, const Triple &triple) JL_NOTSAFEPOINT
2685
+ std::unique_ptr<Module> jl_create_llvm_module (StringRef name, LLVMContext &context,
2686
+ const DataLayout &DL, const Triple &triple,
2687
+ bool toplevel) JL_NOTSAFEPOINT
2686
2688
{
2687
2689
++ModulesCreated;
2688
2690
auto m = std::make_unique<Module>(name, context);
2689
- // According to clang darwin above 10.10 supports dwarfv4
2690
- if (!m->getModuleFlag (" Dwarf Version" )) {
2691
- m->addModuleFlag (llvm::Module::Warning, " Dwarf Version" , 4 );
2692
- }
2693
- if (!m->getModuleFlag (" Debug Info Version" ))
2694
- m->addModuleFlag (llvm::Module::Warning, " Debug Info Version" ,
2695
- llvm::DEBUG_METADATA_VERSION);
2696
2691
m->setDataLayout (DL);
2697
2692
m->setTargetTriple (triple.str ());
2698
2693
2699
- if (triple.isOSWindows () && triple.getArch () == Triple::x86) {
2700
- // tell Win32 to assume the stack is always 16-byte aligned,
2701
- // and to ensure that it is 16-byte aligned for out-going calls,
2702
- // to ensure compatibility with GCC codes
2703
- m->setOverrideStackAlignment (16 );
2704
- }
2694
+ // when this is a toplevel module, add additional flags.
2695
+ // otherwise, these are inherited from the parent module when linking.
2696
+ if (toplevel) {
2697
+ // According to clang darwin above 10.10 supports dwarfv4
2698
+ m->addModuleFlag (llvm::Module::Warning, " Dwarf Version" , 4 );
2699
+ m->addModuleFlag (llvm::Module::Warning, " Debug Info Version" ,
2700
+ llvm::DEBUG_METADATA_VERSION);
2701
+
2702
+ if (triple.isOSWindows () && triple.getArch () == Triple::x86) {
2703
+ // tell Win32 to assume the stack is always 16-byte aligned,
2704
+ // and to ensure that it is 16-byte aligned for out-going calls,
2705
+ // to ensure compatibility with GCC codes
2706
+ m->setOverrideStackAlignment (16 );
2707
+ }
2705
2708
2706
2709
#if defined(JL_DEBUG_BUILD)
2707
- m->setStackProtectorGuard (" global" );
2710
+ m->setStackProtectorGuard (" global" );
2708
2711
#endif
2712
+ }
2713
+
2709
2714
return m;
2710
2715
}
2711
2716
0 commit comments