diff mbox

: sim: prototype of --enable-targets support

Message ID 047d7bd7600cf629310518cfd8de@google.com
State RFC
Delegated to: Mike Frysinger
Headers show

Commit Message

Doug Evans June 18, 2015, 7:31 p.m. UTC
Hi.

I wanted to test a change to the generation of cgen simulator files.
Rather than have a build for each sim, which is what I normally
do but my system with those sandboxes is down,
I figured I might as well hack a prototype of --enable-targets=all
support for the sims.

Obviously, this is just a prototype, and it doesn't link
all sims into gdb.  It just exists to make it trivial to
build all the sim directories.

bash$ $src/configure --prefix=$(pwd)/rel \
     --enable-cgen-maint \
     --enable-targets=all \
     --enable-sim
bash$ make -j10 all-sim

I'm not intending to apply this, at least not as is.
Need to think about it some more.
And is it worth it without the hard part which is linking
all the sims into gdb?
OTOH, being able to trivially build all the sims today is really nice.

There are a couple of issues in the patch.
1) ${sim}-unknown-unknown is used as the target triplet.
    when --enable-targets=all is specified.
    It works, but maybe it could be cleaner.
2) IWBN if all_sims was defined in configure.tgt and not configure.ac.
    However, configure.tgt can only be sinclude'd once.
    I wrote a different version that solves this, but it had its
    own issues.

2015-06-18  Doug Evans  <dje@google.com>

	* configure.ac: Add support for --enable-targets.
	* configure.tgt: Use $targ instead of $target.
	Remove AC_SUBST(sim_arch).
	* configure: Regenerate.

         ;;
@@ -104,4 +107,3 @@ case "${target}" in
         sim_common=no
         ;;
  esac
-AC_SUBST(sim_arch)

Comments

Mike Frysinger June 21, 2015, 6:48 p.m. UTC | #1
On 18 Jun 2015 19:31, Doug Evans wrote:
> And is it worth it without the hard part which is linking
> all the sims into gdb?

yes, if we can build all the sims, then that alone makes it worth it.
we need to make sure we don't break gdb linking/running though.

the other bits i think we'd want sorted out first:
 - does `make check` for all of them ?
 - what should `make install` do ?  atm they all install as `run` ...
-mike
diff mbox

Patch

diff --git a/sim/configure.ac b/sim/configure.ac
index f1734e3..c6ac81e 100644
--- a/sim/configure.ac
+++ b/sim/configure.ac
@@ -27,6 +27,29 @@  AC_SUBST(CC_FOR_BUILD)
  CFLAGS_FOR_BUILD=${CFLAGS_FOR_BUILD-${CFLAGS}}
  AC_SUBST(CFLAGS_FOR_BUILD)

+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
+
+# Canonicalize the secondary target names.
+if test -n "$enable_targets" ; then
+    for targ in `echo $enable_targets | sed 's/,/ /g'`
+    do
+	result=`$ac_config_sub $targ 2>/dev/null`
+	if test -n "$result" ; then
+	    canon_targets="$canon_targets $result"
+	else
+	    # Allow targets that config.sub doesn't recognize, like "all".
+	    canon_targets="$canon_targets $targ"
+	fi
+    done
+fi
+
  # If a cpu ever has more than one simulator to choose from, use
  # --enable-sim=... to choose.
  AC_ARG_ENABLE(sim,
@@ -36,19 +59,55 @@  yes | no) ;;
  *)	AC_MSG_ERROR(bad value ${enableval} given for --enable-sim option) ;;
  esac])

+# IWBN to define all_sims in configure.tgt, but we can only sinclude
+# configure.tgt once.  Otherwise autoconf complains about the apparent
+# duplicate calls to AC_CONFIG_SUBDIRS for each arch.
+all_sims="arm avr bfin cr16 cris d10v frv h8300 iq2000 lm32 m32c m32r"
+all_sims="$all_sims m68hc11 mcore microblaze mips mn10300 moxie msp430"
+all_sims="$all_sims rl78 rx sh64 sh erc32 ppc ft32 v850"
+
  m4_define([SIM_ARCH], [
    sim_arch=$1
    AC_CONFIG_SUBDIRS($1)
  ])
+
  if test "${enable_sim}" != no; then
-   sinclude(configure.tgt)
-   AC_CONFIG_SUBDIRS(testsuite)
-   if test "$sim_common" = yes; then
-      AC_CONFIG_SUBDIRS(common)
-   fi
-   if test "$sim_igen" = yes; then
-      AC_CONFIG_SUBDIRS(igen)
-   fi
+  any_sim_uses_sim_common=no
+  any_sim_uses_sim_igen=no
+
+  all_targets=false
+  for targ in $canon_targets
+  do
+    if test "x$targ" = xall; then
+      all_targets=true
+    fi
+  done
+  if test "$all_targets" = true; then
+    canon_targets=
+    for sim in $all_sims
+    do
+      canon_targets="$canon_targets ${sim}-unknown-unknown"
+    done
+  fi
+
+  for targ in $target $canon_targets
+  do
+    sinclude(configure.tgt)
+    if test "x$sim_common" = xyes; then
+      any_sim_uses_sim_common=yes
+    fi
+    if test "x$sim_igen" = xyes; then
+      any_sim_uses_sim_igen=yes
+    fi
+  done
+
+  AC_CONFIG_SUBDIRS(testsuite)
+  if test "$any_sim_uses_sim_common" = yes; then
+    AC_CONFIG_SUBDIRS(common)
+  fi
+  if test "$any_sim_uses_sim_igen" = yes; then
+    AC_CONFIG_SUBDIRS(igen)
+  fi
  fi

  AC_OUTPUT(Makefile)
diff --git a/sim/configure.tgt b/sim/configure.tgt
index 5f3bb03..1924b39 100644
--- a/sim/configure.tgt
+++ b/sim/configure.tgt
@@ -14,7 +14,10 @@  m4_ifndef([SIM_ARCH],  
[AC_DEFUN([SIM_ARCH],[sim_arch=$1])])
  sim_common=yes
  sim_igen=no
  sim_arch=
-case "${target}" in
+
+# N.B. The order here is alphabetical.
+
+case "${targ}" in
     arm*-*-*)
         SIM_ARCH(arm)