Skip to content

Commit

Permalink
use -Bstatic -lphobos2 -Bdynamic rather than -l:libphobos2.a
Browse files Browse the repository at this point in the history
- the latter is only supported on newer versions of ld
  • Loading branch information
MartinNowak committed Aug 28, 2015
1 parent f0879ea commit 94c66ea
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions src/link.d
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,34 @@ extern (C++) int runLINK()
{
char* buf = cast(char*)malloc(3 + slen + 1);
strcpy(buf, "-l");
/* Use "-l:libname.a" if the library name is complete
*/
if (slen > 3 + 2 && memcmp(libname, cast(char*)"lib", 3) == 0 && (memcmp(libname + slen - 2, cast(char*)".a", 2) == 0 || memcmp(libname + slen - 3, cast(char*)".so", 3) == 0))

if (slen > 3 + 2 && memcmp(libname, cast(char*)"lib", 3) == 0)
{
if (memcmp(libname + slen - 2, cast(char*)".a", 2) == 0)
{
argv.push("-Xlinker");
argv.push("-Bstatic");
strncat(buf, libname + 3, slen - 3 - 2);
argv.push(buf);
argv.push("-Xlinker");
argv.push("-Bdynamic");
}
else if (memcmp(libname + slen - 3, cast(char*)".so", 3) == 0)
{
strncat(buf, libname + 3, slen - 3 - 3);
argv.push(buf);
}
else
{
strcat(buf, libname);
argv.push(buf);
}
}
else
{
strcat(buf, ":");
strcat(buf, libname);
argv.push(buf);
}
strcat(buf, libname);
argv.push(buf); // turns into /usr/lib/libphobos2.a
}
// argv.push("-ldruntime");
argv.push("-lpthread");
Expand Down

0 comments on commit 94c66ea

Please sign in to comment.