Open kinke opened 1 year ago
✅ PR OK, no changes in deprecations or warnings
Total deprecations: 0
Total warnings: 0
Build statistics:
statistics (-before, +after)
executable size=5318488 bin/dub
-rough build time=61s
+rough build time=62s
Example scenarios:
-dllimport=defaultLibsOnly
too [the default with -link-defaultlib-shared
].export
ed symbols work after #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.TODO:
-fvisibility
should be handled identically on Posix platforms, enabling to use hidden visibility for all static-lib deps of some .so/dylib too.FYI @rikkimax @p0nce
Would be super nice to be able to get rid of DFLAGS
tweaking! Thanks.
Our flags are:
"dflags-windows-ldc": ["-mscrtlib=libcmt","-fvisibility=hidden", "-link-defaultlib-shared=false"],
(in adddition to the DFLAGS override as current workaround)
Does -mscrtlib
need to be passed through too?
Does
-mscrtlib
need to be passed through too?
Nope, that flag really only affects linking, not compilation. And I think LDC defaults to static libcmt
with -link-defaultlib-shared=false
, for DLLs too [if an MSVC installation is found].
My one concern (apart from code review), is that this would be better suited to be handled from a pretty significant refactor in the form of placing directives to have the relationship to other packages of just this
, goes up
, goes down
. But since this would be the default, its still a good PR in theory.
no longer draft? in that case also adjust title pls
Rebased, changelog entry added, and not passing stuff down to shared-library deps.
While I fully agree that there would ideally be a generic way of controlling the flags propagation, this automatism solves a number of use cases which can currently only be handled by setting the DFLAGS env variable. As DMD seems to be adopting the relevant LDC switches (-fvisibility
and -dllimport
), the approach could eventually be generalized to DMD too. GDC has -fvisibility
already, so we could include it already (but the main use cases are on Windows).
On Windows.