Skip to content

Commit 1309d14

Browse files
author
Shadab Naseem
committed
scripts: gcc-wrapper: Route the GCC errors to stderr
The GCC wrapper writes any error message from GCC to stdout along with the messages from the wrapper itself. This is okay for most case, but when GCC is used with -print-xxx flags, the stdout output is supposed to be taken as input to some other build command, so putting error messages in there is pretty bad. Fix this by writing error messages to stderr. Change-Id: I4656033f11ba5212fdcc884cc588f8b9d2c23419 Signed-off-by: Shadab Naseem <[email protected]>
1 parent e77f22c commit 1309d14

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: scripts/gcc-wrapper.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def interpret_warning(line):
5151
line = line.rstrip('\n')
5252
m = warning_re.match(line)
5353
if m and m.group(2) not in allowed_warnings:
54-
print "error, forbidden warning:", m.group(2)
54+
print >> sys.stderr, "error, forbidden warning:", m.group(2)
5555

5656
# If there is a warning, remove any object if it exists.
5757
if ofile:
@@ -76,17 +76,17 @@ def run_gcc():
7676
try:
7777
proc = subprocess.Popen(args, stderr=subprocess.PIPE)
7878
for line in proc.stderr:
79-
print line,
79+
print >> sys.stderr, line,
8080
interpret_warning(line)
8181

8282
result = proc.wait()
8383
except OSError as e:
8484
result = e.errno
8585
if result == errno.ENOENT:
86-
print args[0] + ':',e.strerror
87-
print 'Is your PATH set correctly?'
86+
print >> sys.stderr, args[0] + ':',e.strerror
87+
print >> sys.stderr, 'Is your PATH set correctly?'
8888
else:
89-
print ' '.join(args), str(e)
89+
print >> sys.stderr, ' '.join(args), str(e)
9090

9191
return result
9292

0 commit comments

Comments
 (0)