https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/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`. >From 31da211e0566e7254c9cff615eb9ca17106b5923 Mon Sep 17 00:00:00 2001 From: Fangrui Song <i...@maskray.me> Date: Sun, 19 Nov 2023 10:32:54 -0800 Subject: [PATCH] [Driver] Allow -e entry but reject -eentry 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`. --- clang/include/clang/Driver/Options.td | 2 +- clang/test/Driver/entry.s | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 clang/test/Driver/entry.s diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index df12ba8fbcb296a..83b09a892049bb6 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