From a0e674c1ce2c877426f8a861c5294c535c5d49e6 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 16 Jan 2021 02:27:38 -0500 Subject: [PATCH] sim: add preliminary support for --enable-targets 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/ChangeLog | 7 + sim/Makefile.am | 3 + sim/Makefile.in | 2 + sim/common/ChangeLog | 5 + sim/common/Make-common.in | 7 +- sim/configure | 329 ++++++++++++++++++++++++++++++++++---- sim/configure.ac | 158 +++++++----------- sim/ppc/ChangeLog | 5 + sim/ppc/Makefile.in | 4 + 9 files changed, 389 insertions(+), 131 deletions(-) diff --git a/sim/ChangeLog b/sim/ChangeLog index 74961efbef2..8e4d93275dd 100644 --- a/sim/ChangeLog +++ b/sim/ChangeLog @@ -1,3 +1,10 @@ +2021-04-03 Mike Frysinger + + * Makefile.am (SIM_PRIMARY_TARGET, AM_MAKEFLAGS): Define. + * configure.ac: Add --enable-targets option. Define SIM_PRIMARY_TARGET + and SIM_TARGET. Rewrite case statement with SIM_TARGET calls. + * Makefile.in, configure: Regenerate. + 2021-04-02 Mike Frysinger * Makefile.am [SIM_ENABLE_IGEN]: Include igen/local.mk. diff --git a/sim/Makefile.am b/sim/Makefile.am index 79e162a439d..a121c1fed43 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 vars 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/Makefile.in b/sim/Makefile.in index 2f7284ddba6..21fc22bb4c7 100644 --- a/sim/Makefile.in +++ b/sim/Makefile.in @@ -350,6 +350,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ +SIM_PRIMARY_TARGET = @SIM_PRIMARY_TARGET@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ @@ -411,6 +412,7 @@ AUTOMAKE_OPTIONS = dejagnu foreign no-dist subdir-objects ACLOCAL_AMFLAGS = -Im4 -I.. -I../config srcroot = $(srcdir)/.. SUBDIRS = @subdirs@ +AM_MAKEFLAGS = SIM_PRIMARY_TARGET=$(SIM_PRIMARY_TARGET) # We don't set some of these vars here, but we need to define them so they may # be used consistently in local.mk files we include below. diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog index aaccbb7ed2f..ded8bbf5558 100644 --- a/sim/common/ChangeLog +++ b/sim/common/ChangeLog @@ -1,3 +1,8 @@ +2021-04-03 Mike Frysinger + + * Make-common.in (install-common): Install as run-$arch and + libsim-$arch.a when not the primary arch. + 2021-04-02 Mike Frysinger * Make-common.in (CFLAGS_FOR_BUILD): Define. diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in index a6875fe8f96..c8445bce59e 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 b/sim/configure index 194cdcd4b0e..24e57ff3bd6 100755 --- a/sim/configure +++ b/sim/configure @@ -630,6 +630,7 @@ LIBOBJS SIM_ENABLE_IGEN_FALSE SIM_ENABLE_IGEN_TRUE subdirs +SIM_PRIMARY_TARGET AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V @@ -743,6 +744,7 @@ enable_maintainer_mode enable_dependency_tracking enable_silent_rules enable_sim +enable_targets ' ac_precious_vars='build_alias host_alias @@ -1412,6 +1414,7 @@ Optional Features: --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-sim Enable the GNU simulator + --enable-targets alternative target configurations Some influential environment variables: CC C compiler command @@ -4829,139 +4832,401 @@ esac fi +# Check whether --enable-targets was given. +if test "${enable_targets+set}" = set; then : + enableval=$enable_targets; case "${enableval}" in + yes | "") as_fn_error $? "enable-targets option must specify target names or 'all'" "$LINENO" 5 + ;; + no) enable_targets= ;; + *) enable_targets=$enableval ;; +esac +fi + + +SIM_PRIMARY_TARGET= + + + + if test "${enable_sim}" != no; then sim_igen=no - case "${target}" in - aarch64*-*-*) + for targ in `echo $target $enable_targets | sed 's/,/ /g'` + do + + case "${targ}" in + all|aarch64*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=aarch64 + fi subdirs="$subdirs aarch64" + ;; - arm*-*-*) + esac + + + case "${targ}" in + all|arm*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=arm + fi subdirs="$subdirs arm" + ;; - avr*-*-*) + esac + + + case "${targ}" in + all|avr*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=avr + fi subdirs="$subdirs avr" + ;; - bfin-*-*) + esac + + + case "${targ}" in + all|bfin-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=bfin + fi subdirs="$subdirs bfin" + ;; - bpf-*-*) + esac + + + case "${targ}" in + all|bpf-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=bpf + fi subdirs="$subdirs bpf" + ;; - cr16*-*-*) + esac + + + case "${targ}" in + all|cr16*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=cr16 + fi subdirs="$subdirs cr16" + ;; - cris-*-* | crisv32-*-*) + esac + + + case "${targ}" in + all|cris-*-* | crisv32-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=cris + fi subdirs="$subdirs cris" + ;; - d10v-*-*) + esac + + + case "${targ}" in + all|d10v-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=d10v + fi subdirs="$subdirs d10v" + ;; - frv-*-*) + esac + + + case "${targ}" in + all|frv-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=frv + fi subdirs="$subdirs frv" + ;; - h8300*-*-*) + esac + + + case "${targ}" in + all|h8300*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=h8300 + fi subdirs="$subdirs h8300" + ;; - iq2000-*-*) + esac + + + case "${targ}" in + all|iq2000-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=iq2000 + fi subdirs="$subdirs iq2000" + ;; - lm32-*-*) + esac + + + case "${targ}" in + all|lm32-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=lm32 + fi subdirs="$subdirs lm32" + ;; - m32c-*-*) + esac + + + case "${targ}" in + all|m32c-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=m32c + fi subdirs="$subdirs m32c" + ;; - m32r-*-*) + esac + + + case "${targ}" in + all|m32r-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=m32r + fi subdirs="$subdirs m32r" + ;; - m68hc11-*-*|m6811-*-*) + esac + + + case "${targ}" in + all|m68hc11-*-*|m6811-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=m68hc11 + fi subdirs="$subdirs m68hc11" + ;; - mcore-*-*) + esac + + + case "${targ}" in + all|mcore-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=mcore + fi subdirs="$subdirs mcore" + ;; - microblaze-*-*) + esac + + + case "${targ}" in + all|microblaze-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=microblaze + fi subdirs="$subdirs microblaze" + ;; - mips*-*-*) + esac + + + case "${targ}" in + all|mips*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=mips + fi subdirs="$subdirs mips" sim_igen=yes ;; - mn10300*-*-*) + esac + + + case "${targ}" in + all|mn10300*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=mn10300 + fi subdirs="$subdirs mn10300" sim_igen=yes ;; - moxie-*-*) + esac + + + case "${targ}" in + all|moxie-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=moxie + fi subdirs="$subdirs moxie" + ;; - msp430*-*-*) + esac + + + case "${targ}" in + all|msp430*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=msp430 + fi subdirs="$subdirs msp430" + ;; - or1k-*-* | or1knd-*-*) + esac + + + case "${targ}" in + all|or1k-*-* | or1knd-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=or1k + fi subdirs="$subdirs or1k" + ;; - pru*-*-*) + esac + + + case "${targ}" in + all|pru*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=pru + fi subdirs="$subdirs pru" + ;; - riscv*-*-*) + esac + + + case "${targ}" in + all|riscv*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=riscv + fi subdirs="$subdirs riscv" + ;; - rl78-*-*) + esac + + + case "${targ}" in + all|rl78-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=rl78 + fi subdirs="$subdirs rl78" + ;; - rx-*-*) + esac + + + case "${targ}" in + all|rx-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=rx + fi subdirs="$subdirs rx" + ;; - sh*-*-*) + esac + + + case "${targ}" in + all|sh*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=sh + fi subdirs="$subdirs sh" + ;; - sparc-*-rtems*|sparc-*-elf*) + esac + + + case "${targ}" in + all|sparc-*-rtems*|sparc-*-elf*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=erc32 + fi subdirs="$subdirs erc32" + ;; - powerpc*-*-*) + esac + + + case "${targ}" in + all|powerpc*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=ppc + fi subdirs="$subdirs ppc" + ;; - ft32-*-*) + esac + + + case "${targ}" in + all|ft32-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=ft32 + fi subdirs="$subdirs ft32" + ;; - v850*-*-*) + esac + + + case "${targ}" in + all|v850*-*-*) + if test "${targ}" = "${target}"; then + SIM_PRIMARY_TARGET=v850 + fi subdirs="$subdirs v850" sim_igen=yes ;; esac + + done fi if test "$sim_igen" = "yes"; then SIM_ENABLE_IGEN_TRUE= diff --git a/sim/configure.ac b/sim/configure.ac index 48d812b9885..35101a0d672 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/ChangeLog b/sim/ppc/ChangeLog index 16b3ab78cb1..539d3179ef8 100644 --- a/sim/ppc/ChangeLog +++ b/sim/ppc/ChangeLog @@ -1,3 +1,8 @@ +2021-04-03 Mike Frysinger + + * Makefile.in (install): Install as run-ppc when not the primary arch. + (install-strip): Likewise. + 2021-03-13 Mike Frysinger * Makefile.in (BUILD_LDFLAGS): Rename to ... diff --git a/sim/ppc/Makefile.in b/sim/ppc/Makefile.in index ae99dc3a103..d2bd1d31775 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.2