mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-17 07:24:34 +00:00
60cdabd931
abidiff-ing libGLU.so against the result of 'abidw libGLU.so' does not yield the empty set. This is because hashing certain types when they are read (de-serialized) from DWARF doesn't give the same result as when they are de-serialized from abixml. I call this type degradation. And it leads to spurious comparison differences. This is due to several issues. 1/ The logical link between a class declaration and its definition -- that is built when reading types from DWARF is not preserved in abixml. So, for example, when a class S refers to itself via a pointer to its declaration, that type might hash differently when read from DWARF and when read from abixml. When read from abixml it's a pointer to S itself. But then that 'self' can be a copy of S that is defined in another file because abixml doesn't enforce the One Definition Rule from C++ either. 2/ As the result of hashing is kept in a cache for var_decl and function_decl, hashing those decl before their types are completely built caches a value that becomes wrong when their type become completely built. 3/ In DWARF, a class which has a virtual member function can still be considered as being declaration-only. And its definition can come later in the DWARF info. Our DWARF reader removes the "declaration-only" flag from a class as soon as it sees virtual member functions in that class; that makes us consider that class as a definition. And then later when we read the real definition of the class we have two classes of the same name, with different layouts/size in the system. This leads to spurious comparison differences too. This patch addresses issues 1, 2 and 3. * src/abg-dwarf-reader.cc (build_class_type_and_add_to_ir): Do not consider that virtual member functions disqualify a class from being declaration-only. * src/abg-hash.cc (var_decl:#️⃣:operator()): Do not cache the result of hashing before we are done building the type of the var_decl. (function_decl:#️⃣:operator()): Likewise, do not cache the result of hashing before we are done building the type of the function_decl. * src/abg-reader.cc (build_class_decl): Build the link between a class declaration and its definition. If there are several definitions of a class in the corpus, keep just one. * src/abg-writer.cc (write_class_is_declaration_only): Emit the link between a class declaration and its definition. (write_class_decl): Emit a class declaration even if it has a definition. The definition is going to be emitted separately. * tests/data/test-read-dwarf/test14-pr18893.so: New binary test input. * tests/data/test-read-dwarf/test14-pr18893.so.abi: New test reference output. * tests/data/Makefile.am: Add the new test input files to source distribution. * tests/test-read-dwarf.cc (in_out_specs): Run the new tests. * tests/data/test-abidiff/test-PR18791-report0.txt: Adjust. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2.0 MiB
2.0 MiB