aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-07-12 22:51:38 -0400
committerNirbheek Chauhan <nirbheek@centricular.com>2022-08-08 19:28:51 +0530
commit988890c8a04e1676664fee1a4d10aad52203e8f5 (patch)
treefb3f1844d633af97f28028e6197513d1db4b0d99
parent15e5830dd84e540357c5d9948b8bf19f909b6d28 (diff)
downloadmeson-988890c8a04e1676664fee1a4d10aad52203e8f5.zip
meson-988890c8a04e1676664fee1a4d10aad52203e8f5.tar.gz
meson-988890c8a04e1676664fee1a4d10aad52203e8f5.tar.bz2
compilers: add logging to obscure compiler defines scraper
If this command fails, for example when CXX is something not generic enough to be a valid universal compiler command (clang -std=c++11 perhaps), we end up with two problems: - it's impossible to figure out what Meson ran to get that error - the error report isn't clear on what is stdout and what is stderr, or even that that is what the message is about. ``` meson.build:1:0: ERROR: Unable to get clang pre-processor defines: error: invalid argument '-std=c++11' not allowed with 'C' ``` What's C doing there and why is Meson talking about it? Answer: that's compiler stdout. Say so.
-rw-r--r--mesonbuild/compilers/detect.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/mesonbuild/compilers/detect.py b/mesonbuild/compilers/detect.py
index 09a0345..0db70d4 100644
--- a/mesonbuild/compilers/detect.py
+++ b/mesonbuild/compilers/detect.py
@@ -1232,9 +1232,12 @@ def _get_gnu_compiler_defines(compiler: T.List[str]) -> T.Dict[str, str]:
# Arguments to output compiler pre-processor defines to stdout
# gcc, g++, and gfortran all support these arguments
args = compiler + ['-E', '-dM', '-']
+ mlog.debug(f'Running command: {join_args(args)}')
p, output, error = Popen_safe(args, write='', stdin=subprocess.PIPE)
if p.returncode != 0:
- raise EnvironmentException('Unable to detect GNU compiler type:\n' + output + error)
+ raise EnvironmentException('Unable to detect GNU compiler type:\n'
+ f'Compiler stdout:\n{output}\n-----\n'
+ f'Compiler stderr:\n{error}\n-----\n')
# Parse several lines of the type:
# `#define ___SOME_DEF some_value`
# and extract `___SOME_DEF`
@@ -1256,9 +1259,12 @@ def _get_clang_compiler_defines(compiler: T.List[str]) -> T.Dict[str, str]:
Get the list of Clang pre-processor defines
"""
args = compiler + ['-E', '-dM', '-']
+ mlog.debug(f'Running command: {join_args(args)}')
p, output, error = Popen_safe(args, write='', stdin=subprocess.PIPE)
if p.returncode != 0:
- raise EnvironmentException('Unable to get clang pre-processor defines:\n' + output + error)
+ raise EnvironmentException('Unable to get clang pre-processor defines:\n'
+ f'Compiler stdout:\n{output}\n-----\n'
+ f'Compiler stderr:\n{error}\n-----\n')
defines: T.Dict[str, str] = {}
for line in output.split('\n'):
if not line: