Skip to content

[LLD] [MinGW] Handle the --dll option #68575

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

Merged
merged 1 commit into from
Oct 9, 2023
Merged

Conversation

mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Oct 9, 2023

Treat this as an alias for the --shared option.

In practice in GNU ld, they aren't exact aliases but there are small subtle differences in what happens and what doesn't, when they are set, but those differences are probably not intended by users who might be using the --dll option (which gets passed by -mdll in the compiler driver), and the differences are within the area where small details differ between LLD and GNU ld anyway.

Treat this as an alias for the --shared option.

In practice in GNU ld, they aren't exact aliases but there are
small subtle differences in what happens and what doesn't, when they
are set, but those differences are probably not intended by users
who might be using the --dll option (which gets passed by -mdll in
the compiler driver), and the differences are within the area where
small details differ between LLD and GNU ld anyway.
@llvmbot
Copy link
Member

llvmbot commented Oct 9, 2023

@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-lld

Changes

Treat this as an alias for the --shared option.

In practice in GNU ld, they aren't exact aliases but there are small subtle differences in what happens and what doesn't, when they are set, but those differences are probably not intended by users who might be using the --dll option (which gets passed by -mdll in the compiler driver), and the differences are within the area where small details differ between LLD and GNU ld anyway.


Full diff: https://github.com/llvm/llvm-project/pull/68575.diff

2 Files Affected:

  • (modified) lld/MinGW/Options.td (+1)
  • (modified) lld/test/MinGW/driver.test (+1)
diff --git a/lld/MinGW/Options.td b/lld/MinGW/Options.td
index f59bd5bc38a8db8..fa4c4ecc75d6543 100644
--- a/lld/MinGW/Options.td
+++ b/lld/MinGW/Options.td
@@ -203,6 +203,7 @@ def alias_Bdynamic_dy: Flag<["-"], "dy">, Alias<Bdynamic>;
 def alias_Bstatic_dn: Flag<["-"], "dn">, Alias<Bstatic>;
 def alias_Bstatic_non_shared: Flag<["-"], "non_shared">, Alias<Bstatic>;
 def alias_Bstatic_static: Flag<["-"], "static">, Alias<Bstatic>;
+def alias_dll: F<"dll">, Alias<shared>;
 def alias_entry_e: JoinedOrSeparate<["-"], "e">, Alias<entry>;
 def alias_no_dynamicbase: F<"no-dynamicbase">, Alias<disable_dynamicbase>;
 def alias_strip_s: Flag<["-"], "s">, Alias<strip_all>;
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 2893f8c66fd122c..1fdd494754af4bf 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -27,6 +27,7 @@ ARM64-SAME: foo.o
 
 RUN: ld.lld -### foo.o -m i386pep -shared 2>&1 | FileCheck -check-prefix=SHARED %s
 RUN: ld.lld -### foo.o -m i386pep --shared 2>&1 | FileCheck -check-prefix=SHARED %s
+RUN: ld.lld -### foo.o -m i386pep --dll 2>&1 | FileCheck -check-prefix=SHARED %s
 SHARED:      -out:a.dll
 SHARED-SAME: -dll
 

Copy link
Member

@zero9178 zero9178 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Given that LDs doc say that it is basically equal to using -shared and that that is the only way users should use it, implementing implementation details of LD doesn't make sense to me unless really really often used in the wild.

Copy link
Collaborator

@tru tru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mstorsjo mstorsjo merged commit 3548b79 into llvm:main Oct 9, 2023
@mstorsjo mstorsjo deleted the lld-dll-option branch October 9, 2023 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants