-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Driver] Allow -e entry but reject -eentry #72804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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`.
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Fangrui Song (MaskRay) ChangesThis short option taking an argument is unfortunate.
It seems Full diff: https://github.com/llvm/llvm-project/pull/72804.diff 2 Files Affected:
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'
|
Driver used to accept This change will get us out of the business to support random |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This short option taking an argument is unfortunate.
-e
, using it for driver will not bereported as an error (e.g. commit
6cd9886c88d16d288c74846495d89f2fe84ff827).
-e
driver option is intended but a typo is made, theoption will be recognized as a
-e
.gcc -export-dynamic
passes-export-dynamic
to ld. It's not clearwhether some options behave this way.
It seems
-Wl,-eentry
and-Wl,--entry=entry
are primarily used. Theremay also be a few
gcc -e entry
, butgcc -eentry
is extremely rare ornot used at all. Therefore, we probably should reject the Joined form of
-e
.