Bug 64839 - libsanitizer shouldn't require <rpc/xdr.h>
Summary: libsanitizer shouldn't require <rpc/xdr.h>
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-28 14:50 UTC by Harald van Dijk
Modified: 2018-11-19 18:57 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-02-10 00:00:00


Attachments
Proposed patch (2.57 KB, patch)
2015-04-10 07:53 UTC, Yury Gribov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Harald van Dijk 2015-01-28 14:50:31 UTC
glibc stopped installing rpc headers by default back in 2011: versions 2.14 and 2.15 never install them, versions 2.16 and higher require the configuration option --enable-obsolete-rpc. Most distros still install the headers for backwards compatibility, but on systems that use default glibc, building libsanitizer, and thus GCC, fails with

    ../../../../gcc/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc:134:21: fatal error: rpc/xdr.h: No such file or directory

Given that libsanitizer doesn't actually use anything from the header other than as a sanity check, the build shouldn't fail if the header is missing.

GCC is configured with

  ../gcc/configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --prefix=$HOME/gcc-run --enable-languages=c,c++

and re-checked today with sources from:

  commit 31aebeec4f215f444c96c0dbc333c4eff3f7809a
  Author: ienkovich <ienkovich@138bc75d-0d04-0410-961f-82ee72b054a4>
  Date:   Wed Jan 28 11:46:44 2015 +0000

Version 4.9.2 builds just fine.
Comment 1 Harald van Dijk 2015-01-29 14:48:56 UTC
FWIW, libsanitizer builds just fine if the rpc references are forcibly removed, like so:

--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
@@ -131,7 +131,6 @@
 #include <netax25/ax25.h>
 #include <netipx/ipx.h>
 #include <netrom/netrom.h>
-#include <rpc/xdr.h>
 #include <scsi/scsi.h>
 #include <sys/mtio.h>
 #include <sys/kd.h>
@@ -1148,19 +1147,6 @@ CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);
 
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
-CHECK_TYPE_SIZE(XDR);
-CHECK_SIZE_AND_OFFSET(XDR, x_op);
-CHECK_SIZE_AND_OFFSET(XDR, x_ops);
-CHECK_SIZE_AND_OFFSET(XDR, x_public);
-CHECK_SIZE_AND_OFFSET(XDR, x_private);
-CHECK_SIZE_AND_OFFSET(XDR, x_base);
-CHECK_SIZE_AND_OFFSET(XDR, x_handy);
-COMPILER_CHECK(__sanitizer_XDR_ENCODE == XDR_ENCODE);
-COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
-COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
-#endif
-
-#if SANITIZER_LINUX && !SANITIZER_ANDROID
 COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
 CHECK_SIZE_AND_OFFSET(FILE, _flags);
 CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);

But that's clearly not acceptable :)
Comment 2 Andrew Pinski 2015-02-10 06:54:50 UTC
Confirmed.
Comment 3 Yury Gribov 2015-03-30 14:01:41 UTC
I've sent fix upstream: http://reviews.llvm.org/D8698 . We'll probably need similar checks for existance of xdr.h in GCC Autoconf.
Comment 4 Yury Gribov 2015-04-09 08:14:21 UTC
Finally fixed upstream in https://github.com/llvm-mirror/compiler-rt/commit/d09b23010698144d10cba0dacc5c599f230cbf62 . Does anyone have time to backport to GCC 5?
Comment 5 Yury Gribov 2015-04-10 07:53:05 UTC
Created attachment 35286 [details]
Proposed patch

Would something like this make sense? If yes, I'll do full round of testing and send to gcc-patches so that we hopefully get it in GCC5.
Comment 6 Jakub Jelinek 2015-04-10 08:04:46 UTC
if test "$ac_cv_header_rpc_xdr_h" = "yes"; then
etc. should be written as
if test x"$ac_cv_header_rpc_xdr_h" = xyes; then
Otherwise, LGTM (patch preapproved), but if you want to get it into GCC 5, commit it RSN (within a few hours).
Comment 7 Yury Gribov 2015-04-13 09:00:27 UTC
Author: ygribov
Date: Mon Apr 13 08:59:55 2015
New Revision: 222043

URL: https://gcc.gnu.org/viewcvs?rev=222043&root=gcc&view=rev
Log:
2015-04-13  Yury Gribov  <y.gribov@samsung.com>

	PR sanitizer/64839

	libsanitizer/
	* sanitizer_common/sanitizer_platform.h: Cherry pick
	upstream r234470.
	* sanitizer_common/sanitizer_platform_limits_posix.cc: Ditto.
	* configure.ac (RPC_DEFS): Check for precense of RPC headers.
	* sanitizer_common/Makefile.am (DEFS): Pass info to compiler.
	* Makefile.in: Regenerate.
	* asan/Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* interception/Makefile.in: Regenerate.
	* libbacktrace/Makefile.in: Regenerate.
	* lsan/Makefile.in: Regenerate.
	* sanitizer_common/Makefile.in: Regenerate.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.in: Regenerate.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/Makefile.in
    trunk/libsanitizer/asan/Makefile.in
    trunk/libsanitizer/config.h.in
    trunk/libsanitizer/configure
    trunk/libsanitizer/configure.ac
    trunk/libsanitizer/interception/Makefile.in
    trunk/libsanitizer/libbacktrace/Makefile.in
    trunk/libsanitizer/lsan/Makefile.in
    trunk/libsanitizer/sanitizer_common/Makefile.am
    trunk/libsanitizer/sanitizer_common/Makefile.in
    trunk/libsanitizer/sanitizer_common/sanitizer_platform.h
    trunk/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
    trunk/libsanitizer/tsan/Makefile.in
    trunk/libsanitizer/ubsan/Makefile.in
