binutils: fix build with host gcc < 4.9
[openwrt/openwrt.git] / package / devel / binutils / patches / 0001-Do-not-pass-host-compiler-sanitization-flags-on-to-l.patch
1 From 183eb37e25d903ccd68cc2d8f8a37e75872c03d2 Mon Sep 17 00:00:00 2001
2 From: Nick Clifton <nickc@redhat.com>
3 Date: Tue, 6 Sep 2016 17:35:35 +0100
4 Subject: [PATCH 1/2] Do not pass host compiler sanitization flags on to linker
5 testsuite.
6
7 * Makefile.am (CFLAGS_FOR_TARGET): Define as a copy of CFLAGS but
8 without any sanitization options.
9 (CXXFLAGS_FOR_TARGET): Define as a copy of CXXFLAGS but without
10 any sanitization options.
11 (check-DEJAGNU): Pass CFLAGS_FOR_TARGET and CXXFLAGS_FOR_TARGET
12 as CFLAGS and CXXFLAGS respectively.
13 ---
14 ld/Makefile.am | 8 ++++++--
15 ld/Makefile.in | 8 ++++++--
16 2 files changed, 12 insertions(+), 4 deletions(-)
17
18 --- a/ld/Makefile.am
19 +++ b/ld/Makefile.am
20 @@ -136,6 +136,10 @@ CXX_FOR_TARGET = ` \
21 fi; \
22 fi`
23
24 +# Strip out sanitization options as we want to test building binaries without any extra paraphernalia
25 +CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
26 +CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
27 +
28 transform = s/^ld-new$$/$(installed_linker)/;@program_transform_name@
29 bin_PROGRAMS = ld-new
30 info_TEXINFOS = ld.texinfo
31 @@ -2075,8 +2079,8 @@ check-DEJAGNU: site.exp
32 runtest=$(RUNTEST); \
33 if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
34 $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
35 - CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS)" \
36 - CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS)" \
37 + CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \
38 + CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
39 CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
40 OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" \
41 LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
42 --- a/ld/Makefile.in
43 +++ b/ld/Makefile.in
44 @@ -507,6 +507,10 @@ CXX_FOR_TARGET = ` \
45 fi; \
46 fi`
47
48 +
49 +# Strip out sanitization options as they require special host libraries.
50 +CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
51 +CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
52 info_TEXINFOS = ld.texinfo
53 ld_TEXINFOS = configdoc.texi
54 noinst_TEXINFOS = ldint.texinfo
55 @@ -3644,8 +3648,8 @@ check-DEJAGNU: site.exp
56 runtest=$(RUNTEST); \
57 if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
58 $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
59 - CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS)" \
60 - CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS)" \
61 + CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \
62 + CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
63 CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
64 OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" \
65 LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \