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.
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.
We've been using SIM_ADDR which has always been 32-bit. This means
the upper 32-bit address range in 64-bit sims is inaccessible. Use
64-bit addresses all the time since we want the APIs to be stable
regardless of the active arch backend (which can be 32 or 64-bit).
The length is also 64-bit because it's completely feasible to have
a program that is larger than 4 GiB in size/image/runtime. Forcing
the caller to manually chunk those accesses up into 4 GiB at a time
doesn't seem useful to anyone.
Bug: https://sourceware.org/PR7504
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.
We still have to maintain custom install rules due to how we rename
arch-specific files with an arch prefix in their name, but we can at
least unify the logic in the common dir.
We have configure tests for this in the top-level configure script
to link this when necessary, so we don't need to explicitly list it
for specific ports.
The erc32 sim does a lot itself, including handling of the CLI. It
used to provide a run-compatible interface in the pre-nrun days, but
it was dropped when the old run interface was punted. Since the old
commit 465fb143c8 ("sim: make nrun the
default run program"), the erc32 run & sis programs have been the
same, and erc32 hasn't provide a real run-compatible interface.
Simplify this by linking the two programs via ln/cp instead of running
the linking phase twice to produce the same result. If/when we fix up
the erc32 port to have a proper run interface, it should be easy to
split these back apart into real programs.
Note: the interf.o reference in here is a bit of a misdirect. Since
that object is placed into libsim.a, it's never been linked into the
programs since the linker ignores objects that aren't referenced, and
only gdb uses those symbols.
When reading/writing arbitrary data to the system's memory, the unsigned
char pointer type doesn't make that much sense. Switch it to void so we
align a bit with standard C library read/write functions, and to avoid
having to sprinkle casts everywhere.
When reading/writing arbitrary data to the system's memory, the unsigned
char pointer type doesn't make that much sense. Switch it to void so we
align a bit with standard C library read/write functions, and to avoid
having to sprinkle casts everywhere.
Clang generates a warning if an argument is passed to a function without
prototype (zero arguments, even without (void)). Such calls are deprecated
forms of indefinite arguments passing ("-Wdeprecated-non-prototype").
On the default configuration, it (somehow) doesn't cause a build failure but
a warning is generated.
But because the cause is the same as the issue the author fixed in
"sim/erc32: Use int32_t as event callback argument", it would be better to
fix it now to prevent problems in the future.
To fix the issue, this commit makes struct irqcall to use int32_t as a
callback (callback) argument of an IRQ.
Clang generates a warning if an argument is passed to a function without
prototype (zero arguments, even without (void)). Such calls are deprecated
forms of indefinite arguments passing ("-Wdeprecated-non-prototype").
On the default configuration, it causes a build failure (unless
"--disable-werror" is specified).
To fix that, this commit makes struct evcell to use int32_t as a callback
(cfunc) argument of an event. int32_t is chosen because "event" function
accepts "int32_t arg".
Clang generates a warning if there is a function declaration/definition
with zero arguments. Such declarations/definitions without a prototype (an
argument list) are deprecated forms of indefinite arguments
("-Wdeprecated-non-prototype"). On the default configuration, it causes a
build failure (unless "--disable-werror" is specified).
This commit replaces () with (void) to avoid this warning.
When building the erc32 simulator I get a few warnings like this:
/tmp/build/sim/../../src/sim/erc32/exec.c:1377:21: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
1377 | sregs->fs[rd] = *((float32 *) & ddata[0]);
| ~^~~~~~~~~~~~~~~~~~~~~~~
The type of '& ddata[0]' will be 'uint32_t *', which is what triggers
the warning.
This commit makes use of memcpy when performing the type-punning,
which resolves the above warnings.
With this change, I now see no warnings when compiling exec.c, which
means that the line in Makefile.in that disables -Werror can be
removed.
There should be no change in behaviour after this commit.
Clang generates a warning if the format string of a printf-like function is
not a literal ("-Wformat-nonliteral"). On the default configuration, it
causes a build failure (unless "--disable-werror" is specified).
To avoid warnings on the printf-like wrapper, it requires proper
__attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason.
This commit adds ATTRIBUTE_PRINTF to the printf-like functions.
In commit:
commit 7b01c1cc1d
Date: Mon Apr 4 22:38:04 2022 +0100
sim: fixes for libopcodes styled disassembler
changes were made to the simulator source to handle the new libopcodes
disassembler styling API.
Unfortunately, these changes broke building GDB with the erc32 (sparc)
simulator, like this:
../src/configure --target=sparc-linux
make all-gdb
....
/usr/bin/ld: ../sim/erc32/libsim.a(interf.o): in function `sim_open':
/tmp/build/sim/../../src/sim/erc32/interf.c:247: undefined reference to `fprintf_styled'
collect2: error: ld returned 1 exit status
The problem is that in commit 7b01c1cc1d the fprintf_styled function
was added into sis.c. This file is only used when building the 'run'
binary, that is, the standalone simulator, and is not included in the
libsim.a library.
Now, the obvious fix would be to move fprintf_styled into libsim.a,
however, that turns out to be tricky.
The erc32 simulator currently has two copies of the function run_sim,
one in sis.c, and one in interf.c, both of these copies are global.
Currently, the 'run' binary links fine, though I suspect this might be
pure luck. When I tried moving fprintf_styled into interf.c, I ran
into multiple-definition (of run_sim) errors. I suspect that by
requiring the linker to pull in fprintf_styled from libsim.a I was
changing the order in which symbols were loaded, and the linker was
now seeing both copies of run_sim, while currently we only see one
copy.
The ideal solution of course, would be to merge the two similar, but
slightly different copies of run_sim, and just use the one copy. Then
we could safely move fprintf_styled into interf.c too, and all would
be good.
But I don't have time right now to start debugging the erc32
simulator, so I wanted a solution that fixes the build without
introducing multiple definition errors.
The easiest solution I think is to just have two copies of
fprintf_styled, one in sis.c, and one in interf.c. Unlike run_sim,
these two copies are both static, so we will not run into multiple
definition issues with this function. The functions themselves are
not very big, so it's not a huge amount of duplicate code.
I am very aware that this is not an ideal solution, and I would
welcome anyone who wants to take on fixing the run_sim problem
properly, and then cleanup the fprintf_styled duplication.
Like commit b82817674f, this replaces BFD_VMA_FMT "x" in sim/ with
PRIx64 and casts to promote bfd_vma to uint64_t. The one file using
BFD_VMA_FMT in gdb/ instead now uses hex_string, and a typo in the
warning message is fixed.
In commit:
commit 60a3da00bd
Date: Sat Jan 22 11:38:18 2022 +0000
objdump/opcodes: add syntax highlighting to disassembler output
I broke several sim/ targets by forgetting to update their uses of the
libopcodes disassembler to take account of the new styled printing.
These should all be fixed by this commit.
I've not tried to add actual styled output to the simulator traces,
instead, the styled print routines just ignore the style and print the
output unstyled.
This commit brings all the changes made by running gdb/copyright.py
as per GDB's Start of New Year Procedure.
For the avoidance of doubt, all changes in this commits were
performed by the script.
The ## marker tells automake to not include the comment in its
generated output, so use that in most places where the comment
only makes sense in the inputs.
Only one file in here still generates warnings, so reduce the -Werror
disable to that alone now that we require GNU make and can set variables
on a per-object basis.
Tweak the if indentation & brace style to avoid ambiguous warnings.
Add ATTRIBUTE_UNUSED to UART functions that aren't used when FAST_UART
is defined (which is the default).
Now that ChangeLog entries are no longer used for sim patches,
this commit renames all relevant sim ChangeLog to ChangeLog-2021,
similar to what we would do in the context of the "Start of New
Year" procedure.
The purpose of this change is to avoid people merging ChangeLog
entries by mistake when applying existing commits that they are
currently working on.
Also throw in a .gitignore entry to keep people from adding new
ChangeLog files anywhere in the sim tree.
We're starting to move more objects to the common build that sis did
not need before, so linking them is causing problems (when common
objects end up needing symbols from non-common objects). Switch it
to the libsim.a archive which will allow the link to pull out only
what it needs.
These ports only use the pieces that have been unified, so we can
merge them into the common configure script and get rid of their
unique one entirely.
We still compile & link separate run programs, and have dedicated
subdir Makefiles, but the configure script portion is merged.
The sim-hardware configure option allows builders to select a set of
device models to enable. But this seems like unnecessary overkill:
the existence of individual device models doesn't affect performance
at all as they are only enabled at runtime if the config uses them,
and individually these are all <5KB a piece. Stripping off a total
of ~50KB from a ~1MB binary doesn't seem useful, and it's extremely
unlikely anyone will ever bother.
So let's simplify the configure/make logic by turning sim-hardware
into a boolean option like many of the other sim options. Any ports
that have unique device models will declare them in their Makefile
instead of at configure time. This will allow us to (eventually)
unify the setting into the common dir.
Move these options up to the common dir so we only test & export
them once across all ports. This takes a page from the cgen maint
logic to make $(MAINT) work for non-automake Makefiles which will
allow us to merge it together.