Skip to content

Commit 282201d

Browse files
authored
[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`.
1 parent a77ea94 commit 282201d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,7 @@ def extract_api_ignores_EQ: CommaJoined<["--"], "extract-api-ignores=">,
14521452
Visibility<[ClangOption, CC1Option]>,
14531453
HelpText<"Comma separated list of files containing a new line separated list of API symbols to ignore when extracting API information.">,
14541454
MarshallingInfoStringVector<FrontendOpts<"ExtractAPIIgnoresFileList">>;
1455-
def e : JoinedOrSeparate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
1455+
def e : Separate<["-"], "e">, Flags<[LinkerInput]>, Group<Link_Group>;
14561456
def fmax_tokens_EQ : Joined<["-"], "fmax-tokens=">, Group<f_Group>,
14571457
Visibility<[ClangOption, CC1Option]>,
14581458
HelpText<"Max total number of preprocessed tokens for -Wmax-tokens.">,

clang/test/Driver/entry.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// To prevent mistaking -exxx as --entry=xxx, we allow -e xxx but reject -exxx.
2+
/// GCC -export-dynamic is rejected as well.
3+
// RUN: not %clang -### --target=x86_64-linux-gnu -export-dynamic %s 2>&1 | FileCheck %s
4+
5+
// CHECK: error: unknown argument: '-export-dynamic'

0 commit comments

Comments
 (0)