public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/3] gnulib: support building for --build [PR sim/30882]
@ 2023-10-15 17:17 Mike Frysinger
  2023-10-15 17:17 ` [PATCH 2/3] gnulib: enable a --build setup for sim " Mike Frysinger
  2023-10-15 17:17 ` [PATCH 3/3] sim: use build-gnulib with build-time tools " Mike Frysinger
  0 siblings, 2 replies; 3+ messages in thread
From: Mike Frysinger @ 2023-10-15 17:17 UTC (permalink / raw)
  To: gdb-patches

The sim tree has some build-time programs for generating source files
that are a bit complicated and expect a POSIX-compatible system.  But
some targets (e.g. mingw) might not provide up-to-date support.  Since
we already have gnulib in the tree, leverage that to also build for
the --build system.

The top-level configure logic will pass down --with-build-subdir when
the subdir is built for it.  Use that to adjust the output variable
names and paths.  This allows us to include the gnulib makefile frags
for both --host and --build simultaneously.
---
 gnulib/Makefile.gnulib.inc.in | 18 ++++++++-----
 gnulib/Makefile.in            |  2 ++
 gnulib/configure              | 50 ++++++++++++++++++++++++++---------
 gnulib/configure.ac           | 12 +++++++++
 gnulib/import/Makefile.in     |  2 ++
 5 files changed, 65 insertions(+), 19 deletions(-)

diff --git a/gnulib/Makefile.gnulib.inc.in b/gnulib/Makefile.gnulib.inc.in
index 777a99c58d17..755516632f75 100644
--- a/gnulib/Makefile.gnulib.inc.in
+++ b/gnulib/Makefile.gnulib.inc.in
@@ -31,16 +31,20 @@
 #
 # INCGNU: A list of -I.... include paths that should be passed to the
 #        compiler, these are where the gnulib headers can be found.
+#
+# When building for --build, the variables will be prefixed with BUILD_.
 
 # Packages must define the relative path to gnulib's parent dir.
 ifndef GNULIB_PARENT_DIR
 $(error missing GNULIB_PARENT_DIR)
 endif
 
-LIBGNU = $(GNULIB_PARENT_DIR)/gnulib/import/libgnu.a
-LIBGNU_EXTRA_LIBS = @FREXPL_LIBM@ @FREXP_LIBM@ @INET_NTOP_LIB@ \
-                    @LIBTHREAD@ @LIB_GETLOGIN@ @LIB_GETRANDOM@ \
-                    @LIB_HARD_LOCALE@ @LIB_MBRTOWC@ \
-                    @LIB_SETLOCALE_NULL@ @LIBINTL@ @LIB_SELECT@ @LIBSOCKET@
-INCGNU = -I$(srcdir)/$(GNULIB_PARENT_DIR)/gnulib/import \
-         -I$(GNULIB_PARENT_DIR)/gnulib/import
+@VAR_PREFIX@LIBGNU = $(GNULIB_PARENT_DIR)/@BUILD_SUBDIR@gnulib/import/libgnu.a
+@VAR_PREFIX@LIBGNU_EXTRA_LIBS = \
+	@FREXPL_LIBM@ @FREXP_LIBM@ @INET_NTOP_LIB@ \
+	@LIBTHREAD@ @LIB_GETLOGIN@ @LIB_GETRANDOM@ \
+	@LIB_HARD_LOCALE@ @LIB_MBRTOWC@ \
+	@LIB_SETLOCALE_NULL@ @LIBINTL@ @LIB_SELECT@ @LIBSOCKET@
+@VAR_PREFIX@INCGNU = \
+	-I$(srcdir)/$(GNULIB_PARENT_DIR)/gnulib/import \
+	-I$(GNULIB_PARENT_DIR)/@BUILD_SUBDIR@gnulib/import
diff --git a/gnulib/configure.ac b/gnulib/configure.ac
index 9f081614efd5..72a16d5ae6ea 100644
--- a/gnulib/configure.ac
+++ b/gnulib/configure.ac
@@ -56,6 +56,18 @@ AC_CHECK_TOOL(AR, ar)
 # Checks for libraries.  #
 # ---------------------- #
 
