Commit Graph

4507 Commits

Author SHA1 Message Date
Mike Frysinger
843bf75416 sim: include ansidecl.h when needed
Avoid implicit include deps with this to help untangle sim headers
so we can get rid of arch-specific sim-main.h.
2021-12-04 22:10:04 -05:00
Mike Frysinger
33bbd5e8dd sim: include stdint.h when needed
Avoid implicit include deps with this to help untangle sim headers
so we can get rid of arch-specific sim-main.h.
2021-12-04 22:10:02 -05:00
Mike Frysinger
2c29882f83 sim: include stdarg.h when used
Avoid implicit include deps with this to help untangle sim headers
so we can get rid of arch-specific sim-main.h.
2021-12-04 22:09:42 -05:00
Mike Frysinger
20a8e078cc sim: reorder header includes
We're including system headers after local headers in a bunch of
places, but this leads to conflicts when our local headers happen
to define symbols that show up in the system headers.

Use the more standard order of:
* config.h (via defs.h)
* system headers
* local library headers (e.g. bfd & libiberty)
* sim specific headers
2021-12-04 22:09:26 -05:00
Mike Frysinger
94f5dfed74 sim: moxie: hoist dtb rules up to common builds
These rules don't depend on the target compiler settings, so hoist
the build logic up to the common builds for better parallelization.
2021-12-04 13:55:13 -05:00
Mike Frysinger
520e19d589 sim: m68hc11: delete unused profile flags
These were moved to the common configure script a while ago and have
the same default as these, so just delete it.
2021-12-04 13:45:16 -05:00
Mike Frysinger
784712bf4f sim: msp430: delete redundant comments & settings
These were copied from the example docs, so aren't adding any value.
2021-12-04 13:45:16 -05:00
Mike Frysinger
23bd26ecf6 sim: erc32: drop old configure target
There is no configure script in here anymore to regenerate.
2021-12-04 13:45:16 -05:00
Mike Frysinger
0344e65132 sim: m32c/rl78: drop redundant -Wall settings
We already turn these on in the configure script.
2021-12-04 13:45:16 -05:00
Mike Frysinger
3daaa003d2 sim: frv: split up testsuite a bit
Running frv's allinsn in serial is quite slow due to the sheer number
of tests it contains.  By splitting it up and running in parallel, the
execution time on my system goes from ~100sec to ~60sec.
2021-12-04 12:52:35 -05:00
Mike Frysinger
b42f20d2ac sim: testsuite: drop most specific istarget checks
We'll rely on the toolchain probing to determine whether each arch's
tests can be run rather the current configure target.  This allows
testing all of the ports in a multitarget configuration.

For now, we don't reformat the files entirely to make it easier to
review, and in case we need to make adjustments.  Once this feels
like it's stable, we can flatten the code a bit by removing the if
statement entirely.
2021-11-28 21:55:16 -05:00
Mike Frysinger
804de1faf4 sim: testsuite: support parallel execution
Break up the dejagnu logic so that we can parallelize the testsuite.
This takes a page from gcc & gdb where each .exp is run in isolation
instead of in serial.

For most targets, this doesn't make much of a difference as they only
have a single .exp.  A few (like cris & frv) have multiple .exp though
and will see a bit of a speed up.

The real gain is when testing a multitarget build.  This way we can
run all the targets in parallel and cut the execution time a bit.
On my system, it goes from ~155sec to ~100sec.

We can gain further speedups by splitting up some of the larger .exp
files into smaller groups.  We'll do that in a followup though.
2021-11-28 21:55:15 -05:00
Mike Frysinger
7a259895bb sim: testsuite: expand arch specific toolchain settings
Leverage the new per-port toolchain settings to initialize the env
for eeach set of tests.  This allows us to run all the tests in a
multitarget build if the user sets up the vars.  If they don't, we
can still skip all the tests.
2021-11-28 21:55:15 -05:00
Mike Frysinger
8996c21067 sim: testsuite: setup per-port toolchain settings for multitarget build
Gas does not support multitarget builds -- it still only supports
a single input & output format.  ld is a bit better, but requires
manual flags to select the right output.  This makes it impossible
to run the complete testsuite in a multitarget build.

To address this limitation, create a suite of FOR_TARGET variables
so these can be set to precompiled as & ld programs.  It requires
a bit of setup ahead of time, but it's a one-time cost, and makes
running the full testsuite at once much easier.
2021-11-28 21:55:15 -05:00
Mike Frysinger
e9307449c3 sim: add checks to core headers to prevent incorrect common building
Some of the core sim headers rely on the SIM_AC_OPTION_BITSIZE macro
which can change the size of core types.  Since these haven't been
unified across ports, add checks to make sure they aren't accidentally
included when building for all ports.  This caught the sim-load file
using poisoned headers that it didn't actually need.
2021-11-28 14:28:35 -05:00
Mike Frysinger
6688220490 sim: unify syscall.o building
Now that we've unified all the syscall tables, this file does not rely
on any port-specific settings, so move it up to building as part of the
common step so we only do it once in a multibuild.
2021-11-28 13:24:04 -05:00
Mike Frysinger
1e42d01772 sim: drop unused gentmap & nltvals.def logic
Now that all ports have switched to target-newlib-* files, there's
no need for these files & generating things at build time.  So punt
the logic and make target-newlib-syscall a hard requirement.
2021-11-28 13:24:00 -05:00
Mike Frysinger
6cbb891faa sim: mcore: switch to new target-newlib-syscall
Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and mcore has a custom syscall
table for its newlib/libgloss port.
2021-11-28 13:23:59 -05:00
Mike Frysinger
c8c6ef3807 sim: riscv: switch to new target-newlib-syscall
Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and riscv has a custom syscall
table for its newlib/libgloss port.
2021-11-28 13:23:58 -05:00
Mike Frysinger
ab230d13fc sim: cr16: switch to new target-newlib-syscall
Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and cr16 has a custom syscall
table for its newlib/libgloss port.

This allows cleaning up the syscall ifdef logic.  We know these will
always exist now.
2021-11-28 13:23:58 -05:00
Mike Frysinger
0bf1633f01 sim: d10v: switch to new target-newlib-syscall
Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and d10v has a custom syscall
table for its newlib/libgloss port.

This allows cleaning up the syscall ifdef logic.  We know these will
always exist now.
2021-11-28 13:23:58 -05:00
Mike Frysinger
c44df9148d sim: sh: switch to new target-newlib-syscall
Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and sh has a custom syscall
table for its newlib/libgloss port.
2021-11-28 13:23:58 -05:00
Mike Frysinger
96b1eb7e17 sim: v850: switch to new target-newlib-syscall
Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and v850 has a custom syscall
table for its newlib/libgloss port.

This allows cleaning up the syscall ifdef logic.  We know these will
always exist now.
2021-11-28 13:23:58 -05:00
Mike Frysinger
e38330f8b0 sim: iq2000/lm32/m32c/moxie/rx: switch to new target-newlib-syscall.h
Use the new target-newlib-syscall.h to provide the target syscall
defines.  These code paths are written specifically for the newlib
ABI rather than being generalized, so switching them to the defines
rather than trying to go through the dynamic callback conversion
seems like the best trade-off for now.  Might have to reconsider
this in the future.
2021-11-28 13:23:58 -05:00
Mike Frysinger
64ae70dde5 sim: nltvals: pull target syscalls out into a dedicated source file
Like we just did for pulling out the errno map, pull out the syscall
maps into a dedicated common file.  Most newlib ports are using the
same syscall map, but not all, which means we have to do a bit more
work to migrate.

This commit adds the maps and switches the ports using the common
default syscall table over to it.  Ports using unique syscall tables
are still using the old targ-map.c logic.

Switching common ports over is easy by checking NL_TARGET, but the
ppc code needs a bit more cleanup here hence its larger diff.
2021-11-28 13:23:57 -05:00
Mike Frysinger
96537189c9 sim: frv: resolve syscalls dynamically
Avoid use of TARGET_<syscall> defines and rely on the callback layers
to resolve these dynamically so we can support multiple syscall layers
instead of assuming the newlib/libgloss numbers all the time.
2021-11-28 01:08:25 -05:00
Mike Frysinger
9af706c919 sim: mn10300: resolve syscalls dynamically
Avoid use of TARGET_<syscall> defines and rely on the callback layers
to resolve these dynamically so we can support multiple syscall layers
instead of assuming the newlib/libgloss numbers all the time.
2021-11-28 01:01:50 -05:00
Mike Frysinger
d485f8c7c2 sim: nltvals: drop i960
This port was dropped from gdb/bfd/sim years ago, so stop including
its syscall constants too.
2021-11-28 00:57:22 -05:00
Mike Frysinger
961af0641e sim: moxie: fix datadir handling
Expand the value at `make` time rather than configure generation time
so that we handle $(datarootdir) setting properly.
2021-11-28 00:56:44 -05:00
Mike Frysinger
d9a84d15f2 sim: hw: mark hw_descriptors const 2021-11-27 12:15:16 -05:00
Mike Frysinger
6916d9e65c sim: testsuite: add dedicated flag for init toolchain tests
As we setup more reliable CC_FOR_TARGET variables for each target, the
bfin way of overriding it to stuff custom CFLAGS doesn't scale well.
Add a dedicated CFLAGS_FOR_TARGET_init setting that each set of tests
can setup if they want to add custom options.
2021-11-27 03:09:57 -05:00
Mike Frysinger
2b9c7c262e sim: testsuite: clean up arch specific toolchain settings
In a multitarget build, we process all targets in order, so make sure
the toolchain settings from one don't leak into the next.
2021-11-27 01:27:17 -05:00
Mike Frysinger
8613fa4c49 sim: cris: always search for local rvdummy tool
If the board info sets the sim to a basename that is found via $PATH
(which is the default dejagnu behavior), the logic here to use its
dirname to find rvdummy fails because it looks for `./rvdummy`.  So
switch it to always use the local build of rvdummy which is the one
we want to be testing against in the first place.

