On 21/11/2023 16:06, Richard Earnshaw wrote:
I'm going to hold off for 24 hours on this to give some chance for
feedback before committing.  Is using EXTRA_PARTS in this way
acceptable?  If not, what method would you recommend?  Is there a
better way of achieving this than using --defsym (which seems to have
the side effect of causing the target function to be included in the
image even if the function isn't actually used)?

R.

Prior to Armv6 there was no architected method to synchronize data
across processors.  Armv6 saw the first introduction of
multi-processor support, using a CP15 operation; but this was
deprecated in Armv7 and is not supported on m-profile devices of any
form.  Armv7 (and armv6-m) and later support data synchronization via
the DMB instruction.

This all leads to difficulties when linking programs as the user
generally needs to know which synchronization method is needed, but
there seems no easy way around this, when there are no OS-related
primitives available.

I've addressed this by adding multiple variants of __sync_synchronize
to libgcc, one for each of the above use cases.  I've named these
__sync_synchronize_none, __sync_synchronize_cp15dmb and
__sync_synchronize_dmb.  I've also added three specs files that can be
used to direct the linker to pick the appropriate implementation.
Using specs fragments for this is preferable to directing the user to
directly use --defsym as the latter has to be placed at the correct
position on the command line to be effective and the spec rule ensures
this automatically.

I've also added a default implementation of __sync_synchronize.  The
default implementation will use DMB if that is available in the target
ISA, or fall back to a nul-implementation if it isn't.  In the latter
case it will cause the linker (GNU LD) to emit a warning that
specifies how to pick a specific implementation.  I've chosen not to
permit this default to use the CP15 solution as that has been
deprecated.

I've now pushed this.

R.


libgcc:

        * config.host (arm*-*-eabi* | arm*-*-rtems*):
        Add arm/t-sync to the makefile rules.
        * config/arm/lib1funcs.S (__sync_synchronize_none)
        (__sync_synchronize_cp15dmb, __sync_synchronize_dmb)
        (__sync_synchronize): New functions.
        * config/arm/t-sync: New file.
        * config/arm/sync-none.specs: Likewise.
        * config/arm/sync-dmb.specs: Likewise.
        * config/arm/sync-cp15dmb.specs: Likewise.
---
  libgcc/config.host                   |  2 +-
  libgcc/config/arm/lib1funcs.S        | 72 ++++++++++++++++++++++++++++
  libgcc/config/arm/sync-cp15dmb.specs |  4 ++
  libgcc/config/arm/sync-dmb.specs     |  4 ++
  libgcc/config/arm/sync-none.specs    |  4 ++
  libgcc/config/arm/t-sync             | 13 +++++
  6 files changed, 98 insertions(+), 1 deletion(-)
  create mode 100644 libgcc/config/arm/sync-cp15dmb.specs
  create mode 100644 libgcc/config/arm/sync-dmb.specs
  create mode 100644 libgcc/config/arm/sync-none.specs
  create mode 100644 libgcc/config/arm/t-sync

Reply via email to