From 490443357668a87e3c322f218873a7649a2552df Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tschwinge@baylibre.com>
Date: Mon, 2 Dec 2024 15:06:58 +0100
Subject: [PATCH] 'gcc/config/nvptx/t-nvptx': Don't use the 'shell' function of
'make'
The exit status of the command invoked in a 'Makefile' via '$(shell [...])'
effectively gets discarded (unless explicitly checking the GNU Make 4.2+
'.SHELLSTATUS' variable or jumping through other hoops). In order to be able
to catch errors in what the 'shell' function invokes, let's make things
explicit: similar to how 'gcc/config/avr/t-avr' is doing with 't-multilib-avr',
for example.
gcc/
* config/nvptx/t-nvptx (multilib_matches): Don't use the 'shell'
function of 'make'.
* config/nvptx/gen-multilib-matches.sh: Adjust.
---
gcc/config/nvptx/gen-multilib-matches.sh | 9 +++++++--
gcc/config/nvptx/t-nvptx | 14 +++++++++++++-
2 files changed, 20 insertions(+), 3 deletions(-)
@@ -33,6 +33,8 @@ sms=$(grep ^NVPTX_SM $nvptx_sm_def | sed 's/.*(//;s/,.*//')
# ('misa=sm_SM'; thus not remapped), or has to be remapped to the "next lower"
# variant that does get built.
+multilib_matches=
+
# The "lowest" variant has to be built.
sm_next_lower=INVALID
@@ -50,11 +52,14 @@ for sm in $sms; do
else
# Output format as required for 'MULTILIB_MATCHES'.
if [ x"$sm_map" = x. ]; then
- echo ".=misa?sm_$sm"
+ multilib_matches_sm=".=misa?sm_$sm"
else
- echo "misa?sm_$sm_map=misa?sm_$sm"
+ multilib_matches_sm="misa?sm_$sm_map=misa?sm_$sm"
fi
+ multilib_matches="$multilib_matches $multilib_matches_sm"
sm_next_lower=$sm_map
fi
done
+
+echo "multilib_matches := $multilib_matches"
@@ -43,12 +43,24 @@ MULTILIB_OPTIONS += mgomp
multilib_options_isa_list := $(TM_MULTILIB_CONFIG)
multilib_options_isa_default := $(word 1,$(multilib_options_isa_list))
multilib_options_misa_list := $(addprefix misa=,$(multilib_options_isa_list))
+
+t-nvptx-gen-multilib-matches: $(srcdir)/config/nvptx/gen-multilib-matches.sh \
+ $(srcdir)/config/nvptx/t-nvptx \
+ Makefile \
+ $(srcdir)/config/nvptx/nvptx-sm.def
+ $(SHELL) $< \
+ $(dir $<) \
+ $(multilib_options_isa_default) \
+ '$(multilib_options_isa_list)' \
+ > $@
+
+include t-nvptx-gen-multilib-matches
+
# Add the requested '-misa' variants as a multilib option ('misa=VAR1/misa=VAR2/misa=VAR3' etc.):
empty :=
space := $(empty) $(empty)
MULTILIB_OPTIONS += $(subst $(space),/,$(multilib_options_misa_list))
# ..., and remap '-misa' variants as appropriate:
-multilib_matches := $(shell $(srcdir)/config/nvptx/gen-multilib-matches.sh $(srcdir)/config/nvptx $(multilib_options_isa_default) "$(multilib_options_isa_list)")
MULTILIB_MATCHES += $(multilib_matches)
# ..., and don't actually build what's the default '-misa':
MULTILIB_EXCEPTIONS += *misa=$(multilib_options_isa_default)*
--
2.34.1