On Sun, Jun 21, 2026 at 3:51 AM Iain Sandoe <[email protected]> wrote:
>
> This does not yet change any tests - but is expected to simplify cases
> where scan-assembler is used that needs to be file syntax aware.
>
> Tested with "make pdf" for the documentation, OK for trunk?

Ok.

> thanks
> Iain
>
> --- 8< ---
>
> There are already target supports tests for ELF and PE/COFF, this adds
> one for Mach-O and documents all three in sourcebuild.
>
> gcc/ChangeLog:
>
>         * doc/sourcebuild.texi: Document object file checks.
>
> gcc/testsuite/ChangeLog:
>
>         * lib/target-supports.exp: Add a check for Mach-O object file
>         format.
>
> Signed-off-by: Iain Sandoe <[email protected]>
> ---
>  gcc/doc/sourcebuild.texi              | 23 +++++++++++++++++++++--
>  gcc/testsuite/lib/target-supports.exp | 22 ++++++++++++++++------
>  2 files changed, 37 insertions(+), 8 deletions(-)
>
> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> index ef2ca9eab5e..7850b9de934 100644
> --- a/gcc/doc/sourcebuild.texi
> +++ b/gcc/doc/sourcebuild.texi
> @@ -876,9 +876,9 @@ included, in this file you should guard declarations 
> using these types
>  inside appropriate @code{#ifdef RTX_CODE} or @code{#ifdef TREE_CODE}
>  conditional code segments.
>
> -If the backend uses shared data structures that require @code{GTY} markers
> +If the backend uses shared data structures that require @code{GTY} markers
>  for garbage collection (@pxref{Type Information}), you must declare those
> -in @file{@var{machine}.h} rather than @file{@var{machine}-protos.h}.
> +in @file{@var{machine}.h} rather than @file{@var{machine}-protos.h}.
>  Any definitions required for building libgcc must also go in
>  @file{@var{machine}.h}.
>
> @@ -1506,6 +1506,25 @@ By convention, keywords ending in @code{_nocache} can 
> also include options
>  specified for the particular test in an earlier @code{dg-options} or
>  @code{dg-add-options} directive.
>
> +@subsubsection Object file format
> +
> +This identifies the object file format emitted by the compiler. Matching
> +assembler output often depends on content that differs between file formats.
> +
> +@table @code
> +
> +@item elf
> +Target uses the ELF file format (note that ELFv2 is matched specifically for
> +the powerpc platform, below).
> +
> +@item macho
> +Target uses the Mach-O file format (currently applies only to Darwin / 
> macOS).
> +
> +@item pe
> +Target uses the PE/COFF file format (e.g. for Windows).
> +
> +@end table
> +
>  @subsubsection Endianness
>
>  @table @code
> diff --git a/gcc/testsuite/lib/target-supports.exp 
> b/gcc/testsuite/lib/target-supports.exp
> index 668434e933f..c6ebbed4f4b 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -335,7 +335,7 @@ proc check_weak_available { } {
>
>      # VxWorks supports it only since VxWorks 7 (assumed >= r2) for RTPs.
>      # Kernel mode works fine as well for our testsuite's purposes.
> -
> +
>      if { [istarget *-*-vxworks*] } {
>         return [istarget *-*-vxworks7*]
>      }
> @@ -560,6 +560,16 @@ proc check_effective_target_elf { } {
>      }
>  }
>
> +# Returns 1 if the target uses the Mach-O object format, 0 otherwise.
> +
> +proc check_effective_target_macho { } {
> +    if { [gcc_target_object_format] == "mach-o" } {
> +       return 1;
> +    } else {
> +       return 0;
> +    }
> +}
> +
>  # Returns 1 if the target uses the PE/COFF object format, 0 otherwise.
>
>  proc check_effective_target_pe { } {
> @@ -6336,7 +6346,7 @@ foreach { armfunc armflag armdefs } {
>  #        /* { dg-add-options arm_cpu_xscale } */
>  #       /* { dg-require-effective-target arm_xscale_multilib } */
>
> -# NOTE: -mcpu does not override -mtune, so to ensure the tuning is consistent
> +# NOTE: -mcpu does not override -mtune, so to ensure the tuning is consistent
>  # for tests using these flags all entries should set -mcpu and -mtune 
> explicitly
>
>  # This table should only be used to set -mcpu= (and associated
> @@ -13775,7 +13785,7 @@ proc check_effective_target_autoincdec { } {
>  #
>  proc check_effective_target_supports_stack_clash_protection { } {
>
> -    if { [check_effective_target_x86]
> +    if { [check_effective_target_x86]
>           || [istarget powerpc*-*-*] || [istarget rs6000*-*-*]
>           || [istarget aarch64*-**] || [istarget s390*-*-*]
>           || [istarget loongarch64*-**] || [istarget riscv64*-**] } {
> @@ -14790,7 +14800,7 @@ proc check_nvptx_default_ptx_isa_version_at_least { 
> major minor } {
>              "#error unsupported" \
>              "#endif"]
>      set src [join $src "\n"]
> -
> +
>      set res [check_no_compiler_messages $name assembly $src ""]
>
>      return $res
> @@ -14825,7 +14835,7 @@ proc 
> check_nvptx_default_ptx_isa_target_architecture_at_least { ta } {
>              "#error unsupported" \
>              "#endif"]
>      set src [join $src "\n"]
> -
> +
>      set res [check_no_compiler_messages $name assembly $src ""]
>
>      return $res
> @@ -14940,7 +14950,7 @@ proc check_effective_target_alarm { } {
>         #include <stdlib.h>
>         #include <unistd.h>
>         void do_exit(int i) { exit (0); }
> -       int main (void) {
> +       int main (void) {
>           struct sigaction s;
>           sigemptyset (&s.sa_mask);
>           s.sa_handler = exit;
> --
> 2.50.1 (Apple Git-155)
>

Reply via email to