[PATCH] D107556: [profile] Only use NT_GNU_BUILD_ID if supported

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 5 04:50:18 PDT 2021


ro created this revision.
ro added reviewers: gulfem, davidxl.
Herald added subscribers: fedor.sergeev, jyknight.
ro requested review of this revision.
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

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 make the relevant code conditional on the definition of
`NT_GNU_BUILD_ID`.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107556

Files:
  compiler-rt/lib/profile/InstrProfilingPlatformLinux.c


Index: compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
===================================================================
--- compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -85,6 +85,7 @@
 COMPILER_RT_VISIBILITY ValueProfNode *CurrentVNode = &PROF_VNODES_START;
 COMPILER_RT_VISIBILITY ValueProfNode *EndVNode = &PROF_VNODES_STOP;
 
+#ifdef NT_GNU_BUILD_ID
 static size_t RoundUp(size_t size, size_t align) {
   return (size + align - 1) & ~(align - 1);
 }
@@ -188,5 +189,10 @@
 
   return 0;
 }
+#else /* !NT_GNU_BUILD_ID */
+COMPILER_RT_VISIBILITY int __llvm_write_binary_ids(ProfDataWriter *Writer) {
+  return 0;
+}
+#endif
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107556.364417.patch
Type: text/x-patch
Size: 713 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210805/2c03e351/attachment.bin>


More information about the llvm-commits mailing list