This is an archive of the discontinued LLVM Phabricator instance.

Fix DWARF DebugInfo unit test errors when cross-compiling
ClosedPublic

Authored by daltenty on May 17 2019, 2:31 PM.

Details

Summary

When building with a Default Target set we can experience issues in the DWARF DebugInfo unit tests because:

  • They assume we can generate object files for the host platform
  • Some tests assume the endianess of the target we are generating DWARF for and the host match

This patch correct these issues by ensuring the tests which generate objects in memory are run with respect to LVM_DEFAULT_TARGET_TRIPLE and it's
endianess. We also make sure we don't use the hosts address size for line test and split the triple util function in DwarfUtils into a version that takes an address size and one that doesn't.

See also for discussion: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131212.html

Diff Detail

Repository
rL LLVM

Event Timeline

daltenty created this revision.May 17 2019, 2:31 PM

For implementing the direction discussed on the referenced thread, the changes look correct to me.

Looks like the right solution, but have you actually tried it with an empty default triple?

llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp
28 ↗(On Diff #200097)

I think getDefaultTargetTriple would be a better name here.

daltenty updated this revision to Diff 201703.May 28 2019, 10:41 AM

Respond to comments round 1.

If LLVM_DEFAULT_TARGET_TRIPLE is set to empty, cmake will not define it due to the behavior of configure_file, so the fallback behavior in this patch needs to be corrected.

Rather than trying to guess a fall back for these empty triple situations (some existing tests do not handle this anyway), I've update the patch to rely on the functionality of sys::getDefaultTargetTriple().

This brings us in line with other tests and allows selection of a test triple with the LLVM_TARGET_TRIPLE_ENV functionality (introduced in D33662). Thus in cases where an empty LLVM_DEFAULT_TARGET_TRIPLE is specified at configuration time, running the tests with LLVM_TARGET_TRIPLE_ENV is required.

daltenty marked an inline comment as done.May 28 2019, 10:42 AM
This revision is now accepted and ready to land.Jun 3 2019, 12:51 PM
This revision was automatically updated to reflect the committed changes.