https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124094
Bug ID: 124094
Summary: aarch64: poor diagnostics for bad inputs to
-muser-provided-CPU=
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: dmalcolm at gcc dot gnu.org
Target Milestone: ---
Target: aarch64-*-*
In GCC 16 the aarch64 target has gained the ability to load tuning information
in JSON form via -muser-provided-CPU=FILENAME.json (see
r16-5615-g59f37983222d86 through r16-5619-ga0b8cc4a473e1e).
The UX is currently rather poor for malformed and invalid inputs to
-muser-provided-CPU=:
$ ./xgcc -B. -S test.c -muser-provided-CPU=malformed.json
cc1: error: error parsing JSON data: expected ':'; got number
$ ./xgcc -B. -S test.c -muser-provided-CPU=unsigned-3.json
cc1: warning: JSON tuning file does not contain version information;
compatibility cannot be verified
cc1: error: key ‘tune_params.sve_width’ value 5000000000 is out of range for
‘uint’ type [0, 4294967295]
cc1: error: validation failed for the provided JSON data
In particular it doesn't show location information within the JSON file.
I'm testing a patch that converts the above to:
$ ./xgcc -B. -S test.c -muser-provided-CPU=malformed.json
malformed.json:3:17: error: error parsing JSON data: expected ':'; got number
3 | "sve_width" 128
| ^~~
$ ./xgcc -B. -S test.c -muser-provided-CPU=unsigned-3.json
cc1: warning: JSON tuning file does not contain version information;
compatibility cannot be verified
unsigned-3.json: In JSON value ‘/tune_params/sve_width’
unsigned-3.json:3:18: error: key ‘tune_params.sve_width’ value 5000000000 is
out of range for ‘uint’ type [0, 4294967295]
3 | "sve_width": 5000000000
| ^~~~~~~~~~
cc1: error: validation failed for the provided JSON data
showing file:line:column of the problematic JSON, quoting and underlining the
pertinent part of the input, and showing the JSON Pointer of the relevant
value, if there is one.
Filing this bug to track this potential improvement.