]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Bail out on usage of .incbin` assembler directives
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 26 Oct 2016 21:25:05 +0000 (23:25 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 26 Oct 2016 21:25:05 +0000 (23:25 +0200)
Fixes #136.

MANUAL.txt
NEWS.txt
ccache.c
ccache.h
stats.c
test.sh

index ab01886dffa00eec1c370993f4212873b6c0fd9b..dea2fdc869377f1ab9fb9759eda1914e357b75fc 100644 (file)
@@ -800,13 +800,6 @@ invoke the other wrapper when doing preprocessing (normally by adding *-E*).
 Caveats
 -------
 
-* ccache doesn't handle the GNU Assembler's *.incbin* directive correctly. This
-  directive can be embedded in the source code inside an *__asm__* statement in
-  order to include a file verbatim in the object file. If the included file is
-  modified, ccache doesn't pick up the change since the inclusion isn't done by
-  the preprocessor. A workaround of this problem is to set
-  *extra_files_to_hash* to the path of the included file.
-
 * The direct mode fails to pick up new header files in some rare scenarios. See
   <<_the_direct_mode,THE DIRECT MODE>> above.
 
index 2c95723c7d314c90327cac016ac09a0c3d9dd428..b254b0a570931e48e90cd726bc82da43b1d08247 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,16 @@
 ccache news
 ===========
 
+Unreleased 3.3.3
+----------------
+
+Bug fixes
+~~~~~~~~~
+
+- ccache now detects usage of `.incbin` assembler directives in the source code
+  and avoids caching such compilations.
+
+
 ccache 3.3.2
 ------------
 Release date: 2016-09-28
index 1ad4df95fca122a5e8ae5cc25eb408ef60c50a1e..b93e027ff710140708f1203e2c5de33a525389a0 100644 (file)
--- a/ccache.c
+++ b/ccache.c
@@ -815,6 +815,15 @@ process_preprocessed_file(struct mdfour *hash, const char *path)
                        inc_path = make_relative_path(inc_path);
                        remember_include_file(inc_path, hash, system);
                        p = q;
+               } else if (q[0] == '.' && q[1] == 'i' && q[2] == 'n' && q[3] == 'c'
+                          && q[4] == 'b' && q[5] == 'i' && q[6] == 'n') {
+                       // An assembler .incbin statement (which could be part of inline
+                       // assembly) refers to an external file. If the file changes, the hash
+                       // should change as well, but finding out what file to hash is too hard
+                       // for ccache, so just bail out.
+                       cc_log("Found unsupported .incbin directive in source code");
+                       stats_update(STATS_UNSUPPORTED_DIRECTIVE);
+                       failed();
                } else {
                        q++;
                }
index a79d144197f1a771c247c55b3142e6f3a36df596..8b738aba0c10e8bc52aa6d93a472c43e45dcf1f0 100644 (file)
--- a/ccache.h
+++ b/ccache.h
@@ -52,6 +52,7 @@ enum stats {
        STATS_CANTUSEPCH = 27,
        STATS_PREPROCESSING = 28,
        STATS_NUMCLEANUPS = 29,
+       STATS_UNSUPPORTED_DIRECTIVE = 30,
 
        STATS_END
 };
diff --git a/stats.c b/stats.c
index ff352bc6d0c2c9093b579e6913cc6f65196bc797..5d9fc737885001b5ff822be01eccd481c3105226 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -170,6 +170,12 @@ static struct {
                NULL,
                0
        },
+       {
+               STATS_UNSUPPORTED_DIRECTIVE,
+               "unsupported code directive",
+               NULL,
+               0
+       },
        {
                STATS_OUTSTDOUT,
                "output to stdout",
diff --git a/test.sh b/test.sh
index 3e041574570335b8560505a7dbd68c4d44097bd6..ada8697363f585ff5dd2b5cdee2df816b549b4ce 100755 (executable)
--- a/test.sh
+++ b/test.sh
@@ -1101,6 +1101,18 @@ EOF
     if [ "$(./c)" != OK ]; then
         test_failed "Incorrect header file used"
     fi
+
+    # -------------------------------------------------------------------------
+    TEST ".incbin"
+
+    cat <<EOF >incbin.c
+char x[] = ".incbin";
+EOF
+
+    $CCACHE_COMPILE -c incbin.c
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 0
+    expect_stat 'unsupported code directive' 1
 }
 
 # =============================================================================