Bug 7508 - PATCH: fix 'ccache -c' logging
Summary: PATCH: fix 'ccache -c' logging
Status: CLOSED FIXED
Alias: None
Product: ccache
Classification: Unclassified
Component: ccache (show other bugs)
Version: 3.0pre0
Hardware: Other Windows XP
: P3 minor
Target Milestone: 3.0
Assignee: Joel Rosdahl
QA Contact: Joel Rosdahl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-10 14:39 UTC by Wilson Snyder
Modified: 2010-07-09 04:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wilson Snyder 2010-06-10 14:39:33 UTC
I was debugging a cleanup issue, and using 'ccache -c' with a CCACHE_LOGFILE set, but surprise, logging doesn't work because the CCACHE_LOGFILE is read too late.

The attached patch fixes it.  If you don't like cc_log with CCACHE STARTED right up front, maybe put it in util.c right after the logfile is opened.

Thanks

From 92789d29ea73a3aee1b038f061687ec3c9195ace Mon Sep 17 00:00:00 2001
From: Wilson Snyder <wsnyder@wsnyder.org>
Date: Thu, 10 Jun 2010 15:21:55 -0400
Subject: [PATCH] set logfile so -c messages show up

---
 ccache.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ccache.c b/ccache.c
index fa54bdf..5ba2105 100644
--- a/ccache.c
+++ b/ccache.c
@@ -1818,8 +1818,6 @@ static void ccache(int argc, char *argv[])
 	/* Arguments to send to the real compiler. */
 	ARGS *compiler_args;
 
-	cc_log("=== CCACHE STARTED =========================================");
-
 	sloppiness = parse_sloppiness(getenv("CCACHE_SLOPPINESS"));
 
 	cc_log("Hostname: %s", get_hostname());
@@ -2100,6 +2098,10 @@ int main(int argc, char *argv[])
 	char *p;
 	char *program_name;
 
+	/* check for logging early so cc_log messages start working ASAP */
+	cache_logfile = getenv("CCACHE_LOGFILE");
+	cc_log("=== CCACHE STARTED =========================================");
+
 	/* the user might have set CCACHE_UMASK */
 	p = getenv("CCACHE_UMASK");
 	if (p) {
@@ -2142,8 +2144,6 @@ int main(int argc, char *argv[])
 		x_asprintf(&temp_dir, "%s/tmp", cache_dir);
 	}
 
-	cache_logfile = getenv("CCACHE_LOGFILE");
-
 	base_dir = getenv("CCACHE_BASEDIR");
 	if (base_dir && base_dir[0] != '/') {
 		cc_log("Ignoring non-absolute base directory %s", base_dir);
-- 
1.5.5.6
Comment 1 Joel Rosdahl 2010-06-13 04:22:05 UTC
Applied in fdf1b54d158917890d504a9d1af1dc9cb323f86f. Thanks!