summaryrefslogtreecommitdiff
blob: ca871c37b994a2d3e28904fd7fa23c2fc22ffb68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From e198d21b9a5851dbc061f60911e3b3da910bca0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Wed, 6 Jun 2018 12:16:38 +0200
Subject: [PATCH 7/8] [sanitizer_common] Fix using libtirpc on Linux

Fix using libtirpc on Linux by using pkg-config to detect it, and append
appropriate include directory.  The libtirpc headers reference one
another via '#include <rpc/...>', so attempting to include it via
'#include <tirpc/...>' just failed and resulted in RPC headers not being
detected at all.

Additionally, perform the header check without -nodefaultlibs as that
apparently causes it to fail.
---
 lib/sanitizer_common/CMakeLists.txt                   | 11 ++++++++++-
 .../sanitizer_platform_limits_posix.cc                |  4 +---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt
index e0226ae49..4071bc0e8 100644
--- a/lib/sanitizer_common/CMakeLists.txt
+++ b/lib/sanitizer_common/CMakeLists.txt
@@ -151,9 +151,18 @@ include_directories(..)
 
 set(SANITIZER_COMMON_DEFINITIONS)
 
+include(FindPkgConfig)
+pkg_check_modules(TIRPC libtirpc)
+if (TIRPC_FOUND)
+  include_directories(${TIRPC_INCLUDE_DIRS})
+  set(CMAKE_REQUIRED_INCLUDES ${TIRPC_INCLUDE_DIRS})
+endif()
+
 include(CheckIncludeFile)
+cmake_push_check_state()
+string(REPLACE "-nodefaultlibs" "" CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
 append_have_file_definition(rpc/xdr.h HAVE_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
-append_have_file_definition(tirpc/rpc/xdr.h HAVE_TIRPC_RPC_XDR_H SANITIZER_COMMON_DEFINITIONS)
+cmake_pop_check_state()
 
 set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
 append_rtti_flag(OFF SANITIZER_CFLAGS)
diff --git a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
index feb7bad6f..2e736ee26 100644
--- a/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/lib/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -146,8 +146,6 @@ typedef struct user_fpregs elf_fpregset_t;
 #include <netrom/netrom.h>
 #if HAVE_RPC_XDR_H
 # include <rpc/xdr.h>
-#elif HAVE_TIRPC_RPC_XDR_H
-# include <tirpc/rpc/xdr.h>
 #endif
 #include <scsi/scsi.h>
 #include <sys/mtio.h>
@@ -1236,7 +1234,7 @@ CHECK_SIZE_AND_OFFSET(group, gr_passwd);
 CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);
 
-#if HAVE_RPC_XDR_H || HAVE_TIRPC_RPC_XDR_H
+#if HAVE_RPC_XDR_H
 CHECK_TYPE_SIZE(XDR);
 CHECK_SIZE_AND_OFFSET(XDR, x_op);
 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
-- 
2.18.0