[Issue 7044] Missing a way to control the order of arguments passed to the linker makes impossible to link some programs
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 15 08:31:51 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=7044
--- Comment #48 from Leandro Lucarella <leandro.lucarella at sociomantic.com> ---
(In reply to Walter Bright from comment #44)
> > How is this then different from just specifying a whole new config file?
>
> Because multiple sections can be selected, rather than having a separate
> config file for each combination of sections, which would be a combinatorial
> explosion.
I don't see how this could explode, as you only need 2: normal and debug. But
maybe I'm just looking at my limited use case...
> > The user should be required to just use -debug when he wants to use the debug version of the library,
>
> I agree, but I'd like to try this out first to see what the common usage
> patterns will be, and then adding those later. If we add them now, we may
> wind up with a bunch of useless clutter that we cannot remove because we
> don't want to break legacy makefiles.
OK, I can see your concern and conservative approach to the problem. In our
particular case, is not something we can test really, to test it you are
breaking all our makefiles anyway, as we need to add the new extra flags for
the case where we want to build a debug version, so the "do not break the users
build system" is not working very well with this approach :)
> > getting rid from automatic linker flags inserted by compiler and make it fully controllable by packager (preferrably via dmd.conf) instead. This is actual issue that needs to be solved
>
> Linker flags can already be specified with the -L switch. The trouble is the
> order of them. I just do not have a good idea for that, and yet still have
> the compiler conveniently generate them. It's also good to keep in mind that
> all dmd does is generate a command line for gcc - that can always be done by
> the user.
Again, this is not a satisfactory solution. We are not talking about users code
here, we are using about the runtime. You can't ask the user to link manually
just because the compiler can't let the runtime pick the right linker flags to
compile a simple hello world.
> Pull 497 does add a switch to add linker switches in front, but I feel this
> is simply doomed - what happens when a linker switch is needed in the middle?
Yeah, I agree the current approach suggested here is superior, is just for me
the solution is not that useful unless you have a section automatically
selected when -debug is used.
Let's recap the current problems/facts:
* The compiler automatically adds some -llib to the linker command-line,
hardcoded with a particular order. This is not good because it highly depends
on the runtime implementation, so it shouldn't be done by the compiler.
* The compiler links against 2 different libraries depending on whether -debug
was specified or not (and according to -defaultlib and -debuglib). So if the
runtime uses different libraries in debug and default mode, it might need to
pass different linker flags.
About the solution, I think the requirements are:
* There should be no user intervention to be able to compile a program only
depending on the runtime/base library, either using -debug or not (all the
linker flags configuration should be set by the runtime developer/packager via
configuration files).
Do we at least agree on these basic problems and requirements for a solution?
--
More information about the Digitalmars-d-bugs
mailing list