From e31e645f5c29b6587404c1efe534c65b4691e023 Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Fri, 1 Apr 2022 22:00:36 -0700 Subject: RISC-V: don't die() on -march errors, just warn Parsing RISC-V ISA strings is extremely complicated: there are many extensions, versions of extensions, versions of the ISA string rules, and a bunch of unwritten rules to deal with all the bugs that fell out of that complexity. Rather than die()ing when the ISA string parsing fails, just stop parsing where we get lost and emit a warning. Changes tend to end up at the end of the ISA string, so that's probably going to work (and if it doesn't there's a warning to true and clue folks in). This does have the oddity in that "-Wsparse-error" is ignored for this warning but this option was never meant to be used at this stage of the processing.. [Luc Van Oostenryck: drop handling of "-Wsparse-error"] Suggested-by: Linus Torvalds Based-on-patch-by: Palmer Dabbelt Signed-off-by: Luc Van Oostenryck --- target-riscv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target-riscv.c b/target-riscv.c index 3bba7c15..1707e6b9 100644 --- a/target-riscv.c +++ b/target-riscv.c @@ -3,6 +3,7 @@ #include "target.h" #include "machine.h" #include +#include #define RISCV_32BIT (1 << 0) #define RISCV_64BIT (1 << 1) @@ -64,7 +65,10 @@ static void parse_march_riscv(const char *arg) goto ext; } } - die("invalid argument to '-march': '%s'\n", arg); + +unknown: + fprintf(stderr, "WARNING: invalid argument to '-march': '%s'\n", arg); + return; ext: for (i = 0; i < ARRAY_SIZE(extensions); i++) { @@ -77,7 +81,7 @@ ext: } } if (arg[0]) - die("invalid argument to '-march': '%s'\n", arg); + goto unknown; } static void init_riscv(const struct target *self) -- cgit 1.2.3-korg