[v2,1/6] Remove HAVE_GNU_AS

Message ID yddecjpq86p.fsf_-_@CeBiTec.Uni-Bielefeld.DE
State New
Headers
Series [v2,1/6] Remove HAVE_GNU_AS |

Commit Message

Rainer Orth May 6, 2026, 8 a.m. UTC
  Hi David,

>>> >> * AIX: native as and ld
>>> >
>>> > AIX supports both native as/ld and GNU as/ld.  GNU ld is more common than
>>> > GNU as.
>>> > It would have been nice to handle both, like Solaris, but I understand
>>> that
>>> > supporting both is more
>>> > of a hassle.
>>>
>>> I missed that in the AIX install.texi section.  Maybe it would be good
>>> to weed that out a bit.
>>>
>>> Anyway, handling those cases isn't really hard: just like the
>>> solaris_as/solaris_ld handling in gcc/configure.ac, and hpux_ld in the v2
>>>
>>>         build: Remove $gnu_ld
>>>         https://gcc.gnu.org/pipermail/gcc-patches/2026-May/715430.html
>>>
>>> patch one can just check $gcc_cv_as/$gcc_cv_ld for the output of the
>>> native commands, assuming gas/gld otherwise.  Depending on that, one
>>> would define AIX_{AS,LD} just like SOLARIS_{AS,LD} and use that to
>>> restrict the ASM_V_SPEC redefinition to AIX as.
>>>
>>> It's quite trivial, actually.  I could give it a try on cfarm119 (AIX
>>> 7.3) if you like.
>>>
>>
>> If you can handle both, that would be nicer, but I'm not going to make
>> that a requirement for the patch if you don't have time.
>
> fine.  I'll go ahead with the patch as is for now, but handle the AIX
> as/ld as a follow-up.  I have a similar patch for ASM_V_SPEC with gas on
> Solaris already done, to be installed after this series is in.

this is the revised patch, handling both AIX and Solaris as.  That's the
only change relative to v1.

So the only part that needs approval is this rs6000/aix.h change.

---------------------------------------------------------------------------

This patch removes or replaces the remaining uses of HAVE_GNU_AS:

* gcc.cc (asm_options) has a sub-spec to map the gcc -v/-w/-I options to
  their assembler equivalents.  It is replaced by ASM_V_SPEC, defaulting
  to the gas version.  Non-gas configurations define their own versions.

* Darwin has ASM_OPTIONS which is identical to the default ASM_V_SPEC
  and can just be removed.

* sol2.h currently handles -v in ASM_SPEC_BASE.  This patch moves this
  to an Solaris-as only version of ASM_V_SPEC.  This also handles the
  gcc -w -> as -n mapping.  The spec doesn't pass on -I, though:
  preprocessing .S files is handled by gcc itself, the -I option is only
  used for gas' .include directive which as doesn't support.  Solaris as
  instead could handle preprocessing by passing the source through cpp
  when the -P option is given.  It also uses -D/-U/-I for that.

* ia64/hpux.h guards AS_NEEDS_DASH_FOR_PIPED_INPUT with !HAVE_GNU_AS,
  but according to install.texi ia64-*-hpux* requires gas so this can
  just go.

* nvptx/nvptx.h handles the mapping in ASM_SPEC.  This is done in
  ASM_V_SPEC now.  The nvptx as has no equivalents of -w and -I.

* AIX as only supports -v and -W, so rs6000/aix.h gets a matching
  ASM_V_SPEC when as is in use.

Ok for trunk?

	Rainer
  

Comments

David Edelsohn May 6, 2026, 2:21 p.m. UTC | #1
On Wed, May 6, 2026 at 4:00 AM Rainer Orth <ro@cebitec.uni-bielefeld.de>
wrote:

