Re: [ccache] preprocessor mode

2016-05-20 Thread Yoav Alon
I've come to the same conclusion as you have.
We encountered a corner case where gcc will not compile when working with
-P.
I'll open a PR for this on github.
Thanks!

On Tue, 17 May 2016 at 21:56 Joel Rosdahl  wrote:

> Hi Yoav,
>
> > I've dug a bit deeper, and found that when doing a diff between the
> output
> > of the preprocessor the resolved include path is emitted as part of the
> > output as a comment, in our case it's
> >
> > # 1 "a/a.h" 1
> >
> > There's a flag -P to the preprocessor to remove these comments.
>
> It sounds good to not include names of included files in the hash, I think.
>
> > [...]
> > I think this should be default, do you think there's a safety issue with
> > adding -P?
>
> I see two problems:
>
> 1. -P is likely not supported by all compilers that can be used with
> ccache.
> 2. Using -P discards #line directives that may have been put there by code
> generator tools, for instance yacc/bison. This would lead to incorrect file
> name references when the compiler generates warnings when compiling the
> preprocessed output.
>
> However, it's possible to get more or less the same effect (not hashing
> filenames) like this:
>
> diff --git a/ccache.c b/ccache.c
> index 23103ee..dd11927 100644
> --- a/ccache.c
> +++ b/ccache.c
> @@ -863,7 +863,6 @@ process_preprocessed_file(struct mdfour *hash, const
> char *path)
>   has_absolute_include_headers = is_absolute_path(path);
>   }
>   path = make_relative_path(path);
> - hash_string(hash, path);
>   remember_include_file(path, hash, system);
>   p = r;
>   } else {
>
> What do you think?
>
> -- Joel
>
>
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


Re: [ccache] preprocessor mode

2016-05-17 Thread Joel Rosdahl
Hi Yoav,

> I've dug a bit deeper, and found that when doing a diff between the output
> of the preprocessor the resolved include path is emitted as part of the
> output as a comment, in our case it's
>
> # 1 "a/a.h" 1
>
> There's a flag -P to the preprocessor to remove these comments.

It sounds good to not include names of included files in the hash, I think.

> [...]
> I think this should be default, do you think there's a safety issue with
> adding -P?

I see two problems:

1. -P is likely not supported by all compilers that can be used with ccache.
2. Using -P discards #line directives that may have been put there by code
generator tools, for instance yacc/bison. This would lead to incorrect file
name references when the compiler generates warnings when compiling the
preprocessed output.

However, it's possible to get more or less the same effect (not hashing
filenames) like this:

diff --git a/ccache.c b/ccache.c
index 23103ee..dd11927 100644
--- a/ccache.c
+++ b/ccache.c
@@ -863,7 +863,6 @@ process_preprocessed_file(struct mdfour *hash, const
char *path)
  has_absolute_include_headers = is_absolute_path(path);
  }
  path = make_relative_path(path);
