@@ -1055,19 +1055,21 @@ try:
10551055 if DEBUG : save_intermediate ('opt' , 'bc' )
10561056 # Do LTO in a separate pass to work around LLVM bug XXX (see failure e.g. in cubescript)
10571057 if shared .Building .can_build_standalone ():
1058+ # If we can LTO, do it before dce, since it opens up dce opportunities
1059+ if llvm_lto and shared .Building .can_use_unsafe_opts ():
1060+ if not shared .Building .can_inline (): link_opts .append ('-disable-inlining' )
1061+ link_opts += ['-std-link-opts' , '-disable-internalize' ]
1062+ if DEBUG : print >> sys .stderr , 'emcc: LLVM linktime:' , link_opts
1063+ shared .Building .llvm_opt (in_temp (target_basename + '.bc' ), link_opts )
1064+ if DEBUG : save_intermediate ('linktime' , 'bc' )
1065+ link_opts = []
10581066 # At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
10591067 exports = ',' .join (map (lambda exp : exp [1 :], shared .Settings .EXPORTED_FUNCTIONS ))
10601068 # internalize carefully, llvm 3.2 will remove even main if not told not to
10611069 link_opts += ['-internalize' , '-internalize-public-api-list=' + exports , '-globaldce' ]
10621070 if DEBUG : print >> sys .stderr , 'emcc: LLVM linktime:' , link_opts
10631071 shared .Building .llvm_opt (in_temp (target_basename + '.bc' ), link_opts )
10641072 if DEBUG : save_intermediate ('dce' , 'bc' )
1065- if llvm_lto and shared .Building .can_use_unsafe_opts ():
1066- if not shared .Building .can_inline (): link_opts .append ('-disable-inlining' )
1067- link_opts = ['-std-link-opts' , '-disable-internalize' ]
1068- if DEBUG : print >> sys .stderr , 'emcc: LLVM linktime:' , link_opts
1069- shared .Building .llvm_opt (in_temp (target_basename + '.bc' ), link_opts )
1070- if DEBUG : save_intermediate ('linktime' , 'bc' )
10711073
10721074 # Prepare .ll for Emscripten
10731075 if not LEAVE_INPUTS_RAW :
0 commit comments