If we get a request for testing against a different setup, we can
figure out & document the needs at that point, and then setup some
config knobs to control it.
2021-11-27 01:26:41 -05:00
Mike Frysinger
429a55b865 sim: testsuite: fix bits-gen EXEEXT handling
Add missing $(EXEEXT) to dependencies on bits-gen.  These are actually
build-only tools, but automake doesn't allow for build & host tools, so
the rules are re-using EXEEXT.
2021-11-26 20:41:44 -05:00
Mike Frysinger
1214c97666 sim: testsuite: initial support for OS-specific tests
We usually test against the newlib/libgloss environment, but for a
few ports that also support Linux apps, we want to test that logic
too.  A lot of the C code is written such that it works with either
newlib/libgloss or glibc/linux toolchains, but we have some tests
that end up being Linux-specific.  Cris has been using the target
tuple as a rough proxy for this (where cris*-*-elf is assumed to be
newlib/libgloss, and everything else is glibc/linux), but that is a
bit too rough, and it doesn't work in a multitarget build.

So lets create a few stub files that we can do compile tests with
to detect the different setups, and then let tests declare which
one they require (if they require any at all).
2021-11-26 20:06:55 -05:00
Mike Frysinger
264dcc17cc sim: testsuite: unify basic C compiler checks
Both bfin & cris ports test the C compiler to see if it works, but in
their own way.  Unify the checks in the common code so we can leverage
them in more ports in the future, and collapse the bfin & cris code.
2021-11-26 19:51:15 -05:00
Mike Frysinger
c0d6a6e582 sim: testsuite: rework sim_init usage
The sim_init function was called by runtest for each test when --tool
was set to sim.  When we changed to --tool '' to collapse the testsuite
dir, the init function was no longer called on every test.  However, it
was still being called explicitly by config/default.exp.  It's not clear
why that explicit call ever existed since, in the past, it meant it was
redundant.

Lets drop the single sim_init call in config/default.exp and move it out
to all our tests.  This replicates the runtest behavior so we can setup
variables on a per-test basis which allows us to recollapse the sim_path
logic back.  We'll also leverage this in the future for toolchain setup.

Also add a few comments clarifying the overall runtime behavior.
2021-11-26 19:48:05 -05:00
Mike Frysinger
4c721b266f sim: cris: fix testsuite hang when sim is missing
If the cris sim hasn't been built yet, trying to run its testsuite
will hang indefinitely.  The common sim APIs already have this, so
copy it over to the cris forks of the test+run functions.
2021-11-26 19:37:31 -05:00
Mike Frysinger
e1e1ae6e9b sim: testsuite: fix objdir handling
The tests assume that the cwd is the objdir directory and write its
intermediates to there all the time.  When using runtest's --objdir
setting though, this puts the files in the wrong place.  This isn't
a big problem currently as we never change --objdir, but in order to
support parallel test execution, we're going to start setting that
option, so clean up the code ahead of time.