Comment 8 Jakub Jelinek 2015-04-13 10:23:49 UTC
Please consider backporting it to gcc-5-branch, but at this point only after 5.1 is released.
Comment 9 Thierry Reding 2015-05-07 13:04:52 UTC
Is there something I can do to help move this along? I've tried to locally backport Yury's changeset to the gcc-5-branch and the only conflict I get is in ChangeLog and that's easy to fix up. I don't have commit access, though, so I can't commit the result.
Comment 10 Yury Gribov 2015-05-09 05:46:49 UTC
Did libsanitizer build for you both with and without xdr.h? If yes, I'll just go ahead and submit this.
Comment 11 Harald van Dijk 2015-05-09 08:36:33 UTC
(In reply to Yury Gribov from comment #10)
> Did libsanitizer build for you both with and without xdr.h? If yes, I'll
> just go ahead and submit this.

I'm using your patch applied to 5.1.0 without issues on my system without xdr.h. If you need someone to confirm that it doesn't break systems that do have it, and don't get feedback from someone else soon enough, I can probably check that in the weekend.
Comment 12 Yury Gribov 2015-05-09 08:39:54 UTC
> I'm using your patch applied to 5.1.0 without issues on my system without xdr.h.

That's probably ok, thanks. I'll submit on Monday then (to be online if problems arise).
Comment 13 Yury Gribov 2015-05-12 07:02:41 UTC
Author: ygribov
Date: Tue May 12 07:02:09 2015
New Revision: 223032

URL: https://gcc.gnu.org/viewcvs?rev=223032&root=gcc&view=rev
Log:
2015-05-12  Yury Gribov  <y.gribov@samsung.com>

	Backport from mainline
	2015-04-13  Yury Gribov  <y.gribov@samsung.com>

	PR sanitizer/64839
	* sanitizer_common/sanitizer_platform.h: Cherry pick
	upstream r234470.
	* sanitizer_common/sanitizer_platform_limits_posix.cc: Ditto.
	* configure.ac (RPC_DEFS): Check for precense of RPC headers.
	* sanitizer_common/Makefile.am (DEFS): Pass info to compiler.
	* Makefile.in: Regenerate.
	* asan/Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* interception/Makefile.in: Regenerate.
	* libbacktrace/Makefile.in: Regenerate.
	* lsan/Makefile.in: Regenerate.
	* sanitizer_common/Makefile.in: Regenerate.
	* tsan/Makefile.in: Regenerate.
	* ubsan/Makefile.in: Regenerate.

Modified:
    branches/gcc-5-branch/libsanitizer/ChangeLog
    branches/gcc-5-branch/libsanitizer/Makefile.in
    branches/gcc-5-branch/libsanitizer/asan/Makefile.in
    branches/gcc-5-branch/libsanitizer/config.h.in
    branches/gcc-5-branch/libsanitizer/configure
    branches/gcc-5-branch/libsanitizer/configure.ac
    branches/gcc-5-branch/libsanitizer/interception/Makefile.in
    branches/gcc-5-branch/libsanitizer/libbacktrace/Makefile.in
    branches/gcc-5-branch/libsanitizer/lsan/Makefile.in
    branches/gcc-5-branch/libsanitizer/sanitizer_common/Makefile.am
    branches/gcc-5-branch/libsanitizer/sanitizer_common/Makefile.in
    branches/gcc-5-branch/libsanitizer/sanitizer_common/sanitizer_platform.h
    branches/gcc-5-branch/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc
    branches/gcc-5-branch/libsanitizer/tsan/Makefile.in
    branches/gcc-5-branch/libsanitizer/ubsan/Makefile.in
Comment 14 Thierry Reding 2015-05-12 10:42:45 UTC
Thanks Yury.
Comment 15 Yury Gribov 2015-05-12 10:44:19 UTC
(In reply to Thierry Reding from comment #14)
> Thanks Yury.

Np, you are welcome.

@Harald: could you close the bug if it works for you?
Comment 16 Geoff Nixon 2015-05-12 11:09:35 UTC
Sorry to be an idiot, but I just ran into this building from the 5.1 release tarball. Is the patch attached to this bug (dated 2015-04-10) what I should use to patch against the release? Or is there a different set of changes specific to the 5.1 branch backport?
Comment 17 Yury Gribov 2015-05-12 11:31:05 UTC
(In reply to Geoff Nixon from comment #16)
> what I should use to patch against the release?
> Or is there a different set of changes
> specific to the 5.1 branch backport?

For 5.1 you'd better use the patch in gcc-5-branch: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=223032
Comment 18 Geoff Nixon 2015-05-12 11:57:53 UTC
Ok thanks, for other idiots like myself who can't seem to figure out how to get viewvc to generate a diff for a specific rev, a -p1 patch is:

svn diff -c 223032 svn://gcc.gnu.org/svn/gcc/branches/gcc-5-branch

Or if you don't have subversion installed, here:
http://gist.github.com/anonymous/7f239960c46240d83a67/raw
Comment 19 Martin Liška 2018-11-19 13:26:03 UTC
Can the bug be marked as resolved?
Comment 20 Harald van Dijk 2018-11-19 18:57:01 UTC
(In reply to Martin Liška from comment #19)
> Can the bug be marked as resolved?

Yes, sorry for missing the earlier request to do so.