diff mbox series

[v2,2/3] aarch64: Add support for aarch64-gnu (GNU/Hurd on AArch64)

Message ID 20240323143513.120786-2-bugaevc@gmail.com
State New
Headers show
Series [v2,1/3] Move GNU/Hurd startfile spec from config/i386/gnu.h to config/gnu.h | expand

Commit Message

Sergey Bugaev March 23, 2024, 2:35 p.m. UTC
Coupled with a corresponding binutils patch, this produces a toolchain that can
sucessfully build working binaries targeting aarch64-gnu.

gcc/Changelog:

	* config.gcc: Recognize aarch64*-*-gnu* targets.
	* config/aarch64/aarch64-gnu.h: New file.

Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
---
 gcc/config.gcc                   |  6 +++
 gcc/config/aarch64/aarch64-gnu.h | 68 ++++++++++++++++++++++++++++++++
 2 files changed, 74 insertions(+)
 create mode 100644 gcc/config/aarch64/aarch64-gnu.h

Comments

Richard Sandiford April 2, 2024, 5:26 p.m. UTC | #1
Sergey Bugaev <bugaevc@gmail.com> writes:
> Coupled with a corresponding binutils patch, this produces a toolchain that can
> sucessfully build working binaries targeting aarch64-gnu.
>
> gcc/Changelog:
>
> 	* config.gcc: Recognize aarch64*-*-gnu* targets.
> 	* config/aarch64/aarch64-gnu.h: New file.
>
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
> ---
>  gcc/config.gcc                   |  6 +++
>  gcc/config/aarch64/aarch64-gnu.h | 68 ++++++++++++++++++++++++++++++++
>  2 files changed, 74 insertions(+)
>  create mode 100644 gcc/config/aarch64/aarch64-gnu.h

I don't know if you're waiting on me, but just in case: this and patch 3
still LGTM if Thomas is OK with them.

Thanks,
Richard

> diff --git a/gcc/config.gcc b/gcc/config.gcc
> index 87a5c92b6..9d935164c 100644
> --- a/gcc/config.gcc
> +++ b/gcc/config.gcc
> @@ -1264,6 +1264,12 @@ aarch64*-*-linux*)
>  	done
>  	TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
>  	;;
> +aarch64*-*-gnu*)
> +        tm_file="${tm_file} elfos.h gnu-user.h gnu.h glibc-stdint.h"
> +        tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-gnu.h"
> +        tmake_file="${tmake_file} aarch64/t-aarch64"
> +        tm_defines="${tm_defines}  TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
> +	;;
>  aarch64*-wrs-vxworks*)
>          tm_file="${tm_file} elfos.h aarch64/aarch64-elf.h"
>          tm_file="${tm_file} vx-common.h vxworks.h aarch64/aarch64-vxworks.h"
> diff --git a/gcc/config/aarch64/aarch64-gnu.h b/gcc/config/aarch64/aarch64-gnu.h
> new file mode 100644
> index 000000000..ee5494034
> --- /dev/null
> +++ b/gcc/config/aarch64/aarch64-gnu.h
> @@ -0,0 +1,68 @@
> +/* Definitions for AArch64 running GNU/Hurd.
> +   Copyright (C) 2009-2024 Free Software Foundation, Inc.
> +
> +   This file is part of GCC.
> +
> +   GCC is free software; you can redistribute it and/or modify it
> +   under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3, or (at your option)
> +   any later version.
> +
> +   GCC is distributed in the hope that it will be useful, but
> +   WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with GCC; see the file COPYING3.  If not see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#ifndef GCC_AARCH64_GNU_H
> +#define GCC_AARCH64_GNU_H
> +
> +#define GNU_USER_DYNAMIC_LINKER "/lib/ld-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
> +
> +#define CPP_SPEC "%{pthread:-D_REENTRANT}"
> +
> +#define GNU_TARGET_LINK_SPEC  "%{h*}		\
> +   %{static:-Bstatic}				\
> +   %{shared:-shared}				\
> +   %{symbolic:-Bsymbolic}			\
> +   %{!static:%{!static-pie:			\
> +     %{rdynamic:-export-dynamic}		\
> +     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}} \
> +   %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \
> +   -X						\
> +   %{mbig-endian:-EB} %{mlittle-endian:-EL}     \
> +   -maarch64gnu%{mabi=ilp32:32}%{mbig-endian:b}"
> +
> +
> +#define LINK_SPEC GNU_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC
> +
> +#define GNU_USER_TARGET_MATHFILE_SPEC \
> +  "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}}"
> +
> +#undef ENDFILE_SPEC
> +#define ENDFILE_SPEC   \
> +  GNU_USER_TARGET_MATHFILE_SPEC " " \
> +  GNU_USER_TARGET_ENDFILE_SPEC
> +
> +#define TARGET_OS_CPP_BUILTINS()		\
> +  do						\
> +    {						\
> +	GNU_USER_TARGET_OS_CPP_BUILTINS();	\
> +    }						\
> +  while (0)
> +
> +#define TARGET_ASM_FILE_END aarch64_file_end_indicate_exec_stack
> +
> +/* Uninitialized common symbols in non-PIE executables, even with
> +   strong definitions in dependent shared libraries, will resolve
> +   to COPY relocated symbol in the executable.  See PR65780.  */
> +#undef TARGET_BINDS_LOCAL_P
> +#define TARGET_BINDS_LOCAL_P default_binds_local_p_2
> +
> +/* Define this to be nonzero if static stack checking is supported.  */
> +#define STACK_CHECK_STATIC_BUILTIN 1
> +
> +#endif  /* GCC_AARCH64_GNU_H */
Sergey Bugaev April 5, 2024, 12:13 p.m. UTC | #2
Hello,

