[profile] Only use NT_GNU_BUILD_ID if supported
authorRainer Orth <ro@gcc.gnu.org>
Fri, 6 Aug 2021 12:04:11 +0000 (14:04 +0200)
committerRainer Orth <ro@gcc.gnu.org>
Fri, 6 Aug 2021 12:04:11 +0000 (14:04 +0200)
commit779714f89bef33f153841b7ec969578ee22b3694
tree031313bcde90b139b56e52cc60ebff0f54ebdbce
parentae1a2a09e41ee7464e785e8925f360f256d0eaca
[profile] Only use NT_GNU_BUILD_ID if supported

The Solaris buildbots have been broken for some time by the unconditional
use of `NT_GNU_BUILD_ID`, e.g. Solaris/sparcv9
<https://lab.llvm.org/staging/#/builders/50/builds/4910> and Solaris/amd64
<https://lab.llvm.org/staging/#/builders/101/builds/3751>.  Being a GNU
extension, it is not defined in `<sys/elf.h>`.  However, providing a
fallback definition doesn't help because the code also relies on
`__ehdr_start`, another unportable GNU extension that most likely never
will be implemented in Solaris `ld`.  Besides, there's reallly no point in
supporting build ids since they aren't used on Solaris at all.

This patch fixes this by making the relevant code conditional on the
definition of `NT_GNU_BUILD_ID`.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Differential Revision: https://reviews.llvm.org/D107556
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c