+AC_ARG_WITH(build-subdir,
+  [AS_HELP_STRING([--with-build-subdir=SUBDIR], [Configuring in a subdirectory for build])])
+
+VAR_PREFIX=
+BUILD_SUBDIR=
+AS_IF([test -n "${with_build_subdir}"], [dnl
+  VAR_PREFIX="BUILD_"
+  BUILD_SUBDIR="${with_build_subdir}/"
+])
+AC_SUBST(BUILD_SUBDIR)
+AC_SUBST(VAR_PREFIX)
+
 AC_CONFIG_FILES(Makefile.gnulib.inc)
 
 AC_OUTPUT(Makefile import/Makefile,
-- 
2.42.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/3] gnulib: enable a --build setup for sim [PR sim/30882]
  2023-10-15 17:17 [PATCH 1/3] gnulib: support building for --build [PR sim/30882] Mike Frysinger
@ 2023-10-15 17:17 ` Mike Frysinger
  2023-10-15 17:17 ` [PATCH 3/3] sim: use build-gnulib with build-time tools " Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2023-10-15 17:17 UTC (permalink / raw)
  To: gdb-patches

The sim tree has some build-time programs for generating source files
that are a bit complicated and expect a POSIX-compatible system.  Use
the existing gnulib project to provide missing APIs.
---
 Makefile.def |  2 ++
 Makefile.in  | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure    |  5 +++++
 configure.ac |  5 +++++
 4 files changed, 71 insertions(+)

diff --git a/Makefile.def b/Makefile.def
index 15c068e4ac40..3e477fe073e0 100644
--- a/Makefile.def
+++ b/Makefile.def
@@ -27,6 +27,7 @@ AutoGen definitions Makefile.tpl;
 build_modules= { module= libiberty; };
 build_modules= { module= bison; };
 build_modules= { module= flex; };
+build_modules= { module= gnulib; };
 build_modules= { module= m4; };
 build_modules= { module= texinfo; };
 build_modules= { module= fixincludes; };
@@ -585,6 +586,7 @@ dependencies = { module=install-strip-sid; on=install-strip-tcl; };
 dependencies = { module=install-sid; on=install-tk; };
 dependencies = { module=install-strip-sid; on=install-strip-tk; };
 
+dependencies = { module=configure-sim; on=all-build-gnulib; };
 dependencies = { module=configure-sim; on=all-gnulib; };
 dependencies = { module=configure-sim; on=configure-intl; };
 dependencies = { module=all-sim; on=all-intl; };
diff --git a/Makefile.in b/Makefile.in
index efe3565a6e5e..4f58b288a9c0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1199,6 +1199,7 @@ all:
 all-build: maybe-all-build-libiberty
 all-build: maybe-all-build-bison
 all-build: maybe-all-build-flex
+all-build: maybe-all-build-gnulib
 all-build: maybe-all-build-m4
 all-build: maybe-all-build-texinfo
 all-build: maybe-all-build-fixincludes
@@ -3300,6 +3301,63 @@ all-build-flex: configure-build-flex
 
 
 
