diff mbox series

Darwin, Arm64 : Ada fixes for hosted tools.

Message ID 20211105161338.33814-1-iain@sandoe.co.uk
State New
Headers show
Series Darwin, Arm64 : Ada fixes for hosted tools. | expand

Commit Message

Iain Sandoe Nov. 5, 2021, 4:13 p.m. UTC
This is host-only support (target support will come later).

This will allow someone (with an existing Ada compiler on the
platform - which can be provided by the experimental aarch64-darwin
branch) - to build the host tools (gnatmake and friends) for a
non-native cross.

The existing provisions for iOS are OK for cross-compilation from
an x86-64-darwin platform, but we need some adjustments so that these
host tools can be built to run on aarch64-darwin.

tested on aarch64-darwin20.
OK for master?
thanks
Iain

---
 gcc/ada/gcc-interface/Make-lang.in | 18 +++++++++++++-----
 gcc/ada/sigtramp-ios.c             |  8 ++++++++
 2 files changed, 21 insertions(+), 5 deletions(-)

Comments

Arnaud Charlet Nov. 5, 2021, 4:36 p.m. UTC | #1
> This is host-only support (target support will come later).
> 
> This will allow someone (with an existing Ada compiler on the
> platform - which can be provided by the experimental aarch64-darwin
> branch) - to build the host tools (gnatmake and friends) for a
> non-native cross.
> 
> The existing provisions for iOS are OK for cross-compilation from
> an x86-64-darwin platform, but we need some adjustments so that these
> host tools can be built to run on aarch64-darwin.
> 
> tested on aarch64-darwin20.
> OK for master?

Did you forget to attach the commit log (git show is your friend)?

The patch itself looks OK on principle, pending the associated log! ;-)

Arno
Iain Sandoe Nov. 5, 2021, 4:45 p.m. UTC | #2
Hi Arno,

> On 5 Nov 2021, at 16:36, Arnaud Charlet <charlet@adacore.com> wrote:
> 
>> This is host-only support (target support will come later).
>> 
>> This will allow someone (with an existing Ada compiler on the
>> platform - which can be provided by the experimental aarch64-darwin
>> branch) - to build the host tools (gnatmake and friends) for a
>> non-native cross.
>> 
>> The existing provisions for iOS are OK for cross-compilation from
>> an x86-64-darwin platform, but we need some adjustments so that these
>> host tools can be built to run on aarch64-darwin.
>> 
>> tested on aarch64-darwin20.
>> OK for master?
> 
> Did you forget to attach the commit log (git show is your friend)?

No, I just managed to delete it when adding the post-notes to the email
header ;-) … and then didn’t notice when git send-emailing it …
Iain

—— this is the missing part.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>

gcc/ada/ChangeLog:

	* gcc-interface/Make-lang.in: Use ios signal trampoline code
	for hosted Ada tools.
	* sigtramp-ios.c: Wrap the declarations in extern "C" when the
	code is built by a C++ compiler.


> 
> The patch itself looks OK on principle, pending the associated log! ;-)
> 
> Arno
Arnaud Charlet Nov. 5, 2021, 4:49 p.m. UTC | #3
> No, I just managed to delete it when adding the post-notes to the email
> header ;-) … and then didn’t notice when git send-emailing it …

OK!

> Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
> 
> gcc/ada/ChangeLog:

should be gcc/ada/

> 	* gcc-interface/Make-lang.in: Use ios signal trampoline code
> 	for hosted Ada tools.
> 	* sigtramp-ios.c: Wrap the declarations in extern "C" when the
> 	code is built by a C++ compiler.

I confirm that the patch is OK, thanks!
diff mbox series

Patch

diff --git a/gcc/ada/gcc-interface/Make-lang.in b/gcc/ada/gcc-interface/Make-lang.in
index ba194d1369d..b2feaa7d808 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -725,6 +725,14 @@  endif
 # For unwind-pe.h
 CFLAGS-ada/raise-gcc.o += -I$(srcdir)/../libgcc -DEH_MECHANISM_$(EH_MECHANISM)
 
