Add explicit arch-specific modules.c rules to keep the build from
generating an incorrect common/modules.c. Otherwise the pattern
rules would cascade such that it'd look for $arch/modules.o which
turned into common/modules.c which triggered the gen rule.
My local testing of this code didn't catch this bug because of how
Automake manages .Po (dependency files) in incremental builds -- it
was adding extra rules that override the pattern rules which caused
the build to generate correct modules.c files. But when building
from a cold cache, the pattern rules would force common/modules.c to
be used leading to crashes at runtime.
This makes sure the arch-specific modules.c wildcard is matched and
not the common/%.c so that we compile it correctly. It also makes
sure each subdir has depdir logic enabled.
Now that we build these objects in the top dir & generate modules.c
there, we don't need to generate them all first -- we can let the
normal dependency graph take care of building things in parallel.
This simplifies the build logic and avoids an Automake bug where the
common_libcommon_a_OBJECTS variable isn't set in the arch libsim.a
DEPENDENCIES for targets that, alphabetically, come before "common".
We aren't affected by that bug with the current code, but as we move
things out of SIM_ALL_RECURSIVE_DEPS and rely on finer dependencies,
we will trip over it.
The objects are still compiled in the subdir, but the creation of the
archive itself is in the top-level. This is a required step before we
can move compilation itself up, and makes it easier to review.
The downside is that each object compile is a recursive make instead of
a single one. On my 4 core system, it adds ~100msec to the build per
port, so it's not great, but it shouldn't be a big deal. This will go
away of course once the top-level compiles objects.
The mips code is a little more tricky than others because, for multi-run
targets, it generates the list of sources & objects on the fly in the
configure script.
Add rules for tracking generated subdir modules.c files. This doesn't
actually generate the file from the top-level, but allows us to add
rules that need to be ordered wrt it. Once those changes land, we can
rework this to actually generate from the top-level.
This currently builds off of the objects that go into the libsim.a as
we don't build those from the top-level either. Once we migrate that
up, we can switch this to the source files directly. It's a bit hacky
overall, but makes it easier to migrate things in smaller chunks, and
we aren't going to keep this logic long term.
The multirun generation mode is a bit of a mess as generated run files
depend on generate igen files, all with unknown names ahead of time.
In the multirun mode, be lazy and declare all of these generated source
files as built sources so they'll be created early on.
Automake's automatic header deptracking has a bootstrap problem where
it can't detect generated headers when compiling. We've been handling
that by adding a custom SIM_ALL_RECURSIVE_DEPS variable, but that only
works when building objects recursively in subdirs. As we move those
out to the top-level, we don't have any recursive steps anymore. The
Automake approach is to declare those headers in BUILT_SOURCES.
This isn't completely foolproof as the Automake manual documents: it
only activates for `make all`, not `make foo.o`, but that shouldn't be
a huge limitation as it only affects the initial compile. After that,
rebuilds should work fine.
Clean up includes a bit by making ports include bfd/ headers
explicitly. This matches other projects, and makes it more clear
where these headers are coming from.
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
The naming in here has grown organically and is confusing to follow.
Originally there was only one set of rules for generating code from
the igen sources, so calling it "tmp-igen" and such made sense. But
when other multigen modes were added ("m16" & "multi") which also
used igen, it's not clear what's common igen and what's specific to
this generation mode. So rename the set of rules from "igen" to
"single" so it's easier to follow.
The m16 & multi targets generate itable once even when all the other
modules are generated multiple times. The default igen target will
generate itable with everything else out of convenience. This means
flags are passed which don't affect the generated itable there.
We can unify the itable generation by making sure the right -F/-M
filter variables are passed down. Since there's already a dedicated
rule & variable in the multi build mode, generalize that and switch
the m16 & igen builds over too.
I spent a lot of time staring at this code, building for diff mips
targets, and exploring all the shell code paths. I think this is
safe, but only time (and users) will really tell.
This variable is only used to generate the itable files. In preparation
for merging the itable logic among all ports, rename "multi_flags" to a
more appropriate "igen_itable_flags" variable. There should be no real
chagnes here otherwise.
This code appears to be unused since it was first merged. When
micromips was enabled, it was via the "MULTI" config, not the
"MICROMIPS" config, and the multi configs have sep vars. Since
nothing sets SIM_MIPS_GEN=MICROMIPS in the config, all of this
should be unreachable, so punt it to simplify. Further, the
SIM_MIPS_MICROMIPS16_FLAGS & SIM_MIPS_MICROMIPS_FLAGS settings
rely on sim_mips_micromips{,16}_{filter,machine} variables that
are never set in the configure script.
While mips has respected sim_igen_smp at configure time (which was
always empty since it defaulted smp to off), no other igen port did.
Move this to a makefile variable and plumb it through the common
IGEN_RUN variable instead so everyone gets it by default. We also
clean up some redundant -N0 setting with multirun mips.
All the runtimes were only initializing a single CPU. When SMP is
enabled, things quickly crash as none of the other CPU structs are
setup. Change the default from 0 to the compile time value.
This is the last bit of logic that exists in the mips configure
script, so move it to the top-level configure to kill it off.
We still have to move the Makefile.in igen logic to local.mk,
but this is a required first step for that.
To prepare moving this logic to the top-level configure, the vars
need to be namespaced. Do that here to make it easier to review.
Basically sim_xxx -> SIM_MIPS_XXX when a var is exported from the
configure script to the Makefile, and sim_xxx -> sim_mips_xxx when
the var is internal in the configure script.
Make sure the igen tool exists before trying to compile the mips
subdir. This happens to work when mips has a subconfigure, but
hits a race condition when that is removed.
Not all arches include this in sim-main.h, and the ones that do don't
actually use bfd defines in the sim-main.h header. Prune it to make
sim-main.h simpler so we can kill it off entirely in the future.
We add the include to the files that utilize e.g. bfd_vma though.
These variables are setting the same value as the defaults. Trim
this redundant logic to make it easier to see the real differences
so we can try to keep unifying cases.
Change the default (unhandled) mips64* targets to use the existing
mips64 multi-run build. It already handles the formats, we just
have to list the mips8000 bfd for it.
The existing mips64vr-* multi-run build already handles mips5000
targets, so reuse that for mips64vr5* targets too. This moves
more logic from build-time to runtime so we can have a single
binary that supports many targets.
The existing mips64vr-* multi-run build already handles mips4300
targets, so reuse that for mips64vr43* targets too. This moves
more logic from build-time to runtime so we can have a single
binary that supports many targets.
We don't need to enforce larger target settings when the only thing
the sim should care about is the CPU target. So reduce most of the
target matches to only check the CPU.
This drops support for the --enable-sim-float configure option,
but it's not clear anyone ever actually used that. Eventually
we'll want this to be a runtime option anyways.
Don't assume that the default bfd that we configured for is the one
that is always active when running a program. We already have access
to the real runtime value, so use it directly. This simplifies the
code quite a bit, and will make it easier to support multiple mach's
in a single binary.
We need these in the top-level to generate libsim.a, but also in the
subdirs to generate hw-config.h. Move it to the local.mk, and pass
it down when running recursive make. This avoids duplication, and
makes it available to both. We can simplify this once we move the
various steps up to the top-level too.
The intention of this code seems to be to indicate that this insn
should not be used and produces undefined behavior, so instead of
setting registers to bogus values, call Unpredictable. This fixes
build warnings due to 32-bit/64-bit type conversions, and outputs
a log message for users at runtime instead of silent corruption.
Bug: https://sourceware.org/PR29276
Automake will run each subdir individually before moving on to the next
one. This means that the linking phase, a single threaded process, will
not run in parallel with anything else. When we have to link ~32 ports,
that's 32 link steps that don't take advantage of parallel systems. On
my really old 4-core system, this cuts a multi-target build from ~60 sec
to ~30 sec. We eventually want to move all compile+link steps to this
common dir anyways, so might as well move linking now for a nice speedup.
We use noinst_PROGRAMS instead of bin_PROGRAMS because we're taking care
of the install ourselves rather than letting automake process it.