This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: 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>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 25 Mar 2014 20:28:56 +0100
- Subject: [PATCH] Fix --with-build-config=bootstrap-ubsan bootstrap of lto-plugin (PR sanitizer/56781)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
lto-plugin is another problematic directory in asan/ubsan bootstraps.
Unlike fixincludes, it is bootstrapped, and like fixincludes it is also
linked against host libiberty. The problem for lto-plugin is that the
-static-libubsan -fsanitize=undefined -B/some/path/to/libsanitizer/ -B/some/path/to/libsanitizer/ubsan/.libs/
switches are eaten by libtool, which throws them away on the floor.
We apparently have libtool-ldflags which is used by other libraries
to filter some options so that libtool doesn't eat them, but even after
applying the lto-plugin/Makefile.am changes I got failures, because
while -fsanitize=undefined now made it through, the rest of the options
didn't. So, this patch also tweaks libtool-ldflags to handle some more
options.
Bootstrapped/regtested on x86_64-linux (normally) and i686-linux
(--with-build-config=bootstrap-ubsan). Ok for trunk?
2014-03-25 Jakub Jelinek <jakub@redhat.com>
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.
--- libtool-ldflags.jj 2008-09-05 12:59:51.000000000 +0200
+++ libtool-ldflags 2014-03-25 15:43:36.726185093 +0100
@@ -2,7 +2,7 @@
# Script to translate LDFLAGS into a form suitable for use with libtool.
-# Copyright (C) 2005 Free Software Foundation, Inc.
+# Copyright (C) 2005-2014 Free Software Foundation, Inc.
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,14 +36,15 @@ prev_arg=
for arg
do
case $arg in
- -f*|--*)
+ -f*|--*|-static-lib*|-shared-lib*|-B*)
# Libtool does not ascribe any special meaning options
# that begin with -f or with a double-dash. So, it will
# think these options are linker options, and prefix them
# with "-Wl,". Then, the compiler driver will ignore the
# options. So, we prefix these options with -Xcompiler to
# make clear to libtool that they are in fact compiler
- # options.
+ # options. Similarly for e.g. -static-libstdc++, or
+ # -B/some/path.
case $prev_arg in
-Xpreprocessor|-Xcompiler|-Xlinker)
# This option is already prefixed; don't prefix it again.
--- lto-plugin/Makefile.am.jj 2014-03-17 20:01:54.000000000 +0100
+++ lto-plugin/Makefile.am 2014-03-25 15:46:26.832294118 +0100
@@ -18,6 +18,7 @@ in_gcc_libs = $(foreach lib, $(libexecsu
# Can be removed when libiberty becomes a normal convenience library
Wc=-Wc,
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
liblto_plugin_la_SOURCES = lto-plugin.c
liblto_plugin_la_LIBADD = \
@@ -28,6 +29,9 @@ liblto_plugin_la_LDFLAGS = $(AM_LDFLAGS)
$(if $(wildcard ../libiberty/pic/libiberty.a),,-Wc,../libiberty/libiberty.a)
liblto_plugin_la_DEPENDENCIES = $(if $(wildcard \
../libiberty/pic/libiberty.a),../libiberty/pic/libiberty.a,)
+liblto_plugin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(liblto_plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
all-local: $(in_gcc_libs)
--- lto-plugin/Makefile.in.jj 2014-03-17 20:01:54.000000000 +0100
+++ lto-plugin/Makefile.in 2014-03-25 15:47:10.059071353 +0100
@@ -84,9 +84,6 @@ am__installdirs = "$(DESTDIR)$(libexecsu
LTLIBRARIES = $(libexecsub_LTLIBRARIES)
am_liblto_plugin_la_OBJECTS = lto-plugin.lo
liblto_plugin_la_OBJECTS = $(am_liblto_plugin_la_OBJECTS)
-liblto_plugin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
- $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
- $(liblto_plugin_la_LDFLAGS) $(LDFLAGS) -o $@
DEFAULT_INCLUDES = -I.@am__isrc@
depcomp =
am__depfiles_maybe =
@@ -239,6 +236,7 @@ in_gcc_libs = $(foreach lib, $(libexecsu
# Can be removed when libiberty becomes a normal convenience library
Wc = -Wc,
+LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
liblto_plugin_la_SOURCES = lto-plugin.c
liblto_plugin_la_LIBADD = \
$(if $(wildcard ../libiberty/pic/libiberty.a),$(Wc)../libiberty/pic/libiberty.a,)
@@ -251,6 +249,10 @@ liblto_plugin_la_LDFLAGS = $(AM_LDFLAGS)
liblto_plugin_la_DEPENDENCIES = $(if $(wildcard \
../libiberty/pic/libiberty.a),../libiberty/pic/libiberty.a,)
+liblto_plugin_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(liblto_plugin_la_LDFLAGS) $(LTLDFLAGS) -o $@
+
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
Jakub