Commit Graph

4373 Commits

Author SHA1 Message Date
Mike Frysinger
65dcce8f79 sim: add arch-specific conditional logic
This will make it easy to include arch-specific logic (build files)
as we migrate ports to the common top level build.
2021-10-31 02:03:16 -04:00
Mike Frysinger
68c2129ae6 sim: v850: delete old gencode logic
The v850 port used to have a gencode helper, but it was deleted long
ago.  Clean up the settings that no longer make sense w/out it.
2021-10-31 01:49:17 -04:00
Mike Frysinger
2213e33dd2 sim: common: merge multiple clean commands
This provides a minor speedup when cleaning in a multi-target build.
2021-10-31 01:17:10 -04:00
Mike Frysinger
b46621118d sim: m32c: tighten up opc2c build output
Drop the single debugging line that repeats the command line option,
and use the silent build helpers to tighten up output.
2021-10-31 01:11:41 -04:00
Mike Frysinger
9709fa5bcb sim: tighten up build regen rules
Update the makefile & configure related rules to use the silent
build helpers.
2021-10-31 01:08:05 -04:00
Mike Frysinger
4837497a7f sim: tighten up gencode output
Update the gencode rules to use the silent build helpers.
2021-10-31 01:05:27 -04:00
Mike Frysinger
ac9b6df28f sim: igen: tighten up build output
Add a new stamp helper for quiet builds, and don't dump the command
line options when it runs.  That isn't standard tool behavior, and
doesn't really seem necessary in any way.
2021-10-31 00:55:50 -04:00
Mike Frysinger
65f42b88ff sim: tighten up stamp rules
Add a new ECHO_STAMP helper and convert existing stamp code over
to it.  This is mostly common rules and cgen mloop rules.
2021-10-31 00:49:39 -04:00
Mike Frysinger
b6143d3162 sim: silence stamp touch rules
We pretty much never care about these stamp touches, so silence them.
Also switch to using $@ when it makes sense.
2021-10-31 00:46:28 -04:00
Mike Frysinger
4f2b181ecb sim: standardize move-if-change rules
Use the srcroot path and make them all silent.
2021-10-31 00:39:40 -04:00
Mike Frysinger
bdcbd1b67f sim: mips/v850: remove redundant variable setup
The common/Make-common.in fragment already provides these variables.
2021-10-31 00:23:36 -04:00
Orgad Shaneh
1352aabb23 sim: fix compilation on mingw64 [PR sim/28476]
...by reordering includes.

1. sim-utils.c

sim/mips/sim-main.h defines UserMode, while there is a struct in winnt.h
which has UserMode as a member. So if sim-main.h is included before winnt.h,
compilation fails.

2. ppc

registers.h defines CR, which is used as a member in winnt.h.

winsock2.h is included by sys/time.h, so sys/time.h has to be included
before registers.h.

Bug: https://sourceware.org/PR28476
2021-10-30 23:50:09 -04:00
Christian Biesinger
cf365c10d0 [sim] Include defs.h in ppc/hw_memory.c
To fix this error (seen on cygwin):
/../../sim/ppc/../common ../../../sim/ppc/hw_memory.c
In file included from ../../gnulib/import/stdlib.h:100,
                 from ../../../sim/ppc/hw_memory.c:28:
../../gnulib/import/unistd.h:663:3: error: #error "Please include config.h first."
  663 |  #error "Please include config.h first."
      |   ^~~~~
../../gnulib/import/unistd.h:665:24: error: expected ';' before 'extern'
  665 | _GL_INLINE_HEADER_BEGIN
      |                        ^
      |                        ;
../../gnulib/import/unistd.h:2806:22: error: expected ';' before 'extern'
 2806 | _GL_INLINE_HEADER_END
      |                      ^
      |                      ;
2021-10-28 15:09:00 -04:00
Mike Frysinger
adc82fdb71 sim: add --info-target for listing supported BFD targets
It can be difficult to guess the exact bfd name, so add an option to
list all the targets that the current build supports.  This aligns with
other simulator options like --info-architecture.
2021-10-04 02:19:58 -04:00
Mike Frysinger
39d53d0435 sim: filter out SIGSTKSZ [PR sim/28302]
We map target signals to host signals so we can propagate signals
between the host & simulated worlds.  That means we need to know
the symbolic names & values of all signals that might be sent.

The tools that generate that list use signal.h and include all
symbols that start with "SIG" so as to automatically include any
new symbols that the C library might add.  Unfortunately, this
also picks up "SIGSTKSZ" which is not actually a signal itself,
but a signal related setting -- it's the size of the stack when
a signal is handled.

