diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2013-09-23 14:33:51 +0300 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-09-23 15:20:29 +0300 |
commit | d3e5647bd49d2a4861e10531c76a61febe24e848 (patch) | |
tree | 53068f83ed18ad6d861a287d9ccc14d9c2d7127a | |
parent | 45f8f9c948c5548665438827e3d6b39a40eca06e (diff) |
Make input file parsing in 'emcc' tool stricter. Don't silently fail if a file is missing or is a bitcode file if an archive file was expected, but issue an error and abort. Related to #1648.
-rwxr-xr-x | emcc | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -976,9 +976,13 @@ try: if (os.path.islink(arg) and os.path.realpath(arg).endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES)): arg = os.path.realpath(arg) - if not arg.startswith('-') and (arg.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES) or shared.Building.is_ar(arg)): # we already removed -o <target>, so all these should be inputs - newargs[i] = '' - if os.path.exists(arg): + if not arg.startswith('-'): + if not os.path.exists(arg): + logging.error(arg + ': No such file or directory') + exit(1) + + if arg.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs + newargs[i] = '' if arg.endswith(SOURCE_SUFFIXES): input_files.append(arg) has_source_inputs = True @@ -998,8 +1002,15 @@ try: newargs[i] = '' else: logging.warning(arg + ' is not valid LLVM bitcode') + elif arg.endswith(STATICLIB_SUFFIXES): + if not shared.Building.is_ar(arg): + if shared.Building.is_bitcode(arg): + logging.error(arg + ': File has a suffix of a static library ' + str(STATICLIB_SUFFIXES) + ', but instead is an LLVM bitcode file! When linking LLVM bitcode files, use one of the suffixes ' + str(BITCODE_SUFFIXES)) + else: + logging.error(arg + ': Unknown format, not a static library!') + exit(1) else: - logging.error(arg + ': No such file or directory') + logging.error(arg + ": Input file has an unknown suffix, don't know what to do with it!") exit(1) elif arg.startswith('-L'): lib_dirs.append(arg[2:]) |