[PATCH] Don't override various Makefile variables for gnulib et al

Christian Biesinger via gdb-patches
2019-11-22T23:30:43Z

Normally the toplevel Makefile will pass various CC=foo and other
flags down to subdir Makefiles. However, for Gnulib this is a problem
because Gnulib's configure specifically sets CC to something that
includes a -std=gnu11 flag on some systems, and this override would
set it back to CC=gcc, leading to compile errors in a GDB build
with an updated Gnulib.

I don't believe this is needed outside of GCC, so this patch changes
Gnulib and other non-GCC modules to just not override any flags --
the values set during configure time should be fine. If a user
overrides them manually when invoking make, those will still work.

Under the same condition, I also removed the host_exports. I don't
understand why this is ever necessary (this is only after configure
has run).

The other option is to clear MAKEOVERRIDES in gnulib/Makefile.am, but
that means the user can't override any variables for this subdirectory.

ChangeLog:

2019-11-22 Christian Biesinger <cbiesinger@google.com>

* Makefile.def: Pass no_exports_and_flags to various non-GCC
modules.
* Makefile.in: Allow passing a no_exports_and_flags argument to
"all" to suppress emitting exports and make flags. Useful when
invoked via host_modules from Makefile.def.
* Makefile.tpl: Regenerate.

Change-Id: I7d80328cf81c133ba6157eec7d10c422b6790723
---
Makefile.def | 12 ++++++------
Makefile.in | 30 ++++++++++++------------------
Makefile.tpl | 9 ++++++---
3 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/Makefile.def b/Makefile.def
index 311feb9de3..e1ff065202 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -33,7 +33,7 @@ build_modules= { module= fixincludes; };
build_modules= { module= libcpp;
extra_configure_flags='--disable-nls am_cv_func_iconv=no';};

-host_modules= { module= bfd; bootstrap=true; };
+host_modules= { module= bfd; bootstrap=true; no_exports_and_flags=true; };
host_modules= { module= opcodes; bootstrap=true; };
host_modules= { module= binutils; bootstrap=true; };
host_modules= { module= bison; no_check_cross= true; };
@@ -105,15 +105,15 @@ host_modules= { module= libiconv;
missing= install-html;
missing= install-info; };
host_modules= { module= m4; };
-host_modules= { module= readline; };
+host_modules= { module= readline; no_exports_and_flags=true; };
host_modules= { module= sid; };
-host_modules= { module= sim; };
+host_modules= { module= sim; no_exports_and_flags=true; };
host_modules= { module= texinfo; no_install= true; };
host_modules= { module= zlib; no_install=true; no_check=true;
bootstrap=true;
extra_configure_flags='@extra_host_zlib_configure_flags@';};
-host_modules= { module= gnulib; };
-host_modules= { module= gdb; };
+host_modules= { module= gnulib; no_exports_and_flags=true; };
+host_modules= { module= gdb; no_exports_and_flags=true; };
host_modules= { module= expect; };
host_modules= { module= guile; };
host_modules= { module= tk; };
@@ -129,7 +129,7 @@ host_modules= { module= lto-plugin; bootstrap=true;
extra_make_flags='@extra_linker_plugin_flags@'; };
host_modules= { module= libcc1; extra_configure_flags=--enable-shared; };
host_modules= { module= gotools; };
-host_modules= { module= libctf; no_check=true;
+host_modules= { module= libctf; no_check=true; no_exports_and_flags=true;
bootstrap=true; };

target_modules = { module= libstdc++-v3;
diff --git a/Makefile.in b/Makefile.in
index 1aabf6ede4..bd41753543 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -3414,10 +3414,9 @@ maybe-all-bfd: all-bfd
all-bfd: configure-bfd
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) \
+ \
(cd $(HOST_SUBDIR)/bfd && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
- $(TARGET-bfd))
+ $(MAKE) $(TARGET-bfd))
@endif bfd

@@ -25530,10 +25529,9 @@ all-readline: configure-readline
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) \
+ \
(cd $(HOST_SUBDIR)/readline && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
- $(TARGET-readline))
+ $(MAKE) $(TARGET-readline))
@endif readline

@@ -26412,10 +26410,9 @@ all-sim: configure-sim
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) \
+ \
(cd $(HOST_SUBDIR)/sim && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
- $(TARGET-sim))
+ $(MAKE) $(TARGET-sim))
@endif sim

@@ -28150,10 +28147,9 @@ all-gnulib: configure-gnulib
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) \
+ \
(cd $(HOST_SUBDIR)/gnulib && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
- $(TARGET-gnulib))
+ $(MAKE) $(TARGET-gnulib))
@endif gnulib

@@ -28591,10 +28587,9 @@ all-gdb: configure-gdb
@: $(MAKE); $(unstage)
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) \
+ \
(cd $(HOST_SUBDIR)/gdb && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
- $(TARGET-gdb))
+ $(MAKE) $(TARGET-gdb))
@endif gdb

@@ -33571,10 +33566,9 @@ maybe-all-libctf: all-libctf
all-libctf: configure-libctf
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- $(HOST_EXPORTS) \
+ \
(cd $(HOST_SUBDIR)/libctf && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_HOST_FLAGS) $(STAGE1_FLAGS_TO_PASS) \
- $(TARGET-libctf))
+ $(MAKE) $(TARGET-libctf))
@endif libctf

diff --git a/Makefile.tpl b/Makefile.tpl
index 5b118a8ba4..876ecf8dbd 100644
--- a/Makefile.tpl
+++ b/Makefile.tpl
@@ -1126,10 +1126,13 @@ all-[+prefix+][+module+]: configure-[+prefix+][+module+][+ IF bootstrap +][+ ELS
@: $(MAKE); $(unstage)[+ ENDIF bootstrap +]
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
- [+exports+] [+extra_exports+] \
+ [+ IF no_exports_and_flags +][+ ELSE
+ +][+exports+] [+extra_exports+][+
+ ENDIF no_exports_and_flags +] \
(cd [+subdir+]/[+module+] && \
- $(MAKE) $(BASE_FLAGS_TO_PASS) [+args+] [+stage1_args+] [+extra_make_flags+] \
- $(TARGET-[+prefix+][+module+]))
+ $(MAKE) [+ IF no_exports_and_flags +][+ ELSE
+ +]$(BASE_FLAGS_TO_PASS) [+args+] [+stage1_args+] [+extra_make_flags+] \
+ [+ ENDIF no_exports_and_flags +]$(TARGET-[+prefix+][+module+]))
@endif [+prefix+][+module+]

[+ IF bootstrap +]

base-commit: 987012b89bce7f6385ed88585547f852a8005a3f
--
2.24.0.432.g9d3f5f5b63-goog