+.PHONY: configure-build-gnulib maybe-configure-build-gnulib
+maybe-configure-build-gnulib:
+@if gcc-bootstrap
+configure-build-gnulib: stage_current
+@endif gcc-bootstrap
+@if build-gnulib
+maybe-configure-build-gnulib: configure-build-gnulib
+configure-build-gnulib: 
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	test ! -f $(BUILD_SUBDIR)/gnulib/Makefile || exit 0; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(BUILD_SUBDIR)/gnulib; \
+	$(BUILD_EXPORTS)  \
+	echo Configuring in $(BUILD_SUBDIR)/gnulib; \
+	cd "$(BUILD_SUBDIR)/gnulib" || exit 1; \
+	case $(srcdir) in \
+	  /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \
+	  *) topdir=`echo $(BUILD_SUBDIR)/gnulib/ | \
+		sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \
+	esac; \
+	module_srcdir=gnulib; \
+	rm -f no-such-file || : ; \
+	CONFIG_SITE=no-such-file $(SHELL) \
+	  $$s/$$module_srcdir/configure \
+	  --srcdir=$${topdir}/$$module_srcdir \
+	  $(BUILD_CONFIGARGS) --build=${build_alias} --host=${build_alias} \
+	  --target=${target_alias}  \
+	  || exit 1
+@endif build-gnulib
+
+
+
+
+
+.PHONY: all-build-gnulib maybe-all-build-gnulib
+maybe-all-build-gnulib:
+@if gcc-bootstrap
+all-build-gnulib: stage_current
+@endif gcc-bootstrap
+@if build-gnulib
+TARGET-build-gnulib=all
+maybe-all-build-gnulib: all-build-gnulib
+all-build-gnulib: configure-build-gnulib
+	@: $(MAKE); $(unstage)
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	$(BUILD_EXPORTS)  \
+	(cd $(BUILD_SUBDIR)/gnulib && \
+	  $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_BUILD_FLAGS)   \
+		$(TARGET-build-gnulib))
+@endif build-gnulib
+
+
+
+
+
 .PHONY: configure-build-m4 maybe-configure-build-m4
 maybe-configure-build-m4:
 @if gcc-bootstrap
@@ -66801,6 +66859,7 @@ install-sid: maybe-install-tcl
 install-strip-sid: maybe-install-strip-tcl
 install-sid: maybe-install-tk
 install-strip-sid: maybe-install-strip-tk
+configure-sim: maybe-all-build-gnulib
 configure-sim: maybe-all-gnulib
 configure-sim: maybe-all-readline
 all-fastjar: maybe-all-build-texinfo
diff --git a/configure.ac b/configure.ac
index 01cfd017273a..23290ddaa6fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3076,6 +3076,11 @@ case " ${configdirs} " in
     configdirs="${configdirs} gnulib"
     ;;
 esac
+case " ${configdirs} " in
+  *\ sim\ *)
+    build_configdirs="${build_configdirs} gnulib"
+    ;;
+esac
 
 # Strip out unwanted targets.
 
-- 
2.42.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 3/3] sim: use build-gnulib with build-time tools [PR sim/30882]
  2023-10-15 17:17 [PATCH 1/3] gnulib: support building for --build [PR sim/30882] Mike Frysinger
  2023-10-15 17:17 ` [PATCH 2/3] gnulib: enable a --build setup for sim " Mike Frysinger