- hash_string(hash, path);
  remember_include_file(path, hash, system);
  p = r;
  } else {

What do you think?

-- Joel
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


Re: [ccache] preprocessor mode

2016-05-13 Thread Yoav Alon
I've dug a bit deeper, and found that when doing a diff between the output
of the preprocessor the resolved include path is emitted as part of the
output as a comment, in our case it's
# 1 "a/a.h" 1

There's a flag -P to the preprocessor to remove these comments.
When adding a patch to the code:

diff --git a/ccache.c b/ccache.c

index 23103ee..acfa0d8 100644

--- a/ccache.c

+++ b/ccache.c

@@ -1406,6 +1406,7 @@ get_object_name_from_cpp(struct args *args, struct
mdfour *hash)

add_pending_tmp_file(path_stdout);



args_add(args, "-E");

+   args_add(args, "-P");

if (conf->keep_comments_cpp) {

args_add(args, "-C");

}

I get a preprocessed cache hit.

I think this should be default, do you think there's a safety issue with
adding -P?

Thanks again

Yoav

On Thu, 12 May 2016 at 22:24 Yoav Alon  wrote:

> Hi ccache,
> I'm trying to use ccache with preprocessor mode (direct_mode=false) and
> I'm unable to get cache hits.
> I have the following hierarchy:
> main.c
> includes1/a.h
> includes2/a.h
>
> main.c conatins:
> #include 
> #include 
> int main() {
>   printf("%s\n", __A__);
> }
>
> includes1/a.h and includes2/a.h are identical and contain just:
> #define __A__ "ccache"
>
> My compilation command is:
>
> ccache gcc -c main.c -o main.o -Iincludes1
>
> ccache gcc -c main.c -o main.o -Iincludes2
>
> And the result is two cache misses (and two new files in cache). And I
> don't understand why.
>
> this is my configuration:
>
> (default) base_dir =
>
> (default) cache_dir = /Users/yoavalon/.ccache
>
> (default) cache_dir_levels = 2
>
> (default) compiler =
>
> (default) compiler_check = mtime
>
> (default) compression = false
>
> (default) compression_level = 6
>
> (default) cpp_extension =
>
> (/Users/yoavalon/.ccache/ccache.conf) direct_mode = false
>
> (default) disable = false
>
> (default) extra_files_to_hash =
>
> (default) hard_link = false
>
> (default) hash_dir = false
>
> (/Users/yoavalon/.ccache/ccache.conf) log_file = /tmp/ccache_log
>
> (default) max_files = 0
>
> (/Users/yoavalon/.ccache/ccache.conf) max_size = 5.0G
>
> (default) path =
>
> (default) prefix_command =
>
> (default) read_only = false
>
> (default) read_only_direct = false
>
> (default) recache = false
>
> (default) run_second_cpp = false
>
> (default) sloppiness =
>
> (default) stats = true
>
> (default) temporary_dir =
>
> (default) umask =
>
> (default) unify = false
>
>
> The reason I'm seeking a cache hit when the include directory is changed
> is that our CI system always increments the version on each build for each
> dependency, thus changing the include directory for that build. reading the
> documentation I thought preprocessor mode will help me but it doesn't seem
> to work. Am i missing something?
>
> Thanks
>
> Yoav
>
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache


[ccache] preprocessor mode

2016-05-12 Thread Yoav Alon
Hi ccache,
I'm trying to use ccache with preprocessor mode (direct_mode=false) and I'm
unable to get cache hits.
I have the following hierarchy:
main.c
includes1/a.h
includes2/a.h

main.c conatins:
#include 
#include 
int main() {
  printf("%s\n", __A__);
}

includes1/a.h and includes2/a.h are identical and contain just:
#define __A__ "ccache"

My compilation command is:

ccache gcc -c main.c -o main.o -Iincludes1

ccache gcc -c main.c -o main.o -Iincludes2

And the result is two cache misses (and two new files in cache). And I
don't understand why.

this is my configuration:

(default) base_dir =

(default) cache_dir = /Users/yoavalon/.ccache

(default) cache_dir_levels = 2

(default) compiler =

(default) compiler_check = mtime

(default) compression = false

(default) compression_level = 6

(default) cpp_extension =

(/Users/yoavalon/.ccache/ccache.conf) direct_mode = false

(default) disable = false

(default) extra_files_to_hash =

(default) hard_link = false

(default) hash_dir = false

(/Users/yoavalon/.ccache/ccache.conf) log_file = /tmp/ccache_log

(default) max_files = 0

(/Users/yoavalon/.ccache/ccache.conf) max_size = 5.0G

(default) path =

(default) prefix_command =

(default) read_only = false

(default) read_only_direct = false

(default) recache = false

(default) run_second_cpp = false

(default) sloppiness =

(default) stats = true

(default) temporary_dir =

(default) umask =

(default) unify = false


The reason I'm seeking a cache hit when the include directory is changed is
that our CI system always increments the version on each build for each
dependency, thus changing the include directory for that build. reading the
documentation I thought preprocessor mode will help me but it doesn't seem
to work. Am i missing something?

Thanks

Yoav
___
ccache mailing list
ccache@lists.samba.org
https://lists.samba.org/mailman/listinfo/ccache