Hi all, I noticed that try-compile leaves a temp.1234.o file in the current directory when invoked (see #1213). The definition actually has a "oname" variable, but it isn't used. So the attached patch causes it to explicitly pass "-o ONAME" to the compiler, to ensure that it writes to that file (which should now be created under the tempdir instead of the current directory as an added bonus), and then removes it.
I've added "shellpath" for good measure. create-temporary-file should never create file names which are unsafe to pass to the shell, but when reading the code that isn't immediately obvious. Perhaps we should also try adding shellpath to *target-lib-home*, but I decided to keep this change self-contained and ask, first. This change should also go into the chicken-5 branch, I think. Cheers, Peter
From fae373d9eaf2464c1e1001ce363368a74530976c Mon Sep 17 00:00:00 2001 From: Peter Bex <pe...@more-magic.net> Date: Mon, 24 Aug 2015 21:45:39 +0200 Subject: [PATCH] Ensure "try-compile" from setup-api cleans up tempfiles. It now creates the file with a controlled name, which can then be cleaned up. Fixes #1213 --- NEWS | 6 ++++++ setup-api.scm | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ab034eb..c2cda9f 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +4.10.1 + +- Core libraries + - try-compile from setup-api cleans up temporary output files (#1213). + + 4.10.0 - Security fixes diff --git a/setup-api.scm b/setup-api.scm index 547558a..0fdfc1e 100644 --- a/setup-api.scm +++ b/setup-api.scm @@ -528,7 +528,7 @@ cc " " (if compile-only "-c" "") " " cflags " " *target-cflags* " " - fname " " + (shellpath fname) " -o " (shellpath oname) " " (if compile-only "" (conc "-L" *target-lib-home* " " ldflags " " *target-libs*) ) @@ -538,6 +538,7 @@ cmd) ) ) ) ) (when verb (print (if (zero? r) "succeeded." "failed."))) (ignore-errors ($system (sprintf "~A ~A" *remove-command* (shellpath fname)))) + (ignore-errors ($system (sprintf "~A ~A" *remove-command* (shellpath oname)))) (zero? r) ) ) (define test-compile try-compile) -- 2.1.4
signature.asc
Description: Digital signature
_______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-hackers