Re: (VAX) cc0 anyone? (was: [PATCH 0/2] Fixes for old version NetBSD targets)

2020-11-17 Thread Kamil Rytarowski
On 17.11.2020 04:49, Hans-Peter Nilsson wrote:
> On Sun, 15 Nov 2020, Maciej W. Rozycki wrote:
> 
>> Hi,
>>
>>  In the course of my recent VAX backend modernisation effort
> 
> Hi.  That reminds me that VAX is "still" a cc0 target.
> 
> Are you aware of anyone planning on that level of modernization?
> 
> More than a year ago, there was a major heads-up that all
> remaining cc0 targets would be "retired" in the next release.
> 
> Now, I'm thinking that was just an empty threat. 0:-)
> 
> brgds, H-P
> PS. not volunteering, sorry.
> 

The "VAX backend modernisation effort" means upgrading out of cc0.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-06 Thread Kamil Rytarowski
On 06.05.2020 22:25, Andreas Tobler wrote:
> On 06.05.20 22:12, Jakub Jelinek wrote:
>> On Wed, May 06, 2020 at 09:54:47PM +0200, Andreas Tobler wrote:
>>> --- a/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
>>> +++ b/gcc/testsuite/gcc.dg/analyzer/alloca-leak.c
>>> @@ -1,5 +1,6 @@
>>> -#include 
>>> -
>>> +#include 
>>
>> It needs to be:
>>> +#if __has_include()
>>
>> +#include 
>>
>>> +#endif
> 
> Doh :(
> 
> Fixed, thanks.
> 
>> __has_include doesn't include anything, just checks if the header is
>> available.
> 
> Then I just wonder why the tests passed on Linux (ubuntu-20.04)
> 

alloca.h is only needed on solaris. Other system can use stdlib.h.

> Andreas




signature.asc
Description: OpenPGP digital signature


Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-04 Thread Kamil Rytarowski
On 04.05.2020 12:04, Jakub Jelinek wrote:
> On Mon, May 04, 2020 at 11:49:27AM +0200, Kamil Rytarowski wrote:
>>>> Please include in your patch "|| defined(__NetBSD__)".
>>>
>>> is this ok for you?
>>>
>>> This is one reason why I'd prefer #define alloca __builtin_alloca and
>>> leave the include away.
>>>
>>> Andreas
>>
>> It looks fine to me now.
>>
>> Personally, I would include stdlib.h unconditionally and alloca.h on
>> !FreeBSD && !NetBSD.
> 
> It just just a test.
> Perhaps it could
> #include 
> #if __has_include()
> #include 
> #endif
> ?
> 
>   Jakub
> 

This looks fine too.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-04 Thread Kamil Rytarowski
On 03.05.2020 22:31, Andreas Tobler wrote:
> On 03.05.20 18:27, Kamil Rytarowski wrote:
>> On 01.05.2020 21:49, Andreas Tobler wrote:
>>> Hi all,
>>>
>>> FreeBSD does not have the alloca.h header. Do not include it in the test
>>> cases which do include alloca.h.
>>>
>>> There are two versions of this patch available, the one attached which
>>> uses ifdef or another one which defines alloca with __builtin_alloca.
>>>
>>> I tested both approaches and they work on FreeBSD. I do not know which
>>> one you prefer.
>>>
>>> Opinions welcome.
>>>
>>> Ok for trunk?
>>> TIA,
>>> Andreas
>>
>> Please include in your patch "|| defined(__NetBSD__)".
> 
> is this ok for you?
> 
> This is one reason why I'd prefer #define alloca __builtin_alloca and
> leave the include away.
> 
> Andreas

It looks fine to me now.

Personally, I would include stdlib.h unconditionally and alloca.h on
!FreeBSD && !NetBSD.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] testsuite:analyzer: Fix header include for FreeBSD

2020-05-03 Thread Kamil Rytarowski
On 01.05.2020 21:49, Andreas Tobler wrote:
> Hi all,
> 
> FreeBSD does not have the alloca.h header. Do not include it in the test
> cases which do include alloca.h.
> 
> There are two versions of this patch available, the one attached which
> uses ifdef or another one which defines alloca with __builtin_alloca.
> 
> I tested both approaches and they work on FreeBSD. I do not know which
> one you prefer.
> 
> Opinions welcome.
> 
> Ok for trunk?
> TIA,
> Andreas

Please include in your patch "|| defined(__NetBSD__)".



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] Rearrange detection of temporary directory for NetBSD

2020-03-25 Thread Kamil Rytarowski
On 25.03.2020 23:36, Jeff Law wrote:
> On Wed, 2020-03-18 at 20:29 +0100, Kamil Rytarowski wrote:
>> Set /tmp first, then /var/tmp. /tmp is volatile on NetBSD and
>> /var/tmp not. This improves performance in the common use.
>> The downstream copy of GCC was patched for this preference
>> since 2015.
>>
>> Remove occurence of /usr/tmp as it was never valid for NetBSD.
>> It was already activey disabled in the GCC manual page in 1996 and
>> in the GCC source code at least in 1998.
>>
>> This change is not a matter of user-preference but Operating
>> System defaults that disagree with the libiberty detection plan.
>>
>> No functional change for other Operataing Systems/environments.
>>
>> libiberty/ChangeLog:
>>
>>  * make-temp-file.c (choose_tmpdir): Honor NetBSD specific paths.
>> ---
>>  libiberty/ChangeLog| 4 
>>  libiberty/make-temp-file.c | 8 +++-
>>  2 files changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
>> index 106c107e91a..18b9357aaed 100644
>> --- a/libiberty/ChangeLog
>> +++ b/libiberty/ChangeLog
>> @@ -1,3 +1,7 @@
>> +2020-03-18  Kamil Rytarowski  
>> +
>> +* make-temp-file.c (choose_tmpdir): Honor NetBSD specific paths.
> I'd strongly recommend against this as-is.
>
> The whole reason we prefer /var/tmp is because it's often dramatically larger
> than a ram-backed /tmp.
>

NetBSD supports swap whenever /tmp is too small. Whenever tmpfs+ram are
too small, users use /tmp that is a regular directory (if I am not
wrong, this is still the default setup from an installer).

In NetBSD we want to use a non-persistent storage for performance
reasons. /var/tmp also affects negatively modern SSD devices with
needless writes.

It would be enough to get these try_dir paths tuned at least from
preprocessor during libiberty build for gdb/gcc/etc.

> I wouldn't mind dropping /usr/tmp.  That so antiquated that it'd be non-
> controversial.  Can you send that as a separate patch.
>

Behavior for !__NetBSD__ is out of interest.

> Jeff
>>
>



[PATCH] Rearrange detection of temporary directory for NetBSD

2020-03-18 Thread Kamil Rytarowski
Set /tmp first, then /var/tmp. /tmp is volatile on NetBSD and
/var/tmp not. This improves performance in the common use.
The downstream copy of GCC was patched for this preference
since 2015.

Remove occurence of /usr/tmp as it was never valid for NetBSD.
It was already activey disabled in the GCC manual page in 1996 and
in the GCC source code at least in 1998.

This change is not a matter of user-preference but Operating
System defaults that disagree with the libiberty detection plan.

No functional change for other Operataing Systems/environments.

libiberty/ChangeLog:

* make-temp-file.c (choose_tmpdir): Honor NetBSD specific paths.
---
 libiberty/ChangeLog| 4 
 libiberty/make-temp-file.c | 8 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 106c107e91a..18b9357aaed 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,7 @@
+2020-03-18  Kamil Rytarowski  
+
+   * make-temp-file.c (choose_tmpdir): Honor NetBSD specific paths.
+
 2020-03-05  Egeyar Bagcioglu  

* simple-object.c (handle_lto_debug_sections): Name
diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c
index cb08c27af6f..674333f042b 100644
--- a/libiberty/make-temp-file.c
+++ b/libiberty/make-temp-file.c
@@ -129,10 +129,16 @@ choose_tmpdir (void)
base = try_dir (P_tmpdir, base);
 #endif

-  /* Try /var/tmp, /usr/tmp, then /tmp.  */
+#if defined(__NetBSD__)
+  /* Try /tmp (volatile), then /var/tmp (non-volatile) on NetBSD.  */
+  base = try_dir (tmp, base);
+  base = try_dir (vartmp, base);
+#else
+  /* For others try /var/tmp, /usr/tmp, then /tmp.  */
   base = try_dir (vartmp, base);
   base = try_dir (usrtmp, base);
   base = try_dir (tmp, base);
+#endif

   /* If all else fails, use the current directory!  */
   if (base == 0)
--
2.25.0



Re: [PATCH]: gcc: Enable bits for sanitizer support on FreeBSD x86_64

