]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Deduce split dwarf filename from object file with zero or multiple dots
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Jan 2021 10:44:06 +0000 (11:44 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 3 Jan 2021 11:40:02 +0000 (12:40 +0100)
(cherry picked from commit 5bcba58358ef2e88e1cc910583830c6830f6c712)

src/argprocessing.cpp
test/suites/split_dwarf.bash

index 983ccdb45607a8924c2caf106bf97331cd645d92..330dc0eac3b071beb67a06b8256a6c1267d41a14 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2020 Joel Rosdahl and other contributors
+// Copyright (C) 2020-2021 Joel Rosdahl and other contributors
 //
 // See doc/AUTHORS.adoc for a complete list of contributors.
 //
@@ -1069,12 +1069,6 @@ process_args(Context& ctx)
   }
 
   if (args_info.seen_split_dwarf) {
-    size_t pos = args_info.output_obj.rfind('.');
-    if (pos == std::string::npos || pos == args_info.output_obj.size() - 1) {
-      LOG_RAW("Badly formed object filename");
-      return Statistic::bad_compiler_arguments;
-    }
-
     args_info.output_dwo = Util::change_extension(args_info.output_obj, ".dwo");
   }
 
index d8c38050fba1cfa0e137a0f53aaf4d5e66289d8c..28a329345cefe7af50456cc685b2e60441000a4a 100644 (file)
@@ -142,4 +142,38 @@ SUITE_split_dwarf() {
     elif [ ! -f reference.dwo ] && [ -f test.dwo ]; then
         test_failed ".dwo not missing"
     fi
+
+    # -------------------------------------------------------------------------
+    TEST "Object file without dot"
+
+    $CCACHE_COMPILE -gsplit-dwarf -c test.c -o test
+    expect_stat 'cache hit (direct)' 0
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+    expect_exists test.dwo
+
+    rm test.dwo
+
+    $CCACHE_COMPILE -gsplit-dwarf -c test.c -o test
+    expect_stat 'cache hit (direct)' 1
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+    expect_exists test.dwo
+
+    # -------------------------------------------------------------------------
+    TEST "Object file with two dots"
+
+    $CCACHE_COMPILE -gsplit-dwarf -c test.c -o test.x.y
+    expect_stat 'cache hit (direct)' 0
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+    expect_exists test.x.dwo
+
+    rm test.x.dwo
+
+    $CCACHE_COMPILE -gsplit-dwarf -c test.c -o test.x.y
+    expect_stat 'cache hit (direct)' 1
+    expect_stat 'cache hit (preprocessed)' 0
+    expect_stat 'cache miss' 1
+    expect_exists test.x.dwo
 }