[PowerPC] undef Relocation names in PowerPC*.def
authorHal Finkel <hfinkel@anl.gov>
Wed, 30 Sep 2015 22:34:35 +0000 (22:34 +0000)
committerHal Finkel <hfinkel@anl.gov>
Wed, 30 Sep 2015 22:34:35 +0000 (22:34 +0000)
commitd741fc02b0fdabe236b978db24ae31c033392edf
tree790a03f272eaf375a0bd50d4e7a7f0a2f6932c80
parent4f55287fa6b7810e1845f606f0d2929d1192a50a
[PowerPC] undef Relocation names in PowerPC*.def

glibc's PowerPC /usr/include/asm/sigcontext.h, has this:

  #ifdef __powerpc64__
  #include <asm/elf.h>
  #endif

and that contains defines of all of the relocation symbols, like this:

  #define R_PPC_NONE              0

and if that file is included prior to including
include/llvm/Support/ELFRelocs/PowerPC*.def, which we cannot in general
prevent, the result will fail.

As it turns out, this happens when compiling
lld/unittests/DriverTests/GnuLdDriverTest.cpp under PPC64/Linux, because:

  lld/include/lld/ReaderWriter/ELFLinkingContext.h includes
  lld/unittests/DriverTests/DriverTest.h which includes
  utils/unittest/googletest/include/gtest/gtest.h which includes
  utils/unittest/googletest/include/gtest/internal/gtest-internal.h which includes
  /usr/include/sys/wait.h which includes
  /usr/include/signal.h which includes
  /usr/include/bits/sigcontext.h which includes
  /usr/include/asm/sigcontext.h which includes
  /usr/include/asm/elf.h

the test could be fixed to include ReaderWriter/ELFLinkingContext.h before
including unittests/DriverTests/DriverTest.h, but dealing with this in the
*.def files is a more-general solution that localizes the fix to the headers
instead of requiring changes to an unbounded number of other source files (both
in-tree and external).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@248957 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/ELFRelocs/PowerPC.def
include/llvm/Support/ELFRelocs/PowerPC64.def