On Tue, Apr 2, 2024 at 8:26 PM Richard Sandiford
<richard.sandiford@arm.com> wrote:
> I don't know if you're waiting on me, but just in case: this and patch 3
> still LGTM if Thomas is OK with them.

Thanks. Thomas asked me to resubmit with Changelog entries added (but
hasn't pointed out anything else), so this is waiting for him to
confirm that this looks OK now.

Sergey
Thomas Schwinge April 9, 2024, 7:27 a.m. UTC | #3
Hi!

On 2024-04-05T15:13:33+0300, Sergey Bugaev <bugaevc@gmail.com> wrote:
> On Tue, Apr 2, 2024 at 8:26 PM Richard Sandiford
> <richard.sandiford@arm.com> wrote:
>> I don't know if you're waiting on me, but just in case: this and patch 3
>> still LGTM if Thomas is OK with them.
>
> Thanks. Thomas asked me to resubmit with Changelog entries added (but
> hasn't pointed out anything else), so this is waiting for him to
> confirm that this looks OK now.

Thanks, pushed to trunk branch:

  - commit 532c57f8c3a15b109a46d3e2b14d60a5c40979d5 "Move GNU/Hurd startfile spec from config/i386/gnu.h to config/gnu.h"
  - commit 9670a2326333caa8482377c00beb65723b7b4b26 "aarch64: Add support for aarch64-gnu (GNU/Hurd on AArch64)"
  - commit 46c91665f4bceba19aed56f5bd6e934c548b84ff "libgcc: Add basic support for aarch64-gnu (GNU/Hurd on AArch64)"


Grüße
 Thomas
Sergey Bugaev April 9, 2024, 8:04 a.m. UTC | #4
On Tue, Apr 9, 2024 at 10:27 AM Thomas Schwinge <tschwinge@baylibre.com> wrote:
> Thanks, pushed to trunk branch:
>
>   - commit 532c57f8c3a15b109a46d3e2b14d60a5c40979d5 "Move GNU/Hurd startfile spec from config/i386/gnu.h to config/gnu.h"
>   - commit 9670a2326333caa8482377c00beb65723b7b4b26 "aarch64: Add support for aarch64-gnu (GNU/Hurd on AArch64)"
>   - commit 46c91665f4bceba19aed56f5bd6e934c548b84ff "libgcc: Add basic support for aarch64-gnu (GNU/Hurd on AArch64)"

\o/ Thanks a lot!

This will unblock merging the aarch64-gnu glibc port upstream.

I assume the buildbot failure that I just got an email about is
unrelated; it's failing on some RISC-V thing.

Sergey

P.S. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114629
Palmer Dabbelt April 9, 2024, 4:24 p.m. UTC | #5
On Tue, 09 Apr 2024 01:04:34 PDT (-0700), bugaevc@gmail.com wrote:
> On Tue, Apr 9, 2024 at 10:27 AM Thomas Schwinge <tschwinge@baylibre.com> wrote:
>> Thanks, pushed to trunk branch:
>>
>>   - commit 532c57f8c3a15b109a46d3e2b14d60a5c40979d5 "Move GNU/Hurd startfile spec from config/i386/gnu.h to config/gnu.h"
>>   - commit 9670a2326333caa8482377c00beb65723b7b4b26 "aarch64: Add support for aarch64-gnu (GNU/Hurd on AArch64)"
>>   - commit 46c91665f4bceba19aed56f5bd6e934c548b84ff "libgcc: Add basic support for aarch64-gnu (GNU/Hurd on AArch64)"
>
> \o/ Thanks a lot!
>
> This will unblock merging the aarch64-gnu glibc port upstream.
>
> I assume the buildbot failure that I just got an email about is
> unrelated; it's failing on some RISC-V thing.

Sorry if I missed something here, do you have a pointer?

>
> Sergey
>
> P.S. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114629
Sergey Bugaev April 9, 2024, 4:57 p.m. UTC | #6
On Tue, Apr 9, 2024 at 7:24 PM Palmer Dabbelt <palmer@dabbelt.com> wrote:
> > I assume the buildbot failure that I just got an email about is
> > unrelated; it's failing on some RISC-V thing.
>
> Sorry if I missed something here, do you have a pointer?

The buildbot failure emails reference [0] and [1].

[0]: https://builder.sourceware.org/buildbot/#/builders/269/builds/4216
[1]: https://builder.sourceware.org/buildbot/#/builders/269/builds/4218

 Specifically, the "git diff_1" step seems to be failing with

    diff --git a/gcc/config/riscv/riscv.opt.urls
b/gcc/config/riscv/riscv.opt.urls
    index da31820e234..351f7f0dda2 100644
    --- a/gcc/config/riscv/riscv.opt.urls
    +++ b/gcc/config/riscv/riscv.opt.urls
    @@ -89,3 +89,5 @@ UrlSuffix(gcc/RISC-V-Options.html#index-minline-strncmp)
     minline-strlen
     UrlSuffix(gcc/RISC-V-Options.html#index-minline-strlen)

    +; skipping UrlSuffix for 'mtls-dialect=' due to finding no URLs
    +

I don't know what to make of that, but it seems unrelated to my
aarch64-gnu changes.

Sergey
Palmer Dabbelt April 10, 2024, 12:04 a.m. UTC | #7
On Tue, 09 Apr 2024 09:57:11 PDT (-0700), bugaevc@gmail.com wrote:
> On Tue, Apr 9, 2024 at 7:24 PM Palmer Dabbelt <palmer@dabbelt.com> wrote:
>> > I assume the buildbot failure that I just got an email about is
>> > unrelated; it's failing on some RISC-V thing.
>>
>> Sorry if I missed something here, do you have a pointer?
>
> The buildbot failure emails reference [0] and [1].
>
> [0]: https://builder.sourceware.org/buildbot/#/builders/269/builds/4216
> [1]: https://builder.sourceware.org/buildbot/#/builders/269/builds/4218
>
>  Specifically, the "git diff_1" step seems to be failing with
>
>     diff --git a/gcc/config/riscv/riscv.opt.urls
> b/gcc/config/riscv/riscv.opt.urls
>     index da31820e234..351f7f0dda2 100644
>     --- a/gcc/config/riscv/riscv.opt.urls
>     +++ b/gcc/config/riscv/riscv.opt.urls
>     @@ -89,3 +89,5 @@ UrlSuffix(gcc/RISC-V-Options.html#index-minline-strncmp)
>      minline-strlen
>      UrlSuffix(gcc/RISC-V-Options.html#index-minline-strlen)
>
>     +; skipping UrlSuffix for 'mtls-dialect=' due to finding no URLs
>     +
>
> I don't know what to make of that, but it seems unrelated to my
> aarch64-gnu changes.

I'd never heard of it either, looks like a new thing we're supposed to 
do when toching the options.  I just sent 
<https://inbox.sourceware.org/gcc-patches/20240410000338.3926-1-palmer@rivosinc.com/>, 
I'm sure there's a better way to do it...

>
> Sergey
Thomas Schwinge April 10, 2024, 7:12 a.m. UTC | #8
Hi!

On 2024-04-09T09:24:29-0700, Palmer Dabbelt <palmer@dabbelt.com> wrote:
> On Tue, 09 Apr 2024 01:04:34 PDT (-0700), bugaevc@gmail.com wrote:
>> On Tue, Apr 9, 2024 at 10:27 AM Thomas Schwinge <tschwinge@baylibre.com> wrote:
>>> Thanks, pushed to trunk branch:
>>>
>>>   - commit 532c57f8c3a15b109a46d3e2b14d60a5c40979d5 "Move GNU/Hurd startfile spec from config/i386/gnu.h to config/gnu.h"
>>>   - commit 9670a2326333caa8482377c00beb65723b7b4b26 "aarch64: Add support for aarch64-gnu (GNU/Hurd on AArch64)"
>>>   - commit 46c91665f4bceba19aed56f5bd6e934c548b84ff "libgcc: Add basic support for aarch64-gnu (GNU/Hurd on AArch64)"
>>
>> \o/ Thanks a lot!
>>
>> This will unblock merging the aarch64-gnu glibc port upstream.

\o/


>> I assume the buildbot failure that I just got an email about is
>> unrelated; it's failing on some RISC-V thing.
>
> Sorry if I missed something here, do you have a pointer?

<https://inbox.sourceware.org/20240409074850.ED7BD385841C@sourceware.org>
and several more such messages, requesting:

    --- a/gcc/config/riscv/riscv.opt.urls
    +++ b/gcc/config/riscv/riscv.opt.urls
    @@ -89,3 +89,5 @@ UrlSuffix(gcc/RISC-V-Options.html#index-minline-strncmp)
     minline-strlen
     UrlSuffix(gcc/RISC-V-Options.html#index-minline-strlen)
     
    +; skipping UrlSuffix for 'mtls-dialect=' due to finding no URLs
    +

To be fixed by
<https://inbox.sourceware.org/20240409145724.9640-1-ishitatsuyuki@gmail.com>
"Regenerate opt.urls".


Grüße
 Thomas
diff mbox series

Patch

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 87a5c92b6..9d935164c 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1264,6 +1264,12 @@  aarch64*-*-linux*)
 	done
 	TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
 	;;
+aarch64*-*-gnu*)
+        tm_file="${tm_file} elfos.h gnu-user.h gnu.h glibc-stdint.h"
+        tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-gnu.h"
+        tmake_file="${tmake_file} aarch64/t-aarch64"
+        tm_defines="${tm_defines}  TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
+	;;
 aarch64*-wrs-vxworks*)
         tm_file="${tm_file} elfos.h aarch64/aarch64-elf.h"
         tm_file="${tm_file} vx-common.h vxworks.h aarch64/aarch64-vxworks.h"
diff --git a/gcc/config/aarch64/aarch64-gnu.h b/gcc/config/aarch64/aarch64-gnu.h
new file mode 100644
index 000000000..ee5494034
--- /dev/null
+++ b/gcc/config/aarch64/aarch64-gnu.h
@@ -0,0 +1,68 @@ 
+/* Definitions for AArch64 running GNU/Hurd.
+   Copyright (C) 2009-2024 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef GCC_AARCH64_GNU_H
+#define GCC_AARCH64_GNU_H
+
+#define GNU_USER_DYNAMIC_LINKER "/lib/ld-aarch64%{mbig-endian:_be}%{mabi=ilp32:_ilp32}.so.1"
+
+#define CPP_SPEC "%{pthread:-D_REENTRANT}"
+
+#define GNU_TARGET_LINK_SPEC  "%{h*}		\
+   %{static:-Bstatic}				\
+   %{shared:-shared}				\
+   %{symbolic:-Bsymbolic}			\
+   %{!static:%{!static-pie:			\
+     %{rdynamic:-export-dynamic}		\
+     %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}} \
+   %{static-pie:-Bstatic -pie --no-dynamic-linker -z text} \
+   -X						\
+   %{mbig-endian:-EB} %{mlittle-endian:-EL}     \
+   -maarch64gnu%{mabi=ilp32:32}%{mbig-endian:b}"
+
+
+#define LINK_SPEC GNU_TARGET_LINK_SPEC AARCH64_ERRATA_LINK_SPEC
+
+#define GNU_USER_TARGET_MATHFILE_SPEC \
+  "%{Ofast|ffast-math|funsafe-math-optimizations:%{!shared:crtfastmath.o%s}}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC   \
+  GNU_USER_TARGET_MATHFILE_SPEC " " \
+  GNU_USER_TARGET_ENDFILE_SPEC
+
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+	GNU_USER_TARGET_OS_CPP_BUILTINS();	\
+    }						\
+  while (0)
+
+#define TARGET_ASM_FILE_END aarch64_file_end_indicate_exec_stack
+
+/* Uninitialized common symbols in non-PIE executables, even with
+   strong definitions in dependent shared libraries, will resolve
+   to COPY relocated symbol in the executable.  See PR65780.  */
+#undef TARGET_BINDS_LOCAL_P
+#define TARGET_BINDS_LOCAL_P default_binds_local_p_2
+
+/* Define this to be nonzero if static stack checking is supported.  */
+#define STACK_CHECK_STATIC_BUILTIN 1
+
+#endif  /* GCC_AARCH64_GNU_H */