mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-04-12 06:49:02 +02:00
Fixed #66 — -shared do not set a SONAME
This commit is contained in:
@@ -110,6 +110,12 @@ cl::opt<std::string> objectDir("od",
|
||||
cl::Prefix,
|
||||
cl::desc("Write object files to directory <objdir>"));
|
||||
|
||||
cl::opt<std::string> soname("soname",
|
||||
cl::value_desc("soname"),
|
||||
cl::Hidden,
|
||||
cl::Prefix,
|
||||
cl::desc("Use <soname> as output shared library soname"));
|
||||
|
||||
|
||||
// Output format options
|
||||
cl::opt<bool> output_bc("output-bc",
|
||||
|
||||
@@ -28,6 +28,7 @@ namespace opts {
|
||||
extern cl::opt<bool> dontWriteObj;
|
||||
extern cl::opt<std::string> objectFile;
|
||||
extern cl::opt<std::string> objectDir;
|
||||
extern cl::opt<std::string> soname;
|
||||
extern cl::opt<bool> output_bc;
|
||||
extern cl::opt<bool> output_ll;
|
||||
extern cl::opt<bool> output_s;
|
||||
|
||||
@@ -278,8 +278,6 @@ int linkObjToBinary(bool sharedLib)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
args.push_back("-o");
|
||||
args.push_back(output.c_str());
|
||||
|
||||
@@ -315,14 +313,17 @@ int linkObjToBinary(bool sharedLib)
|
||||
}
|
||||
|
||||
// default libs
|
||||
bool addSoname = false;
|
||||
switch(global.params.os) {
|
||||
case OSLinux:
|
||||
addSoname = true;
|
||||
args.push_back("-lrt");
|
||||
// fallthrough
|
||||
case OSMacOSX:
|
||||
args.push_back("-ldl");
|
||||
// fallthrough
|
||||
case OSFreeBSD:
|
||||
addSoname = true;
|
||||
args.push_back("-lpthread");
|
||||
args.push_back("-lm");
|
||||
break;
|
||||
@@ -345,6 +346,16 @@ int linkObjToBinary(bool sharedLib)
|
||||
// Assume 32-bit?
|
||||
args.push_back("-m32");
|
||||
|
||||
OutBuffer buf;
|
||||
if (opts::createSharedLib && addSoname) {
|
||||
std::string soname = opts::soname.getNumOccurrences() == 0 ? output : opts::soname;
|
||||
if (!soname.empty()) {
|
||||
buf.writestring("-Wl,-soname,");
|
||||
buf.writestring(soname.c_str());
|
||||
args.push_back(buf.toChars());
|
||||
}
|
||||
}
|
||||
|
||||
// print link command?
|
||||
if (!quiet || global.params.verbose)
|
||||
{
|
||||
|
||||
@@ -419,6 +419,11 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (soname.getNumOccurrences() > 0 && !createSharedLib) {
|
||||
error("-soname can be used only when building a shared library");
|
||||
fatal();
|
||||
}
|
||||
|
||||
// create a proper target
|
||||
Ir ir;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user