Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang compilation fails due to mismatch in include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc #35666

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR36693
Status NEW
Importance P normal
Reported by Mike Lothian (mike@fireburn.co.uk)
Reported on 2018-03-12 09:41:40 -0700
Last modified on 2018-03-14 10:53:59 -0700
Version trunk
Hardware PC Linux
CC aaron@aaronballman.com, llvm-bugs@lists.llvm.org, rnk@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
In Gentoo when building both 32bit and 64bit binaries any agnostic include
members are compared between the two, if there are differences compilation
fails and an error is produced

This is currently happening with Clang from git

 * Header files have changed between ABIs.
 * --- /var/tmp/portage/sys-devel/clang-9999/temp/.multilib_header_cksum        2018-03-12 16:27:29.165639425 +0000
 * +++ /var/tmp/portage/sys-devel/clang-9999/temp/.multilib_header_cksum.new    2018-03-12 16:27:29.759637837 +0000
 * @@ -445,7 +445,7 @@
 *  2530910038 4721 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clang/AST/TypeNodes.def
 *  137739593 4742 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clangrt/7.0.0/include/avx512vbmiintrin.h
 *  3209348314 4753 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clang/Basic/FileSystemStatCache.h
 * -813479829 4798 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc
 * +1849706191 4798 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc
 *  3072834936 48017 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clang/StaticAnalyzer/Checkers/Checkers.inc
 *  4260476026 4802 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clang/ARCMigrate/ARCMT.h
 *  521383886 4865 /var/tmp/portage/sys-devel/clang-9999/image/usr/include/clangrt/7.0.0/include/avx512cdintrin.h

The details of the header in question is:

diff -u ./work/x/y/clang-9999-
abi_x86_64.amd64/include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc
./work/x/y/clang-9999-abi_x86_32.x86/include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc
--- ./work/x/y/clang-9999-
abi_x86_64.amd64/include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc
2018-03-12 16:07:52.542773015 +0000
+++ ./work/x/y/clang-9999-
abi_x86_32.x86/include/clang/Parse/AttrSubMatchRulesParserStringSwitches.inc
2018-03-12 15:55:16.649734176 +0000
@@ -32,21 +32,21 @@
   Default(None);
 }

-Optional<attr::SubjectMatchRule>
isAttributeSubjectMatchSubRuleFor_function(StringRef Name, bool IsUnless) {
+Optional<attr::SubjectMatchRule>
isAttributeSubjectMatchSubRuleFor_objc_method(StringRef Name, bool IsUnless) {
   if (IsUnless)
     return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).
     Default(None);
   return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).
-  Case("is_member", attr::SubjectMatchRule_function_is_member).
+  Case("is_instance", attr::SubjectMatchRule_objc_method_is_instance).
   Default(None);
 }

-Optional<attr::SubjectMatchRule>
isAttributeSubjectMatchSubRuleFor_objc_method(StringRef Name, bool IsUnless) {
+Optional<attr::SubjectMatchRule>
isAttributeSubjectMatchSubRuleFor_function(StringRef Name, bool IsUnless) {
   if (IsUnless)
     return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).
     Default(None);
   return llvm::StringSwitch<Optional<attr::SubjectMatchRule>>(Name).
-  Case("is_instance", attr::SubjectMatchRule_objc_method_is_instance).
+  Case("is_member", attr::SubjectMatchRule_function_is_member).
   Default(None);
 }

@@ -78,10 +78,10 @@
   return "'unless(is_union)'";
   case attr::SubjectMatchRule_variable:
   return "'is_thread_local', 'is_global', 'is_parameter', 'unless(is_parameter)'";
-  case attr::SubjectMatchRule_function:
-  return "'is_member'";
   case attr::SubjectMatchRule_objc_method:
   return "'is_instance'";
+  case attr::SubjectMatchRule_function:
+  return "'is_member'";
   default: return nullptr;
   }
 }
Quuxplusone commented 6 years ago

These .inc files are not public header files. We probably shouldn't be generating most tablegen results into the include tree. This is a pretty common issue with LLVM's build system, though.

Quuxplusone commented 6 years ago

That aside is there a reason they're different on 32bit and 64bit?

Quuxplusone commented 6 years ago
I see, sorry, I misunderstood the report.

This looks like the bug:

void PragmaClangAttributeSupport::generateParsingHelpers(raw_ostream &OS) {
  ...
  std::map<const Record *, std::vector<AttributeSubjectMatchRule>>
      SubMatchRules;
  ...
  for (const auto &SubMatchRule : SubMatchRules) {
    OS << "Optional<attr::SubjectMatchRule> isAttributeSubjectMatchSubRuleFor_"
  ...

Iterating a map keyed by pointer value is not deterministic.

This was added in r300556 by Alex. Should be a quick fix.
Quuxplusone commented 6 years ago

Seems to be fixed now

Quuxplusone commented 6 years ago
(In reply to Mike Lothian from comment #4)
> Seems to be fixed now

I think it's more likely that ASLR lead to a different iteration order on your
next build. The underlying non-determinism still seems present.