> Hi David,
>
> >>> >> * AIX: native as and ld
> >>> >
> >>> > AIX supports both native as/ld and GNU as/ld.  GNU ld is more common
> than
> >>> > GNU as.
> >>> > It would have been nice to handle both, like Solaris, but I
> understand
> >>> that
> >>> > supporting both is more
> >>> > of a hassle.
> >>>
> >>> I missed that in the AIX install.texi section.  Maybe it would be good
> >>> to weed that out a bit.
> >>>
> >>> Anyway, handling those cases isn't really hard: just like the
> >>> solaris_as/solaris_ld handling in gcc/configure.ac, and hpux_ld in
> the v2
> >>>
> >>>         build: Remove $gnu_ld
> >>>         https://gcc.gnu.org/pipermail/gcc-patches/2026-May/715430.html
> >>>
> >>> patch one can just check $gcc_cv_as/$gcc_cv_ld for the output of the
> >>> native commands, assuming gas/gld otherwise.  Depending on that, one
> >>> would define AIX_{AS,LD} just like SOLARIS_{AS,LD} and use that to
> >>> restrict the ASM_V_SPEC redefinition to AIX as.
> >>>
> >>> It's quite trivial, actually.  I could give it a try on cfarm119 (AIX
> >>> 7.3) if you like.
> >>>
> >>
> >> If you can handle both, that would be nicer, but I'm not going to make
> >> that a requirement for the patch if you don't have time.
> >
> > fine.  I'll go ahead with the patch as is for now, but handle the AIX
> > as/ld as a follow-up.  I have a similar patch for ASM_V_SPEC with gas on
> > Solaris already done, to be installed after this series is in.
>
> this is the revised patch, handling both AIX and Solaris as.  That's the
> only change relative to v1.
>
> So the only part that needs approval is this rs6000/aix.h change.
>
> ---------------------------------------------------------------------------
>
> This patch removes or replaces the remaining uses of HAVE_GNU_AS:
>
> * gcc.cc (asm_options) has a sub-spec to map the gcc -v/-w/-I options to
>   their assembler equivalents.  It is replaced by ASM_V_SPEC, defaulting
>   to the gas version.  Non-gas configurations define their own versions.
>
> * Darwin has ASM_OPTIONS which is identical to the default ASM_V_SPEC
>   and can just be removed.
>
> * sol2.h currently handles -v in ASM_SPEC_BASE.  This patch moves this
>   to an Solaris-as only version of ASM_V_SPEC.  This also handles the
>   gcc -w -> as -n mapping.  The spec doesn't pass on -I, though:
>   preprocessing .S files is handled by gcc itself, the -I option is only
>   used for gas' .include directive which as doesn't support.  Solaris as
>   instead could handle preprocessing by passing the source through cpp
>   when the -P option is given.  It also uses -D/-U/-I for that.
>
> * ia64/hpux.h guards AS_NEEDS_DASH_FOR_PIPED_INPUT with !HAVE_GNU_AS,
>   but according to install.texi ia64-*-hpux* requires gas so this can
>   just go.
>
> * nvptx/nvptx.h handles the mapping in ASM_SPEC.  This is done in
>   ASM_V_SPEC now.  The nvptx as has no equivalents of -w and -I.
>
> * AIX as only supports -v and -W, so rs6000/aix.h gets a matching
>   ASM_V_SPEC when as is in use.


> Ok for trunk?
>

Okay.

David


>
>         Rainer
>
> --
>
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University
>
>
> 2026-04-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
>         gcc:
>         * gcc.cc (asm_options) [HAVE_GNU_AS]: Move to ...
>         (ASM_V_SPEC) ... this.
>         * config/nvptx/nvptx.h (ASM_SPEC): Rename to ASM_V_SPEC.
>         Adjust comment.
>         * config/rs6000/aix.h [HAVE_AIX_AS] (ASM_V_SPEC): Define.
>         * config/sol2.h (ASM_SPEC_BASE): Move -v handling to ...
>         [HAVE_SOLARIS_AS] (ASM_V_SPEC): ... this.  Also handle -w.
>         * doc/tm.texi.in (Driver, ASM_V_SPEC): Document.
>         * doc/tm.texi: Regenerate.
>
>         * config/darwin.h (ASM_OPTIONS): Remove.
>         * config/i386/darwin.h (ASM_SPEC): Remove ASM_OPTIONS.
>
>         * config/ia64/hpux.h (AS_NEEDS_DASH_FOR_PIPED_INPUT): Remove.
>
>         * configure.ac (HAVE_GNU_AS): Remove.
>         * configure: Regenerate.
>         * config.in: Regenerate.
>
>
  

Patch

# HG changeset patch
# Parent  4b212240719bda857db3450c6acbb5f518fdb2c0
Remove HAVE_GNU_AS

diff --git a/gcc/config.in b/gcc/config.in
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -1616,12 +1616,6 @@ 
 #endif
 
 