+# Under aarch64 darwin, we need to include the rtl signal trampoline.
+
+ifeq ($(strip $(filter-out aarch64 arm64 darwin%,$(host_cpu) $(host_os))),)
+  EXTRA_HOST_OBJS=ada/sigtramp-ios.o
+else
+  EXTRA_HOST_OBJS =
+endif
+
 ada/libgnat/s-excmac.o: ada/libgnat/s-excmac.ads ada/libgnat/s-excmac.adb
 
 ada/libgnat/s-excmac.ads: $(srcdir)/ada/libgnat/s-excmac__$(EH_MECHANISM).ads
@@ -738,16 +746,16 @@  ada/libgnat/s-excmac.adb: $(srcdir)/ada/libgnat/s-excmac__$(EH_MECHANISM).adb
 # Needs to be built with CC=gcc
 # Since the RTL should be built with the latest compiler, remove the
 #  stamp target in the parent directory whenever gnat1 is rebuilt
-gnat1$(exeext): $(TARGET_ADA_SRCS) $(GNAT1_OBJS) $(ADA_BACKEND) libcommon-target.a \
-		$(LIBDEPS) $(ada.prev)
+gnat1$(exeext): $(TARGET_ADA_SRCS) $(GNAT1_OBJS) $(ADA_BACKEND) $(EXTRA_HOST_OBJS) libcommon-target.a \
+		$(EXTRA_HOST_OBJS) $(LIBDEPS) $(ada.prev)
 	@$(call LINK_PROGRESS,$(INDEX.ada),start)
-	+$(GCC_LLINK) -o $@ $(GNAT1_OBJS) $(ADA_BACKEND) $(CFLAGS) \
+	+$(GCC_LLINK) -o $@ $(GNAT1_OBJS) $(ADA_BACKEND) $(EXTRA_HOST_OBJS) $(CFLAGS) \
 	  libcommon-target.a $(LIBS) $(SYSLIBS) $(BACKENDLIBS) $(GNATLIB)
 	$(RM) stamp-gnatlib2-rts stamp-tools
 	@$(call LINK_PROGRESS,$(INDEX.ada),end)
 
-gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) ggc-none.o libcommon-target.a $(LIBDEPS)
-	+$(GCC_LINK) -o $@ $(CFLAGS) ada/b_gnatb.o $(GNATBIND_OBJS) ggc-none.o libcommon-target.a $(LIBS) $(SYSLIBS) $(GNATLIB)
+gnatbind$(exeext): ada/b_gnatb.o $(CONFIG_H) $(GNATBIND_OBJS) $(EXTRA_HOST_OBJS) ggc-none.o libcommon-target.a $(LIBDEPS)
+	+$(GCC_LINK) -o $@ $(CFLAGS) ada/b_gnatb.o $(GNATBIND_OBJS) $(EXTRA_HOST_OBJS) ggc-none.o libcommon-target.a $(LIBS) $(SYSLIBS) $(GNATLIB)
 
 # use target-gcc target-gnatmake target-gnatbind target-gnatlink
 gnattools: $(GCC_PARTS) $(CONFIG_H) prefix.o force
diff --git a/gcc/ada/sigtramp-ios.c b/gcc/ada/sigtramp-ios.c
index 6e2913d91f2..8403a1865ea 100644
--- a/gcc/ada/sigtramp-ios.c
+++ b/gcc/ada/sigtramp-ios.c
@@ -71,6 +71,10 @@ 
 
 /* sigtramp stub providing unwind info for common registers.  */
 
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
 extern void __gnat_sigtramp_common
   (int signo, void *siginfo, void *sigcontext,
    __sigtramphandler_t * handler);
@@ -87,6 +91,10 @@  void __gnat_sigtramp (int signo, void *si, void *ucontext,
   __gnat_sigtramp_common (signo, si, mcontext, handler);
 }
 
+#if defined(__cplusplus)
+}
+#endif
+
 /* asm string construction helpers.  */
 
 #define STR(TEXT) #TEXT