diff options
author | Jason Liu <jasonliu.development@gmail.com> | 2019-06-03 22:22:03 +0000 |
---|---|---|
committer | Jason Liu <jasonliu.development@gmail.com> | 2019-06-03 22:22:03 +0000 |
commit | 552fda839a313af1f73efa13b6abee624e944f77 (patch) | |
tree | b3dd3d7b8f18b968cfc2ff2472299f216ba61393 /llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp | |
parent | 099f4a9fa828bd982b1da096260a308ba21c3d6f (diff) | |
download | bcm5719-llvm-552fda839a313af1f73efa13b6abee624e944f77.tar.gz bcm5719-llvm-552fda839a313af1f73efa13b6abee624e944f77.zip |
Fix DWARF DebugInfo unit test errors when cross-compiling
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
Patch by: daltenty
Differential Revision: https://reviews.llvm.org/D62084
llvm-svn: 362454
Diffstat (limited to 'llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp')
-rw-r--r-- | llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp index fe0cebd75b0..249cfb42271 100644 --- a/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DwarfUtils.cpp @@ -9,6 +9,7 @@ #include "DwarfUtils.h" #include "llvm/ADT/Triple.h" #include "llvm/Config/llvm-config.h" +#include "llvm/Support/Host.h" #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" @@ -25,9 +26,20 @@ static void initLLVMIfNeeded() { } } -Triple llvm::dwarf::utils::getHostTripleForAddrSize(uint8_t AddrSize) { - Triple T(Triple::normalize(LLVM_HOST_TRIPLE)); +Triple llvm::dwarf::utils::getNormalizedDefaultTargetTriple() { + Triple T(Triple::normalize(sys::getDefaultTargetTriple())); + return T; +} + +Triple llvm::dwarf::utils::getDefaultTargetTripleForAddrSize(uint8_t AddrSize) { + Triple T = getNormalizedDefaultTargetTriple(); + + assert((AddrSize == 4 || AddrSize == 8) && + "Only 32-bit/64-bit address size variants are supported"); + + // If a 32-bit/64-bit address size was specified, try to convert the triple + // if it is for the wrong variant. if (AddrSize == 8 && T.isArch32Bit()) return T.get64BitArchVariant(); if (AddrSize == 4 && T.isArch64Bit()) |