[llvm-branch-commits] [compiler-rt] 6f58e54 - Work around non-existence of ElfW(type) macro on FreeBSD

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 5 10:06:47 PDT 2021


Author: Dimitry Andric
Date: 2021-08-05T10:06:16-07:00
New Revision: 6f58e54d655d0167f3b7d55e35c9806854307204

URL: https://github.com/llvm/llvm-project/commit/6f58e54d655d0167f3b7d55e35c9806854307204
DIFF: https://github.com/llvm/llvm-project/commit/6f58e54d655d0167f3b7d55e35c9806854307204.diff

LOG: Work around non-existence of ElfW(type) macro on FreeBSD

Fixes PR51331. On FreeBSD, the elf headers don't (yet) provide the
ElfW(type) macro. However, there is a similar set of macros in the
<sys/elf-generic.h> header, of which `__ElfN(type)` exactly matches the
indended purpose.

Reviewed By: gulfem

Differential Revision: https://reviews.llvm.org/D107388

(cherry picked from commit 440d9712ebf6d5faa898daa68045ff0c10859db3)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
index 508624a80cd66..d1922e27ae1d0 100644
--- a/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ b/compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -17,6 +17,15 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingInternal.h"
 
+#if defined(__FreeBSD__) && !defined(ElfW)
+/*
+ * FreeBSD's elf.h and link.h headers do not define the ElfW(type) macro yet.
+ * If this is added to all supported FreeBSD versions in the future, this
+ * compatibility macro can be removed.
+ */
+#define ElfW(type) __ElfN(type)
+#endif
+
 #define PROF_DATA_START INSTR_PROF_SECT_START(INSTR_PROF_DATA_COMMON)
 #define PROF_DATA_STOP INSTR_PROF_SECT_STOP(INSTR_PROF_DATA_COMMON)
 #define PROF_NAME_START INSTR_PROF_SECT_START(INSTR_PROF_NAME_COMMON)


        


More information about the llvm-branch-commits mailing list