From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 94EA9388A42F for ; Sat, 13 Mar 2021 17:24:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 94EA9388A42F Received: from vapier.lan (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id A3949340B10 for ; Sat, 13 Mar 2021 17:24:12 +0000 (UTC) From: Mike Frysinger To: gdb-patches@sourceware.org Subject: [PATCH v2 3/3] sim: add preliminary support for --enable-targets Date: Sat, 13 Mar 2021 12:24:05 -0500 Message-Id: <20210313172405.11792-3-vapier@gentoo.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210313172405.11792-1-vapier@gentoo.org> References: <20210308033320.29670-1-vapier@gentoo.org> <20210313172405.11792-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Mar 2021 17:24:18 -0000 This doesn't actually create one `run` program like other projects, but creates multiple `run-$arch` targets. While it might not seem that useful initially, this has some nice properties: - Allows us to quickly build all sim targets in a single tree. - Positions us better for converting targets over to a proper multitarget build+install. We don't have the ability to actually run tests against them, but that's due to a limitation in gas: it doesn't support multitarget. If that ever changes, we should be able to turn on our tests too. We can improve the test framework to fallback to a system toolchain if available to help mitigate that. --- sim/Makefile.am | 3 + sim/Makefile.in | 2 + sim/common/Make-common.in | 7 +- sim/configure | 329 ++++++++++++++++++++++++++++++++++---- sim/configure.ac | 158 +++++++----------- sim/ppc/Makefile.in | 4 + 6 files changed, 372 insertions(+), 131 deletions(-) diff --git a/sim/Makefile.am b/sim/Makefile.am index af79bb5d5c7b..87673cd537e5 100644 --- a/sim/Makefile.am +++ b/sim/Makefile.am @@ -22,6 +22,9 @@ srcroot = $(srcdir)/.. SUBDIRS = @subdirs@ +SIM_PRIMARY_TARGET = @SIM_PRIMARY_TARGET@ +AM_MAKEFLAGS = SIM_PRIMARY_TARGET=$(SIM_PRIMARY_TARGET) + # We don't set some of these files here, but we need to define them so they may # be used consistently in local.mk files we include below. noinst_LIBRARIES = diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index a6875fe8f964..c8445bce59ea 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in @@ -467,9 +467,14 @@ CGEN_MAIN_CPU_DEPS = \ install: install-common $(SIM_EXTRA_INSTALL) install-common: installdirs + a=`basename "$$(pwd)"`; \ n=`echo run | sed '$(program_transform_name)'`; \ + [ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \ $(INSTALL_PROGRAM) run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT) - n=`echo libsim.a | sed s/libsim.a/lib$(target_alias)-sim.a/`; \ + n="$(target_alias)-sim"; \ + a=`basename "$$(pwd)"`; \ + [ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \ + n="lib$$n.a"; \ $(INSTALL_DATA) libsim.a $(DESTDIR)$(libdir)/$$n ; \ ( cd $(DESTDIR)$(libdir) ; $(RANLIB) $$n ) diff --git a/sim/configure.ac b/sim/configure.ac index 48d812b98855..35101a0d6729 100644 --- a/sim/configure.ac +++ b/sim/configure.ac @@ -19,110 +19,72 @@ yes | no) ;; *) AC_MSG_ERROR(bad value ${enableval} given for --enable-sim option) ;; esac]) +AC_ARG_ENABLE(targets, +[ --enable-targets alternative target configurations], +[case "${enableval}" in + yes | "") AC_MSG_ERROR(enable-targets option must specify target names or 'all') + ;; + no) enable_targets= ;; + *) enable_targets=$enableval ;; +esac]) + +dnl Used to keep track of which target (if any) is the default one. This is +dnl used when installing files to see if they need to be suffixed. +SIM_PRIMARY_TARGET= +AC_SUBST(SIM_PRIMARY_TARGET) + +m4_define([SIM_TARGET], [ + case "${targ}" in + all|$1) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=$2 + fi + AC_CONFIG_SUBDIRS($2) + $3 + ;; + esac +]) + dnl WHEN ADDING ENTRIES TO THIS MATRIX: dnl Make sure that the left side always has two dashes. Otherwise you can get dnl spurious matches. Even for unambiguous cases, do this as a convention, else dnl the table becomes a real mess to understand and maintain. if test "${enable_sim}" != no; then sim_igen=no - case "${target}" in - aarch64*-*-*) - AC_CONFIG_SUBDIRS(aarch64) - ;; - arm*-*-*) - AC_CONFIG_SUBDIRS(arm) - ;; - avr*-*-*) - AC_CONFIG_SUBDIRS(avr) - ;; - bfin-*-*) - AC_CONFIG_SUBDIRS(bfin) - ;; - bpf-*-*) - AC_CONFIG_SUBDIRS(bpf) - ;; - cr16*-*-*) - AC_CONFIG_SUBDIRS(cr16) - ;; - cris-*-* | crisv32-*-*) - AC_CONFIG_SUBDIRS(cris) - ;; - d10v-*-*) - AC_CONFIG_SUBDIRS(d10v) - ;; - frv-*-*) - AC_CONFIG_SUBDIRS(frv) - ;; - h8300*-*-*) - AC_CONFIG_SUBDIRS(h8300) - ;; - iq2000-*-*) - AC_CONFIG_SUBDIRS(iq2000) - ;; - lm32-*-*) - AC_CONFIG_SUBDIRS(lm32) - ;; - m32c-*-*) - AC_CONFIG_SUBDIRS(m32c) - ;; - m32r-*-*) - AC_CONFIG_SUBDIRS(m32r) - ;; - m68hc11-*-*|m6811-*-*) - AC_CONFIG_SUBDIRS(m68hc11) - ;; - mcore-*-*) - AC_CONFIG_SUBDIRS(mcore) - ;; - microblaze-*-*) - AC_CONFIG_SUBDIRS(microblaze) - ;; - mips*-*-*) - AC_CONFIG_SUBDIRS(mips) - sim_igen=yes - ;; - mn10300*-*-*) - AC_CONFIG_SUBDIRS(mn10300) - sim_igen=yes - ;; - moxie-*-*) - AC_CONFIG_SUBDIRS(moxie) - ;; - msp430*-*-*) - AC_CONFIG_SUBDIRS(msp430) - ;; - or1k-*-* | or1knd-*-*) - AC_CONFIG_SUBDIRS(or1k) - ;; - pru*-*-*) - AC_CONFIG_SUBDIRS(pru) - ;; - riscv*-*-*) - AC_CONFIG_SUBDIRS(riscv) - ;; - rl78-*-*) - AC_CONFIG_SUBDIRS(rl78) - ;; - rx-*-*) - AC_CONFIG_SUBDIRS(rx) - ;; - sh*-*-*) - AC_CONFIG_SUBDIRS(sh) - ;; - sparc-*-rtems*|sparc-*-elf*) - AC_CONFIG_SUBDIRS(erc32) - ;; - powerpc*-*-*) - AC_CONFIG_SUBDIRS(ppc) - ;; - ft32-*-*) - AC_CONFIG_SUBDIRS(ft32) - ;; - v850*-*-*) - AC_CONFIG_SUBDIRS(v850) - sim_igen=yes - ;; - esac + for targ in `echo $target $enable_targets | sed 's/,/ /g'` + do + SIM_TARGET([aarch64*-*-*], [aarch64]) + SIM_TARGET([arm*-*-*], [arm]) + SIM_TARGET([avr*-*-*], [avr]) + SIM_TARGET([bfin-*-*], [bfin]) + SIM_TARGET([bpf-*-*], [bpf]) + SIM_TARGET([cr16*-*-*], [cr16]) + SIM_TARGET([cris-*-* | crisv32-*-*], [cris]) + SIM_TARGET([d10v-*-*], [d10v]) + SIM_TARGET([frv-*-*], [frv]) + SIM_TARGET([h8300*-*-*], [h8300]) + SIM_TARGET([iq2000-*-*], [iq2000]) + SIM_TARGET([lm32-*-*], [lm32]) + SIM_TARGET([m32c-*-*], [m32c]) + SIM_TARGET([m32r-*-*], [m32r]) + SIM_TARGET([m68hc11-*-*|m6811-*-*], [m68hc11]) + SIM_TARGET([mcore-*-*], [mcore]) + SIM_TARGET([microblaze-*-*], [microblaze]) + SIM_TARGET([mips*-*-*], [mips], [sim_igen=yes]) + SIM_TARGET([mn10300*-*-*], [mn10300], [sim_igen=yes]) + SIM_TARGET([moxie-*-*], [moxie]) + SIM_TARGET([msp430*-*-*], [msp430]) + SIM_TARGET([or1k-*-* | or1knd-*-*], [or1k]) + SIM_TARGET([pru*-*-*], [pru]) + SIM_TARGET([riscv*-*-*], [riscv]) + SIM_TARGET([rl78-*-*], [rl78]) + SIM_TARGET([rx-*-*], [rx]) + SIM_TARGET([sh*-*-*], [sh]) + SIM_TARGET([sparc-*-rtems*|sparc-*-elf*], [erc32]) + SIM_TARGET([powerpc*-*-*], [ppc]) + SIM_TARGET([ft32-*-*], [ft32]) + SIM_TARGET([v850*-*-*], [v850], [sim_igen=yes]) + done fi AM_CONDITIONAL([SIM_ENABLE_IGEN], [test "$sim_igen" = "yes"]) diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index ae99dc3a1038..d2bd1d317754 100644 --- a/sim/ppc/Makefile.in +++ b/sim/ppc/Makefile.in @@ -885,11 +885,15 @@ config.status: configure check: install: installdirs + a=`basename "$$(pwd)"`; \ n=`echo run | sed '$(program_transform_name)'`; \ + [ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \ $(INSTALL_PROGRAM) run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT) install-strip: installdirs + a=`basename "$$(pwd)"`; \ n=`echo run | sed '$(program_transform_name)'`; \ + [ "$(SIM_PRIMARY_TARGET)" = "$$a" ] || n="$$n-$$a"; \ $(INSTALL_PROGRAM) run$(EXEEXT) $(DESTDIR)$(bindir)/$$n$(EXEEXT) $(STRIP) $(DESTDIR)$(bindir)/$$n$(EXEEXT) -- 2.30.0