By itself this doesn't super matter as we will never see a signal
with that same value (since the range of valid signals tend to be
way less than 1024, and the size of the default signal stack will
never be that small).  But with recent glibc changes that make this
into a dynamic value instead of a compile-time constant, some users
see build failures when building the sim.

As suggested by Adam Sampson, update our scripts to ignore this
symbol to simplify everything and avoid the build failure.

Bug: https://sourceware.org/PR28302
2021-10-03 12:02:53 -04:00
Mike Frysinger
46039d3632 sim: ppc: fallback when ln is not available [PR sim/18864]
Not all systems have easy access to hard links or symlinks, so add
fallback logic to the run->psim build code to handle those.

Bug: https://sourceware.org/PR18864
2021-10-03 11:36:30 -04:00
Mike Frysinger
cee4c731af sim: drop weak func attrs on module inits
When I first wrote this, I was thinking we'd scan all source files
that existed and generate a complete init list.  That means for any
particular build, we'd probably have a few functions that didn't
exist, so weak attributes was necessary.  What I ended up scanning
though was only the source files that went into a particular build.

There was another concern too: a source file might be included, but
the build settings would cause all of its contents to be skipped
(via CPP defines).  So scanning via naive grep would pick up names
not actually available.  A check of the source tree shows that we
never do this, and it's pretty easy to institute a policy that we
don't start (by at the very least including a stub init func).

The use of weak symbols ends up causing a problem in practice: for
a few modules (like profiling), nothing else pulls it in, so the
linker omits it entirely, which leads to the profiling module never
being available.  So drop the weak markings since we know all these
funcs will be available.
2021-09-28 01:51:38 -04:00
Nick Alcock
b9004024b9 configure: regenerate in all projects that use libtool.m4
(including sim/, which has no changelog.)

bfd/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

binutils/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gas/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

gprof/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

ld/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

libctf/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
	* Makefile.in: Regenerate.

opcodes/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.

zlib/ChangeLog
2021-09-27  Nick Alcock  <nick.alcock@oracle.com>

	* configure: Regenerate.
2021-09-27 20:31:24 +01:00
Mike Frysinger
f050cfdd82 sim: bfin: add support for SDL2
This probably should have been ported long ago, but better late than
never.  We keep support for both versions for now since both projects
tend to have long lifetimes.  Maybe consider dropping SDL1 in another
ten years.
2021-09-13 22:45:19 -04:00
Mike Frysinger
bf9f8f4179 sim: run: change help short option to -h
It's unclear why -H was picked over the more standard -h, but since
-h is still not used, just change -H to -h to match pretty much every
other tool in the sourceware tree.
2021-09-11 02:55:06 -04:00
Mike Frysinger
21b9b99cd7 sim: accept -EB/-EL short options
Many GNU tools accept -EB/-EL as short options for selecting big &
little endian modes.  While the sim has an -E option, it requires
spelling out "big" and "little".  Adding support for -EB & -EL is
thus quite trivial, so lets round it out to be less annoying.
2021-09-09 03:01:28 -04:00
Mike Frysinger
b728479074 sim: ppc: drop support for std-config.h overrides
Only the ppc arch supports this kind of source file override logic.
All the others expose knobs via configure flags, and for some of
these, the ppc code does as well.  For others, it doesn't make sense
to ever change them.  Since it's unlikely anyone is using this, drop
it all to simplify the code (and to get us a little closer to the
common sim code).
2021-09-09 02:46:35 -04:00
Mike Frysinger
a13ab747e7 sim: ppc: enable use of gnulib
All other sim arches are using this now, so finish up the logic in
the ppc arch to enable gnulib usage here too.
2021-09-09 02:24:00 -04:00
Mike Frysinger
ee73abf25e sim: drop old O_NDELAY & FNBLOCK support
We use these older names inconsistently in the sim codebase, and time
has moved on long ago, so drop support for these non-standard names.
POSIX provides O_NONBLOCK for us, so use it everywhere.
2021-09-09 02:24:00 -04:00
Mike Frysinger
03de8f26e8 sim: dv-sockser: enable for mingw targets too
We have enough functionality from gnulib now to build sockser on
all platforms.