-/* Define to 1 if using GNU as. */
-#ifndef USED_FOR_TARGET
-#undef HAVE_GNU_AS
-#endif
-
-
 /* Define if your system supports gnu indirect functions. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_GNU_INDIRECT_FUNCTION
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -663,21 +663,12 @@  extern GTY(()) int darwin_ms_struct;
 #define ASM_MMACOSX_VERSION_MIN_SPEC " %<asm_macosx_version_min=* "
 #endif
 
-#if HAVE_GNU_AS
-/* The options are added in gcc.cc for this case.  */
-#define ASM_OPTIONS ""
-#else
-/* When we detect that we're cctools or llvm as, we need to insert the right
-   additional options.  Actually, currently these are the same as GAS.  */
-#define ASM_OPTIONS "%{v} %{w:-W} %{I*}"
-#endif
-
 #define AS_NEEDS_DASH_FOR_PIPED_INPUT
 
 /* Default Darwin ASM_SPEC, very simple. */
 #define ASM_SPEC \
 "%{static} -arch %(darwin_arch) " \
-ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC
+ASM_MMACOSX_VERSION_MIN_SPEC
 
 #define ASM_DEBUG_SPEC  ""
 #undef  ASM_DEBUG_OPTION_SPEC
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -105,7 +105,7 @@  along with GCC; see the file COPYING3.  
 #undef ASM_SPEC
 #define ASM_SPEC \
 "%{static} -arch %(darwin_arch) " \
- ASM_OPTIONS ASM_MMACOSX_VERSION_MIN_SPEC EXTRA_ASM_OPTS \
+ ASM_MMACOSX_VERSION_MIN_SPEC EXTRA_ASM_OPTS \
 "%{!force_cpusubtype_ALL:-force_cpusubtype_ALL} "
 
 #undef ENDFILE_SPEC