@ 2023-10-15 17:17 ` Mike Frysinger
  1 sibling, 0 replies; 3+ messages in thread
From: Mike Frysinger @ 2023-10-15 17:17 UTC (permalink / raw)
  To: gdb-patches

Some of our build-time tools are fairly complicated and require some
POSIX APIs that the build system doesn't provide.  Leverage the new
build-gnulib tree to provide fallback implementations automatically.
---
 sim/Makefile.am          |  4 ++++
 sim/Makefile.in          | 33 ++++++++++++++++++++++-----------
 sim/cr16/gencode.c       |  2 +-
 sim/cr16/local.mk        |  2 +-
 sim/d10v/gencode.c       |  3 +++
 sim/d10v/local.mk        |  2 +-
 sim/igen/filter.c        |  2 ++
 sim/igen/filter_host.c   |  3 +++
 sim/igen/gen-engine.c    |  3 +++
 sim/igen/gen-icache.c    |  3 +++
 sim/igen/gen-idecode.c   |  2 ++
 sim/igen/gen-itable.c    |  3 ++-
 sim/igen/gen-model.c     |  2 ++
 sim/igen/gen-semantics.c |  3 ++-
 sim/igen/gen-support.c   |  2 ++
 sim/igen/gen.c           |  2 ++
 sim/igen/igen.c          |  3 +++
 sim/igen/ld-cache.c      |  3 ++-
 sim/igen/ld-decode.c     |  4 +++-
 sim/igen/ld-insn.c       |  2 ++
 sim/igen/lf.c            |  2 ++
 sim/igen/local.mk        |  2 +-
 sim/igen/misc.c          |  3 ++-
 sim/igen/table.c         |  3 ++-
 sim/m32c/local.mk        |  1 +
 sim/m32c/opc2c.c         |  2 +-
 sim/m68hc11/gencode.c    |  2 +-
 sim/m68hc11/local.mk     |  1 +
 sim/sh/gencode.c         |  3 +++
 sim/sh/local.mk          |  1 +
 30 files changed, 80 insertions(+), 23 deletions(-)

diff --git a/sim/Makefile.am b/sim/Makefile.am
index 3693eb18d496..6cd85c7df957 100644
--- a/sim/Makefile.am
+++ b/sim/Makefile.am
@@ -20,6 +20,7 @@ ACLOCAL_AMFLAGS = -Im4 -I.. -I../config
 
 GNULIB_PARENT_DIR = ..
 @am__include@ @am__quote@$(GNULIB_PARENT_DIR)/gnulib/Makefile.gnulib.inc@am__quote@
+@am__include@ @am__quote@$(GNULIB_PARENT_DIR)/build-$(build)/gnulib/Makefile.gnulib.inc@am__quote@
 
 srccom = $(srcdir)/common
 srcroot = $(srcdir)/..
@@ -64,11 +65,14 @@ AM_CPPFLAGS = \
 	$(AM_CPPFLAGS_$(subst -,_,$(@D)_$(@F)))
 
 AM_CPPFLAGS_FOR_BUILD = \
+	$(BUILD_INCGNU) \
+	-I../build-$(build) \
 	-I$(srcroot)/include \
 	$(SIM_HW_CFLAGS) \
 	$(SIM_INLINE)
 COMPILE_FOR_BUILD = $(CC_FOR_BUILD) $(AM_CPPFLAGS_FOR_BUILD) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD)
 LINK_FOR_BUILD = $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
+LIBS_FOR_BUILD = $(BUILD_LIBGNU) $(BUILD_LIBGNU_EXTRA_LIBS)
 
 ## Deps to add to the all-recursive target.  These are built before descending
 ## into any subdirs.
diff --git a/sim/cr16/gencode.c b/sim/cr16/gencode.c
index b0bb67b63c0b..dbe1b9e1423e 100644
--- a/sim/cr16/gencode.c
+++ b/sim/cr16/gencode.c
@@ -18,7 +18,7 @@
    along with this program. If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This must come before any other includes.  */
-#include "defs.h"
+#include "gnulib/config.h"
 
 #include <stdio.h>
 #include <ctype.h>
diff --git a/sim/cr16/local.mk b/sim/cr16/local.mk
index 10533a467333..9eb464f58351 100644
--- a/sim/cr16/local.mk
+++ b/sim/cr16/local.mk
@@ -55,7 +55,7 @@ BUILT_SOURCES += %D%/simops.h
 %D%/modules.c: | $(%C%_BUILD_OUTPUTS)
 
 %C%_gencode_SOURCES = %D%/gencode.c
-%C%_gencode_LDADD = %D%/cr16-opc.o
+%C%_gencode_LDADD = %D%/cr16-opc.o $(LIBS_FOR_BUILD)
 
 # These rules are copied from automake, but tweaked to use FOR_BUILD variables.
 %D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
diff --git a/sim/d10v/gencode.c b/sim/d10v/gencode.c
index 3a37bac62563..42d655d39845 100644
--- a/sim/d10v/gencode.c
+++ b/sim/d10v/gencode.c
@@ -1,3 +1,6 @@
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include <stdio.h>
 #include <ctype.h>
 #include <limits.h>
diff --git a/sim/d10v/local.mk b/sim/d10v/local.mk
index a65635e81ede..0a9aa8fe5d5d 100644
--- a/sim/d10v/local.mk
+++ b/sim/d10v/local.mk
@@ -56,7 +56,7 @@ BUILT_SOURCES += %D%/simops.h
 %D%/modules.c: | $(%C%_BUILD_OUTPUTS)
 
 %C%_gencode_SOURCES = %D%/gencode.c
-%C%_gencode_LDADD = %D%/d10v-opc.o
+%C%_gencode_LDADD = %D%/d10v-opc.o $(LIBS_FOR_BUILD)
 
 # These rules are copied from automake, but tweaked to use FOR_BUILD variables.
 %D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
diff --git a/sim/igen/filter.c b/sim/igen/filter.c
index 71b5482635d0..2e9ae7900a28 100644
--- a/sim/igen/filter.c
+++ b/sim/igen/filter.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/sim/igen/filter_host.c b/sim/igen/filter_host.c
index ce5aa4b7f959..526d6a452e08 100644
--- a/sim/igen/filter_host.c
+++ b/sim/igen/filter_host.c
@@ -19,6 +19,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include "filter_host.h"
 
 /* Shorten traces by eliminating the directory component to filenames.  */
diff --git a/sim/igen/gen-engine.c b/sim/igen/gen-engine.c
index 29eb33310230..83d4292797df 100644
--- a/sim/igen/gen-engine.c
+++ b/sim/igen/gen-engine.c
@@ -19,6 +19,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include "misc.h"
 #include "lf.h"
 #include "table.h"
diff --git a/sim/igen/gen-icache.c b/sim/igen/gen-icache.c
index 366ba9307d0b..aa0cd6685fe2 100644
--- a/sim/igen/gen-icache.c
+++ b/sim/igen/gen-icache.c
@@ -19,6 +19,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include <stdlib.h>
 
 #include "misc.h"
diff --git a/sim/igen/gen-idecode.c b/sim/igen/gen-idecode.c
index 0059c1c2ee10..d6be10be86b2 100644
--- a/sim/igen/gen-idecode.c
+++ b/sim/igen/gen-idecode.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/gen-itable.c b/sim/igen/gen-itable.c
index bea06e861e20..c13307bcab3f 100644
--- a/sim/igen/gen-itable.c
+++ b/sim/igen/gen-itable.c
@@ -19,7 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/gen-model.c b/sim/igen/gen-model.c
index 31f56bc45f30..3731a2eec61a 100644
--- a/sim/igen/gen-model.c
+++ b/sim/igen/gen-model.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/gen-semantics.c b/sim/igen/gen-semantics.c
index 54d83d61eccd..24a3fdbad87a 100644
--- a/sim/igen/gen-semantics.c
+++ b/sim/igen/gen-semantics.c
@@ -19,7 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/gen-support.c b/sim/igen/gen-support.c
index 63b29324c4b1..78ace2084fc8 100644
--- a/sim/igen/gen-support.c
+++ b/sim/igen/gen-support.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/gen.c b/sim/igen/gen.c
index 2176b603fc59..ac4ca6b01d62 100644
--- a/sim/igen/gen.c
+++ b/sim/igen/gen.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/igen.c b/sim/igen/igen.c
index b9919a9d80c1..eaf69b9982f7 100644
--- a/sim/igen/igen.c
+++ b/sim/igen/igen.c
@@ -19,6 +19,9 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include <getopt.h>
 #include <stdlib.h>
 
diff --git a/sim/igen/ld-cache.c b/sim/igen/ld-cache.c
index 3c00f3443b7d..b5f5b9ded855 100644
--- a/sim/igen/ld-cache.c
+++ b/sim/igen/ld-cache.c
@@ -19,7 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/ld-decode.c b/sim/igen/ld-decode.c
index 6edd7c8ec3d6..ad0e64f58c7f 100644
--- a/sim/igen/ld-decode.c
+++ b/sim/igen/ld-decode.c
@@ -19,9 +19,11 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
 /* load the opcode stat structure */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include "misc.h"
 #include "lf.h"
 #include "table.h"
diff --git a/sim/igen/ld-insn.c b/sim/igen/ld-insn.c
index af639df7c0ae..fa5b46bcf15c 100644
--- a/sim/igen/ld-insn.c
+++ b/sim/igen/ld-insn.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include "misc.h"
 #include "lf.h"
diff --git a/sim/igen/lf.c b/sim/igen/lf.c
index 46b1f6b59ec9..e664fbc46278 100644
--- a/sim/igen/lf.c
+++ b/sim/igen/lf.c
@@ -19,6 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include <stdbool.h>
 #include <stdio.h>
diff --git a/sim/igen/local.mk b/sim/igen/local.mk
index 75b9cebd8f7b..bfc754b29338 100644
--- a/sim/igen/local.mk
+++ b/sim/igen/local.mk
@@ -47,7 +47,7 @@ EXTRA_LIBRARIES += %D%/libigen.a
 	%D%/gen.c
 
 %C%_igen_SOURCES = %D%/igen.c
-%C%_igen_LDADD = %D%/libigen.a
+%C%_igen_LDADD = %D%/libigen.a $(LIBS_FOR_BUILD)
 
 # These rules are copied from automake, but tweaked to use FOR_BUILD variables.
 igen/libigen.a: $(igen_libigen_a_OBJECTS) $(igen_libigen_a_DEPENDENCIES) $(EXTRA_igen_libigen_a_DEPENDENCIES) igen/$(am__dirstamp)
diff --git a/sim/igen/misc.c b/sim/igen/misc.c
index a083f6d1bbd2..5e90107cf9df 100644
--- a/sim/igen/misc.c
+++ b/sim/igen/misc.c
@@ -19,7 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include <stdio.h>
 #include <stdarg.h>
diff --git a/sim/igen/table.c b/sim/igen/table.c
index fdca9cb32554..d5c7068bce11 100644
--- a/sim/igen/table.c
+++ b/sim/igen/table.c
@@ -19,7 +19,8 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
 
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/sim/m32c/local.mk b/sim/m32c/local.mk
index 39620b5ce2f2..f8efd074b9bc 100644
--- a/sim/m32c/local.mk
+++ b/sim/m32c/local.mk
@@ -61,6 +61,7 @@ noinst_PROGRAMS += %D%/run
 %D%/modules.c: | $(%C%_BUILD_OUTPUTS)
 
 %C%_opc2c_SOURCES = %D%/opc2c.c
+%C%_opc2c_LDADD = $(LIBS_FOR_BUILD)
 
 # These rules are copied from automake, but tweaked to use FOR_BUILD variables.
 %D%/opc2c$(EXEEXT): $(%C%_opc2c_OBJECTS) $(%C%_opc2c_DEPENDENCIES) %D%/$(am__dirstamp)
diff --git a/sim/m32c/opc2c.c b/sim/m32c/opc2c.c
index da4da1c2a97f..e8a089eac596 100644
--- a/sim/m32c/opc2c.c
+++ b/sim/m32c/opc2c.c
@@ -19,7 +19,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This must come before any other includes.  */
-#include "defs.h"
+#include "gnulib/config.h"
 
 #include <stdio.h>
 #include <string.h>
diff --git a/sim/m68hc11/gencode.c b/sim/m68hc11/gencode.c
index 4e507701b9d0..4862a6dd7a73 100644
--- a/sim/m68hc11/gencode.c
+++ b/sim/m68hc11/gencode.c
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 /* This must come before any other includes.  */
-#include "defs.h"
+#include "gnulib/config.h"
 
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/sim/m68hc11/local.mk b/sim/m68hc11/local.mk
index 36c503e3bd88..1ec60d701ff0 100644
--- a/sim/m68hc11/local.mk
+++ b/sim/m68hc11/local.mk
@@ -71,6 +71,7 @@ noinst_PROGRAMS += %D%/run
 %D%/modules.c: | $(%C%_BUILD_OUTPUTS)
 
 %C%_gencode_SOURCES = %D%/gencode.c
+%C%_gencode_LDADD = $(LIBS_FOR_BUILD)
 
 # These rules are copied from automake, but tweaked to use FOR_BUILD variables.
 %D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c
index 5eb7caf25893..e989afbf169e 100644
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -30,6 +30,9 @@
 
 */
 
+/* This must come before any other includes.  */
+#include "gnulib/config.h"
+
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
diff --git a/sim/sh/local.mk b/sim/sh/local.mk
index 6cbd3a7f1581..0d8a28a9db46 100644
--- a/sim/sh/local.mk
+++ b/sim/sh/local.mk
@@ -57,6 +57,7 @@ BUILT_SOURCES += \
 %D%/modules.c: | $(%C%_BUILD_OUTPUTS)
 
 %C%_gencode_SOURCES = %D%/gencode.c
+%C%_gencode_LDADD = $(LIBS_FOR_BUILD)
 
 # These rules are copied from automake, but tweaked to use FOR_BUILD variables.
 %D%/gencode$(EXEEXT): $(%C%_gencode_OBJECTS) $(%C%_gencode_DEPENDENCIES) %D%/$(am__dirstamp)
-- 
2.42.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-15 17:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-15 17:17 [PATCH 1/3] gnulib: support building for --build [PR sim/30882] Mike Frysinger
2023-10-15 17:17 ` [PATCH 2/3] gnulib: enable a --build setup for sim " Mike Frysinger
2023-10-15 17:17 ` [PATCH 3/3] sim: use build-gnulib with build-time tools " Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).