[gcc r17-3413] PR modula2/126911: Build fix to prevent Python hanging
Gaius Mulley via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:dc80afc49b7a0eddaf2152379971e36d4d2bf953 commit r17-3413-gdc80afc49b7a0eddaf2152379971e36d4d2bf953 Author: Gaius Mulley <[email protected]> Date: Wed Aug 19 12:38:09 2026 +0100 PR modula2/126911: Build fix to prevent Python hanging This patch fixes mktargetsrc.py if gm2 fails to run. With this patch mktargetsrc.py will remove any output file and any temporary file before exiting with a non zero status. This prevents def2doc.py from spinning attempting to read the first 8192 bytes of a zero length file. mktargetsrc.py now defensively invokes gm2 with -S preventing the driver from invoking an assembler which might not be installed. Bootstrapped on Debian x86_64 and FreeBSD15. The build fails appropriately when configured with --target=nvptx-none. gcc/m2/ChangeLog: PR modula2/126911 * tools-src/mktargetsrc.py (quietSystem): Add temporaryFile parameter. Tidy up if result is non zero by removing temporaryFile and args.outputfile. Signed-off-by: Gaius Mulley <[email protected]> Diff: --- gcc/m2/tools-src/mktargetsrc.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gcc/m2/tools-src/mktargetsrc.py b/gcc/m2/tools-src/mktargetsrc.py index cd61ecec87cf..34c19233043e 100644 --- a/gcc/m2/tools-src/mktargetsrc.py +++ b/gcc/m2/tools-src/mktargetsrc.py @@ -38,7 +38,7 @@ def printf (format, *args): print(str(format) % args, end=' ') -def quietSystem(args, commandLine): +def quietSystem(args, commandLine, temporaryFile): # Execute commandline and exit if unsuccessful. It will run # gdb on the command line if --gdb is set in args. if args.gdb: @@ -46,6 +46,9 @@ def quietSystem(args, commandLine): else: result = os.system(commandLine + " 2>&1 /dev/null") if result != 0: + os.remove(temporaryFile) + if (args.outputfile != None) and os.path.exists(args.outputfile): + os.remove(args.outputfile) printf("failed to execute: %s with an exit code: %d\n", commandLine, result) sys.exit(result) @@ -397,14 +400,14 @@ def determineBuiltins(args, includePath): if args.fiso or (not args.fpim): dialect = '-fiso' compiler = stripBackslash(args.compiler) - commandLine = "%s %s %s %s -c -fdump-system-exports -o /dev/null %s > %s" % ( + commandLine = "%s %s %s %s -S -fdump-system-exports -o /dev/null %s > %s" % ( compiler, dialect, includePath, minimalCommandLine, args.modinputfile, temporaryFile) - quietSystem(args, commandLine) - commandLine = "%s %s %s %s -c -fdump-builtins %s >> %s" % ( + quietSystem(args, commandLine, temporaryFile) + commandLine = "%s %s %s %s -S -fdump-builtins %s >> %s" % ( compiler, dialect, includePath, minimalCommandLine, args.modinputfile, temporaryFile) - quietSystem(args, commandLine) + quietSystem(args, commandLine, temporaryFile) generateSource(args, temporaryFile) os.remove(temporaryFile)