We also have to tweak some of the cris tests which were making
assumptions about the argv[0] value.
2021-11-26 19:27:21 -05:00
Mike Frysinger
03c0f9c205 sim: testsuite: rename global_sim_options to SIMFLAGS_FOR_TARGET
Now that all the other toolchain settings have been renamed to match
the dejagnu settings of XXX_FOR_TARGET, rename global_sim_options to
SIMFLAGS_FOR_TARGET too.
2021-11-26 19:17:59 -05:00
Mike Frysinger
d07ada6f5a sim: testsuite: replace global_ld_options with LDFLAGS_FOR_TARGET
Only a few tests actually use global_ld_options, but we can replace the
sim-specific settings with the dejagnu common LDFLAGS_FOR_TARGET and get
the same result.
2021-11-26 19:03:13 -05:00
Mike Frysinger
0e87783408 sim: testsuite: replace global_as_options with ASFLAGS_FOR_TARGET
Only a few tests actually use global_as_options, but we can replace the
sim-specific settings with the dejagnu common ASFLAGS_FOR_TARGET and get
the same result.
2021-11-26 15:07:04 -05:00
Mike Frysinger
c099934746 sim: testsuite: drop unused global_cc_options
Nothing in the testsuite is using this setting, so let's drop it.
Any code that wants to set compiler flags can use CFLAGS_FOR_TARGET
instead to get the same effect.
2021-11-26 13:28:15 -05:00
Mike Frysinger
aa1b9bdef2 sim: testsuite: punt unused toolchain variables
These haven't been used in over 20 years.  The sim testsuite used to
run these tools itself directly, but back in ~1999 it switched to the
dejagnu helpers (e.g. target_assemble & target_link), and the dejagnu
logic only utilizes XXX_FOR_TARGET variables.  Punt them here to avoid
confusion with dead code.
2021-11-26 13:27:34 -05:00
Mike Frysinger
c0f9d65827 sim: mips: avoid _ namespace
Some C libraries export _P symbols in their headers (like older
newlib and its ctype.h), so use P_ instead to avoid conflicts.
2021-11-25 23:48:45 -05:00
Mike Frysinger
bbda248c50 sim: v850: fix cpu_option testsuite handling
The v850 testsuite code has been testing the $opt variable, but this
was never actually set anywhere globally or v850-specific.  Instead,
this was a random variable leaking out of the sh testsuite code.  As
far as I can tell, it has always been this way.  That means the code
only ever tested the v850 cpu target (which is the default).

This failure can be easily seen in practice by running the v850 code
in isolation and seeing it crash:
$ runtest v850/allinsns.exp
...
Running target unix
Using /usr/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/share/dejagnu/config/unix.exp as generic interface file for target.
Using ../../../sim/testsuite/config/default.exp as tool-and-target-specific interface file.
WARNING: Assuming target board is the local machine (which is probably wrong).
You may need to set your DEJAGNU environment variable.
Running ../../../sim/testsuite/v850/allinsns.exp ...
ERROR: tcl error sourcing ../../../sim/testsuite/v850/allinsns.exp.
ERROR: tcl error code TCL LOOKUP VARNAME opt
ERROR: can't read "opt": no such variable
    while executing
"switch -regexp -- $opt {

Backing up a bit, the reason for this logic in the first place is
because the common sim testsuite code makes an assumption about the
assembler options with cpu_option -- the option and its value are
always separated by an =.  This is not the case with v850.  So tweak
the core sim logic a bit to support omitting the = so that we can
switch v850 to the standard all_machs setting and avoid opt entirely.
2021-11-20 23:13:50 -05:00
Jeff Law
dbf98db6f0 Fix intermittent failures on the H8, particularly H8/SX tests.
The upstream GCC tester has  showed spurious execution failures on the
    H8 target for the H8/SX multilibs. I suspected memory corruption or an
    uninitialized variable early as the same binary would sometimes work and
    sometimes it got the wrong result. Worse yet, the point where the test
    determined it was getting the wrong result would change.

    Because it only happened on the H8/SX variant I was able to zero in on
    the "mova" support and the "short form" of those instructions in particular.

    As the code stands it checks if code->op3.type == 0 to try and identify cases
    where op3 wasn't filled in and thus we've got the short form of the mova
    instruction.

    But for the short-form of those instructions we never set any of the "op3"
    data structure. We get whatever was lying around -- it's usually zero and
     thus things usually work, but if the stale data was nonzero, then we'd
    fail to recognize the instruction as a short-form and fail to set up the
    various fields appropriately.

    I initially initialized the op3.type field to zero, but didn't like that
     because it was inconsistent with how other operands were initialized.
    Bringing consistency meant using -1 as the initializer value and adjusting
    the check for short form mova appropriately.

    I've had this in the upstream GCC tester for perhaps a year at this point
    and haven't seen any of the intermittent failures again.
2021-11-20 13:06:15 -05:00
Mike Frysinger
6e3e76d17b sim: bfin: fix short --env usage in testsuite
Now that we have more than one option that matches "--env", the test
config here doesn't work.  Use the explicit --environment.
2021-11-19 21:27:50 -05:00
Mike Frysinger
ed939535e2 sim: install various doc files 2021-11-19 03:36:45 -05:00
Mike Frysinger
fccf4ba5ad sim: use program_transform_name for libsim
Instead of always using target_alias as a prefix on the name, use
program_transform_name instead so that the library is scoped in the
same way as the run program.
2021-11-18 19:56:45 -05:00