diff --git a/ld/lexsup.c b/ld/lexsup.c index b8f066745f..f906508037 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -735,6 +735,21 @@ parse_args (unsigned argc, char **argv) optind = last_optind; optc = getopt_long (argc, argv, "-", really_longopts, &longind); } + /* Attempt to detect grouped short options, eg: "-non-start". + Accepting such options is error prone as it is not clear if the user + intended "-n -o n-start" or "--non-start". */ + else if (longind == 0 /* This is a short option. */ + && optc > 32 /* It is a valid option. */ + && optind != last_optind /* It is not a repeat of the previous option. */ + && optc != argv[last_optind][1] /* The character is not the second character of argv[last_optind]. */ + ) + { + if (optarg) + einfo (_("%F%P: Error: unable to disambiguate: %s (did you mean -%s ?)\n"), + argv[last_optind], argv[last_optind]); + else + einfo (_("%P: Warning: grouped short command line options are deprecated: %s\n"), argv[last_optind]); + } if (ldemul_handle_option (optc)) continue;