Bug 82824 - [8 regression] libsanitizer fails to build: VM_MEMORY_OS_ALLOC_ONCE undefined
Summary: [8 regression] libsanitizer fails to build: VM_MEMORY_OS_ALLOC_ONCE undefined
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 8.0
: P1 normal
Target Milestone: 8.0
Assignee: Rainer Orth
URL: https://gcc.gnu.org/ml/gcc-patches/20...
Keywords:
: 82921 (view as bug list)
Depends on:
Blocks:
 
Reported: 2017-11-03 13:43 UTC by Rainer Orth
Modified: 2019-03-03 04:39 UTC (History)
7 users (show)

See Also:
Host: x86_64-apple-darwin11.4.2
Target: x86_64-apple-darwin11.4.2
Build: x86_64-apple-darwin11.4.2
Known to work:
Known to fail:
Last reconfirmed: 2017-11-09 00:00:00


Attachments
proposed patch (490 bytes, patch)
2017-11-03 13:43 UTC, Rainer Orth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rainer Orth 2017-11-03 13:43:29 UTC
Created attachment 42543 [details]
proposed patch

Since the import of libsanitizer from upstream r315899, it fails to build on
Mac OS X 10.7/Darwin 11:

/vol/gcc/src/hg/trunk/local/libsanitizer/lsan/lsan_common_mac.cc: In function 'void __lsan::ProcessPlatformSpecificAllocations(__lsan::Frontier*)':
/vol/gcc/src/hg/trunk/local/libsanitizer/lsan/lsan_common_mac.cc:158:26: error: 'VM_MEMORY_OS_ALLOC_ONCE' was not declared in this scope
     if (info.user_tag == VM_MEMORY_OS_ALLOC_ONCE) {
                          ^~~~~~~~~~~~~~~~~~~~~~~
/vol/gcc/src/hg/trunk/local/libsanitizer/lsan/lsan_common_mac.cc:158:26: note: suggested alternative: 'VM_MEMORY_MALLOC_HUGE'
     if (info.user_tag == VM_MEMORY_OS_ALLOC_ONCE) {
                          ^~~~~~~~~~~~~~~~~~~~~~~
                          VM_MEMORY_MALLOC_HUGE
make[4]: *** [lsan_common_mac.lo] Error 1

I've found that VM_MEMORY_OS_ALLOC_ONCE is defined in <mach/vm_statistics.h>
since Mac OS X 10.9/Darwin 13.  Wrapping the affected section of code as in the
attached patch allows the build to finish.

Given that I've never had any success getting even the most trivial patches
upstream and have no idea which Darwin versions are supported there, I'm
reporting this here.

  Rainer
Comment 1 Eric Gallager 2017-11-04 11:15:01 UTC
(In reply to Rainer Orth from comment #0)
> 
> Given that I've never had any success getting even the most trivial patches
> upstream and have no idea which Darwin versions are supported there, I'm
> reporting this here.
> 
>   Rainer

Apparently 10.6/Darwin 11 isn't supported either; see bug 82829. As I said there, it'd really be nice to have a --disable-libsanitizer configure flag for whenever upstream breaks stuff again
Comment 2 ro@CeBiTec.Uni-Bielefeld.DE 2017-11-06 14:36:26 UTC
> --- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
[...]
> Apparently 10.6/Darwin 11 isn't supported either; see bug 82829. As I said

I couldn't find an explicit statement of support (or non-support) for
LLVM on Darwin.  However, we could either try to get patches upstream
or keep them gcc-local if they are as trivial as those two.

> there, it'd really be nice to have a --disable-libsanitizer configure flag for
> whenever upstream breaks stuff again

Your wish has already been granted: for most if not all target
libraries, there's already a --disable-libX/--enable-libX switch,
libsanitizer included.

However, this isn't the right way to handle this: if it's really
concluded that libsanitizer isn't supported on certain Darwin versions,
this should be handled in libsanitizer/configure.tgt so users don't get
failing bootstraps without non-default options.

	Rainer
Comment 3 Eric Gallager 2017-11-06 15:39:00 UTC
(In reply to ro@CeBiTec.Uni-Bielefeld.DE from comment #2)
> > --- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
> [...]
> > Apparently 10.6/Darwin 11 isn't supported either; see bug 82829. As I said
> 
> I couldn't find an explicit statement of support (or non-support) for
> LLVM on Darwin.  However, we could either try to get patches upstream
> or keep them gcc-local if they are as trivial as those two.
> 
> > there, it'd really be nice to have a --disable-libsanitizer configure flag
> > for whenever upstream breaks stuff again
> 
> Your wish has already been granted: for most if not all target
> libraries, there's already a --disable-libX/--enable-libX switch,
> libsanitizer included.

Really? It doesn't show up in the ./configure --help output:

Local-Admins-MacBook-Pro:gcc ericgallager$ ./configure --help=recursive | grep -i sanit
Report bugs to <libsanitizer>.
Local-Admins-MacBook-Pro:gcc ericgallager$

> 
> However, this isn't the right way to handle this: if it's really
> concluded that libsanitizer isn't supported on certain Darwin versions,
> this should be handled in libsanitizer/configure.tgt so users don't get
> failing bootstraps without non-default options.
> 
> 	Rainer
Comment 4 ro@CeBiTec.Uni-Bielefeld.DE 2017-11-06 15:42:20 UTC
> --- Comment #3 from Eric Gallager <egallager at gcc dot gnu.org> ---
[...]
> Really? It doesn't show up in the ./configure --help output:
>
> Local-Admins-MacBook-Pro:gcc ericgallager$ ./configure --help=recursive | grep
> -i sanit
> Report bugs to <libsanitizer>.

Sure: check for able_lib in configure.  Not everything that's not
documented doesn't exist ;-)

	Rainer
Comment 5 Andrew Pinski 2017-11-09 17:04:39 UTC
*** Bug 82921 has been marked as a duplicate of this bug. ***
Comment 6 ro@CeBiTec.Uni-Bielefeld.DE 2017-11-10 09:19:17 UTC
I've now submitted the patch upstream: https://reviews.llvm.org/D39888.
Let's see how this goes.

	Rainer
Comment 7 Dominique d'Humieres 2017-11-12 19:10:20 UTC
> I've now submitted the patch upstream: https://reviews.llvm.org/D39888.

This patch allowed to bootstrap gcc on darwin10, but running the test suite gave me ~2500 asan failures (gcc/g++, -m32/-m64) of the kind

dyld: Symbol not found: _strndup
  Referenced from: /opt/gcc/gcc8w/lib/libasan.5.dylib
  Expected in: flat namespace
 in /opt/gcc/gcc8w/lib/libasan.5.dylib
Trace/BPT trap
Comment 8 ro@CeBiTec.Uni-Bielefeld.DE 2017-11-12 19:29:14 UTC
> --- Comment #7 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
>> I've now submitted the patch upstream: https://reviews.llvm.org/D39888.
>
> This patch allowed to bootstrap gcc on darwin10, but running the test suite
> gave me ~2500 asan failures (gcc/g++, -m32/-m64) of the kind
>
> dyld: Symbol not found: _strndup
>   Referenced from: /opt/gcc/gcc8w/lib/libasan.5.dylib
>   Expected in: flat namespace
>  in /opt/gcc/gcc8w/lib/libasan.5.dylib
> Trace/BPT trap

It seems there's no point in trying: compiler-rt's cmake/config-ix.cmake
requires Mac OS X 10.7/Darwin 11 and up for the sanitizers.  I guess all
we can do is disable them (or perhaps only asan) in the gcc tree
(libsanitizer/configure.tgt).

	Rainer
Comment 9 Rainer Orth 2017-11-14 10:45:56 UTC
Patch posted.
Comment 10 Rainer Orth 2018-01-13 16:08:39 UTC
Revised patch posted.
Comment 11 Dominique d'Humieres 2018-01-13 16:50:40 UTC
> Revised patch posted.

Where?
Comment 12 ro@CeBiTec.Uni-Bielefeld.DE 2018-01-13 16:52:17 UTC
See the PR URL fieldd.
Comment 13 Dominique d'Humieres 2018-01-13 17:25:06 UTC
> See the PR URL fieldd.

Found, thanks!

Out of curiosity, why 73 in 'kSanitizerVmMemoryOsAllocOnce = 73'?
Comment 14 ro@CeBiTec.Uni-Bielefeld.DE 2018-01-13 17:27:30 UTC
That's the value of VM_MEMORY_OS_ALLOC_ONCE on Mac OS X 10.9 and up.
Comment 15 Dominique d'Humieres 2018-01-13 17:42:13 UTC
> That's the value of VM_MEMORY_OS_ALLOC_ONCE on Mac OS X 10.9 and up.

Thanks!
Comment 16 Rainer Orth 2018-01-13 21:01:58 UTC
Author: ro
Date: Sat Jan 13 21:01:27 2018
New Revision: 256650

URL: https://gcc.gnu.org/viewcvs?rev=256650&root=gcc&view=rev
Log:
Allow for lack of VM_MEMORY_OS_ALLOC_ONCE on Mac OS X (PR sanitizer/82824)

	PR sanitizer/82824
	* lsan/lsan_common_mac.cc: Cherry-pick upstream r322437.

Modified:
    trunk/libsanitizer/ChangeLog
    trunk/libsanitizer/lsan/lsan_common_mac.cc
Comment 17 Rainer Orth 2018-01-13 21:03:07 UTC
Fixed for GCC 8.1.