aboutsummaryrefslogtreecommitdiff
path: root/libbuild2
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-01-09 10:52:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-01-09 10:52:58 +0200
commit8bda0cde0a0ce2b713753666c438df8638583b91 (patch)
tree17c4b441ebbc37540b27421a12b783e0477434f9 /libbuild2
parent16f5b5d540950f882ee20b13114917f420f41cbb (diff)
Disable use of -frewrite-includes for assembler with preprocessor files
With -frewrite-includes Clang has issues with correctly tracking location information (manifests itself as wrong line numbers in debug info, for example). The result also appears to reference the .Si file instead of the original source file for some reason. While at it also omit trying to scan such files since that can be hazardous (such files sometimes use `#`-style comments).
Diffstat (limited to 'libbuild2')
-rw-r--r--libbuild2/cc/compile-rule.cxx27
1 files changed, 24 insertions, 3 deletions
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index b4d405b..5c811a1 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -3290,8 +3290,8 @@ namespace build2
// Note that for assembler-with-cpp GCC currently forces full
// preprocessing in (what appears to be) an attempt to paper over
// a deeper issue (see GCC bug 109534). If/when that bug gets
- // fixed, we can enable this on our side. Note also that Clang's
- // -frewrite-includes appear to work correctly on such files.
+ // fixed, we can enable this on our side. Note that Clang's
+ // -frewrite-includes also has issues (see below).
//
if (!x_assembler_cpp (src))
pp = "-fdirectives-only";
@@ -3304,7 +3304,16 @@ namespace build2
// -frewrite-includes is available since Clang 3.2.0.
//
if (cmaj > 3 || (cmaj == 3 && cmin >= 2))
- pp = "-frewrite-includes";
+ {
+ // While Clang's -frewrite-includes appears to work, there are
+ // some issues with correctly tracking location information
+ // (manifests itself as wrong line numbers in debug info, for
+ // example). The result also appears to reference the .Si file
+ // instead of the original source file for some reason.
+ //
+ if (!x_assembler_cpp (src))
+ pp = "-frewrite-includes";
+ }
break;
}
@@ -5094,6 +5103,18 @@ namespace build2
{
tracer trace (x, "compile_rule::parse_unit");
+ // Scanning .S files with our parser is hazardous since such files
+ // sometimes use `#`-style comments. Presumably real compilers just
+ // ignore them in some way, but it doesn't seem worth it to bother in
+ // our case. Also, the checksum calculation over assembler tokens feels
+ // iffy.
+ //
+ if (x_assembler_cpp (src))
+ {
+ tu.type = unit_type::non_modular;
+ return "";
+ }
+
otype ot (li.type);
// If things go wrong give the user a bit extra context. Let's call it