From cb52925fec13dcf92b77f1fe5aea7a2a1926bb83 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Wed, 15 Oct 2008 21:52:00 +0000 Subject: [PATCH] ccc: support -fsyntax-only, add some more darwin options, support logging of actions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57603 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/ccc | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/utils/ccc b/utils/ccc index 2ffdcfc35d..6c92f918dc 100755 --- a/utils/ccc +++ b/utils/ccc @@ -32,6 +32,7 @@ def checkbool(name, default=False): pass return default +CCC_LOG = checkenv('CCC_LOG') CCC_ECHO = checkbool('CCC_ECHO') CCC_NATIVE = checkbool('CCC_NATIVE','1') CCC_FALLBACK = checkbool('CCC_FALLBACK') @@ -99,6 +100,10 @@ def preprocess(args): command = [CLANG,'-E'] run(command + args) +def syntaxonly(args): + command = [CLANG,'-fsyntax-only'] + run(command + args) + def compile_fallback(args): command = [CC,'-c'] run(command + args) @@ -130,12 +135,14 @@ def compile(args, native, save_temps=False): def checked_compile(args, native, language, save_temps): if CCC_LANGUAGES and language and language not in CCC_LANGUAGES: + log('fallback', args) print >>sys.stderr, 'NOTE: ccc: Using fallback compiler for: %s'%(' '.join(map(quote, args)),) compile_fallback(args) elif CCC_FALLBACK: try: compile(args, native, save_temps) except: + log('fallback-on-fail', args) print >>sys.stderr, 'WARNING: ccc: Using fallback compiler for: %s'%(' '.join(map(quote, args)),) compile_fallback(args) else: @@ -180,9 +187,17 @@ def inferlanguage(extension): else: return "" +def log(name, item): + if CCC_LOG: + f = open(CCC_LOG,'a') + print >>f, (name, item) + f.close() + def inferaction(args): if '-E' in args: return 'preprocess' + if '-fsyntax-only' in args: + return 'syntax-only' if '-c' in args: return 'compile' for arg in args: @@ -191,6 +206,8 @@ def inferaction(args): return 'link' def main(args): + log('invoke', args) + action = inferaction(args) output = '' compile_opts = [] @@ -247,7 +264,8 @@ def main(args): i += 1 # Options with no arguments that should pass through - if (arg in ('-dynamiclib', '-bundle', '-headerpad_max_install_names') or + if (arg in ('-dynamiclib', '-bundle', '-headerpad_max_install_names', + '-nostdlib', '-static', '-dynamic', '-r') or arg.startswith('-Wl,')): link_opts.append(arg) @@ -336,6 +354,17 @@ def main(args): # Discard the explicit language after used once language = '' + if action == 'syntax-only': + for i, file in enumerate(files): + if not language: + language = inferlanguage(extension(file)) + args = [] + if language: + args.extend(['-x', language]) + args += [file] + compile_opts + syntaxonly(args) + language = '' + if action == 'compile' or save_temps: for i, file in enumerate(files): if not language: -- 2.40.0