Commit Graph

4260 Commits

Author SHA1 Message Date
Mike Frysinger
1bf5c34239 sim: unify cgen maintainer settings
Move these options up to the common dir so we only test & export
them once across all ports.  It makes it available to targets that
aren't cgen-based, but those will just ignore the settings, so it
shouldn't be an issue.
2021-06-20 00:25:13 -04:00
Mike Frysinger
4ca8baee00 sim: m68hc11: fix unused function warnings with -O0
Mark these functions as unused in case they don't get inlined when
building with -O0.
2021-06-20 00:17:08 -04:00
Mike Frysinger
d73f39ee43 sim: move sim-inline to the common code
This will allow us to build the common code with the same inline
settings as the arch subdirs, and only do the test once.
2021-06-20 00:12:11 -04:00
Simon Marchi
57a922a598 sim: move UNUSED before TYPE in SIM_ENDIAN_INLINE's definition
I get this when building with gcc 11:

      CC       common/common_libcommon_a-sim-load.o
    In file included from /home/simark/src/binutils-gdb/sim/common/sim-n-bits.h:27,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.c:259,
                     from /home/simark/src/binutils-gdb/sim/common/sim-bits.h:599,
                     from /home/simark/src/binutils-gdb/sim/common/sim-basics.h:122,
                     from /home/simark/src/binutils-gdb/sim/common/sim-load.c:30:
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:27: error: 'offset_16' defined but not used [-Werror=unused-function]
       39 | #define offset_N XCONCAT2(offset_,N)
          |                           ^~~~~~~
    /home/simark/src/binutils-gdb/sim/../include/symcat.h:23:26: note: in definition of macro 'CONCAT2'
       23 | #define CONCAT2(a,b)     a##b
          |                          ^
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:39:18: note: in expansion of macro 'XCONCAT2'
       39 | #define offset_N XCONCAT2(offset_,N)
          |                  ^~~~~~~~
    /home/simark/src/binutils-gdb/sim/common/sim-n-endian.h:138:1: note: in expansion of macro 'offset_N'
      138 | offset_N (unsigned_N *x,
          | ^~~~~~~~

offset_N uses INLINE_SIM_ENDIAN, which uses UNUSED to put the "unused"
attribute.  However, it appears after the function's return type, which
seems to make it not apply to the function.  Moving it to before the
return type fixes the error.

Change all instances found in that file.

sim/common/ChangeLog:

	* sim-inline.h: Move UNUSED before TYPE.

Change-Id: Ide20106683ed7a9ebf35d484dabf70b309cb1ba6
2021-06-19 22:49:52 -04:00
Mike Frysinger
a979f2a07a sim: unify dtc tool checks
Only one arch uses this currently, but others could too.  By moving
it up to the common checks, it'll also let us simplify the moxie code
significantly.
2021-06-19 22:43:56 -04:00
Mike Frysinger
54c47dfb68 sim: ppc: rename inline defines to match common code
Use the same basic names as the common sim inline logic so we can
merge the two.  We don't do that here, just prepare for it.

The common code seems to be based on the ppc version but with slightly
different names as it was cleaned up & generalized.  I *think* these
concepts are the same, so binding them together is OK, but maybe I'm
misreading them.  If so, can always tweak them later.
	REVEAL_MODULE  ->  H_REVEALS_MODULE
	INLINE_MODULE  ->  C_REVEALS_MODULE
2021-06-19 22:41:05 -04:00
Mike Frysinger
36842f65be sim: drop old BUILT_SRC_FROM_COMMON ref
The code that set & used this variable was deleted long ago,
but the clean target was missed.  Clean that up now.
2021-06-19 22:24:03 -04:00
Mike Frysinger
ce3ec98acd sim: unify gettext/intl probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 16:18:07 -04:00
Mike Frysinger
bc56166f66 sim: unify toolchain dependency logic
The common dir is already probing this info since it's using automake,
so pass it down to the subdirs so they don't have to probe it at all.
2021-06-19 16:07:31 -04:00
Mike Frysinger
d3562f83a7 sim: unify toolchain probing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 16:01:37 -04:00
Mike Frysinger
b5689863bd sim: unify bfd library dependency testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 01:08:39 -04:00
Mike Frysinger
17a5da800d sim: mips: drop unused AC_PATH_X call
We don't use anything from X, so no sense in probing the env.
2021-06-19 01:03:20 -04:00
Mike Frysinger
07490bf81d sim: unify various library testing logic
Move these options up to the common dir so we only test & export
them once across all ports.
2021-06-19 01:01:21 -04:00
Mike Frysinger
47ce766a8b sim: unify -Werror build settings
Move these options up to the common dir so we only test & export
them once across all ports.  It also enables -Werror usage on the
common files we've been pulling out of arch subdirs.
2021-06-18 10:25:04 -04:00
Mike Frysinger
982c3a65ca sim: move -Werror disabling to Makefile
For the ports that still don't build with -Werror, rather than disable
the flag at configure time, do it at make time.  This will allow us to
unify these tests in the common sim configure script.
2021-06-18 10:15:15 -04:00
Mike Frysinger
3f8414df7a sim: create a makefile fragment to pass common settings down
As we merge settings from subdirs into the common configure, we
sometimes need to keep the settings working in both dirs.  Create
a makefile fragment to pass them down so we don't have to run the
checks twice.  For now, the file is empty, but we'll start moving
logic in shortly.
2021-06-18 10:11:58 -04:00
Mike Frysinger
1fef66b0dc sim: split sim-signal.h include out
The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.
2021-06-18 00:50:14 -04:00
Mike Frysinger
7039b29160 sim: drop core libiberty.h include
This doesn't need to be included for every sim file, so drop it.
Every C file that needs it seems to already include it.
2021-06-18 00:39:32 -04:00
Mike Frysinger
f9a4d54332 sim: overhaul & unify endian settings management
The m4 macro has 2 args: the "wire" settings (which represents the
hardwired port behavior), and the default settings (which are used
if nothing else is specified).  If none are specified, the arch is
expected to support both, and the value will be probed based on the
user runtime options or the input program.

Only two arches today set the default value (bpf & mips).  We can
probably let this go as it only shows up in one scenario: the sim
is invoked, but with no inputs, and no user endian selection.  This
means bpf will not behave like the other arches: an error is shown
and forces the user to make a choice.  If an input program is used
though, we'll still switch the default to that.  This allows us to
remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting.

For the ports that set a "wire" endian, move it to the runtime init
of the respective sim_open calls.  This allows us to change the
WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting
if they want to force a specific endianness.

With all the endian logic moved to runtime selection, we can move
the configure call up to the common dir so we only process it once
across all ports.

The ppc arch was picking the wire endian based on the target used,
but since we weren't doing that for other biendian arches, we can
let this go too.  We'll rely on the input selecting the endian, or
make the user decide.
2021-06-17 23:20:13 -04:00
Mike Frysinger
a49dd19e81 sim: ppc: avoid "PAGE_SIZE" name
This define is used for a particular target and depends on the
simulated CPU hardware.  It has no relation to the host CPU that
the sim is running on.  So rename the common "PAGE_SIZE" here to
better reflect its usage and avoid conflicts with system headers.
2021-06-17 19:05:59 -04:00
Mike Frysinger
209f108f73 sim: mn10300: tweak static inlines
Use INLINE2 instead of INLINE to fix builds when -O0 are used -- the
latter define is omitted at -O0 levels while the former is always
set to inline.  These helper funcs are used by defines in here but
the defines aren't always called.
2021-06-17 00:14:02 -04:00
Mike Frysinger
ef5058ae87 sim: split sim/callback.h include out
The sim-basics.h is too big and includes too many things.  This leads
to some arch's sim-main.h having circular loop issues with defs, and
makes it hard to separate out common objects from arch-specific defs.
By splitting up sim-basics.h and killing off sim-main.h, it'll make
it easier to separate out the two.

Start with splitting out sim/callback.h.
2021-06-17 00:11:48 -04:00
Simon Marchi
7daf500de2 sim: make some rules silent by default in Make-common.in
Use GDB's silent-rules.mk to make some rules silent by default.  These
rules cover most of what is built in sim/.

gdb/ChangeLog:

	* silent-rules.mk (ECHO_CCLD, ECHO_AR, ECHO_RANLIB): New.

sim/ChangeLog:

	* common/Make-common.in (COMPILE, libsim.a, run$(EXEEXT),
	gentmap.o, gentmap): Make rules silent.

Change-Id: Idf9ba5beaee10c7c614859ace5fbdcd1de0287db
2021-06-16 11:56:28 -04:00
Mike Frysinger
b80d447580 sim: mips: add printf attribute to trace func
This helps catch format errors in code, although they're all clean
at this point already.
2021-06-16 01:56:22 -04:00
Mike Frysinger
6828a30253 sim: mips: rework dynamic printf logic to avoid compiler warnings
The compiler doesn't like passing non-constant strings to printf
functions, so tweak the code to always pass one in.  This code is
a little more verbose, but it's probably the same performance.

The macro usage is a bit ugly, but maybe less than copying &
pasting the extended conditional format logic.
2021-06-16 01:55:31 -04:00
Mike Frysinger
df32b446c3 sim: mips: tweak buffer sign
This model uses unsigned char buffers, but this temporary pointer is
declared as signed.  Switch it to unsigned since it's just a temporary
variable to hold the new pointer.
2021-06-16 01:53:09 -04:00
Mike Frysinger
7b2298cbd8 sim: mips: fix uninitialized register use
In the default case, this code will read from this variable before
it is initialized as a dummy access.  Set it to 0 to fix the compiler
warning.
2021-06-16 01:51:32 -04:00
Mike Frysinger
a8a3d90792 sim: drop obsolete AC_EXEEXT call
The current autoconf 2.69 defines this to nothing because the logic
in AC_PROG_CC takes care of it all the time now.  Delete the call.
2021-06-16 01:29:41 -04:00
Mike Frysinger
46f0c0c6cc sim: ppc: use common sim-assert setting
The common sim code already sets this up for us, so no need to
duplicate the logic.
2021-06-16 01:24:20 -04:00
Mike Frysinger
956f0babcd sim: ppc: convert to bfd_endian
Rather than re-invent endian defines, as well as maintain our own list
of OS & arch-specific includes, punt all that logic in favor of the bfd
ones already set up and maintained elsewhere.  We already rely on the
bfd library, so leveraging the endian aspect should be fine.

This was done for all the other ports years ago, so catch ppc up.
2021-06-16 01:22:50 -04:00
Mike Frysinger
1b828ebe53 sim: ppc: replace local __attribute__ fallback
The common ansidecl.h provides fallbacks for these so we don't need to.
2021-06-16 01:14:53 -04:00
Mike Frysinger
69ff2dac7a sim: ppc: use common ATTRIBUTE_PRINTF macros
Use the common ansidecl.h macros to replace our ad-hoc printf attributes.
2021-06-16 01:14:05 -04:00
Mike Frysinger
3547f99a30 sim: ppc: use common ATTRIBUTE_PACKED macro
Drop local packed attribute with the common ansidecl.h define.
2021-06-16 01:11:08 -04:00
Mike Frysinger
6e57d02532 sim: ppc: replace local NORETURN macros with common one
Drop local NORETURN macro with the common ansidecl.h ATTRIBUTE_NORETURN define.
2021-06-16 01:10:11 -04:00
Mike Frysinger
f6428ce423 sim: ppc: replace local UNUSED macros with common one
Drop local UNUSED macro with the common ansidecl.h ATTRIBUTE_UNUSED define.
2021-06-16 01:08:43 -04:00
Mike Frysinger
b778e6b079 sim: ppc: replace local CONCAT macros with common ones
Drop local copies of CONCAT macros that the common ansidecl.h provides.
2021-06-16 01:06:28 -04:00
Mike Frysinger
5976569641 sim: ppc: change bool variable name to boolean
This is a reserved type with stdbool.h.
2021-06-16 01:05:10 -04:00
Mike Frysinger
430456e347 sim: ppc: drop host endian configure option
The --enable-sim-hostendian flag was purely so people had an escape route
for when cross-compiling.  This is because historically, AC_C_BIGENDIAN
did not work in those cases.  That was fixed a while ago though, so we can
require that macro everywhere now and simplify a good bit of code.

This was done for all the other ports years ago, so catch ppc up.
2021-06-16 01:03:54 -04:00
Mike Frysinger
dae666c968 sim: mips: fix format warnings when setting up memory
The majority of these inputs are not long's, so don't use %lx.
This fixes compiler warnings about type mismatches.
2021-06-16 00:50:56 -04:00
Mike Frysinger
52d37d2c91 sim: drop arch-specific config.h
All of the settings in here are handled by the common top-level
config.h, so drop the individual arch-config.h files entirely.

This will also help guarantee that we don't add any new arch
specific defines that would affect common code which will help
with the effort of unifying them.
2021-06-16 00:22:53 -04:00
Mike Frysinger
bcaa61f7c8 sim: move dv-sockser define to CPPFLAGS
This is the only define left in m4/ that is not in the common config.h,
so move it to sim_hw_cflags so we can drop the arch-specific config.h.
2021-06-15 23:27:14 -04:00
Mike Frysinger
015f7b7462 sim: switch modules.c & version.c to stamp files
This fixes remaking of these files and avoids unnecessary rebuilds.

Also add both to `make clean` to match other stamp files.
2021-06-15 17:06:46 -04:00
Mike Frysinger
79afa8caab sim: mn10300: enable -Werror
Now that all warnings are fixed in this port, enable -Werror by default.
2021-06-14 23:47:01 -04:00
Mike Frysinger
aa077c0d18 sim: mn10300: switch abort to sim_engine_abort
This allows the caller to catch engine aborts if they want, and fixes
the warning about missing stdlib.h include by not using abort().
2021-06-14 23:46:41 -04:00
Mike Frysinger
757b3c2fea sim: erc32: fix build w/out F_{G,S}ETFL
Add conditional logic around fcntl.h F_{G,S}ETFL usage to fix builds
on systems that don't have it (e.g. Windows).  The code is only used
to save & restore limited terminal stdin state.
2021-06-14 23:30:17 -04:00
Mike Frysinger
4df5cdbd3a sim: erc32: fix build w/out termios.h
Add conditional logic around termios.h usage to fix builds on systems
that don't have it (e.g. Windows).
2021-06-14 23:29:11 -04:00
Mike Frysinger
82e6d6bf90 sim: drop redundant SIM_AC_OPTION_WARNINGS
The common code already calls this, so no need to do so in arch dirs.
We leave the calls that disable -Werror.  This will help unify the
configure scripts.
2021-06-14 23:19:52 -04:00
Mike Frysinger
fbe8d1cf5b sim: enable silent rules in common builds
We only do the common code as automake simplifies the logic.
2021-06-14 20:04:44 -04:00
Mike Frysinger
483ab96a1b gnulib: define the path to gnulib's parent dir
The current setting assumes that gnulib is only used by dirs
immediately under the source root.  Trying to build it two or
more levels deep fails.  Switch GNULIB_BUILDDIR to a relative
GNULIB_PARENT_DIR so that it can be used to construct both the
build & source paths.
2021-06-14 18:01:20 -04:00
Mike Frysinger
92a3f61363 sim: ppc: use common version.o too
The common version.o we're building can be used for the ppc subdir,
so switch it over too.
2021-06-13 23:04:22 -04:00