2020-01-22 Thread Kamil Rytarowski
On 22.01.2020 22:27, Andreas Tobler wrote:
> Hi all,
> 
> this patch adds the necessary bits to enable asan support on FreeBSD
> x86_64.
> Results will be produced over night.
> 
> Ok for trunk once it is open again?
> TIA,
> Andreas
> 
> gcc/
> 
>   * config/i386/i386.h: Define a new macro: SUBTARGET_SHADOW_OFFSET.
>   * config/i386/i386.c (ix86_asan_shadow_offset): Use this macro.
>   * config/i386/darwin.h: Override the SUBTARGET_SHADOW_OFFSET macro.
>   * config/i386/freebsd.h: Likewise.
>   * config/freebsd.h (LIBASAN_EARLY_SPEC): Define.
>   LIBTSAN_EARLY_SPEC): Likewise. (LIBLSAN_EARLY_SPEC): Likewise.
> 
> libsanitizer:
> 
>   * configure.tgt: Add x86_64- and i?86-*-freebsd* targets.
>   * asan/asan_interceptors.h: Define ASAN_INTERCEPT_SWAPCONTEXT for
>   FreeBSD.
> 

Please push the libsanitizer change through LLVM compiler-rt. There was
a contract to submit all patches there and merge in GCC.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