diff --git a/gcc/config/ia64/hpux.h b/gcc/config/ia64/hpux.h
--- a/gcc/config/ia64/hpux.h
+++ b/gcc/config/ia64/hpux.h
@@ -62,10 +62,6 @@  do {							\
 #undef  ASM_EXTRA_SPEC
 #define ASM_EXTRA_SPEC "%{milp32:-milp32} %{mlp64:-mlp64}"
 
-#ifndef HAVE_GNU_AS
-#define AS_NEEDS_DASH_FOR_PIPED_INPUT
-#endif
-
 #ifndef CROSS_DIRECTORY_STRUCTURE
 #undef MD_EXEC_PREFIX
 #define MD_EXEC_PREFIX "/usr/ccs/bin/"
diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -31,9 +31,8 @@ 
 #define OPTION_DEFAULT_SPECS \
   { "arch", "%{!misa=*:-misa=%(VALUE)}" }, \
 
-/* Assembler supports '-v' option; handle similar to
-   '../../gcc.cc:asm_options', 'HAVE_GNU_AS'.  */
-#define ASM_SPEC "%{v}"
+/* Assembler only supports '-v' option.  */
+#define ASM_V_SPEC "%{v}"
 
 #define STARTFILE_SPEC "%{mmainkernel:crt0.o%s}"
 
diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h
--- a/gcc/config/rs6000/aix.h
+++ b/gcc/config/rs6000/aix.h
@@ -177,6 +177,10 @@ 
 #undef ASM_DEFAULT_SPEC
 #define ASM_DEFAULT_SPEC ""
 
+#ifdef HAVE_AIX_AS
+#define ASM_V_SPEC "%{v} %{w:-W}"
+#endif
+
 /* Tell the assembler to assume that all undefined names are external.
 
    Don't do this until the fixed IBM assembler is more generally available.
diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h
--- a/gcc/config/sol2.h
+++ b/gcc/config/sol2.h
@@ -143,7 +143,7 @@  along with GCC; see the file COPYING3.  
 /* It's safe to pass -s always, even if -g is not used.  Those options are
    handled by both Sun as and GNU as.  */
 #define ASM_SPEC_BASE \
-"%{v:-V} %{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
+"%{Qy:} %{!Qn:-Qy} %{Ym,*} -s %(asm_cpu)"
 
 #define ASM_PIC_SPEC " %{" FPIE_OR_FPIC_SPEC ":-K PIC}"
 
@@ -447,9 +447,14 @@  along with GCC; see the file COPYING3.  
 #undef TARGET_ASM_ASSEMBLE_VISIBILITY
 #define TARGET_ASM_ASSEMBLE_VISIBILITY solaris_assemble_visibility
 
-#define AS_NEEDS_DASH_FOR_PIPED_INPUT
+/* Handle gcc -v/-w options.  There's no point including -I: while as accepts
+   it, it's only useful in combination with -P which invokes cpp.  Instead, gas
+   uses -I for the .include directive, but as doesn't understand that.  */
+#define ASM_V_SPEC "%{v:-V} %{w:-n}"
 
+#define AS_NEEDS_DASH_FOR_PIPED_INPUT
 #endif
+
 /* Solaris has an implementation of __enable_execute_stack.  */
 #define HAVE_ENABLE_EXECUTE_STACK
 
diff --git a/gcc/configure b/gcc/configure
--- a/gcc/configure
+++ b/gcc/configure
@@ -13126,13 +13126,6 @@  cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-gnu_as_bool=`if test x"$gas" = x"yes"; then echo 1; else echo 0; fi`
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_GNU_AS $gnu_as_bool
-_ACEOF
-
-
 count=a
 for f in $host_xm_file; do
 	count=${count}x
@@ -21975,7 +21968,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21978 "configure"
+#line 21971 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22081,7 +22074,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 22084 "configure"
+#line 22077 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -2035,9 +2035,6 @@  fi
 gnu_ld_bool=`if test x"$gnu_ld" = x"yes"; then echo 1; else echo 0; fi`
 AC_DEFINE_UNQUOTED(HAVE_GNU_LD, $gnu_ld_bool, [Define to 1 if using GNU ld.])
 
-gnu_as_bool=`if test x"$gas" = x"yes"; then echo 1; else echo 0; fi`
-AC_DEFINE_UNQUOTED(HAVE_GNU_AS, $gnu_as_bool, [Define to 1 if using GNU as.])
-
 count=a
 for f in $host_xm_file; do
 	count=${count}x
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -232,6 +232,15 @@  See the file @file{sun3.h} for an exampl
 Do not define this macro if it does not need to do anything.
 @end defmac
 
+@defmac ASM_V_SPEC
+A C string constant that tells the GCC driver how to translate the
+@option{-v}, @option{-w}, and @option{-I} options into their assembler
+equivalents.
+
+Only define this macro if the default, which matches GNU as, isn't
+appropriate.
+@end defmac
+
 @defmac ASM_FINAL_SPEC
 A C string constant that tells the GCC driver program how to
 run any programs which cleanup after the normal assembler.
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -232,6 +232,15 @@  See the file @file{sun3.h} for an exampl
 Do not define this macro if it does not need to do anything.
 @end defmac
 
+@defmac ASM_V_SPEC
+A C string constant that tells the GCC driver how to translate the
+@option{-v}, @option{-w}, and @option{-I} options into their assembler
+equivalents.
+
+Only define this macro if the default, which matches GNU as, isn't
+appropriate.
+@end defmac
+
 @defmac ASM_FINAL_SPEC
 A C string constant that tells the GCC driver program how to
 run any programs which cleanup after the normal assembler.
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -709,6 +709,12 @@  proper position among the other output f
 #define ASM_SPEC ""
 #endif
 
+/* config.h can define ASM_V_SPEC to pass equivalents of -v, -w (no warnings),
+   and -I to the assembler.  */
+#ifndef ASM_V_SPEC
+#define ASM_V_SPEC "%{v} %{w:-W} %{I*}"
+#endif
+
 /* config.h can define ASM_FINAL_SPEC to run a post processor after
    the assembler has run.  */
 #ifndef ASM_FINAL_SPEC
@@ -1327,12 +1333,8 @@  static const char *cc1_options =
 
 static const char *asm_options =
 "%{-target-help:%:print-asm-header()} "
-#if HAVE_GNU_AS
-/* If GNU AS is used, then convert -w (no warnings), -I, and -v
-   to the assembler equivalents.  */
-"%{v} %{w:-W} %{I*} "
-#endif
-"%(asm_debug_option)"
+ASM_V_SPEC
+" %(asm_debug_option)"
 ASM_COMPRESS_DEBUG_SPEC
 "%a %Y %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}";