[PATCH] D127581: [ELF] Relax R_RISCV_ALIGN

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 20 02:47:16 PDT 2022


arichardson added a comment.

I haven't looked at the code yet, but I can confirm that I was able to build and boot FreeBSD for RISCV64 with this patch and the FreeBSD patch below to remove `-mno-relax` (I could have just defined the `riscv-relaxations` linker feature, but I wanted to make sure that the code is actually built with relaxations):

  diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
  index 36d91ea019f3..b37ebe39ecf4 100644
  --- a/share/mk/bsd.lib.mk
  +++ b/share/mk/bsd.lib.mk
  @@ -123,8 +123,8 @@ CXXFLAGS+= ${DEBUG_FILES_CFLAGS}
   CTFFLAGS+= -g
   .endif
   
  -.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == ""
  -CFLAGS += -mno-relax
  +.if ${MACHINE_CPUARCH} == "riscv"
  +CFLAGS += -mrelax
   .endif
   
   .include <bsd.libnames.mk>
  diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk
  index 6b8da09edaf0..3743250c2c87 100644
  --- a/share/mk/bsd.prog.mk
  +++ b/share/mk/bsd.prog.mk
  @@ -84,8 +84,8 @@ CXXFLAGS+= -ftrivial-auto-var-init=pattern
   # bsd.sanitizer.mk is not installed, so don't require it (e.g. for ports).
   .sinclude "bsd.sanitizer.mk"
   
  -.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == ""
  -CFLAGS += -mno-relax
  +.if ${MACHINE_CPUARCH} == "riscv"
  +CFLAGS += -mrelax
   .endif
   
   .if defined(CRUNCH_CFLAGS)
  diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
  index 221e8b028479..f6266d7b991b 100644
  --- a/share/mk/bsd.sys.mk
  +++ b/share/mk/bsd.sys.mk
  @@ -83,6 +83,13 @@ CWARNFLAGS.clang+=   -Wno-unused-const-variable
   .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 130000
   CWARNFLAGS.clang+=     -Wno-error=unused-but-set-variable
   .endif
  +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150000
  +CWARNFLAGS.clang+=     -Wno-deprecated-non-prototype
  +CWARNFLAGS.clang+=     -Wno-unreachable-code-generic-assoc
  +CWARNFLAGS.clang+=     -Wno-strict-prototypes
  +CWARNFLAGS.clang+=     -Wno-error=unused-but-set-parameter
  +CWARNFLAGS.clang+=     -Wno-error=implicit-function-declaration
  +.endif
   .endif # WARNS <= 6
   .if ${WARNS} <= 3
   CWARNFLAGS.clang+=     -Wno-tautological-compare -Wno-unused-value\
  diff --git a/stand/defs.mk b/stand/defs.mk
  index e9c97f7720ab..753bf39ced31 100644
  --- a/stand/defs.mk
  +++ b/stand/defs.mk
  @@ -175,9 +175,7 @@ CFLAGS+=    -fPIC
   
   # Some RISC-V linkers have support for relaxations, while some (lld) do not
   # yet. If this is the case we inhibit the compiler from emitting relaxations.
  -.if ${LINKER_FEATURES:Mriscv-relaxations} == ""
  -CFLAGS+=       -mno-relax
  -.endif
  +CFLAGS+=       -mrelax
   
   # The boot loader build uses dd status=none, where possible, for reproducible
   # build output (since performance varies from run to run). Trouble is that
  diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk
  index b86149ab4618..2c82ff97b88e 100644
  --- a/sys/conf/kern.mk
  +++ b/sys/conf/kern.mk
  @@ -34,6 +34,9 @@ NO_WUNUSED_BUT_SET_VARIABLE=  -Wno-unused-but-set-variable
   .if ${COMPILER_VERSION} >= 140000
   NO_WBITWISE_INSTEAD_OF_LOGICAL=        -Wno-bitwise-instead-of-logical
   .endif
  +.if ${COMPILER_VERSION} >= 150000
  +CWARNFLAGS+=   -Wno-strict-prototypes -Wno-error=unused-but-set-variable
  +.endif
   # Several other warnings which might be useful in some cases, but not severe
   # enough to error out the whole kernel build.  Display them anyway, so there is
   # some incentive to fix them eventually.
  @@ -151,9 +154,7 @@ CFLAGS.clang+=      -mcmodel=medium
   CFLAGS.gcc+=   -mcmodel=medany
   INLINE_LIMIT?= 8000
   
  -.if ${LINKER_FEATURES:Mriscv-relaxations} == ""
  -CFLAGS+=       -mno-relax
  -.endif
  +CFLAGS+=       -mrelax
   .endif
   
   #


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127581/new/

https://reviews.llvm.org/D127581



More information about the llvm-commits mailing list