2020-01-14 Thread Kamil Rytarowski
On 10.01.2020 17:11, Jonathan Wakely wrote:
> On 07/01/20 12:44 -0800, Jason Thorpe wrote:
>>
>>> On Jan 7, 2020, at 7:43 AM, Jonathan Wakely  wrote:
>>>
>>> For Jason and Krister's benefit, that last comment was referring to
>>> an earlier suggestion to not try to support old NetBSD releases, see
>>> https://gcc.gnu.org/ml/libstdc++/2020-01/msg00026.html
>>>
 I think we need the netbsd target maintainers (CC'd) to decide whether
 GCC should still support older releases or drop that support for GCC
 10. Usually I'd say we need a period of deprecation, but if GCC
 doesn't currently build on NetBSD then maybe that's unnecessary.
>>
>> The affected NetBSD versions are NetBSD 6 and earlier, which are EOL
>> from the NetBSD perspective, so I think this is OK.
> 
> So is this patch OK then?
> 

Looks good to me.

> Could somebody please test it on NetBSD? (Ideally on the oldest
> supported release, but anything is better than nothing).
> 

Works for me on:

$ uname -a
NetBSD chieftec 9.99.37 NetBSD 9.99.37 (GENERIC) #5: Mon Jan 13 15:39:58
CET 2020
root@chieftec:/public/netbsd-root/sys/arch/amd64/compile/GENERIC amd64

I see no reason why would it break on older releases, but I don't have
them handy for tests.

> This differs from the patches posted by using _CTYPE_BL for the
> isblank class, which seems better than using _CTYPE_S.
> 
> 

_CTYPE_BL is the right bit for isblank().



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

2020-01-06 Thread Kamil Rytarowski
On 07.01.2020 01:28, Jonathan Wakely wrote:
> On 07/01/20 00:18 +0100, Kamil Rytarowski wrote:
>> On 06.01.2020 16:34, Jonathan Wakely wrote:
>>> On 22/12/19 09:36 +1000, Gerald Pfeifer wrote:
>>>> Hi Matthew,
>>>>
>>>> On Mon, 4 Feb 2019, Matthew Bauer wrote:
>>>>> The ctype_base.h file in libstdc++-v3 is out of date for NetBSD. They
>>>>> have changed their ctype.h definition. It was updated in their intree
>>>>> libstdc++-v3 but not in the GCC one. My understanding is this is a
>>>>> straightforward rewrite. I've attached my own patch, but the file can
>>>>> be obtained directly here:
>>>>>
>>>>> http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libstdc%2b%2b-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>
>>>>>
>>>>>
>>>>> With the attached patch, libstdc++-v3 can succesfully be built with
>>>>> NetBSD headers (along with --disable-libcilkrts).
>>>>
>>>> I noticed this has not been applied yet, nor seen a follow-up?, and
>>>> also
>>>> noticed it went to the gcc-patches list, but not libstd...@gcc.gnu.org.
>>>>
>>>> Let me re-address this to libstd...@gcc.gnu.org in the hope the
>>>> maintainers there will have a look.
>>>>
>>>> Gerald
>>>
>>>> diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> index ff3ec893974..21eccf9fde1 100644
>>>> --- a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> +++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> @@ -38,40 +38,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>>   /// @brief  Base class for ctype.
>>>>   struct ctype_base
>>>>   {
>>>> -    // Non-standard typedefs.
>>>> -    typedef const unsigned char*    __to_type;
>>>>
>>>>     // NB: Offsets into ctype::_M_table force a particular size
>>>>     // on the mask type. Because of this, we don't use an enum.
>>>> -    typedef unsigned char  mask;
>>>>
>>>> #ifndef _CTYPE_U
>>>> -    static const mask upper    = _U;
>>>> -    static const mask lower = _L;
>>>> -    static const mask alpha = _U | _L;
>>>> -    static const mask digit = _N;
>>>> -    static const mask xdigit = _N | _X;
>>>> -    static const mask space = _S;
>>>> -    static const mask print = _P | _U | _L | _N | _B;
>>>> -    static const mask graph = _P | _U | _L | _N;
>>>> -    static const mask cntrl = _C;
>>>> -    static const mask punct = _P;
>>>> -    static const mask alnum = _U | _L | _N;
>>>> +    // Non-standard typedefs.
>>>> +    typedef const unsigned char*    __to_type;
>>>> +
>>>> +    typedef unsigned char    mask;
>>>> +
>>>> +    static const mask upper    = _U;
>>>> +    static const mask lower    = _L;
>>>> +    static const mask alpha    = _U | _L;
>>>> +    static const mask digit    = _N;
>>>> +    static const mask xdigit    = _N | _X;
>>>> +    static const mask space    = _S;
>>>> +    static const mask print    = _P | _U | _L | _N | _B;
>>>> +    static const mask graph    = _P | _U | _L | _N;
>>>> +    static const mask cntrl    = _C;
>>>> +    static const mask punct    = _P;
>>>> +    static const mask alnum    = _U | _L | _N;
>>>> #else
>>>> -    static const mask upper    = _CTYPE_U;
>>>> -    static const mask lower = _CTYPE_L;
>>>> -    static const mask alpha = _CTYPE_U | _CTYPE_L;
>>>> -    static const mask digit = _CTYPE_N;
>>>> -    static const mask xdigit = _CTYPE_N | _CTYPE_X;
>>>> -    static const mask space = _CTYPE_S;
>>>> -    static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>>>> _CTYPE_N | _CTYPE_B;
>>>> -    static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>>>> _CTYPE_N;
>>>> -    static const mask cntrl = _CTYPE_C;
>>>> -    static const mask punct = _CTYPE_P;
>>>> -    static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
>>>> +    typedef const unsigned short*    __to_type;
>>>> +
>>>> +    typedef unsig

Re: [PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

2020-01-06 Thread Kamil Rytarowski
On 07.01.2020 01:26, Jonathan Wakely wrote:
> On 06/01/20 23:20 +0100, Kamil Rytarowski wrote:
>> On 06.01.2020 16:24, Jonathan Wakely wrote:
>>> On 22/12/19 09:36 +1000, Gerald Pfeifer wrote:
>>>> Hi Matthew,
>>>>
>>>> On Mon, 4 Feb 2019, Matthew Bauer wrote:
>>>>> The ctype_base.h file in libstdc++-v3 is out of date for NetBSD. They
>>>>> have changed their ctype.h definition. It was updated in their intree
>>>>> libstdc++-v3 but not in the GCC one. My understanding is this is a
>>>>> straightforward rewrite. I've attached my own patch, but the file can
>>>>> be obtained directly here:
>>>>>
>>>>> http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libstdc%2b%2b-v3/config/os/bsd/netbsd/ctype_base.h
>>>>>
>>>>>
>>>>>
>>>>> With the attached patch, libstdc++-v3 can succesfully be built with
>>>>> NetBSD headers (along with --disable-libcilkrts).
>>>>
>>>> I noticed this has not been applied yet, nor seen a follow-up?, and
>>>> also
>>>> noticed it went to the gcc-patches list, but not libstd...@gcc.gnu.org.
>>>>
>>>> Let me re-address this to libstd...@gcc.gnu.org in the hope the
>>>> maintainers there will have a look.
>>>>
>>>> Gerald
>>>
>>>> diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> index ff3ec893974..21eccf9fde1 100644
>>>> --- a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> +++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>>>> @@ -38,40 +38,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>>>   /// @brief  Base class for ctype.
>>>>   struct ctype_base
>>>>   {
>>>> -    // Non-standard typedefs.
>>>> -    typedef const unsigned char*    __to_type;
>>>>
>>>>     // NB: Offsets into ctype::_M_table force a particular size
>>>>     // on the mask type. Because of this, we don't use an enum.
>>>> -    typedef unsigned char  mask;
>>>>
>>>> #ifndef _CTYPE_U
>>>> -    static const mask upper    = _U;
>>>> -    static const mask lower = _L;
>>>> -    static const mask alpha = _U | _L;
>>>> -    static const mask digit = _N;
>>>> -    static const mask xdigit = _N | _X;
>>>> -    static const mask space = _S;
>>>> -    static const mask print = _P | _U | _L | _N | _B;
>>>> -    static const mask graph = _P | _U | _L | _N;
>>>> -    static const mask cntrl = _C;
>>>> -    static const mask punct = _P;
>>>> -    static const mask alnum = _U | _L | _N;
>>>> +    // Non-standard typedefs.
>>>> +    typedef const unsigned char*    __to_type;
>>>> +
>>>> +    typedef unsigned char    mask;
>>>> +
>>>> +    static const mask upper    = _U;
>>>> +    static const mask lower    = _L;
>>>> +    static const mask alpha    = _U | _L;
>>>> +    static const mask digit    = _N;
>>>> +    static const mask xdigit    = _N | _X;
>>>> +    static const mask space    = _S;
>>>> +    static const mask print    = _P | _U | _L | _N | _B;
>>>> +    static const mask graph    = _P | _U | _L | _N;
>>>> +    static const mask cntrl    = _C;
>>>> +    static const mask punct    = _P;
>>>> +    static const mask alnum    = _U | _L | _N;
>>>> #else
>>>> -    static const mask upper    = _CTYPE_U;
>>>> -    static const mask lower = _CTYPE_L;
>>>> -    static const mask alpha = _CTYPE_U | _CTYPE_L;
>>>> -    static const mask digit = _CTYPE_N;
>>>> -    static const mask xdigit = _CTYPE_N | _CTYPE_X;
>>>> -    static const mask space = _CTYPE_S;
>>>> -    static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>>>> _CTYPE_N | _CTYPE_B;
>>>> -    static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>>>> _CTYPE_N;
>>>> -    static const mask cntrl = _CTYPE_C;
>>>> -    static const mask punct = _CTYPE_P;
>>>> -    static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
>>>> +    typedef const unsigned short*    __to_type;
>>>> +
>>>> +    typedef unsigned short    mask;
>>&g

Re: [PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

2020-01-06 Thread Kamil Rytarowski
On 06.01.2020 16:34, Jonathan Wakely wrote:
> On 22/12/19 09:36 +1000, Gerald Pfeifer wrote:
>> Hi Matthew,
>>
>> On Mon, 4 Feb 2019, Matthew Bauer wrote:
>>> The ctype_base.h file in libstdc++-v3 is out of date for NetBSD. They
>>> have changed their ctype.h definition. It was updated in their intree
>>> libstdc++-v3 but not in the GCC one. My understanding is this is a
>>> straightforward rewrite. I've attached my own patch, but the file can
>>> be obtained directly here:
>>>
>>> http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libstdc%2b%2b-v3/config/os/bsd/netbsd/ctype_base.h
>>>
>>>
>>> With the attached patch, libstdc++-v3 can succesfully be built with
>>> NetBSD headers (along with --disable-libcilkrts).
>>
>> I noticed this has not been applied yet, nor seen a follow-up?, and also
>> noticed it went to the gcc-patches list, but not libstd...@gcc.gnu.org.
>>
>> Let me re-address this to libstd...@gcc.gnu.org in the hope the
>> maintainers there will have a look.
>>
>> Gerald
> 
>> diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> index ff3ec893974..21eccf9fde1 100644
>> --- a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> +++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> @@ -38,40 +38,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>   /// @brief  Base class for ctype.
>>   struct ctype_base
>>   {
>> -    // Non-standard typedefs.
>> -    typedef const unsigned char*    __to_type;
>>
>>     // NB: Offsets into ctype::_M_table force a particular size
>>     // on the mask type. Because of this, we don't use an enum.
>> -    typedef unsigned char  mask;
>>
>> #ifndef _CTYPE_U
>> -    static const mask upper    = _U;
>> -    static const mask lower = _L;
>> -    static const mask alpha = _U | _L;
>> -    static const mask digit = _N;
>> -    static const mask xdigit = _N | _X;
>> -    static const mask space = _S;
>> -    static const mask print = _P | _U | _L | _N | _B;
>> -    static const mask graph = _P | _U | _L | _N;
>> -    static const mask cntrl = _C;
>> -    static const mask punct = _P;
>> -    static const mask alnum = _U | _L | _N;
>> +    // Non-standard typedefs.
>> +    typedef const unsigned char*    __to_type;
>> +
>> +    typedef unsigned char    mask;
>> +
>> +    static const mask upper    = _U;
>> +    static const mask lower    = _L;
>> +    static const mask alpha    = _U | _L;
>> +    static const mask digit    = _N;
>> +    static const mask xdigit    = _N | _X;
>> +    static const mask space    = _S;
>> +    static const mask print    = _P | _U | _L | _N | _B;
>> +    static const mask graph    = _P | _U | _L | _N;
>> +    static const mask cntrl    = _C;
>> +    static const mask punct    = _P;
>> +    static const mask alnum    = _U | _L | _N;
>> #else
>> -    static const mask upper    = _CTYPE_U;
>> -    static const mask lower = _CTYPE_L;
>> -    static const mask alpha = _CTYPE_U | _CTYPE_L;
>> -    static const mask digit = _CTYPE_N;
>> -    static const mask xdigit = _CTYPE_N | _CTYPE_X;
>> -    static const mask space = _CTYPE_S;
>> -    static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>> _CTYPE_N | _CTYPE_B;
>> -    static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>> _CTYPE_N;
>> -    static const mask cntrl = _CTYPE_C;
>> -    static const mask punct = _CTYPE_P;
>> -    static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
>> +    typedef const unsigned short*    __to_type;
>> +
>> +    typedef unsigned short    mask;
>> +
>> +    static const mask upper    = _CTYPE_U;
>> +    static const mask lower    = _CTYPE_L;
>> +    static const mask alpha    = _CTYPE_A;
>> +    static const mask digit    = _CTYPE_D;
>> +    static const mask xdigit    = _CTYPE_X;
>> +    static const mask space    = _CTYPE_S;
>> +    static const mask print    = _CTYPE_R;
>> +    static const mask graph    = _CTYPE_G;
>> +    static const mask cntrl    = _CTYPE_C;
>> +    static const mask punct    = _CTYPE_P;
>> +    static const mask alnum    = _CTYPE_A | _CTYPE_D;
>> #endif
>> #if __cplusplus >= 201103L
>> -    static const mask blank = space;
>> +    static const mask blank    = space;
>> #endif
>>   };
>>
>> diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc
>> b/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc
>> index ed3b7cd0d6a..33358e8f5d8 100644
>> --- a/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc
>> +++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc
>> @@ -38,11 +38,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>
>> // Information as gleaned from /usr/include/ctype.h
>>
>> -  extern "C" const u_int8_t _C_ctype_[];
>> -
>>   const ctype_base::mask*
>>   ctype::classic_table() throw()
>> -  { return _C_ctype_ + 1; }
>> +  { return _C_ctype_tab_ + 1; }
> 
> The first patch attached to PR 64271 (i.e.
> 

Re: [PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

2020-01-06 Thread Kamil Rytarowski
On 06.01.2020 16:24, Jonathan Wakely wrote:
> On 22/12/19 09:36 +1000, Gerald Pfeifer wrote:
>> Hi Matthew,
>>
>> On Mon, 4 Feb 2019, Matthew Bauer wrote:
>>> The ctype_base.h file in libstdc++-v3 is out of date for NetBSD. They
>>> have changed their ctype.h definition. It was updated in their intree
>>> libstdc++-v3 but not in the GCC one. My understanding is this is a
>>> straightforward rewrite. I've attached my own patch, but the file can
>>> be obtained directly here:
>>>
>>> http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libstdc%2b%2b-v3/config/os/bsd/netbsd/ctype_base.h
>>>
>>>
>>> With the attached patch, libstdc++-v3 can succesfully be built with
>>> NetBSD headers (along with --disable-libcilkrts).
>>
>> I noticed this has not been applied yet, nor seen a follow-up?, and also
>> noticed it went to the gcc-patches list, but not libstd...@gcc.gnu.org.
>>
>> Let me re-address this to libstd...@gcc.gnu.org in the hope the
>> maintainers there will have a look.
>>
>> Gerald
> 
>> diff --git a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> index ff3ec893974..21eccf9fde1 100644
>> --- a/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> +++ b/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h
>> @@ -38,40 +38,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>>   /// @brief  Base class for ctype.
>>   struct ctype_base
>>   {
>> -    // Non-standard typedefs.
>> -    typedef const unsigned char*    __to_type;
>>
>>     // NB: Offsets into ctype::_M_table force a particular size
>>     // on the mask type. Because of this, we don't use an enum.
>> -    typedef unsigned char  mask;
>>
>> #ifndef _CTYPE_U
>> -    static const mask upper    = _U;
>> -    static const mask lower = _L;
>> -    static const mask alpha = _U | _L;
>> -    static const mask digit = _N;
>> -    static const mask xdigit = _N | _X;
>> -    static const mask space = _S;
>> -    static const mask print = _P | _U | _L | _N | _B;
>> -    static const mask graph = _P | _U | _L | _N;
>> -    static const mask cntrl = _C;
>> -    static const mask punct = _P;
>> -    static const mask alnum = _U | _L | _N;
>> +    // Non-standard typedefs.
>> +    typedef const unsigned char*    __to_type;
>> +
>> +    typedef unsigned char    mask;
>> +
>> +    static const mask upper    = _U;
>> +    static const mask lower    = _L;
>> +    static const mask alpha    = _U | _L;
>> +    static const mask digit    = _N;
>> +    static const mask xdigit    = _N | _X;
>> +    static const mask space    = _S;
>> +    static const mask print    = _P | _U | _L | _N | _B;
>> +    static const mask graph    = _P | _U | _L | _N;
>> +    static const mask cntrl    = _C;
>> +    static const mask punct    = _P;
>> +    static const mask alnum    = _U | _L | _N;
>> #else
>> -    static const mask upper    = _CTYPE_U;
>> -    static const mask lower = _CTYPE_L;
>> -    static const mask alpha = _CTYPE_U | _CTYPE_L;
>> -    static const mask digit = _CTYPE_N;
>> -    static const mask xdigit = _CTYPE_N | _CTYPE_X;
>> -    static const mask space = _CTYPE_S;
>> -    static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>> _CTYPE_N | _CTYPE_B;
>> -    static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L |
>> _CTYPE_N;
>> -    static const mask cntrl = _CTYPE_C;
>> -    static const mask punct = _CTYPE_P;
>> -    static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N;
>> +    typedef const unsigned short*    __to_type;
>> +
>> +    typedef unsigned short    mask;
> 
> I seem to recall looking at this previously and noting that the change
> to ctype_base::mask is an ABI break. It means that code compiled with
> old versions of GCC or on old versions of NetBSD will not be ABI
> compatible with code compiled by a new GCC on a new version of NetBSD.
> 
> If the NetBSD maintainers are OK with that, then we can go ahead and
> change it.
> 
> 

We are fine with ABI breaks as we bump libstdc++ major on each upgrade
in base.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] libstdcxx: Update ctype_base.h from NetBSD upstream

2019-12-22 Thread Kamil Rytarowski
On 22.12.2019 00:36, Gerald Pfeifer wrote:
> Hi Matthew,
> 
> On Mon, 4 Feb 2019, Matthew Bauer wrote:
>> The ctype_base.h file in libstdc++-v3 is out of date for NetBSD. They
>> have changed their ctype.h definition. It was updated in their intree
>> libstdc++-v3 but not in the GCC one. My understanding is this is a
>> straightforward rewrite. I've attached my own patch, but the file can
>> be obtained directly here:
>>
>> http://cvsweb.netbsd.org/bsdweb.cgi/src/external/gpl3/gcc/dist/libstdc%2b%2b-v3/config/os/bsd/netbsd/ctype_base.h
>>
>> With the attached patch, libstdc++-v3 can succesfully be built with
>> NetBSD headers (along with --disable-libcilkrts).
> 
> I noticed this has not been applied yet, nor seen a follow-up?, and also 
> noticed it went to the gcc-patches list, but not libstd...@gcc.gnu.org.
> 
> Let me re-address this to libstd...@gcc.gnu.org in the hope the 
> maintainers there will have a look.
> 
> Gerald
> 

We (in NetBSD) wait for this to be merged.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-10-27 Thread Kamil Rytarowski
On 26.10.2019 23:57, Andreas Tobler wrote:
> On 04.10.19 19:04, Jeff Law wrote:
>> On 9/30/19 12:47 PM, Andreas Tobler wrote:
>>> On 30.09.19 20:37, Kamil Rytarowski wrote:
>>>> On 30.09.2019 19:47, Jakub Jelinek wrote:
>>>>> On Mon, Sep 30, 2019 at 07:41:00PM +0200, Andreas Tobler wrote:
>>>>>> --- fprintf-2.c    (revision 276292)
>>>>>> +++ fprintf-2.c    (working copy)
>>>>>> @@ -1,7 +1,8 @@
>>>>>>    /* Verify that calls to fprintf don't get eliminated even if their
>>>>>>   result on success can be computed at compile time (they can
>>>>>> fail).
>>>>>>   The calls can still be transformed into those of other
>>>>>> functions.
>>>>>> -   { dg-skip-if "requires io" { freestanding } } */
>>>>>> +   { dg-skip-if "requires io" { freestanding } }
>>>>>> +   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]*
>>>>>> possibly used unsafely; consider using \[^\n\]*\n" } */
>>>>>
>>>>> I'm worried about that (^|\n) at the start + \n at the end, doesn't
>>>>> it prune
>>>>> too much then?
>>>>> Looking at other tests, they dg-prune-output just a few words from a
>>>>> message, or .*few words.*
>>>>> So, can you try just
>>>>>  { dg-prune-output "warning: warning: \[^\n\r\]* possibly used
>>>>> unsafely; consider using" } */
>>>>> or if that doesn't work, with .* at start end end?
>>>>>
>>>>>  Jakub
>>>>>
>>>>
>>>> Please handle the NetBSD specific string too: "warning: tmpnam()
>>>> possibly used unsafely, use mkstemp() or mkdtemp()".
>>>>
>>>> https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52
>>>>
>>>
>>> Ok, I think the attached version should also match these cases. Although
>>> untested on NetBSD.
>>> Kamil, if you have cycles, would you mind giving it a run? Thanks!
>>> Andreas
>>>
>> OK assuming Kamil's testing shows that it works.
>
> Kamil, do you have a feedback? If not I'm going to commit by tomorrow.
>
> Andreas

Please go for it.


Re: [PATCH] C testsuite, silence a FreeBSD libc warning

2019-09-30 Thread Kamil Rytarowski
On 30.09.2019 19:47, Jakub Jelinek wrote:
> On Mon, Sep 30, 2019 at 07:41:00PM +0200, Andreas Tobler wrote:
>> --- fprintf-2.c  (revision 276292)
>> +++ fprintf-2.c  (working copy)
>> @@ -1,7 +1,8 @@
>>  /* Verify that calls to fprintf don't get eliminated even if their
>> result on success can be computed at compile time (they can fail).
>> The calls can still be transformed into those of other functions.
>> -   { dg-skip-if "requires io" { freestanding } } */
>> +   { dg-skip-if "requires io" { freestanding } }
>> +   { dg-prune-output "(^|\n)(\[^\n\])*warning: warning: \[^\n\]* possibly 
>> used unsafely; consider using \[^\n\]*\n" } */ 
> 
> I'm worried about that (^|\n) at the start + \n at the end, doesn't it prune
> too much then?
> Looking at other tests, they dg-prune-output just a few words from a
> message, or .*few words.*
> So, can you try just
>{ dg-prune-output "warning: warning: \[^\n\r\]* possibly used unsafely; 
> consider using" } */
> or if that doesn't work, with .* at start end end?
> 
>   Jakub
> 

Please handle the NetBSD specific string too: "warning: tmpnam()
possibly used unsafely, use mkstemp() or mkdtemp()".

https://nxr.netbsd.org/xref/src/lib/libc/stdio/tmpnam.c#52



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] 2019-09-20 Kamil Rytarowski

2019-09-21 Thread Kamil Rytarowski
On 21.09.2019 16:53, Jakub Jelinek wrote:
> On Fri, Sep 20, 2019 at 10:45:42PM +0200, Kamil Rytarowski wrote:
>> GCC version of https://reviews.llvm.org/D67719
>>
>> From 422827582d84e078df2a8e303d807c830a155ab5 Mon Sep 17 00:00:00 2001
>> From: Kamil Rytarowski 
>> Date: Fri, 20 Sep 2019 22:02:09 +0200
>> Subject: [PATCH] 2019-09-20  Kamil Rytarowski  
>>
>>  * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
>>  builtin __SANITIZE_LEAK__ macros for fsanitize=leak switch.
>>  * doc/cpp.texi: Document new macros.
>>
>>  * c-c++-common/lsan/sanitize-leak-macro.c: New test.
> 
> And this looks even more pointless.  -fsanitize=leak generally isn't a
> compiler option, just a linker option,

This is wrong. -fsanitize=leak IS a compiler option.

> but a patch like this would make it a
> compiler option too.  There are no code changes with -fsanitize=leak, just
> linking arranges a malloc etc. replacement that traces the leaks.
> 

I am aware about its implementation as I ported LSan to NetBSD.

>   Jakub
> 

The same argument applies here as in the UBSan patch.

Here we have got a special use-case to use standalone LSan on NetBSD we
we run whole userland sanitization and ASan is much more fragile
(largely due to its incompleteness in interceptors).

This ifdef is also scheduled to be included in public system headers.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH] Add new builtin __SANITIZE_UNDEFINED__ macros for fsanitize=undefined switch

2019-09-21 Thread Kamil Rytarowski
On 21.09.2019 16:51, Jakub Jelinek wrote:
> On Sat, Sep 21, 2019 at 01:31:10PM +0200, Kamil Rytarowski wrote:
>> GCC version of https://reviews.llvm.org/D52386
>>
>> 2019-09-21  Kamil Rytarowski  
>>
>>  * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
>>  builtin __SANITIZE_UNDEFINED__ macros for fsanitize=undefined switch.
>>  * doc/cpp.texi: Document new macros.
>>
>>  * c-c++-common/lsan/sanitize-undefined-macro.c: New test.
> 
> I fail to see a good use case for this, it will just lead people to add
> workarounds for ubsan diagnostics without actually fixing it for real in
> their production code.

It's needed in real production code in the NetBSD kernel/userland as
there are legitimate code paths that are not UBSan clean.

There is also a UBSan specific header that can be picked with this ifdef.

>  Also, -fsanitize=undefined is a collection of many
> different sanitizers.

I wrote a full UBSan kerne runtime so I am aware about
this, however I don't have a use case on fine-grained processor checks.

>  Those that want such macros to say provide libubsan
> definitions on their own can do that in their build system, next to
> -fsanitize=undefined provide their own -Dwhatever that will make that
> happen.

Do you see point in e.g. __SANITIZER_ADDRESS__ ?

This macro is intended to be used in public NetBSD system headers (as we
need it there) and you volunteer to patch scons, cmake, bmake, gmake,
gn, autotools etc for us?

> 
>   Jakub
> 






signature.asc
Description: OpenPGP digital signature


[PATCH] Add new builtin __SANITIZE_UNDEFINED__ macros for fsanitize=undefined switch

2019-09-21 Thread Kamil Rytarowski
GCC version of https://reviews.llvm.org/D52386

2019-09-21  Kamil Rytarowski  

* cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
builtin __SANITIZE_UNDEFINED__ macros for fsanitize=undefined switch.
* doc/cpp.texi: Document new macros.

* c-c++-common/lsan/sanitize-undefined-macro.c: New test.
---
 gcc/ChangeLog|  6 ++
 gcc/cppbuiltin.c |  3 +++
 gcc/doc/cpp.texi |  3 +++
 gcc/testsuite/ChangeLog  |  4 
 .../c-c++-common/ubsan/sanitize-ubsan-macro.c| 12 
 5 files changed, 28 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/ubsan/sanitize-ubsan-macro.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7b773167433..4f99190ca0c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-21  Kamil Rytarowski  
+
+   * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
+   builtin __SANITIZE_UNDEFINED__ macros for fsanitize=undefined switch.
+   * doc/cpp.texi: Document new macros.
+
 2019-09-20  Jonas Pfeil  

* config/microblaze/microblaze.h (ASM_OUTPUT_SKIP): Use
diff --git a/gcc/cppbuiltin.c b/gcc/cppbuiltin.c
index 60e5bedc366..221fb68b575 100644
--- a/gcc/cppbuiltin.c
+++ b/gcc/cppbuiltin.c
@@ -93,6 +93,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader 
*pfile)
   if (flag_sanitize & SANITIZE_ADDRESS)
 cpp_define (pfile, "__SANITIZE_ADDRESS__");

+  if (flag_sanitize & SANITIZE_UNDEFINED)
+cpp_define (pfile, "__SANITIZE_UNDEFINED__");
+
   if (flag_sanitize & SANITIZE_THREAD)
 cpp_define (pfile, "__SANITIZE_THREAD__");

diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index f2de39a270c..3145d3ebab4 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2359,6 +2359,9 @@ in use.
 This macro is defined, with value 1, when @option{-fsanitize=address}
 or @option{-fsanitize=kernel-address} are in use.

+@item __SANITIZE_UNDEFINED__
+This macro is defined, with value 1, when @option{-fsanitize=undefined} is in 
use.
+
 @item __SANITIZE_THREAD__
 This macro is defined, with value 1, when @option{-fsanitize=thread} is in use.

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 05c25ee28ce..e35880b1b2f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-21  Kamil Rytarowski  
+
+   * c-c++-common/usan/sanitize-undefined-macro.c: New test.
+
 2019-09-20  Iain Sandoe  

* gcc.target/i386/naked-1.c: Alter options to use non-
diff --git a/gcc/testsuite/c-c++-common/ubsan/sanitize-ubsan-macro.c 
b/gcc/testsuite/c-c++-common/ubsan/sanitize-ubsan-macro.c
new file mode 100644
index 000..ecca41da32e
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/sanitize-ubsan-macro.c
@@ -0,0 +1,12 @@
+/* Check that -fsanitize=undefined options defines __SANITIZE_UNDEFINED__ 
macros.  */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+int
+main ()
+{
+#ifndef __SANITIZE_UNDEFINED__
+  bad construction
+#endif
+  return 0;
+}
--
2.23.0



[PATCH] 2019-09-20 Kamil Rytarowski

2019-09-20 Thread Kamil Rytarowski
GCC version of https://reviews.llvm.org/D67719

From 422827582d84e078df2a8e303d807c830a155ab5 Mon Sep 17 00:00:00 2001
From: Kamil Rytarowski 
Date: Fri, 20 Sep 2019 22:02:09 +0200
Subject: [PATCH] 2019-09-20  Kamil Rytarowski  

* cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
builtin __SANITIZE_LEAK__ macros for fsanitize=leak switch.
* doc/cpp.texi: Document new macros.

* c-c++-common/lsan/sanitize-leak-macro.c: New test.
---
 gcc/ChangeLog|  6 ++
 gcc/cppbuiltin.c |  3 +++
 gcc/doc/cpp.texi |  3 +++
 gcc/testsuite/ChangeLog  |  4 
 .../c-c++-common/lsan/sanitize-lsan-macro.c  | 12 
 5 files changed, 28 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/lsan/sanitize-lsan-macro.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 76269e17eb0..1bddb4835a0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-20  Kamil Rytarowski  
+
+   * cppbuiltin.c (define_builtin_macros_for_compilation_flags): Add new
+   builtin __SANITIZE_LEAK__ macros for fsanitize=leak switch.
+   * doc/cpp.texi: Document new macros.
+
 2019-09-20  Richard Biener  
Uros Bizjak  

diff --git a/gcc/cppbuiltin.c b/gcc/cppbuiltin.c
index 60e5bedc366..5a1b6555c53 100644
--- a/gcc/cppbuiltin.c
+++ b/gcc/cppbuiltin.c
@@ -93,6 +93,9 @@ define_builtin_macros_for_compilation_flags (cpp_reader 
*pfile)
   if (flag_sanitize & SANITIZE_ADDRESS)
 cpp_define (pfile, "__SANITIZE_ADDRESS__");

+  if (flag_sanitize & SANITIZE_LEAK)
+cpp_define (pfile, "__SANITIZE_LEAK__");
+
   if (flag_sanitize & SANITIZE_THREAD)
 cpp_define (pfile, "__SANITIZE_THREAD__");

diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index f2de39a270c..74861eaf9c5 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2359,6 +2359,9 @@ in use.
 This macro is defined, with value 1, when @option{-fsanitize=address}
 or @option{-fsanitize=kernel-address} are in use.

+@item __SANITIZE_LEAK__
+This macro is defined, with value 1, when @option{-fsanitize=leak} is in use.
+
 @item __SANITIZE_THREAD__
 This macro is defined, with value 1, when @option{-fsanitize=thread} is in use.

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 05c25ee28ce..4b37e1f3643 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-09-20  Kamil Rytarowski  
+
+   * c-c++-common/lsan/sanitize-leak-macro.c: New test.
+
 2019-09-20  Iain Sandoe  

* gcc.target/i386/naked-1.c: Alter options to use non-
diff --git a/gcc/testsuite/c-c++-common/lsan/sanitize-lsan-macro.c 
b/gcc/testsuite/c-c++-common/lsan/sanitize-lsan-macro.c
new file mode 100644
index 000..c588aa32e86
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/lsan/sanitize-lsan-macro.c
@@ -0,0 +1,12 @@
+/* Check that -fsanitize=leak options defines __SANITIZE_LEAK__ macros.  */
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
+
+int
+main ()
+{
+#ifndef __SANITIZE_LEAK__
+  bad construction
+#endif
+  return 0;
+}
--
2.23.0


Re: [PATCH, netbsd] Include memmodel.h in netbsd-d.c

2019-04-27 Thread Kamil Rytarowski
On 27.04.2019 11:20, Iain Buclaw wrote:
> Hi,
> 
> Baseline compiler builds fail on all sparc*-netbsd configurations.
> 
> In file included from ./tm_p.h:4,
>  from /runner/crossbuilds/../gcc/gcc/config/netbsd-d.c:27:
> /runner/crossbuilds/../gcc/gcc/config/sparc/sparc-protos.h:45:47:
> error: use of enum ‘memmodel’ without previous declaration
>45 | extern void sparc_emit_membar_for_model (enum memmodel, int, int);
>   |   ^~~~
> make[2]: *** [/runner/crossbuilds/../gcc/gcc/config/t-netbsd:24:
> netbsd-d.o] Error 1
> 
> 
> This patch fixes up the includes so compile succeeds.  Tested using
> config-list.mk on all netbsd variants.
> 
> OK?
> 

Looks good!



signature.asc
Description: OpenPGP digital signature


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-24 Thread Kamil Rytarowski
On 24.04.2019 13:25, Iain Buclaw wrote:
> On Wed, 24 Apr 2019 at 13:03, Kamil Rytarowski  wrote:
>>
>> On 24.04.2019 03:30, Iain Buclaw wrote:
>>> On Wed, 24 Apr 2019 at 01:56, Kamil Rytarowski  wrote:
>>>>
>>>> On 24.04.2019 01:13, Iain Buclaw wrote:
>>> https://explore.dgnu.org/z/U29cni
>>>
>>> I'll add special handling for them, but otherwise 48/28 looks like the
>>> reasonable default.
>>>
>>

OK, so please go for this.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-24 Thread Kamil Rytarowski
On 24.04.2019 03:30, Iain Buclaw wrote:
> On Wed, 24 Apr 2019 at 01:56, Kamil Rytarowski  wrote:
>>
>> On 24.04.2019 01:13, Iain Buclaw wrote:
>>> Hi,
>>>
>>> This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
>>> would be noticed when using any bare synchronized statements.
>>>
>>> I couldn't see any target-specific alternatives of pthread_mutex_t in
>>> netbsd headers, so the condition should be right.
>>>
>>> OK for trunk?
>>>
>>
>> This patch is wrong.
>>
>> sizeof(pthread_mutex_t) depends on CPU.
>>
>> Just check that __cpu_simple_lock_nv_t that can be char, int, struct.
>>
> 
> Ah, thanks for pointing to that.  I've made a small working example,
> and it looks like only three have a different size, aarch64, hppa, and
> hppa64.
> 
> https://explore.dgnu.org/z/U29cni
> 
> I'll add special handling for them, but otherwise 48/28 looks like the
> reasonable default.
> 

I recommend to solve it differently: autodetect the size during
./configure. I'm not sure that it is still correct.

The sizes can also change over time. There is coming refactoring of
libpthread(3) in NetBSD that can change sizes of these types, at least
on some platforms.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH, netbsd] Define TARGET_D_CRITSEC_SIZE for D language

2019-04-23 Thread Kamil Rytarowski
On 24.04.2019 01:13, Iain Buclaw wrote:
> Hi,
> 
> This patch adds missing implementation of TARGET_D_CRITSEC_SIZE, which
> would be noticed when using any bare synchronized statements.
> 
> I couldn't see any target-specific alternatives of pthread_mutex_t in
> netbsd headers, so the condition should be right.
> 
> OK for trunk?
> 

This patch is wrong.

sizeof(pthread_mutex_t) depends on CPU.

Just check that __cpu_simple_lock_nv_t that can be char, int, struct.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH 1/2] Untangle stddef.h a little

2018-02-28 Thread Kamil Rytarowski
On 01.03.2018 03:43, co...@sdf.org wrote:
> hi gcc-patches,
> 
> as part of pinging, i'll explain the story of this patch.
> 
> I want to make sure all netbsd archs work with upstream gcc.
> in this case, netbsd/arm's EABI support.
> I try to break up my changes into digestible chunks that are rational,
> which is why this change came first.
> 
> building netbsd/arm gcc-trunk, I had a build error in libstdc++, because
> this stddef.h relies on include guards:
> 
> #if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) || 
> defined(_X86_64_ANSI_H_)  || defined(_I386_ANSI_H_)
> 
> In theory I could have just added:
>  || _ARM_ANSI_H_
> 
> this felt gross, so I tried a better solution.
> the file even comes with comments like:
>   /* Why is this file so hard to maintain properly?
> so I try my best to help.
> 
> Please let me upstream local changes. there are a lot of them. and I
> feel unable to get them across.
> I have so many changes that it feels inappropriate to ask for help with
> hard problems like internal compiler errors because upstream GCC hit a
> different problem. I'm not familiar with stuff so this is hard :-(
> 

Looks good, ping from my point of view for maintainers.

Adding defined(_*_ANSI_H) for each CPU and flavor of headers on NetBSD
does not scale even for the existing set of supported architectures.

NetBSD/hpcsh uses _HPCSH_ANSI_H_, NetBSD/dreamcast _DREAMCAST_ANSI_H_ etc.



signature.asc
Description: OpenPGP digital signature


Re: [committed] hppa: Rework MALLOC_ABI_ALIGNMENT macro

2018-01-16 Thread Kamil Rytarowski
On 17.01.2018 02:52, John David Anglin wrote:
> When I defined MALLOC_ABI_ALIGNMENT, I inadvertently changed the default
> alignment for
> various hppa*-*-*bsd* targets.  Nick Hudson is still maintaining the
> netbsd target.
> 
> This patch corrects the default malloc alignment for 32-bit targest and
> moves the linux special
> case to its own file.
> 
> Committed to trunk.
> 
> Dave
> 

NetBSD supports hppa in Tier2.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3] Add asan and ubsan support on NetBSD/amd64

2017-10-31 Thread Kamil Rytarowski
On 31.10.2017 19:45, Jakub Jelinek wrote:
> On Tue, Oct 31, 2017 at 07:28:23PM +0100, Kamil Rytarowski wrote:
>> I'm giving it a try. I took the asan part and skipped
>> "%{!shared:libasan_preinit%O%s} ". If I understand this correctly, it
>> attempts to use the ELF section with preinit property in order to
>> bootstrap asan quickly. The preinit sections are not enabled on
>> NetBSD/amd64. From my understanding, there is a design choice in NetBSD
>> to not include extensional sections unless they are requested by ABI.
> 
> ??  SHT_PREINIT_ARRAY/DT_PREINIT_ARRAY/DT_PREINIT_ARRAYSZ is not any
> kind of extension, it is an integral part of the ELF gABI:
> http://www.sco.com/developers/gabi/latest/ch5.dynamic.html#dynamic_section
> And that is quite essential for proper asan behavior, because the library
> interposes a lot of functions and if they are invoked before the library
> is initialized, they crash (of course better would be to fix the library
> not to rely on that and initialize the minimal stuff needed for
> interposition if they are called before the initialization, but that is
> unlikely to happen upstream).
> 
>   Jakub
> 

Right now this is only Linux-specific at least in asan/LLVM.

// We can use .preinit_array section on Linux to call sanitizer
initialization
// functions very early in the process startup (unless PIC macro is
defined).
// FIXME: do we have anything like this on Mac?
#if SANITIZER_LINUX && !SANITIZER_ANDROID && !defined(PIC)
# define SANITIZER_CAN_USE_PREINIT_ARRAY 1
#else
# define SANITIZER_CAN_USE_PREINIT_ARRAY 0
#endif

-- lib/sanitizer_common/sanitizer_internal_defs.h

NetBSD needs to use different ways to initialize, like through
interception of a call and during this stage bootstrap initialization
bits. The tricky part is that we cannot initialize a sanitizer before
sufficient libc+libpthread bootstrap and this is my current obstacle
with tsan.

Specifying new LIBASAN_EARLY_SPEC does not fix the "AddressSanitizer can
not provide additional info." problem.



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3] Add asan and ubsan support on NetBSD/amd64

2017-10-31 Thread Kamil Rytarowski
On 31.10.2017 15:04, Jakub Jelinek wrote:
> On Tue, Oct 31, 2017 at 02:53:26PM +0100, Kamil Rytarowski wrote:
>>>> http://netbsd.org/~kamil/gcc/test_summary.log.8-20171022.txt
>>>
>>> That seems that asan pretty much doesn't work at all in GCC for netbsd.
>>> A few FAILs might be acceptable, but so many FAILs certainly aren't.
>>> The testsuite doesn't use python, at least not for *san testing nor
>>> test_summary, so that shouldn't be the problem.  If it is asan/ubsan tests
>>> that are hanging, that is something that needs to be debugged and understood
>>> why it hangs.
>>>
>>
>> It is similar in LLVM, where it works against statically linked .a files
>> with sanitizers. For .so, I can observe similar information about
>> DEADLYSIGNAL without detailed information.
> 
> But dynamic linking of libasan or libubsan is the default in gcc, so
> it needs to work out of the box.
> Note gcc/config/gnu-user.h has:
> /* Link -lasan early on the command line.  For -static-libasan, don't link
>it for -shared link, the executable should be compiled with -static-libasan
>in that case, and for executable link with --{,no-}whole-archive around
>it to force everything into the executable.  And similarly for -ltsan
>and -llsan.  */
> #if defined(HAVE_LD_STATIC_DYNAMIC)
> #undef LIBASAN_EARLY_SPEC
> #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
>   "%{static-libasan:%{!shared:" \
>   LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
>   LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
> #undef LIBTSAN_EARLY_SPEC
> #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
>   "%{static-libtsan:%{!shared:" \
>   LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
>   LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
> #undef LIBLSAN_EARLY_SPEC
> #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
>   "%{static-liblsan:%{!shared:" \
>   LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
>   LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
> #endif
> 
> which might need to be duplicated into gcc/config/netbsd-elf.h.
> 
>   Jakub
> 


I'm giving it a try. I took the asan part and skipped
"%{!shared:libasan_preinit%O%s} ". If I understand this correctly, it
attempts to use the ELF section with preinit property in order to
bootstrap asan quickly. The preinit sections are not enabled on
NetBSD/amd64. From my understanding, there is a design choice in NetBSD
to not include extensional sections unless they are requested by ABI.


$NetBSD$

--- ./gcc/config/netbsd-elf.h.orig  2017-01-01 12:07:43.0 +
+++ ./gcc/config/netbsd-elf.h
@@ -85,3 +85,16 @@ along with GCC; see the file COPYING3.
 #ifdef HAVE_LD_AS_NEEDED
 #define USE_LD_AS_NEEDED 1
 #endif
+
+/* Link -lasan early on the command line.  For -static-libasan, don't link
+   it for -shared link, the executable should be compiled with
-static-libasan
+   in that case, and for executable link with --{,no-}whole-archive around
+   it to force everything into the executable.  And similarly for -ltsan
+   and -llsan.  */
+#if defined(HAVE_LD_STATIC_DYNAMIC)
+#undef LIBASAN_EARLY_SPEC
+#define LIBASAN_EARLY_SPEC \
+  "%{static-libasan:%{!shared:" \
+  LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
+  LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
+#endif





signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3] Add asan and ubsan support on NetBSD/amd64

2017-10-31 Thread Kamil Rytarowski
On 31.10.2017 14:22, Jakub Jelinek wrote:
> On Mon, Oct 30, 2017 at 09:01:25PM +0100, Kamil Rytarowski wrote:
>> On 30.10.2017 08:24, Jakub Jelinek wrote:
>>> On Thu, Oct 26, 2017 at 09:50:43PM +0200, Kamil Rytarowski wrote:
>>>> $ make check-asan
>>>> $ make check-asan-dynamic
>>>> $ make check-ubsan
>>>
>>> That is testing of the upstream code, not of GCC and the libsanitizer
>>> copy in GCC.  What I'm more interested to hear is whether
>>> you've bootstrapped/regtested the gcc tree with this patch on
>>> x86_64-*-netbsd*, as per https://gcc.gnu.org/contribute.html
>>> I.e. /configure ...; make -jN bootstrap; make -jN -k check; 
>>> /contrib/test_summary
>>> and from there if there are any */asan/* or */ubsan/* FAILs.
>>>
>>
>> I've been executing GCC tests.
>>
>> Some/many tests were hanging and I was killing them after a longer
>> period of time. There were certainly environment issues, like attempts
>> to execute non-existent 'python' (in pkgsrc/NetBSD we version python to
>> python2.7, python3.6 etc).
>>
>> http://netbsd.org/~kamil/gcc/test_summary.log.8-20171022.txt
> 
> That seems that asan pretty much doesn't work at all in GCC for netbsd.
> A few FAILs might be acceptable, but so many FAILs certainly aren't.
> The testsuite doesn't use python, at least not for *san testing nor
> test_summary, so that shouldn't be the problem.  If it is asan/ubsan tests
> that are hanging, that is something that needs to be debugged and understood
> why it hangs.
> 

It is similar in LLVM, where it works against statically linked .a files
with sanitizers. For .so, I can observe similar information about
DEADLYSIGNAL without detailed information.

I will try to fix it in LLVM first.

I noted that FreeBSD people has similar issues, caused e.g. by the link
order of libraries (libthr vs libc).. not sure what's the reason in NetBSD.

> You should look into ...objdir/gcc/testsuite/{gcc,g++}/{gcc,g++}.log
> for details on some short/simple tests and see what the problem is.
> 
>   Jakub
> 


T



signature.asc
Description: OpenPGP digital signature


Re: [PATCH v3] Add asan and ubsan support on NetBSD/amd64

2017-10-30 Thread Kamil Rytarowski
On 30.10.2017 08:24, Jakub Jelinek wrote:
> On Thu, Oct 26, 2017 at 09:50:43PM +0200, Kamil Rytarowski wrote:
>> $ make check-asan
>> $ make check-asan-dynamic
>> $ make check-ubsan
> 
> That is testing of the upstream code, not of GCC and the libsanitizer
> copy in GCC.  What I'm more interested to hear is whether
> you've bootstrapped/regtested the gcc tree with this patch on
> x86_64-*-netbsd*, as per https://gcc.gnu.org/contribute.html
> I.e. /configure ...; make -jN bootstrap; make -jN -k check; 
> /contrib/test_summary
> and from there if there are any */asan/* or */ubsan/* FAILs.
> 

I've been executing GCC tests.

Some/many tests were hanging and I was killing them after a longer
period of time. There were certainly environment issues, like attempts
to execute non-existent 'python' (in pkgsrc/NetBSD we version python to
python2.7, python3.6 etc).

http://netbsd.org/~kamil/gcc/test_summary.log.8-20171022.txt

It looks like the tests complains for asan, and nothing complains for
ubsan. I expect that the reporting issue in asan/GCC is generating these
results.

>> 2017-10-26  Kamil Rytarowski  <n...@gmx.com>
>>
>>  * sanitizer_common/Makefile.am (sanitizer_common_files): Add
>>  sanitizer_platform_limits_netbsd.cc.
>>  * sanitizer_common/Makefile.in: Regenerated.
>>  * configure.tgt: Enable asan and ubsan on x86_64-*-netbsd*.
> 
>   Jakub
> 




signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2] Add asan and ubsan support on NetBSD/amd64

2017-10-26 Thread Kamil Rytarowski
On 26.10.2017 21:43, Kamil Rytarowski wrote:
> Tested on:
> 
> $ uname -rms
> NetBSD 8.99.4 amd64
> 

I forgot to amend everything in this patch, will fix in -v3.




signature.asc
Description: OpenPGP digital signature


[PATCH v3] Add asan and ubsan support on NetBSD/amd64

2017-10-26 Thread Kamil Rytarowski
 in ___start (/tmp/a+0x40090a)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/tmp/a+0x400a8e) in main
==20441==ABORTING

There is lack of additional info in asan when used with .so. This bug is not
a show-stopper because a user still can get backtrace under debugger in the
point of detected failure. This bug will be fixed in upstream LLVM sources
and merged back to GCC in future merges from LLVM.

2017-10-26  Kamil Rytarowski  <n...@gmx.com>

* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sanitizer_platform_limits_netbsd.cc.
* sanitizer_common/Makefile.in: Regenerated.
* configure.tgt: Enable asan and ubsan on x86_64-*-netbsd*.
---
 libsanitizer/ChangeLog| 7 +++
 libsanitizer/configure.tgt| 4 
 libsanitizer/sanitizer_common/Makefile.am | 2 +-
 libsanitizer/sanitizer_common/Makefile.in | 5 -
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 63e71317cbf..097230ac5cf 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,10 @@
+2017-10-26  Kamil Rytarowski  <n...@gmx.com>
+
+   * sanitizer_common/Makefile.am (sanitizer_common_files): Add
+   sanitizer_platform_limits_netbsd.cc.
+   * sanitizer_common/Makefile.in: Regenerated.
+   * configure.tgt: Enable asan and ubsan on x86_64-*-netbsd*.
+
 2017-10-20  Jakub Jelinek  <ja...@redhat.com>
 
PR sanitizer/82595
diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
index 573e3b482e9..4c1f8e0bb27 100644
--- a/libsanitizer/configure.tgt
+++ b/libsanitizer/configure.tgt
@@ -55,6 +55,10 @@ case "${target}" in
   x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
TSAN_SUPPORTED=no
;;
+  x86_64-*-netbsd*)
+   TSAN_SUPPORTED=no
+   LSAN_SUPPORTED=no
+   ;;
   *)
UNSUPPORTED=1
;;
diff --git a/libsanitizer/sanitizer_common/Makefile.am 
b/libsanitizer/sanitizer_common/Makefile.am
index adaab4cee54..70563eded36 100644
--- a/libsanitizer/sanitizer_common/Makefile.am
+++ b/libsanitizer/sanitizer_common/Makefile.am
@@ -41,6 +41,7 @@ sanitizer_common_files = \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_posix.cc \
+   sanitizer_platform_limits_netbsd.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
@@ -114,4 +115,3 @@ AM_MAKEFLAGS = \
 MAKEOVERRIDES=
 
 ## 
-
diff --git a/libsanitizer/sanitizer_common/Makefile.in 
b/libsanitizer/sanitizer_common/Makefile.in
index b2acc5caf56..f05c181f0b1 100644
--- a/libsanitizer/sanitizer_common/Makefile.in
+++ b/libsanitizer/sanitizer_common/Makefile.in
@@ -91,7 +91,8 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \
sanitizer_mac.lo sanitizer_mac_libcdep.lo \
sanitizer_persistent_allocator.lo \
sanitizer_platform_limits_linux.lo \
-   sanitizer_platform_limits_posix.lo sanitizer_posix.lo \
+   sanitizer_platform_limits_posix.lo \
+   sanitizer_platform_limits_netbsd.lo sanitizer_posix.lo \
sanitizer_posix_libcdep.lo sanitizer_printf.lo \
sanitizer_procmaps_common.lo sanitizer_procmaps_freebsd.lo \
sanitizer_procmaps_linux.lo sanitizer_procmaps_mac.lo \
@@ -323,6 +324,7 @@ sanitizer_common_files = \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_posix.cc \
+   sanitizer_platform_limits_netbsd.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
@@ -468,6 +470,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_mac_libcdep.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_persistent_allocator.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_netbsd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_posix_libcdep.Plo@am__quote@
-- 
2.14.2



[PATCH v2] Add asan and ubsan support on NetBSD/amd64

2017-10-26 Thread Kamil Rytarowski
 in ___start (/tmp/a+0x40090a)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/tmp/a+0x400a8e) in main
==20441==ABORTING

There is lack of additional info in asan when used with .so. This bug is not
a show-stopper because a user still can get backtrace under debugger in the
point of detected failure. This bug will be fixed in upstream LLVM sources
and merged back to GCC in future merges from LLVM.

2017-10-26  Kamil Rytarowski  <n...@gmx.com>

* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sanitizer_platform_limits_netbsd.cc.
* sanitizer_common/Makefile.in: Regenerated.
* configure.tgt: Enable asan and ubsan on x86_64-*-netbsd*.
---
 libsanitizer/ChangeLog| 6 ++
 libsanitizer/sanitizer_common/Makefile.am | 2 +-
 libsanitizer/sanitizer_common/Makefile.in | 5 -
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 63e71317cbf..c9863c281d1 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-26  Kamil Rytarowski  <n...@gmx.com>
+
+   * sanitizer_common/Makefile.am (sanitizer_common_files): Add
+   sanitizer_platform_limits_netbsd.cc.
+   * sanitizer_common/Makefile.in: Regenerated.
+
 2017-10-20  Jakub Jelinek  <ja...@redhat.com>
 
PR sanitizer/82595
diff --git a/libsanitizer/sanitizer_common/Makefile.am 
b/libsanitizer/sanitizer_common/Makefile.am
index adaab4cee54..70563eded36 100644
--- a/libsanitizer/sanitizer_common/Makefile.am
+++ b/libsanitizer/sanitizer_common/Makefile.am
@@ -41,6 +41,7 @@ sanitizer_common_files = \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_posix.cc \
+   sanitizer_platform_limits_netbsd.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
@@ -114,4 +115,3 @@ AM_MAKEFLAGS = \
 MAKEOVERRIDES=
 
 ## 
-
diff --git a/libsanitizer/sanitizer_common/Makefile.in 
b/libsanitizer/sanitizer_common/Makefile.in
index b2acc5caf56..f05c181f0b1 100644
--- a/libsanitizer/sanitizer_common/Makefile.in
+++ b/libsanitizer/sanitizer_common/Makefile.in
@@ -91,7 +91,8 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \
sanitizer_mac.lo sanitizer_mac_libcdep.lo \
sanitizer_persistent_allocator.lo \
sanitizer_platform_limits_linux.lo \
-   sanitizer_platform_limits_posix.lo sanitizer_posix.lo \
+   sanitizer_platform_limits_posix.lo \
+   sanitizer_platform_limits_netbsd.lo sanitizer_posix.lo \
sanitizer_posix_libcdep.lo sanitizer_printf.lo \
sanitizer_procmaps_common.lo sanitizer_procmaps_freebsd.lo \
sanitizer_procmaps_linux.lo sanitizer_procmaps_mac.lo \
@@ -323,6 +324,7 @@ sanitizer_common_files = \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_posix.cc \
+   sanitizer_platform_limits_netbsd.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
@@ -468,6 +470,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_mac_libcdep.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_persistent_allocator.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_netbsd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_posix_libcdep.Plo@am__quote@
-- 
2.14.2



Re: [PATCH] Include missing source file for sanitizers on NetBSD

2017-10-26 Thread Kamil Rytarowski
On 26.10.2017 21:19, Jakub Jelinek wrote:
> On Thu, Oct 26, 2017 at 09:02:25PM +0200, Kamil Rytarowski wrote:
>> 2017-10-26  Kamil Rytarowski  <n...@gmx.com>
>>
>>  * sanitizer_common/Makefile.am (sanitizer_common_files): Add
>>  sanitizer_platform_limits_netbsd.cc.
>>  * sanitizer_common/Makefile.in: Regenerated.
> 
> Why is this needed?
> libsanitizer/configure.tgt will set UNSUPPORTED=1 for NetBSD.
> So, the rest of the libsanitizer port to NetBSD in GCC is missing too
> and should be submitted together with this change.
> 
>   Jakub
> 

There are missing symbols without sanitizer_platform_limits_netbsd.cc.

I've planned to submit configure.tgt change separately. Should I squash
both changes into one commit?



signature.asc
Description: OpenPGP digital signature


[PATCH] Include missing source file for sanitizers on NetBSD

2017-10-26 Thread Kamil Rytarowski
2017-10-26  Kamil Rytarowski  <n...@gmx.com>

* sanitizer_common/Makefile.am (sanitizer_common_files): Add
sanitizer_platform_limits_netbsd.cc.
* sanitizer_common/Makefile.in: Regenerated.
---
 libsanitizer/ChangeLog| 6 ++
 libsanitizer/sanitizer_common/Makefile.am | 2 +-
 libsanitizer/sanitizer_common/Makefile.in | 5 -
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 63e71317cbf..c9863c281d1 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-26  Kamil Rytarowski  <n...@gmx.com>
+
+   * sanitizer_common/Makefile.am (sanitizer_common_files): Add
+   sanitizer_platform_limits_netbsd.cc.
+   * sanitizer_common/Makefile.in: Regenerated.
+
 2017-10-20  Jakub Jelinek  <ja...@redhat.com>
 
PR sanitizer/82595
diff --git a/libsanitizer/sanitizer_common/Makefile.am 
b/libsanitizer/sanitizer_common/Makefile.am
index adaab4cee54..70563eded36 100644
--- a/libsanitizer/sanitizer_common/Makefile.am
+++ b/libsanitizer/sanitizer_common/Makefile.am
@@ -41,6 +41,7 @@ sanitizer_common_files = \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_posix.cc \
+   sanitizer_platform_limits_netbsd.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
@@ -114,4 +115,3 @@ AM_MAKEFLAGS = \
 MAKEOVERRIDES=
 
 ## 
-
diff --git a/libsanitizer/sanitizer_common/Makefile.in 
b/libsanitizer/sanitizer_common/Makefile.in
index b2acc5caf56..f05c181f0b1 100644
--- a/libsanitizer/sanitizer_common/Makefile.in
+++ b/libsanitizer/sanitizer_common/Makefile.in
@@ -91,7 +91,8 @@ am__objects_1 = sancov_flags.lo sanitizer_allocator.lo \
sanitizer_mac.lo sanitizer_mac_libcdep.lo \
sanitizer_persistent_allocator.lo \
sanitizer_platform_limits_linux.lo \
-   sanitizer_platform_limits_posix.lo sanitizer_posix.lo \
+   sanitizer_platform_limits_posix.lo \
+   sanitizer_platform_limits_netbsd.lo sanitizer_posix.lo \
sanitizer_posix_libcdep.lo sanitizer_printf.lo \
sanitizer_procmaps_common.lo sanitizer_procmaps_freebsd.lo \
sanitizer_procmaps_linux.lo sanitizer_procmaps_mac.lo \
@@ -323,6 +324,7 @@ sanitizer_common_files = \
sanitizer_persistent_allocator.cc \
sanitizer_platform_limits_linux.cc \
sanitizer_platform_limits_posix.cc \
+   sanitizer_platform_limits_netbsd.cc \
sanitizer_posix.cc \
sanitizer_posix_libcdep.cc \
sanitizer_printf.cc \
@@ -468,6 +470,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_mac_libcdep.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_persistent_allocator.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_linux.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_netbsd.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_platform_limits_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sanitizer_posix.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ 
@am__quote@./$(DEPDIR)/sanitizer_posix_libcdep.Plo@am__quote@
-- 
2.14.2



Re: [RFC PATCH] Merge libsanitizer from upstream

2017-10-19 Thread Kamil Rytarowski
On 19.10.2017 13:17, Jakub Jelinek wrote:
> On Thu, Oct 19, 2017 at 02:07:24PM +0300, Maxim Ostapenko wrote:
>>> Is the patch (the merge + this incremental) ok for trunk?
>>
>> I think the patch is OK, just wondering about two things:
> 
> Richi just approved the patch on IRC, so I'll commit, then we can deal with
> follow-ups.
> 
>> 1) We have a bunch of GCC local patches, did you include them into a
>> cumulative patch (I guess yes)?
> 
> I have done some verification today, diff from upstream r285547 to unpatched
> GCC (with the LLVM Compiler infrastructure two liners removed), attached P1,
> and diff from upstream r315899 to patched GCC (again, two liners removed),
> attached P2 and went through the changes in P1 and verified that except for
> the ubsan backwards compatibility we had that can't work anymore everything
> else was upstreamed, or remained in P2.  So P2 is the current diff from
> upstream, with the sanitizer_common/sanitizer_symbolizer_libbacktrace.cc
> changes now filed upstream.
> 
>> 2) Upstream has enabled LSan for x86 and ARM, is it worth to enable them in
>> GCC too?
> 
> Maybe, feel free to post patches.  For LSan we need to split off lsan_preinit
> out of liblsan and link it into executables, will handle it next (there is a
> PR about it, just wanted to wait until the merge is in).
> 
>   Jakub
> 

NetBSD/amd64 ships now with asan, ubsan, libfuzzer (WIP) and safestack
upstreamed.

tsan is work-in-progress and it will be followed by msan.

"make check-tsan" with local patches results so far:

Expected Passes: 248
Expected Failures  : 1
Unsupported Tests  : 83
Unexpected Failures: 44

It's worth to enable the upstreamed features on the GCC/NetBSD frontend
as well. We are doing it currently downstream in the NetBSD distribution.



signature.asc
Description: OpenPGP digital signature