New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue 20244 - New dmd option -preview=noXlinker does not work on Linux to build a simple D application #10438
Conversation
Thanks for your pull request and interest in making D better, @JinShil! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#10438" |
Actually this isn't part of a release, right ? |
Yes will do. |
Actually, the This PR is ready to go. |
…Linux to build a simple D application
Arg! Sorry @thewilsonator . It really is ready now. |
Sounds like the change enabled by this preview flag is going to make it impossible to write a |
IMO a new compiler flag for this rare use case (sending options to the linker driver) would be much more preferable to the breaking change. Also, I should note that there exist solutions to this problem which don't require any change in the compiler at all - simply write your own linker driver which adds the necessary switches, and get DMD to invoke it. This is what Digger has been doing when working around certain problems with building some D versions on some systems. |
The reason I chose not to implement If and when |
You could say that about any breaking change. (Edit: deleted unconstructive rant)
That's a lot of compiler switches. To elaborate on the dmd.conf problem -
In cases 1 and 2, if issue 20244 is anything typical for Linux systems, upgrading DMD is going to break it completely. Right? And, if you fix dmd.conf, you can't downgrade / use older DMD versions again. I hope you will agree that this isn't acceptable. |
In the long term both the |
No, I'm not. I'm trying to fix problems because no one else is. And I don't appreciate being lectured in such a way from spectators.
Agreed. I will look for a different solution and perhaps revert |
Color me an arrogant idiot, but here is what this spectator has observed. Within the last few months, you undertook three projects which you seemed to be completely confident that you were on the right path until it turned out you weren't:
What I'm bothered by is that every time this involved some length of discussion throughout which you were adamant that this was the way to go. I'm sure it can all be attributed to failures in communication, but... well, I'm not sure what to say. Take this particular case: I said nothing new in my last comment, merely elaborated on the problem which I pointed out in my first comment. Nevertheless I'm glad we are in agreement once again. |
I am no dmd expert. But as a happy user of this new feature I did notice the flag was called -preview=noXlinker, and that "preview" is a strong indication to me that it is something entirely new with some barriers to entry. So I find it reasonably acceptable that it is necessary for the user to edit the -L options in the dmd configuration file to get this new feature to work properly right now. And I don't think there is a distro problem since the user of this feature can simply copy the default configuration file to a file he can edit, and then specify that file location with the -conf option. And if a distro becomes an early adopter as a whole, they can certainly put the -preview=noXlinker option in the default dmd configuration file and adjust the -L options in that file for the new -L semantics. So I think this is a good gentle way to introduce this new feature, but assuming after a lot of experience most like these new -L semantics as much as I do, I also like the fact that the plan is this feature will become the default. So hang in there JinShil, and stick to your guns. |
Another aspect of changing the meaning of a linking-related compiler flag is that GDC and LDC frontends (ldmd and gdmd) will need to adjust as well. Probably GDC and LDC maintainers should be included in the discussion.
What do you use it for? Perhaps DMD should just have |
There are something like ~5 dmd bug reports concerning getting access to the C compiler options, and if you read through those the need is for a lot more than just -static. For example, in my case (linking a mixture of C and D code from various static libraries and a D example) I need that access for -pthread (a gcc compiler option [and I think some other compilers as well] that allows gcc to decide on exactly how to link the thread library). For my particular software project http://plplot.org I have noticed there are at least 5 independent external libraries that need to link to the thread library. So that is evidence that the need for the -pthread option is quite common in free software projects. So it is also going to be a common problem for dmd if any of the many free software libraries that are built with -pthread attempt to create a D binding for the static case (as we do). I notice the weight of your continued complaints did help to convince JinShil to revert his work which is not good from my perspective since it means I cannot use dmd to build the D binding to PLplot in the static case. But my hope is he will bounce back with an implementation of the -Xcc option for dmd since that would work for me as well and also satisfy the many dmd bug reports concerning the issue of access to the C compiler options. |
Would this achieve your goal:
? Edit: actually, it's not even necessary to create a file, this should also work:
Though, it does not allow appending options, only prepending them. |
Doesn't compose well, e.g. with
With this approach we'd be condemned to always follow what the underlying driver offers. I share your concerns about breaking code, but the attitude I've witnessed from most users was that they were willing to accept a change that had an upgrade path. E.g. While I haven't always agreed personally with all the changes coming, I'm glad @JinShil challenged some of the features / designs we have. This led, for example, to the deprecation of D1-style operator overloads, which weren't on anyone's radar AFAICS. If anything, we need more people challenging and discussing changes and their implications (like you just did), instead of people blindly merging pull requests. |
It doesn't sound to me like libraries should have much control over how the applications they're used in will be linked. If we allow libraries' dub.sdl files to add linking flags arbitrarily, wouldn't that result in clashes anyway?
Then, what's the problem with
Deprecation allows supporting a range of compiler versions, and when it's introduced, code still continues to work with a warning. A backwards-incompatible change to the meaning of a pre-existing flag will not have the same effect. To remedy this, first, |
That sounds correct, yes. Just to be clear, are you recommending we should go with that, or is that approach problematic ?
Any release that removes a flag could do that, since the default
I don't see how that's workable. Bindings for example have to control how the application they're used in are linked. |
In my opinion, a new switch would be less trouble for everyone, but maybe we should explore the problem a bit more.
True; however, this would be different because it would break versions of
Would it be wrong of me to say that the great majority of bindings simply require linking to the appropriate library? Such as using |
Sorry, but we are going to have to disagree on this one. There is a whole spectrum of attitudes toward welcoming change and adjusting to it, and it appears we are far divided on that. I do agree that changing the -L semantics is a big change. So arguing about whether that change in semantics is an improvement or not is well justified. I happen to think it is an improvement over the "spot rezone" approach with -Xcc since it just makes sense to me to always communicate with the underlying compiler when dealing with linking options because compilers are more powerful linkers (e.g., the -pthread option, but there is quite a few more) than ld. And I think most of the other commentators on these new semantics think it is a well merited change as well. But I don' t think you are arguing about the merits of the new semantics but instead you are concerned about the potential pain to users of this big a change to the -L semantics. And here I disagree again because this early introduction has been gentle (no breakage once the bug I found was fixed except that early adopters of this new feature have to adjust the -L usage in the dmd configuration file they have decided to use). I am also confident that the much later move to adopting these new semantics as default while deprecating the old semantics can be handled smoothly (i.e, with minimal pain to users) as well (e.g., by documenting this change in the semantics in the release notes, updating the man pages and --help results, and by modifying the -L options in the default dmd configuration file according to the new default semantics). But I suspect you don't share my confidence. :-) |
Here is what bothers me about the new behavior itself subjectively:
$ dmd -L-lz test.d
$ gcc -L-lz test.c These are roughly equivalents of the same thing ("pass this flag to the linker"). Even though cc will also understand
When I was just starting with POSIX compilation toolchains many years ago, I remember finding
I think this is a serious aspect of this that you are glossing over. For example some people need to have several DMD versions installed side-by-side; version managers are commonly used with DMD. Of course, users can maintain custom dmd.conf files for every dmd version they need, but we should avoid complications if possible. There is also the issue with non-DMD compilers I mentioned above. For instance, GDC probably does not invoke |
I beg your pardon? This is from the gcc manpage.
|
I already laid out my view on this in the original PR - in short, I'd prefer DMD to adopt A difficulty wrt. That whole Posix mess (abuse C compiler as linker because it's preconfigured for accompanying C libs, startup object files etc.) is the reason LDC's |
GDC is a special case here anyway. We simply reuse the GCC code for linking, which means gdc will behave exactly as gcc does with regards to linker flags. But technically, we never call gcc, we just have exactly the same implementation / share the source code for linker flag handling. |
I beg your pardon? This is from the gcc manpage.
Argh, you're right, sorry... looks like I was still confused about this.
So, that puts me in a very bad place to judge the change, though I still
think we ought to avoid breaking dmd.conf files and linking scripts if we
can.
|
I have already expressed myself in quite general terms about dealing with change. So I plan to say no more on that topic. And I don't know much about dmd so this is likely my last post on this whole topic. However, I do want to take this opportunity to to thank @kinke for implementing the ldc2 -Xcc option which I am already using for my PLplot -pthread needs. So if someone wants to implement the -Xcc option for dmd OR bring back the -review=noXlinker option that worked momentarily for me until it was withdrawn again, that would be fine with me. But please do one or the other and do not leave dmd in its present state (unusable for PLplot for the static libraries case on at least the Linux platform because there is no way to communicate with the underlying C compiler that dmd uses for linking). |
#10439 is still open.
Have you tried |
Here is a draft: master...CyberShadow:pull-20190926-222551 Any thoughts on documenting and submitting that as a PR as a replacement for noXlinker? Edit: Actually, that's what draft PRs are for, submitted: #10441 |
To be clear that PR is a revert of all of -JinShil's work on -review=noXlinker. And that PR is judged ready to be merged so I have assumed that will happen automatically, but I would be happy to be proved wrong for the reason I expressed in my last post. Enuf said by me as you guys work this issue out. |
@airwin1 Since you have a use case in practice, it would be really helpful if you could continue to work with us to ensure that whatever we come up with works for you. I.e. it would be great if you could check that #10441 helps you achieve the same goal, and tell us what's missing or how it is more helpful than setting the |
Fixed. |
@CyberShadow > [I]it would be great if you could check that #10441 helps you achieve the same goal, and tell us what's missing. Will do. Is #10441 ready for immediate testing, and if so how exactly would you communicate the -pthread option to the C compiler with it? Also, I don't use github except to apply patches from there to a git working directory on my home computer. So is there a convenient way for me to create one giant patch representing your PR that I can apply to current git master HEAD or should I just apply your work with the two patches representing the two separate commits in your PR? (This question is not that urgent when your PR consists of just two commits, but it might become much more urgent if that expands to lots of commits.) Also, I should mention that my use case is a work in progress that is only completely tested (on Linux for a version of PLplot with all components configured for that platform) for gdc, and only tested on that platform for ldc2 with -Xcc and dmd with the current -preview=noXlinker option on the dmd git master branch HEAD for an incomplete version of PLplot with just the D components and one threaded component configured beyond the core C components. (I also have a good preliminary report for a "hello, world" test_d project without -pthread needs for dmd on Darwin (MacPorts)). So everything is looking pretty promising, but I (and the tester with access to MacPorts) still have a lot of work to do to get testing of a completely configured PLplot working on both Linux (with gdc, ldc2, and dmd) and Darwin (MacPorts with dmd). And once all problems on those platforms are fixed, I also have a Windows (MSYS2) tester standing by who is willing to try building dmd on MSYS2 (since that Windows distribution of free software does not supply it) to see if the D components of PLplot work on that platform (which they currently do for virtually all other PLplot components other than D). In sum, it is all looking quite promising, but there is a lot of work for me (and testers on MacPorts and MSYS2) to do until we have a good cross-platform D solution for a fully configured PLplot implemented. Meanwhile, I should be able to do testing of the incomplete PLplot version described above. And I plan to continue such testing (and also testing of ldc2) as your PR matures and our build-system configuration of threading and our D component matures. But I really must greatly reduce my commenting here so I can get to grips with all the PLplot work I have just promised to do. :-) |
I think so, yes.
Yes! https://patch-diff.githubusercontent.com/raw/dlang/dmd/pull/10441.diff contains the condensed diff for all commits in the PR.
You may find it easier to check out the PR branch. $ cd .../dlang/dmd
$ git remote add --fetch CyberShadow https://github.com/CyberShadow/dmd
$ git checkout pull-20190926-222551 Also, if I may plug a personal project - you can get, build and run DMD + dependencies using Digger with one command: $ digger run master+dmd#10441 -- dmd -Xcc=-pthread ...
That sounds pretty great. I'm not sure what our situation with MSYS2 or other POSIX environments on Windows is right now though. |
I have had some initial testing success with #10441, and see that PR for more details concerning those test results and an easy way for you to replicate them for yourself. |
No description provided.