diff options
author | Iain Buclaw <ibuclaw@gdcproject.org> | 2020-06-08 12:47:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-08 12:47:44 +0200 |
commit | 91297042a400857fbed3f382f14914a3a34069ea (patch) | |
tree | afb157012fd369edc25884b81f4eb3f15d62f19a /lib/compilers/argument-parsers.js | |
parent | 3a9da38e7782650ed2f503f87f8c534a8bd6406c (diff) | |
download | compiler-explorer-91297042a400857fbed3f382f14914a3a34069ea.tar.gz compiler-explorer-91297042a400857fbed3f382f14914a3a34069ea.zip |
Pass -fsyntax-only when getting GCC options and test that -masm= is really supported (#2001)
* Pass -fsyntax-only when getting GCC options
Without this, the gcc driver will still attempt to invoke the assembler,
even though it is redundant to do so.
* Test that -masm= is both available and supported.
Targets such as i686-apple-darwin or x86_64-apple-darwin may have
-masm=intel present in --target-help, but any use of it will throw:
error: ‘-masm=intel’ not supported in this configuration
Diffstat (limited to 'lib/compilers/argument-parsers.js')
-rw-r--r-- | lib/compilers/argument-parsers.js | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/lib/compilers/argument-parsers.js b/lib/compilers/argument-parsers.js index 03ddc30c1..660995ab5 100644 --- a/lib/compilers/argument-parsers.js +++ b/lib/compilers/argument-parsers.js @@ -82,16 +82,22 @@ class BaseParser { class GCCParser extends BaseParser { static async parse(compiler) { const results = await Promise.all([ - GCCParser.getOptions(compiler, "--target-help"), - GCCParser.getOptions(compiler, "--help=common"), - GCCParser.getOptions(compiler, "--help=optimizers") + GCCParser.getOptions(compiler, "-fsyntax-only --target-help"), + GCCParser.getOptions(compiler, "-fsyntax-only --help=common"), + GCCParser.getOptions(compiler, "-fsyntax-only --help=optimizers") ]); const options = Object.assign({}, ...results); const keys = _.keys(options); logger.debug(`gcc-like compiler options: ${keys.join(" ")}`); if (BaseParser.hasSupport(options, "-masm=")) { - compiler.compiler.intelAsm = "-masm=intel"; - compiler.compiler.supportsIntel = true; + // -masm= may be available but unsupported by the compiler. + compiler.exec(compiler.compiler.exe, ["-fsyntax-only", "--target-help", "-masm=intel"]) + .then(result => { + if (result.code === 0) { + compiler.compiler.intelAsm = "-masm=intel"; + compiler.compiler.supportsIntel = true; + } + }); } if (BaseParser.hasSupport(options, "-fdiagnostics-color")) { if (compiler.compiler.options) compiler.compiler.options += " "; @@ -103,6 +109,15 @@ class GCCParser extends BaseParser { } return compiler; } + + static async getOptions(compiler, helpArg) { + const optionFinder = /^\s*(--?[a-z0-9=+,[\]<>|-]*)\s*(.*)/i; + const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' ')); + const options = result.code === 0 + ? BaseParser.parseLines(result.stdout + result.stderr, optionFinder) : {}; + compiler.possibleArguments.populateOptions(options); + return options; + } } class ClangParser extends BaseParser { |