Skip to content

Commit 89d636b

Browse files
authored
[Support] Fix building on FreeBSD and OpenBSD (#127005)
Fix building after a6f7cb5. Check for the function getauxval() instead of just the sys/auxv.h header.
1 parent 30a9941 commit 89d636b

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

llvm/cmake/config-ix.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ if (ANDROID OR CYGWIN OR CMAKE_SYSTEM_NAME MATCHES "AIX|DragonFly|FreeBSD|Haiku|
2121
set(HAVE_MACH_MACH_H 0)
2222
set(HAVE_MALLOC_MALLOC_H 0)
2323
set(HAVE_PTHREAD_H 1)
24-
set(HAVE_SYS_AUXV_H 1)
2524
set(HAVE_SYS_MMAN_H 1)
2625
set(HAVE_SYSEXITS_H 1)
2726
set(HAVE_UNISTD_H 1)
@@ -53,7 +52,6 @@ else()
5352
check_include_file(mach/mach.h HAVE_MACH_MACH_H)
5453
check_include_file(malloc/malloc.h HAVE_MALLOC_MALLOC_H)
5554
check_include_file(pthread.h HAVE_PTHREAD_H)
56-
check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
5755
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
5856
check_include_file(sysexits.h HAVE_SYSEXITS_H)
5957
check_include_file(unistd.h HAVE_UNISTD_H)
@@ -321,6 +319,7 @@ check_symbol_exists(getrusage sys/resource.h HAVE_GETRUSAGE)
321319
check_symbol_exists(isatty unistd.h HAVE_ISATTY)
322320
check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
323321
check_symbol_exists(futimes sys/time.h HAVE_FUTIMES)
322+
check_symbol_exists(getauxval sys/auxv.h HAVE_GETAUXVAL)
324323
# AddressSanitizer conflicts with lib/Support/Unix/Signals.inc
325324
# Avoid sigaltstack on Apple platforms, where backtrace() cannot handle it
326325
# (rdar://7089625) and _Unwind_Backtrace is unusable because it cannot unwind

llvm/include/llvm/Config/config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,6 @@
295295

296296
#cmakedefine HAVE_BUILTIN_THREAD_POINTER ${HAVE_BUILTIN_THREAD_POINTER}
297297

298-
#cmakedefine HAVE_SYS_AUXV_H ${HAVE_SYS_AUXV_H}
298+
#cmakedefine HAVE_GETAUXVAL ${HAVE_GETAUXVAL}
299299

300300
#endif

llvm/lib/Support/Unix/Process.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#ifdef HAVE_MALLOC_MALLOC_H
3232
#include <malloc/malloc.h>
3333
#endif
34-
#ifdef HAVE_SYS_AUXV_H
34+
#ifdef HAVE_GETAUXVAL
3535
#include <sys/auxv.h>
3636
#endif
3737

@@ -66,7 +66,7 @@ Process::Pid Process::getProcessId() {
6666
// On Cygwin, getpagesize() returns 64k(AllocationGranularity) and
6767
// offset in mmap(3) should be aligned to the AllocationGranularity.
6868
Expected<unsigned> Process::getPageSize() {
69-
#if defined(HAVE_SYS_AUXV_H)
69+
#if defined(HAVE_GETAUXVAL)
7070
static const int page_size = ::getauxval(AT_PAGESZ);
7171
#elif defined(HAVE_GETPAGESIZE)
7272
static const int page_size = ::getpagesize();

0 commit comments

Comments
 (0)