Non-blocking I/O is supported when F_GETFL/F_SETFL are unavailable,
but we can address that in a follow up commit.  This mirrors what
is done in other places in the sim already.
2021-09-09 01:32:16 -04:00
Mike Frysinger
93aaa742b3 sim: cgen: workaround Windows VOID define
The cgen framework provides a "VOID" type for code to use, but this
defines ends up conflicting with the standard Windows VOID define.
Since they actually define to the same thing ("void"), undef it here
to fix the Windows build.

We might want to reconsider the need for "VOID" in cgen, but that
will take larger discussion & coordination with the cgen project.
2021-09-09 01:28:58 -04:00
Mike Frysinger
287fbf951a sim: dv-sockser: move sim-main.h include after system includes
The sim-main.h header is a bit of a dumping ground.  Every arch can
(and many do) define all sorts of weird & common names that end up
conflicting with system headers.  So including it before the system
headers sets us up for pain.  v850 is a good example of this -- when
building for mingw, we see weird failures:

$ i686-w64-mingw32-gcc ... -c -o dv-sockser.o ../../../../sim/v850/../common/dv-sockser.c
In file included from ../../../../sim/v850/sim-main.h:11,
                 from ../../../../sim/v850/../common/dv-sockser.c:24:
../../../../sim/v850/../common/sim-base.h:97:32: error: expected ')' before '->' token
  97 | # define STATE_CPU(sd, n) ((sd)->cpu[0])
     |                                ^~

While gcc is unhelpful at first, running it through the preprocessor
by hand shows more details:

$ i686-w64-mingw32-gcc ... -E -dD -o dv-sockser.i ../../../../sim/v850/../common/dv-sockser.c
$ i686-w64-mingw32-gcc -c dv-sockser.i
In file included from /usr/i686-w64-mingw32/usr/include/minwindef.h:163,
                 from /usr/i686-w64-mingw32/usr/include/windef.h:9,
                 from /usr/i686-w64-mingw32/usr/include/windows.h:69,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from ../../../../sim/v850/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/winnt.h:4803:25: error: expected ')' before '->' token
 4803 |       DWORD State;
      |                         ^
      |                         )

This is because v850 sets up this common name:

All of this needs cleaning up someday, but since the dv-sockser code
definitely should be fixed in this way, lets do that now and unblock
the v850 code.
2021-09-09 01:04:08 -04:00
Mike Frysinger
7eb2a68f28 sim: mips: delete unused PSIZE define
It's unclear what this define is for as it appears to be unused, and
has never been used in the history of the mips sim.  Delete it to tidy
up, and to fix build errors for Windows targets that have a standard
"PSIZE" struct in their system headers.  This doesn't show up yet as
most sim files don't include many system headers, but enabling sockser
code for mingw uncovers the conflict.

Unfortunately the error produced by gcc is inscrutable, but running
it through the preprocessor manually manages to provide a pointer to
the underlying issue.

$ i686-w64-mingw32-gcc ... -c -o dv-sockser.o ../../../../sim/mips/../common/dv-sockser.c
<command-line>: error: expected identifier or '(' before numeric constant
In file included from /usr/i686-w64-mingw32/usr/include/windows.h:71,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from ../../../../sim/mips/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/wingdi.h:2934:59: error: unknown type name 'LPSIZE'; did you mean 'LPSIZEL'?
 2934 |   WINGDIAPI WINBOOL WINAPI GetAspectRatioFilterEx(HDC hdc,LPSIZE lpsize);
      |                                                           ^~~~~~
      |                                                           LPSIZEL
...

$ i686-w64-mingw32-gcc ... -E -dD -o dv-sockser.i ../../../../sim/mips/../common/dv-sockser.c
$ i686-w64-mingw32-gcc -c dv-sockser.i
In file included from /usr/i686-w64-mingw32/usr/include/windows.h:69,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from ../../../../sim/mips/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/windef.h:104:9: error: expected identifier or '(' before numeric constant
  104 | } SIZE,*PSIZE,*LPSIZE;
      |         ^~
2021-09-09 00:34:21 -04:00
Mike Frysinger
f2a13264fb sim: ppc: switch to common warning flags
Now that the ppc code has been cleaned up enough to use the same set
of warning flags as the common code, delete the ppc-specific configure
logic so we can leverage what the common code already defined for us.
2021-09-08 23:33:32 -04:00
Tom de Vries
81f839676d sim: ppc: enable -Wpointer-sign warnings
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into:
...
src/sim/ppc/hw_memory.c: In function 'hw_memory_init_address':
src/sim/ppc/hw_memory.c:204:7: error: pointer targets in passing argument 4 \
  of 'device_find_integer_array_property' differ in signedness \
  [-Werror=pointer-sign]
       &new_chunk->size);
       ^
