Added -shared switch.

If the flag is passed, ldc will create a shared library not an executable file.
This commit is contained in:
Alexey Prokhin
2011-12-06 19:12:38 +04:00
parent 913eda6188
commit 641cc85e64
7 changed files with 61 additions and 21 deletions

View File

@@ -391,7 +391,13 @@ int main(int argc, char** argv)
if (!global.params.obj || !global.params.output_o || createStaticLib)
global.params.link = 0;
if (global.params.link)
if (createStaticLib && createSharedLib)
error("-lib and -shared switches cannot be used together");
if (createSharedLib && mRelocModel == llvm::Reloc::Default)
mRelocModel = llvm::Reloc::PIC_;
if (global.params.link && !createSharedLib)
{
global.params.exefile = global.params.objname;
if (files.dim > 1)
@@ -649,6 +655,14 @@ LDC_TARGETS
fatal();
}
if (global.params.os == OSWindows) {
global.dll_ext = "dll";
global.lib_ext = "lib";
} else {
global.dll_ext = "so";
global.lib_ext = "a";
}
// added in 1.039
if (global.params.doDocComments)
VersionCondition::addPredefinedGlobalIdent("D_Ddoc");
@@ -1034,7 +1048,7 @@ LDC_TARGETS
else
{
if (global.params.link)
status = linkObjToExecutable(global.params.argv0);
status = linkObjToBinary(createSharedLib);
else if (createStaticLib)
createStaticLibrary();