Skip to content

Commit

Permalink
Fix unrecognized option '--no-warn-rwx-segments' on riscv
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake-Carter committed Nov 6, 2023
1 parent 8fe52f2 commit 878f691
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Libraries/CMSIS/Device/Maxim/GCC/gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -308,23 +308,23 @@ LDFLAGS=-mthumb \

# Add --no-warn-rwx-segments on GCC 12+
# This is not universally supported or enabled by default, so we need to check whether the linker supports it first
RWX_SEGMENTS_SUPPORTED ?=
ifeq "$(RWX_SEGMENTS_SUPPORTED)" "" # -------------------------------------
ARM_RWX_SEGMENTS_SUPPORTED ?=
ifeq "$(ARM_RWX_SEGMENTS_SUPPORTED)" "" # -------------------------------------
# Print the linker's help string and parse it for --no-warn-rwx-segments
# Note we invoke the linker through the compiler "-Xlinker" because ld may not
# be on the path, and that's how we invoke the linker for our implicit rules
LINKER_OPTIONS := $(shell $(CC) -Xlinker --help)
ifneq "$(findstring --no-warn-rwx-segments,$(LINKER_OPTIONS))" ""
RWX_SEGMENTS_SUPPORTED := 1
ARM_RWX_SEGMENTS_SUPPORTED := 1
else
RWX_SEGMENTS_SUPPORTED := 0
ARM_RWX_SEGMENTS_SUPPORTED := 0
endif

# export the variable for sub-make calls, so we don't need to interact with the shell again (it's slow).
export RWX_SEGMENTS_SUPPORTED
export ARM_RWX_SEGMENTS_SUPPORTED
endif # ------------------------------------------------------------------

ifeq "$(RWX_SEGMENTS_SUPPORTED)" "1"
ifeq "$(ARM_RWX_SEGMENTS_SUPPORTED)" "1"
LDFLAGS += -Xlinker --no-warn-rwx-segments
endif

Expand Down
15 changes: 8 additions & 7 deletions Libraries/CMSIS/Device/Maxim/GCC/gcc_riscv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -317,23 +317,24 @@ LDFLAGS+=-Xlinker --gc-sections \

# Add --no-warn-rwx-segments on GCC 12+
# This is not universally supported or enabled by default, so we need to check whether the linker supports it first
RWX_SEGMENTS_SUPPORTED ?=
ifeq "$(RWX_SEGMENTS_SUPPORTED)" "" # -------------------------------------
RISCV_RWX_SEGMENTS_SUPPORTED ?=
ifeq "$(RISCV_RWX_SEGMENTS_SUPPORTED)" "" # -------------------------------------
# Print the linker's help string and parse it for --no-warn-rwx-segments
# Note we invoke the linker through the compiler "-Xlinker" because ld may not
# be on the path, and that's how we invoke the linker for our implicit rules
LINKER_OPTIONS := $(shell $(CC) -Xlinker --help)
ifneq "$(findstring --no-warn-rwx-segments,$(LINKER_OPTIONS))" ""
RWX_SEGMENTS_SUPPORTED := 1
$(error test)
RISCV_RWX_SEGMENTS_SUPPORTED := 1
else
RWX_SEGMENTS_SUPPORTED := 0
RISCV_RWX_SEGMENTS_SUPPORTED := 0
endif

# export the variable for sub-make calls, so we don't need to interact with the shell again (it's slow).
export RWX_SEGMENTS_SUPPORTED
export RISCV_RWX_SEGMENTS_SUPPORTED
endif # ------------------------------------------------------------------

ifeq "$(RWX_SEGMENTS_SUPPORTED)" "1"
ifeq "$(RISCV_RWX_SEGMENTS_SUPPORTED)" "1"
LDFLAGS += -Xlinker --no-warn-rwx-segments
endif

Expand Down Expand Up @@ -634,4 +635,4 @@ $(info *************************************************************************
HELP_COMPLETE = 1
export HELP_COMPLETE
endif
endif
endif

0 comments on commit 878f691

Please sign in to comment.