Author: Fangrui Song Date: 2023-11-27T11:04:29+08:00 New Revision: 282201dc633e164042df0ae726a804c0aad46e50
URL: https://github.com/llvm/llvm-project/commit/282201dc633e164042df0ae726a804c0aad46e50 DIFF: https://github.com/llvm/llvm-project/commit/282201dc633e164042df0ae726a804c0aad46e50.diff LOG: [Driver] Allow -e entry but reject -eentry (#72804) This short option taking an argument is unfortunate. * If a cc1-only option starts with `-e`, using it for driver will not be reported as an error (e.g. commit 6cd9886c88d16d288c74846495d89f2fe84ff827). * If another `-e` driver option is intended but a typo is made, the option will be recognized as a `-e`. `gcc -export-dynamic` passes `-export-dynamic` to ld. It's not clear whether some options behave this way. It seems `-Wl,-eentry` and `-Wl,--entry=entry` are primarily used. There may also be a few `gcc -e entry`, but `gcc -eentry` is extremely rare or not used at all. Therefore, we probably should reject the Joined form of `-e`. Added: clang/test/Driver/entry.s Modified: clang/include/clang/Driver/Options.td Removed: ################################################################################ diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 9191ccd2a66ac4a..9689f12fd01417b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -1452,7 +1452,7 @@ def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">, Visibility<[ClangOption, CC1Option]>, HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">, MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>; -def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>; +def e : Separate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>; def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>, Visibility<[ClangOption, CC1Option]>, HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">, diff --git a/clang/test/Driver/entry.s b/clang/test/Driver/entry.s new file mode 100644 index 000000000000000..60ab89704c35462 --- /dev/null +++ b/clang/test/Driver/entry.s @@ -0,0 +1,5 @@ +/// To prevent mistaking -exxx as --entry=xxx, we allow -e xxx but reject -exxx. +/// GCC -export-dynamic is rejected as well. +// RUN: not %clang -### --target=x86_64-linux-gnu -export-dynamic %s 2>&1 | FileCheck %s + +// CHECK: error: unknown argument: '-export-dynamic' _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits