This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Paolo Bonzini <bonzini at gnu dot org>, DJ Delorie <dj at redhat dot com>, Alexandre Oliva <aoliva at redhat dot com>, Ralf Wildenhues <Ralf dot Wildenhues at gmx dot de>, Richard Biener <rguenther at suse dot de>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 25 Mar 2014 15:01:26 -0700
- Subject: Re: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)
- Authentication-results: sourceware.org; auth=none
- References: <20140325192856 dot GW1817 at tucnak dot redhat dot com> <CAMe9rOo4BKhyrf=T7zDV9uPwm8KvD91K7wiRPtVojZo5YE+G4w at mail dot gmail dot com> <20140325195721 dot GY1817 at tucnak dot redhat dot com> <20140325201707 dot GZ1817 at tucnak dot redhat dot com> <20140325213200 dot GA1817 at tucnak dot redhat dot com>
On Tue, Mar 25, 2014 at 2:32 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Mar 25, 2014 at 09:17:07PM +0100, Jakub Jelinek wrote:
>> On Tue, Mar 25, 2014 at 08:57:21PM +0100, Jakub Jelinek wrote:
>> > It works fine for ubsan, and your fix is not the right thing to do,
>> > e.g. bootstrap-ubsan reveals some bugs in libiberty which would be otherwise
>> > unnoticed if you always filter away the sanitizing options from libiberty.
>> >
>> > So, I think my patch is the right thing to do for ubsan bootstraps, and for
>> > asan bootstraps we'll need something different (build libiberty twice, or
>> > build selected libiberty objects inside lto-plugin/ directory again, or
>> > something similar). You do want the libiberty parts in cc1, cc1plus, xgcc
>> > etc. instrumented.
>>
>> Seems libiberty builds (optionally) everything also into pic/ subdirectory,
>> I think best would be if it in case it found -fsanitize=address in CFLAGS
>> also built everything into noasan/ subdirectory with additional
>> -fno-sanitize=address, and filter out -fsanitize=address just in lto-plugin
>> Makefile and use noasan/libiberty.a preferrably over pic/libiberty.a over
>> libiberty.a.
>> I guess I can cook up a patch tomorrow for that, though probably won't have
>> cycles to fully test that.
>
> Here is completely untested patch that should do that (on top of the two
> PR56781 patches I've posted earlier today). Can you give them a shot?
>
> 2014-03-25 Jakub Jelinek <jakub@redhat.com>
>
> PR sanitizer/56781
> lto-plugin/
> * Makefile.am (CFLAGS, LDFLAGS): Filter out -fsanitize=address.
> (liblto_plugin_la_LIBADD, liblto_plugin_la_LDFLAGS,
> liblto_plugin_la_DEPENDENCIES): Prefer ../libiberty/noasan/libiberty.a
> over ../libiberty/pic/libiberty.a if the former exists.
> * Makefile.in: Regenerated.
> libiberty/
> * maint-tool: Also emit rule for noasan/ subdirectory.
> * configure.ac (NOASANFLAG): Set and substitute.
> * Makefile.in: Regenerated.
> (NOASANFLAG): Set.
> (all, $(TARGETLIB), mostlyclean): Handle noasan subdir like pic
> subdir.
> (stamp-noasandir): New goal.
> * configure: Regenerated.
>
I got
/export/gnu/import/git/gcc/libiberty/configure: line 4977: syntax
error near unexpected token `-fsanitize=address'
/export/gnu/import/git/gcc/libiberty/configure: line 4977: ` *
-fsanitize=address *) NOASANFLAG=-fno-sanitize=address ;;'
checking fcntl.h usability... yes
H.J.