Bug 56781 - boostrap-asan failure: fixincl fails to link (missing -lasan)
Summary: boostrap-asan failure: fixincl fails to link (missing -lasan)
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: sanitizer (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2013-03-29 13:33 UTC by Bernhard Reutner-Fischer
Modified: 2014-04-17 12:25 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-03-29 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bernhard Reutner-Fischer 2013-03-29 13:33:11 UTC
bootstrap on x86_64-linux-gnu fails with:

/scratch/obj.x86_64/gcc-4.9.mine/./gcc/xgcc -B/scratch/obj.x86_64/gcc-4.9.mine/./gcc/ -B/opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/bin/ -B/opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/lib/ -isystem /opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/include -isystem /opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/sys-include    -Og -g3 -ggdb3 -static-libstdc++ -static-libgcc  -o fixincl fixincl.o fixtests.o fixfixes.o server.o procopen.o fixlib.o fixopts.o ../libiberty/libiberty.a 
../libiberty/libiberty.a(regex.o): In function `byte_compile_range':
/scratch/obj.x86_64/gcc-4.9.mine/libiberty/../../../src/gcc-4.9.mine/libiberty/regex.c:4499: undefined reference to `__asan_report_store1'
/scratch/obj.x86_64/gcc-4.9.mine/libiberty/../../../src/gcc-4.9.mine/libiberty/regex.c:4499: undefined reference to `__asan_report_load1'
[snip]

we would obviously need to link against asan but it is not immediately obvious to me how to pass POSTSTAGE1_LDFLAGS to fixincludes/

$ /scratch/obj.x86_64/gcc-4.9.mine/./gcc/xgcc -B/scratch/obj.x86_64/gcc-4.9.mine/./gcc/ -B/scratch/obj.x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/libsanitizer/asan -B/scratch/obj.x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/libsanitizer/asan/.libs -B/opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/bin/ -B/opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/lib/ -isystem /opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/include -isystem /opt/x86_64/gcc-4.9.mine/x86_64-unknown-linux-gnu/sys-include    -Og -g3 -ggdb3 -static-libstdc++ -static-libgcc  -o fixincl fixincl.o fixtests.o fixfixes.o server.o procopen.o fixlib.o fixopts.o ../libiberty/libiberty.a -fsanitize=address -static-libasan
produces the desired fixincl

$ /scratch/obj.x86_64/gcc-4.9.mine/./gcc/xgcc -v
Using built-in specs.
COLLECT_GCC=/scratch/obj.x86_64/gcc-4.9.mine/./gcc/xgcc
Target: x86_64-unknown-linux-gnu
Configured with: ../../src/gcc-4.9.mine/configure -v --enable-languages=c,lto,fortran,c++,go LD=/usr/bin/ld.bfd CFLAGS='-O2 -g3 -ggdb3' CXXFLAGS='-O2 -g3 -ggdb3' 'BOOT_CFLAGS=-O2 -g3 -ggdb3' 'BOOT_CXXFLAGS=-O2 -g3 -ggdb3' 'CFLAGS_FOR_TARGET=-Og -g3 -ggdb3' 'CXXFLAGS_FOR_TARGET=-Og -g3 -ggdb3' --prefix=/opt/x86_64/gcc-4.9.mine// --enable-shared --with-system-zlib --enable-nls --without-included-gettext --enable-threads=posix --program-suffix=-4.9.mine-HEAD --with-build-config=bootstrap-asan --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-mpfr --disable-werror --enable-checking=yes --enable-debug -C --disable-intermodule --enable-multilib --disable-libstdcxx-pch --enable-bootstrap --enable-checking=release --with-cpu=native --with-tune=native --enable-plugin
Thread model: posix
gcc version 4.9.0 20130327 (experimental) [vnhoist revision 32ddde1:a851c38:065ec6e627efa59b32f9fb743368a4a55c4ac310] (GCC)
Comment 2 Bernhard Reutner-Fischer 2013-04-04 11:41:08 UTC
(In reply to comment #1)
> Please try
> 
> http://gcc.gnu.org/git/?p=gcc.git;a=commit;h=61be6ebfe22f9ce5799dac2679541911eb744a86
> http://gcc.gnu.org/git/?p=gcc.git;a=commit;h=6b526a34a0bc852461cb50636c6e757bf8e27faf

I don't think that the above is the correct thing to do;
Shouldn't the post-stage1 libs be built with and linked against asan?
Like (i know that this is a generated file) below which reinstates bootstrap:

diff --git a/Makefile.in b/Makefile.in
index 08049de..52249a0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -7786,7 +7786,7 @@ configure-fixincludes:
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
        test ! -f $(HOST_SUBDIR)/fixincludes/Makefile || exit 0; \
        $(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/fixincludes ; \
-       $(HOST_EXPORTS)  \
+       $(POSTSTAGE1_HOST_EXPORTS)  \
        echo Configuring in $(HOST_SUBDIR)/fixincludes; \
        cd "$(HOST_SUBDIR)/fixincludes" || exit 1; \
        case $(srcdir) in \
@@ -7818,7 +7818,7 @@ all-fixincludes: configure-fixincludes
        @: $(MAKE); $(unstage)
        @r=`${PWD_COMMAND}`; export r; \
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-       $(HOST_EXPORTS)  \
+       $(POSTSTAGE1_HOST_EXPORTS)  \
        (cd $(HOST_SUBDIR)/fixincludes && \
          $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS)  \
                $(TARGET-fixincludes))
@@ -7836,7 +7836,7 @@ check-fixincludes:
        @: $(MAKE); $(unstage)
        @r=`${PWD_COMMAND}`; export r; \
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-       $(HOST_EXPORTS) \
+       $(POSTSTAGE1_HOST_EXPORTS) \
        (cd $(HOST_SUBDIR)/fixincludes && \
          $(MAKE) $(FLAGS_TO_PASS)  check)
 
@@ -7851,7 +7851,7 @@ install-fixincludes: installdirs
        @: $(MAKE); $(unstage)
        @r=`${PWD_COMMAND}`; export r; \
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-       $(HOST_EXPORTS) \
+       $(POSTSTAGE1_HOST_EXPORTS) \
        (cd $(HOST_SUBDIR)/fixincludes && \
          $(MAKE) $(FLAGS_TO_PASS)  install)
 
@@ -7866,7 +7866,7 @@ install-strip-fixincludes: installdirs
        @: $(MAKE); $(unstage)
        @r=`${PWD_COMMAND}`; export r; \
        s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
-       $(HOST_EXPORTS) \
+       $(POSTSTAGE1_HOST_EXPORTS) \
        (cd $(HOST_SUBDIR)/fixincludes && \
          $(MAKE) $(FLAGS_TO_PASS)  install-strip)
Comment 3 Jakub Jelinek 2014-03-26 09:20:16 UTC
Author: jakub
Date: Wed Mar 26 09:19:44 2014
New Revision: 208842

URL: http://gcc.gnu.org/viewcvs?rev=208842&root=gcc&view=rev
Log:
	PR sanitizer/56781
	* Makefile.def: Set bootstrap=true; for host fixincludes.
	* configure.ac: Don't bootstrap host fixincludes unless
	--with-build-config=bootstrap-{a,ub}san.
	* Makefile.in: Regenerated.
	* configure: Regenerated.

Modified:
    trunk/ChangeLog
    trunk/Makefile.def
    trunk/Makefile.in
    trunk/configure
    trunk/configure.ac
Comment 4 Jakub Jelinek 2014-04-17 12:24:00 UTC
Author: jakub
Date: Thu Apr 17 12:23:28 2014
New Revision: 209475

URL: http://gcc.gnu.org/viewcvs?rev=209475&root=gcc&view=rev
Log:
	PR sanitizer/56781
	* libtool-ldflags: Also prefix -static-lib*, -shared-lib*
	and -B* options with -Xcompiler.
lto-plugin/
	* Makefile.am (LTLDFLAGS, liblto_plugin_la_LINK): New variables.
	* Makefile.in: Regenerated.

Modified:
    trunk/ChangeLog
    trunk/libtool-ldflags
    trunk/lto-plugin/ChangeLog
    trunk/lto-plugin/Makefile.am
    trunk/lto-plugin/Makefile.in
Comment 5 Jakub Jelinek 2014-04-17 12:25:57 UTC
Author: jakub
Date: Thu Apr 17 12:25:25 2014
New Revision: 209476

URL: http://gcc.gnu.org/viewcvs?rev=209476&root=gcc&view=rev
Log:
	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.

Modified:
    trunk/libiberty/ChangeLog
    trunk/libiberty/Makefile.in
    trunk/libiberty/configure
    trunk/libiberty/configure.ac
    trunk/libiberty/maint-tool
    trunk/lto-plugin/ChangeLog
    trunk/lto-plugin/Makefile.am
    trunk/lto-plugin/Makefile.in