Skip to content
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

LDC: Use -fvisibility=public -dllimport=all when compiling a Windows DLL #2412

Merged
merged 1 commit into from
Aug 20, 2022

Conversation

kinke
Copy link
Contributor

@kinke kinke commented Aug 19, 2022

As -shared can only be used when linking the DLL in the same cmdline too. On Windows, -shared changes the defaults of some important settings wrt. dllim/export, so specify those explicitly when compiling a DLL with dub (or some static lib dependency thereof etc.).

[extracted from #2396]

…s DLL

As `-shared` can only be used when linking the DLL in the same cmdline too.
On Windows, `-shared` changes the defaults of some important settings wrt.
dllim/export, so specify those explicitly when *compiling* a DLL with dub
(or some static lib dependency thereof etc.).
@thewilsonator thewilsonator merged commit 6f66feb into dlang:master Aug 20, 2022
@kinke kinke deleted the fix2377_3 branch August 20, 2022 09:09
kinke added a commit to symmetryinvestments/ldc that referenced this pull request May 10, 2023
…that custom dub

dub was customized to apply dflags affecting symbol visibility to
*all* deps with LDC on Windows, something we need for SIL and
plugins on Windows (adding `-fvisibility=hidden` and
`-dllimport=defaultLibsOnly` in lang's dub.sdl). The previous
ldc2.conf tweaks aren't sufficient anymore after
dlang/dub#2412.

See symmetryinvestments/dub@0158ab3.
kinke added a commit to symmetryinvestments/ldc that referenced this pull request May 10, 2023
…that custom dub

dub was customized to apply dflags affecting symbol visibility to
*all* deps with LDC on Windows, something we need for SIL and
plugins on Windows (adding `-fvisibility=hidden` and
`-dllimport=defaultLibsOnly` in lang's dub.sdl). The previous
ldc2.conf tweaks aren't sufficient anymore after
dlang/dub#2412.

See symmetryinvestments/dub@0158ab3.
kinke added a commit to symmetryinvestments/ldc that referenced this pull request May 12, 2023
…that custom dub

dub was customized to apply dflags affecting symbol visibility to
*all* deps with LDC on Windows, something we need for SIL and
plugins on Windows (adding `-fvisibility=hidden` and
`-dllimport=defaultLibsOnly` in lang's dub.sdl). The previous
ldc2.conf tweaks aren't sufficient anymore after
dlang/dub#2412.

See symmetryinvestments/dub@0158ab3.
kinke added a commit to symmetryinvestments/ldc that referenced this pull request May 12, 2023
…that custom dub

dub was customized to apply dflags affecting symbol visibility to
*all* deps with LDC on Windows, something we need for SIL and
plugins on Windows (adding `-fvisibility=hidden` and
`-dllimport=defaultLibsOnly` in lang's dub.sdl). The previous
ldc2.conf tweaks aren't sufficient anymore after
dlang/dub#2412.

See symmetryinvestments/dub@0158ab3.
kinke added a commit to symmetryinvestments/ldc that referenced this pull request May 14, 2023
…ster with that custom dub

dub was customized to apply dflags affecting symbol visibility to
*all* deps with LDC on Windows, something we need for SIL and
plugins on Windows (adding `-fvisibility=hidden` and
`-dllimport=defaultLibsOnly` in lang's dub.sdl). The previous
ldc2.conf tweaks aren't sufficient anymore after
dlang/dub#2412.

See symmetryinvestments/dub@0158ab3.
kinke added a commit to kinke/dub that referenced this pull request Aug 18, 2023
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
kinke added a commit to kinke/dub that referenced this pull request Aug 19, 2023
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
kinke added a commit to kinke/dub that referenced this pull request Sep 4, 2023
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
kinke added a commit to symmetryinvestments/dub that referenced this pull request Sep 4, 2023
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
kinke added a commit to symmetryinvestments/dub that referenced this pull request Sep 11, 2023
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
kinke added a commit to symmetryinvestments/dub that referenced this pull request Dec 5, 2023
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
kinke added a commit to kinke/dub that referenced this pull request Jan 11, 2024
Example scenarios on Windows:

* If an .exe is linked against druntime/Phobos DLLs (e.g., to enable
  loading other D DLLs, all sharing central druntime/Phobos), all
  static-lib dub dependencies need to be compiled with
  `-dllimport=defaultLibsOnly` too [the default with
  `-link-defaultlib-shared`].
* To make large DLLs with few selective `export`ed symbols work after dlang#2412,
  the implicit flags need to be overridden - for the DLL itself and
  all its static-lib dependencies. This can currently only be
  accomplished by setting the DFLAGS environment variable. This PR
  enables overriding these `dflags` either in the DLL root project/
  config directly, or in some dependency shared by multiple DLLs/
  executables.
  E.g., at Symmetry, we have an .exe with lots of plugin DLLs. All
  plugins and the .exe have a shared dependency, so adding
  `dflags "-fvisibility=hidden" "-dllimport=defaultLibsOnly" platform="windows-ldc"`
  once in the dub.sdl of that shared dependency suffices to compile
  *everything* with those required flags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants