Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Build): Fix unrecognized option '--no-warn-rwx-segments' on riscv #793

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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