1- #!/usr/bin/env python
1+ #!/usr/bin/env python2
22
33'''
44emcc - compiler helper script
@@ -322,11 +322,6 @@ Options that are modified or new in %s include:
322322 -v to Clang, and also enable EMCC_DEBUG
323323 to details emcc's operations
324324
325- --remove-duplicates If set, will remove duplicate symbols when
326- linking. This can be useful because
327- llvm-link's behavior is not as permissive
328- as ld is.
329-
330325 --jcache Use a JavaScript cache. This is disabled by
331326 default. When enabled, emcc will store the
332327 results of compilation in a cache and check
596591 ignore_dynamic_linking = False
597592 shell_path = shared .path_from_root ('src' , 'shell.html' )
598593 js_libraries = []
599- remove_duplicates = False
600594 keep_debug = False
601595 bind = False
602596 jcache = False
705699 newargs [i ] = ''
706700 newargs [i + 1 ] = ''
707701 elif newargs [i ] == '--remove-duplicates' :
708- remove_duplicates = True
702+ print >> sys . stderr , 'emcc: warning: --remove-duplicates is deprecated as it is no longer needed. If you cannot link without it, file a bug with a testcase'
709703 newargs [i ] = ''
710704 elif newargs [i ] == '--jcache' :
711705 jcache = True
924918 # We have a specified target (-o <target>), which is not JavaScript or HTML, and
925919 # we have multiple files: Link them
926920 if DEBUG : print >> sys .stderr , 'emcc: link: ' + str (temp_files ), specified_target
927- shared .Building .link (temp_files , specified_target , remove_duplicates = remove_duplicates )
921+ shared .Building .link (temp_files , specified_target )
928922 exit (0 )
929923
930924 ## Continue on to create JavaScript
943937 # dlmalloc
944938 def create_dlmalloc ():
945939 if DEBUG : print >> sys .stderr , 'emcc: building dlmalloc for cache'
946- execute (shared .ENV_PREFIX + [ 'python' , shared .EMCC , shared .path_from_root ('system' , 'lib' , 'dlmalloc.c' ), '-g' , '-o' , in_temp ('dlmalloc.o' )], stdout = stdout , stderr = stderr )
940+ execute ([ shared .PYTHON , shared .EMCC , shared .path_from_root ('system' , 'lib' , 'dlmalloc.c' ), '-g' , '-o' , in_temp ('dlmalloc.o' )], stdout = stdout , stderr = stderr )
947941 # we include the libc++ new stuff here, so that the common case of using just new/delete is quick to link
948- execute (shared .ENV_PREFIX + [ 'python' , shared .EMXX , shared .path_from_root ('system' , 'lib' , 'libcxx' , 'new.cpp' ), '-g' , '-o' , in_temp ('new.o' )], stdout = stdout , stderr = stderr )
942+ execute ([ shared .PYTHON , shared .EMXX , shared .path_from_root ('system' , 'lib' , 'libcxx' , 'new.cpp' ), '-g' , '-o' , in_temp ('new.o' )], stdout = stdout , stderr = stderr )
949943 shared .Building .link ([in_temp ('dlmalloc.o' ), in_temp ('new.o' )], in_temp ('dlmalloc_full.o' ))
950944 return in_temp ('dlmalloc_full.o' )
951945 def fix_dlmalloc ():
968962 os = []
969963 for src in ['algorithm.cpp' , 'condition_variable.cpp' , 'future.cpp' , 'iostream.cpp' , 'memory.cpp' , 'random.cpp' , 'stdexcept.cpp' , 'system_error.cpp' , 'utility.cpp' , 'bind.cpp' , 'debug.cpp' , 'hash.cpp' , 'mutex.cpp' , 'string.cpp' , 'thread.cpp' , 'valarray.cpp' , 'chrono.cpp' , 'exception.cpp' , 'ios.cpp' , 'locale.cpp' , 'regex.cpp' , 'strstream.cpp' , 'typeinfo.cpp' ]:
970964 o = in_temp (src + '.o' )
971- execute (shared .ENV_PREFIX + [ 'python' , shared .EMXX , shared .path_from_root ('system' , 'lib' , 'libcxx' , src ), '-o' , o ], stdout = stdout , stderr = stderr )
965+ execute ([ shared .PYTHON , shared .EMXX , shared .path_from_root ('system' , 'lib' , 'libcxx' , src ), '-o' , o ], stdout = stdout , stderr = stderr )
972966 os .append (o )
973967 shared .Building .link (os , in_temp ('libcxx.bc' ))
974968 return in_temp ('libcxx.bc' )
987981 os = []
988982 for src in ['private_typeinfo.cpp' ]:
989983 o = in_temp (src + '.o' )
990- execute (shared .ENV_PREFIX + [ 'python' , shared .EMXX , shared .path_from_root ('system' , 'lib' , 'libcxxabi' , 'src' , src ), '-o' , o ], stdout = stdout , stderr = stderr )
984+ execute ([ shared .PYTHON , shared .EMXX , shared .path_from_root ('system' , 'lib' , 'libcxxabi' , 'src' , src ), '-o' , o ], stdout = stdout , stderr = stderr )
991985 os .append (o )
992986 shared .Building .link (os , in_temp ('libcxxabi.bc' ))
993987 return in_temp ('libcxxabi.bc' )
@@ -1039,7 +1033,7 @@ try:
10391033 (not LEAVE_INPUTS_RAW and not (suffix (temp_files [0 ]) in BITCODE_SUFFIXES or suffix (temp_files [0 ]) in DYNAMICLIB_SUFFIXES ) and shared .Building .is_ar (temp_files [0 ])):
10401034 linker_inputs = temp_files + extra_files_to_link
10411035 if DEBUG : print >> sys .stderr , 'emcc: linking: ' , linker_inputs
1042- shared .Building .link (linker_inputs , in_temp (target_basename + '.bc' ), remove_duplicates = remove_duplicates )
1036+ shared .Building .link (linker_inputs , in_temp (target_basename + '.bc' ))
10431037 final = in_temp (target_basename + '.bc' )
10441038 else :
10451039 if not LEAVE_INPUTS_RAW :
@@ -1073,13 +1067,14 @@ try:
10731067 if DEBUG : save_intermediate ('opt' , 'bc' )
10741068 # Do LTO in a separate pass to work around LLVM bug XXX (see failure e.g. in cubescript)
10751069 if shared .Building .can_build_standalone ():
1070+ # If we can LTO, do it before dce, since it opens up dce opportunities
10761071 if llvm_lto and shared .Building .can_use_unsafe_opts ():
10771072 if not shared .Building .can_inline (): link_opts .append ('-disable-inlining' )
1078- link_opts .append ('-std-link-opts' )
1073+ # do not internalize in std-link-opts - it ignores internalize-public-api-list - and add a manual internalize
1074+ link_opts += ['-disable-internalize' ] + shared .Building .get_safe_internalize () + ['-std-link-opts' ]
10791075 else :
1080- # At least remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
1081- link_opts += ['-internalize' , '-globaldce' ]
1082- if link_opts :
1076+ # At minimum remove dead functions etc., this potentially saves a lot in the size of the generated code (and the time to compile it)
1077+ link_opts += shared .Building .get_safe_internalize () + ['-globaldce' ]
10831078 if DEBUG : print >> sys .stderr , 'emcc: LLVM linktime:' , link_opts
10841079 shared .Building .llvm_opt (in_temp (target_basename + '.bc' ), link_opts )
10851080 if DEBUG : save_intermediate ('linktime' , 'bc' )
@@ -1093,7 +1088,7 @@ try:
10931088
10941089 if AUTODEBUG :
10951090 if DEBUG : print >> sys .stderr , 'emcc: autodebug'
1096- execute (shared .ENV_PREFIX + [ 'python' , shared .AUTODEBUGGER , final , final + '.ad.ll' ])
1091+ execute ([ shared .PYTHON , shared .AUTODEBUGGER , final , final + '.ad.ll' ])
10971092 final += '.ad.ll'
10981093 if DEBUG : save_intermediate ('autodebug' , 'll' )
10991094
@@ -1116,7 +1111,7 @@ try:
11161111 file_args += embed_files
11171112 if Compression .on :
11181113 file_args += ['--compress' , Compression .encoder , Compression .decoder , Compression .js_name ]
1119- code = execute (shared .ENV_PREFIX + [ 'python' , shared .FILE_PACKAGER , unsuffixed (target ) + '.data' ] + file_args , stdout = PIPE )[0 ]
1114+ code = execute ([ shared .PYTHON , shared .FILE_PACKAGER , unsuffixed (target ) + '.data' ] + file_args , stdout = PIPE )[0 ]
11201115 src = open (final ).read ().replace ('// {{PRE_RUN_ADDITIONS}}' , '// {{PRE_RUN_ADDITIONS}}\n ' + code )
11211116 final += '.files.js'
11221117 open (final , 'w' ).write (src )
0 commit comments