Created attachment 10879 [details]
Enhanced --ccache-skip functionality to actually exclude an option that follows it from hashing.
Attached is the patch to implement the functionality.
Created attachment 10883 [details]
Uploading new version of patch:
- there was an issue with running preprocessor step from within calculate_object_hash(). The fix is not as beautiful as I would like it to be, but I'm not sure there's a better way...
Thanks for the patch.
I haven't looked closely at it yet, but it makes the test suite uncompilable:
> % make test
> gcc -DHAVE_CONFIG_H -DSYSCONFDIR=/usr/local/etc -I. -I. -MD -MP -MF .deps/test_test_argument_processing.c.d -g -O2 -Wall -W -Werror -c -o test/test_argument_processing.o test/test_argument_processing.c
> test/test_argument_processing.c: In function ‘suite_argument_processing’:
> test/test_argument_processing.c:38:13: error: too few arguments to function ‘cc_process_args’
> CHECK(!cc_process_args(orig, &preprocessed, &compiler));
> In file included from test/test_argument_processing.c:23:0:
> ./ccache.h:229:7: note: declared here
> bool cc_process_args(struct args *args, struct args **preprocessor_args,
My bad. Will update the test suite tomorrow.
Do you want me to update the docs as well?
Created attachment 10895 [details]
Fixed test suite compilation.
Added test suite test for "--ccache-skip" option
Thanks for the patch! Some comments:
1. The current implementation approach reorders the compiler arguments, which doesn't feel acceptable. For example,
cc -c --ccache-skip -Ifoo -Ibar file.c
will be rewritten to
cc -c -Ibar -Ifoo file.c
which changes semantics of the compilation since "-I" options are used in left-to-right order by the compiler. The argument order needs to be preserved.
cc_process_args has become quite complex during the years and adding yet another argument list (nonhash_args) makes it even more complex (although just slightly). I think that some refactoring is needed to introduce "non-hashed arguments" in a good way. One idea is to add one or several type field to "struct args" and let cc_process_args set the new fields for different types of arguments. One field (or bits in a bitmask) could say if it's a preprocessor argument, compiler argument or both. Another could say whether the argument should be hashed or not. Etc.
However, if you can come up with a good way of solving the "nonhashed arguments" functionality without refactoring, that would probably also be OK.
2. Thinking a bit more about this, I think that I would prefer another option than --ccache-skip for excluding an argument from the hash. The reason is that one might want to skip hashing an argument but still want to let ccache interpret the argument specially. Or the other way around. Perhaps the new option could be named --ccache-dont-hash? And maybe --ccache-skip-and-dont-hash could have both effects?
3. Documentation (MANUAL.txt) needs to be updated.
Hi again Mark,
Any progress on this patch?
Closing this now since no progress has been made for a long time. Please create a new issue at https://github.com/ccache/ccache/issues if wanted.