diff --git a/source/dub/compilers/ldc.d b/source/dub/compilers/ldc.d index 8487609..076ab1d 100644 --- a/source/dub/compilers/ldc.d +++ b/source/dub/compilers/ldc.d @@ -150,8 +150,19 @@ settings.lflags = null; } - if (settings.options & BuildOption.pic) - settings.addDFlags("-relocation-model=pic"); + if (settings.options & BuildOption.pic) { + if (platform.isWindows()) { + /* This has nothing to do with PIC, but as the PIC option is exclusively + * set internally for code that ends up in a dynamic library, explicitly + * specify what `-shared` defaults to (`-shared` can't be used when + * compiling only, without linking). + * *Pre*pending the flags enables the user to override them. + */ + settings.prependDFlags("-fvisibility=public", "-dllimport=all"); + } else { + settings.addDFlags("-relocation-model=pic"); + } + } assert(fields & BuildSetting.dflags); assert(fields & BuildSetting.copyFiles); diff --git a/test/1-dynLib-simple/dub.json b/test/1-dynLib-simple/dub.json index 03aa6d8..c7747c3 100644 --- a/test/1-dynLib-simple/dub.json +++ b/test/1-dynLib-simple/dub.json @@ -1,5 +1,4 @@ { "name": "dynlib-simple", - "targetType": "dynamicLibrary", - "dflags-ldc": ["-link-defaultlib-shared", "--fvisibility=public"] + "targetType": "dynamicLibrary" } diff --git a/test/2-dynLib-with-staticLib-dep/.no_build_ldc2 b/test/2-dynLib-with-staticLib-dep/.no_build_ldc2 deleted file mode 100644 index e69de29..0000000 --- a/test/2-dynLib-with-staticLib-dep/.no_build_ldc2 +++ /dev/null