...

Fix these by adding an explicit pointer cast.  It's a bit ugly to use APIs
based on signed integers to read out unsigned values, but in practice, this
is par for the course in the ppc code.

We already use signed APIs and assign the result to unsigned values a lot:
see how device_find_integer_property returns a signed integer (cell), but
then assign it to unsigned types.  The array APIs are not used that often
which is why we don't see many warnings, and we disable warnings when we
assign signed integers to unsigned integers in general.

The dtc/libfdt project (which is the standard in other projects) processes
the fdt blob as a series of bytes without any type information.  Typing is
left to the caller.  They have core APIs that read/write bytes, and a few
helper functions to cast/convert those bytes to the right value (e.g. u32).
In this ppc sim code, the core APIs use signed integers, and the callers
convert to unsigned, usually implicitly.

We could add some core APIs to the ppc sim that deal with raw bytes and then
add some helpers to convert to the right type, but that seems like a lot of
lifting for what boils down to a cast, and is effectively equivalent to all
the implicit assignments we use elsewhere.  Long term, a lot of the ppc code
should either get converted to existing sim common code, or we should stand
up proper APIs in the common code first, or use standard libraries to do all
the processing (e.g. libfdt).  Either way, this device.c code would all get
deleted, and callers (like these hw_*.c files) would get converted.  Which
is also why we go with a cast rather new (but largely unused) APIs.
2021-09-08 23:33:25 -04:00
Mike Frysinger
0c320e1bdc sim: ppc: enable -Wmissing-declarations & -Wmissing-prototypes
This aligns with common code which already uses this flag.  We have
to add another local prototype to fix the failure, and add another
local decl for the SIM_DESC type.  Unwinding these will require a
lot more work & conversions in the process, so going with the decl
for now unblocks the warning unification.
2021-09-08 23:18:43 -04:00
Mike Frysinger
aa0380cc7e sim: microblaze: replace custom basic types with common ones
The basic "byte" type conflicts with Windows headers, and we already
have common types that provide the right sizes.  So replace these with
the common ones to avoid issues.

  CC     dv-sockser.o
In file included from /usr/i686-w64-mingw32/usr/include/wtypes.h:8,
                 from /usr/i686-w64-mingw32/usr/include/winscard.h:10,
                 from /usr/i686-w64-mingw32/usr/include/windows.h:97,
                 from /usr/i686-w64-mingw32/usr/include/winsock2.h:23,
                 from ../../gnulib/import/sys/socket.h:684,
                 from ../../gnulib/import/netinet/in.h:43,
                 from .../build/sim/../../../sim/microblaze/../common/dv-sockser.c:39:
/usr/i686-w64-mingw32/usr/include/rpcndr.h:63:25: error: conflicting types for 'byte'; have 'unsigned char'
   63 |   typedef unsigned char byte;
      |                         ^~~~
In file included from .../buildsim/../../../sim/microblaze/sim-main.h:21,
                 from .../buildsim/../../../sim/microblaze/../common/dv-sockser.c:24:
.../buildsim/../../../sim/microblaze/microblaze.h:94:25: note: previous declaration of 'byte' with type 'byte' {aka 'char'}
   94 | typedef char            byte;
      |                         ^~~~
make: *** [Makefile:513: dv-sockser.o] Error 1
2021-09-08 21:32:34 -04:00
Mike Frysinger
d0d2fb0a25 sim: ppc: align format string settings with common code
This copies logic used in the common sim warning configure code to fix
build errors for mingw targets.  Turning format warnings on triggers
a failure in the debug.c file, so apply a minor fix at the same time.
2021-09-08 21:02:25 -04:00
Mike Frysinger
74e43bd231 sim: ppc: drop unnecessary config includes
This file is compiled for the --host & --build system which leads to
including the configure generated config.h in both environments.
This obviously doesn't work when the two targets don't look alike at
all and can cause build failures here (e.g. a mingw host & a linux
build).  Since we don't actually need any config settings in this
very simple file, drop the includes entirely.
2021-09-08 21:02:25 -04:00
Mike Frysinger
99aedb6243 sim: update configure target list
Fix sorting of the list, and update the globs to match the list used
in gdb's configure script.
2021-09-08 01:24:15 -04:00
Mike Frysinger
fe7f0b0135 sim: m32r: add __linux__ hack for non-Linux hosts
The m32r Linux syscall emulation logic assumes the host environment
directly matches -- it's being run on 32-bit little endian Linux.
This breaks building for non-Linux systems, so put all the code in
__linux__ ifdef checks.  This code needs a lot of love to make it
work everywhere, but let's at least unbreak it for non-Linux hosts.
2021-08-22 03:11:16 -04:00
Mike Frysinger
082cf6944a sim: nltvals: switch output mode to a directory
In preparation for this script generating more files, change the output
argument to specify a directory.  This drops the stdout behavior, but
since no one really runs this tool directly, it's not a big deal.
2021-08-19 21:05:28 -04:00
Mike Frysinger
10d8e25c4d sim: nltvals: localize TARGET_<ERRNO> defines
Code should not be using these directly, instead they should be
resolving these dynamically via cb_host_to_target_errno maps.
Fix the Blackfin code and remove the defines out of the header
so no new code can rely on them.
2021-08-17 21:08:57 -04:00
Mike Frysinger
9335d9f823 sim: rename ChangeLog files to ChangeLog-2021
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.
2021-08-17 20:27:36 -04:00
Mike Frysinger
c8d4ff8a3a sim: erc32: use libsim.a for common objects
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.
2021-07-08 02:30:37 -04:00
Dan Streetman
acbf56d780 sim: ppc: add missing empty targets
These are copied from sim/common/Make-common.in.

On ppc the build fails without at least the 'info' target, e.g.:

Making info in ppc
make[4]: Entering directory '/<<BUILDDIR>>/gdb-10.2.2974.g5b45e89f56d+21.10.20210510155809/build/default/sim/ppc'
make[4]: *** No rule to make target 'info'.  Stop.
2021-07-06 11:47:50 -04:00
Mike Frysinger
7eb1f99ada sim: unify reserved instruction bits settings
Move these options up to the common dir so we only test & export
them once across all ports.

The setting only affects igen based ports, and they were turning
this on by default, so keep the default in place.
2021-07-01 20:53:00 -04:00
Mike Frysinger
313c332ff2 sim: m32r: merge with common configure script
Now that the traps code has been unified, the configure script has no
unique logic in it, so it can be merged into the single common one.
2021-07-01 20:48:07 -04:00
Mike Frysinger
54af62279c sim: m32r: reformat linux traps code
Do this as a sep commit to try and make the history easier to review.
2021-07-01 20:47:09 -04:00
Mike Frysinger
fe41f7211a sim: m32r: unify ELF & Linux traps logic
This makes the simulator work the same regardless of the target (bare
metal m32r-elf or Linux m32r-linux-gnu) by unifying the traps code.
It was mostly already the same with the only difference being support
for trap #2 reserved for Linux syscalls.  We can move that logic to
runtime by checking the current environment operating mode instead.
2021-07-01 20:46:11 -04:00
Mike Frysinger
d4a0121347 sim: m32r: replace custom endian helpers with sim-endian
This improves the logic a bit by making the host<->target translations
a bit more clear.  The structs still bleed way too much between the two
worlds, but let's fix one thing at a time.
2021-07-01 20:43:11 -04:00
Mike Frysinger
055a3f27e8 sim: m32r: fix virtual environment with Linux targets
We don't want to handle Linux syscalls when in the virtual environment,
just the user environment, so adjust the Linux traps logic to check for
that specifically (instead of just skipping the operating environment).

Also tweak some testcases to explicitly specify the environment they run
under rather than relying on the default matching their needs.  This gets
the tests passing for all m32r targets.
2021-07-01 20:38:07 -04:00
Mike Frysinger
33b477e1c7 sim: m32r: namespace Linux syscall table
The use of __NR_ defines in here conflicts a lot with the standard
host syscalls, sometimes leading to build errors (when the numbers
happen to be the same we get duplicate case handlers), and other
times leading to misbehavior (where the m32r syscall # is not what
is actually checked).

Namespace these using the standard that we already use: change the
__NR_ to TARGET_LINUX_SYS_ with a simple `sed`.

Also add a few missing includes so the code at least compiles.
2021-07-01 20:36:42 -04:00
Mike Frysinger
2fe36d31f9 cgen: split GUILE setting out
This makes it easier to override to point to an older version of guile.
The current cgen code doesn't work with guile-2, so need to point to an
older guile-1.8.
2021-07-01 18:05:40 -04:00
Mike Frysinger
79c4446067 sim: ppc: unify (most) compiler warnings with common code
Copy most of the common build warning logic over from the common
code to help keep code behavior a bit consistent, and turn them
on by default.  We disable a few flags for now until we can clean
the code up.
2021-06-30 14:41:25 -04:00