Implement --use-shared-defaultlib switch#1305
Implement --use-shared-defaultlib switch#1305mihails-strasuns wants to merge 1 commit intoldc-developers:masterfrom mihails-strasuns:link-both
Conversation
|
Is the proposed API suitable or shall I change it? |
|
Sorry for the lack of replies here so far, this is pretty much unacceptable from our side. People (including me) are generally quite paranoid about command line argument design, as it is something we tend to be stuck with for a long time. I think we will probably end up with something like this switch. DMD instead seems to recognise specially formatted defaultlib/debuglib strings (see below), but I don't think requiring the user to repeat the libraries to use from the config files would necessarily be a good idea. const(char)* libname = global.params.symdebug ? global.params.debuglibname : global.params.defaultlibname;
size_t slen = strlen(libname);
if (slen)
{
char* buf = cast(char*)malloc(3 + slen + 1);
strcpy(buf, "-l");
if (slen > 3 + 2 && memcmp(libname, "lib".ptr, 3) == 0)
{
if (memcmp(libname + slen - 2, ".a".ptr, 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, ".so".ptr, 3) == 0)
{
strncat(buf, libname + 3, slen - 3 - 3);
argv.push(buf);
}
else
{
strcat(buf, libname);
argv.push(buf);
}
}
else
{
strcat(buf, libname);
argv.push(buf);
}
} |
Yes, DMD approach is this regard is rather terrible and I would prefer to avoid anything like that if possible.
So what would be your desired CLI? I don't care how it looks as long as it doesn't require developer to mention library name explicitly. |
Ah, I meant that us leaving this PR without comments is unacceptable, not the PR itself. ;) Regarding alternatives, I'm not too fond of the |
|
Updated to |
|
This surely doesn't work with the MS linker... |
|
I neither have any idea how MS linker works nor have access to it. Someone else will need to implement support for it. |
|
The command-line options reference is on MSDN. ;) Edit: We may also switch to the LLVM linker (lld) at some point, at least on Windows, which apparently already supports COFF objects and PE output (but no debug-info PDBs yet). It can't be as dumb as the MS one. |
|
Signing out for now, please ensure that this goes somewhere, @redstar / @kinke / @JohanEngelen. ;) |
|
Just in case it wasn't clear - I am not planning work on Windows support (and neither see how it is relevant considering vast amount of differences in linking in general), My only interest is fixing a bug report for Arch Linux package. |
|
For me, it would be OK to add this without Windows support for now. It'd be a shame if this is lost and perhaps someone in the future will add Windows support. It'd be good to |
|
Updated:
|
|
@Dicebot I'll see if I can spend some time in updating the CMake scrips for this, so we can automate testing of this PR |
|
btw travis build seems to fail with |
|
@Dicebot Can you rebase onto master? (There is a problem with Travis+LLVM38 that makes all Linux tests fail) |
|
|
Perhaps the GNU equivalent option Edit: with "GNU equivalent" I meant that GNU's ld accepts both -Bstatic and -static and they do the same thing. |
Partially fixes #1282 Allows to force linking to shared version of standard library if both lphobos2.so and lphobos2.a are present
|
Rebased. MacOS looks tricky if http://www.manpages.info/macosx/ld.1.html data is correct. It implies MacOS |
|
If it also doesn't work on Mac, I think @kinke is right and it is better solved with an extended config file, with different names for the shared and static libraries so that no special linker flag is needed. |
|
Right now ldc config looks like it only provides already existing command-line switches, for example mine looks like this: How would you envision changing it? |
|
I don't know. :/ |
|
Iirc, @redstar proposed something in the past. Something like a |
|
I want to resurrect this but would be nice to have approved config file design first because I keep disliking everything I come up with myself :) So right now I have something along these lines: ... which seems to allow switching between shared/static modes in 100% cross-platform fashion, but:
Any ideas? |
|
Anyone? :( |
|
Do we really need the flexibility to specify the names of the stdlibs? I'd rather tend towards using a fixed, hardcoded scheme. |
|
This in combination with an extended commandline interface to select 1 of the 4 stdlib flavours. |
|
The 32/64 bit issue on Windows (can't specify both 32-bit and 64-bit lib directories and have the linker ignore incompatible libs) has been solved by an extended config file, allowing to specify the default commandline options on a per triple basis. E.g., the Windows CI multilib config looks like this: This could obviously be further extended by pattern-matching/allowing wildcards in the triples, but it's sufficient for now. |
Not sure. I wouldn't be surprised if some of more strict distributions like Debian require specific naming style for all packaged libraries but I don't know certainly. Maybe @ximion can advise.
How would that interact with existing |
It could be deprecated (and ignored). |
|
Sounds good to me but I'd like to hear confirmation from at least one more person from LDC team before proceeding with deprecating (any) functionality :) |
We usually don't require any specific naming (unless of course there are name clashes between two projects). Since D doesn't have an ABI GDC and LDC both obey, we do need different names for all D libraries depending on whether they are compiled with LDC or GDC (which really sucks a lot). |
|
Closing in favor of #1735 |
Partially fixes #1282
Allows to force linking to shared version of standard
library if both lphobos2.so and lphobos2.a are present
Sadly, my cmake knowledge is below zero so I can't tweak build to
generate both targets at the same time but I can workaround it by
building LDC twice in package script.