RISC-V: Pass -mno-relax through to assembler if supported

Message ID 20181118152807.2967-1-jrtc27@jrtc27.com
State New
Headers show
Series
  • RISC-V: Pass -mno-relax through to assembler if supported
Related show

Commit Message

Jessica Clarke Nov. 18, 2018, 3:28 p.m.
GCC will emit ".option (no)relax" in its outputted assembly, but when
using it as an assembler driver, such as for preprocessed assembly, it's
merely preprocessing and therefore will not generate this directive.
Therefore we should pass -mno-relax on to the assembler if specified
(and supported) as we do for other flags.

gcc/
	* configure.ac: (gcc_cv_as_riscv_mno_relax): Check if the
	assembler supports -mno-relax.
	* configure: Regenerate
	* config.in: Regenerate
	* config/riscv/riscv.h (ASM_MNO_RELAX_SPEC): Define based on
	HAVE_AS_MNO_RELAX_OPTION.
	(ASM_SPEC): Add %(asm_mno_relax_spec).
	(EXTRA_SPECS): Define to include $(asm_mno_relax_spec) and
	SUBTARGET_EXTRA_SPECS.
	(SUBTARGET_EXTRA_SPECS): Provide empty default value.
---
 gcc/config/riscv/riscv.h | 25 +++++++++++++++++++++++++
 gcc/configure.ac         |  8 ++++++++
 2 files changed, 33 insertions(+)

-- 
2.14.1

Comments

Jim Wilson Nov. 20, 2018, 7:24 p.m. | #1
On 11/18/18 7:28 AM, James Clarke wrote:
> GCC will emit ".option (no)relax" in its outputted assembly, but when

> using it as an assembler driver, such as for preprocessed assembly, it's

> merely preprocessing and therefore will not generate this directive.

> Therefore we should pass -mno-relax on to the assembler if specified

> (and supported) as we do for other flags.


This looks good.  I will commit when your assignment comes through.

Jim

Patch

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 13e15cc85..77d92acb2 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -55,14 +55,39 @@  along with GCC; see the file COPYING3.  If not see
 #define TARGET_64BIT           (__riscv_xlen == 64)
 #endif /* IN_LIBGCC2 */
 
+#ifdef HAVE_AS_MNO_RELAX_OPTION
+#define ASM_MNO_RELAX_SPEC "%{mno-relax}"
+#else
+#define ASM_MNO_RELAX_SPEC ""
+#endif
+
 #undef ASM_SPEC
 #define ASM_SPEC "\
 %(subtarget_asm_debugging_spec) \
 %{" FPIE_OR_FPIC_SPEC ":-fpic} \
 %{march=*} \
 %{mabi=*} \
+%(asm_mno_relax_spec) \
 %(subtarget_asm_spec)"
 
+/* This macro defines names of additional specifications to put in the specs
+   that can be used in various specifications like CC1_SPEC.  Its definition
+   is an initializer with a subgrouping for each command option.
+
+   Each subgrouping contains a string constant, that defines the
+   specification name, and a string constant that used by the GCC driver
+   program.
+
+   Do not define this macro if it does not need to do anything.  */
+
+#define EXTRA_SPECS							\
+  { "asm_mno_relax_spec", ASM_MNO_RELAX_SPEC },				\
+  SUBTARGET_EXTRA_SPECS
+
+#ifndef SUBTARGET_EXTRA_SPECS
+#define SUBTARGET_EXTRA_SPECS
+#endif
+
 #define TARGET_DEFAULT_CMODEL CM_MEDLOW
 
 #define LOCAL_LABEL_PREFIX	"."
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 260d987da..4b7c0c79f 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -4827,6 +4827,14 @@  pointers into PC-relative form.])
 	[Requesting --with-nan= requires assembler support for -mnan=])
     fi
     ;;
+
+  riscv*-*-*)
+    gcc_GAS_CHECK_FEATURE([-mno-relax option], gcc_cv_as_riscv_mno_relax,,
+      [-mno-relax], [.text],,
+      [AC_DEFINE(HAVE_AS_MNO_RELAX_OPTION, 1,
+		[Define if your assembler supports -mno-relax option.])])
+    ;;
+
     s390*-*-*)
     gcc_GAS_CHECK_FEATURE([.gnu_attribute support],
       gcc_cv_as_s390_gnu_attribute, [2,18,0],,