Add -versions option to list predefined version identifiers.#1145
Add -versions option to list predefined version identifiers.#1145alexrp wants to merge 1 commit intodlang:masterfrom alexrp:version-list
Conversation
|
Could one of the existing compiler switches be extended to include this information? Maybe -v? Please don't use tdata in new code, array now has an overloaded index operator. |
|
Will fix the indexing. |
|
Fixed. |
|
The compiler will exit by itself if you don't pass any files. I think this is useful, but we could do without more switches. Another option would be to do this inside the compiler as a __trait, you could then output it the list in whatever format you liked. |
Just
I really don't get the aversion to compiler switches. I know we don't want the clutter that e.g. GCC has, but we're far from that anyway. We'd have to add a ton of (Relatedly, maybe we should just consider cleaning up
Doing it in a trait would require a lot more boilerplate though, since we'd then have to keep a separate list of predefined identifiers in addition to the ones defined by the programmer. |
|
Also, there are some downsides to a trait:
|
|
Not sure about the name Regarding doing it as a trait, I am not sure if excluding user-defined (if by "defined by the programmer" you mean command line arguments) is actually desirable. There doesn't seem to be a good reason why you should want one but not the other, especially because they could also be added from the config file/an env var. Why wouldn't you want to know these version identifiers? @yebblies: The compiler will exit immediately if you don't pass any files, yes, but with an error code instead of returning 0. This can be annoying to handle in build systems. |
Because the programmer can cheat:
Maybe |
|
Why should "the programmer" want to trick his own build system into obtaining wrong results? |
|
Oh, but yes, in general, I see how a way to obtain the predefined versions can be useful in build systems, if they want things to »just work« in the user's respective environment. If the patch is accepted, I'll definitely add something similar to LDC. |
An incorrectly configured environment could result in such things. My point is that it's error prone, not that you'd want to actually do it on purpose. ;) Any thoughts on |
|
If the environment is configured incorrectly, then why shouldn't you want to know about it, if you are subsequently going to build your code under the same configuration? |
|
But that's the point, I won't know about it: The build system will just think it's building for ARM while in reality it's building for x86 and then everything blows up at some point in the compilation process (or worse yet, at runtime). If you use the predefined identifiers from the compiler, untouched by the environment, you will always get a sane result and can trivially print a "building for arch FOO" message to the user (that message would be lying if the environment was misconfigured). |
|
No, the point is that it doesn't matter if you know about it, you will be in serious trouble anyway, because your own code (which might contain I certainly would find it very surprising if I ask DMD to print a list of predefined switches, but later discover that another version is active as well during compilation. From a user perspective, there is little to no difference between whether a version is defined in |
|
It doesn't have any advantage unless you're expecting the build system to actually present to the user the list of version identifiers on every build so that they can validate it or, somehow, try to work out if there are contradictory version identifiers in the list (this could never be done reliably enough; Autotools as a whole should be proof of this). Right now, Please clarify if I'm misunderstanding... |
|
Now |
|
ping |
|
Can we please get this into the next release so we can get a better build system story than stone age C? |
|
To satisfy both camps maybe we could print both built-ins and user-defined versions but separate them? e.g. --versions would print: It would take a little bit of text post-processing but it shouldn't hurt much? |
|
But, see, with a design like that, the build system will just deliberately ignore the user-supplied version identifiers. Which means that outputting them has no value at all. |
|
Still not happy with the fact that command line, and thus also dmd.conf, arguments are ignored by design. In my opinion, there are two possible designs for
If I remember correctly, the current patch implements neither of the options, as it completely ignores all parameters, also the ones from sc.ini/dmd.conf. I think there is no reason to do that, as from a build system perspective, they are as much part of the environment as any built-in defaults. For example, consider that an user's compiler configuration file could have |
|
I can somewhat understand wanting to include command line options from the configuration file into the output of |
|
I'm thinking that we are reinventing JSON files badly. Maybe this stuff should be added to the JSON output instead? |
|
No. This is simple information that needs to be queried before a build, not after it. Outputting it to a file would also complicate things a lot, unnecessarily. Suddenly you have to find a place to put the file and then read it rather than just reading the stdout/stderr of dmd. |
|
OT: It's true that for IDEs and build tools JSON output mode would probably be nice. Things such as compile errors/warnings, "-vtls" output etc as JSON written to the console output would make it very easy and fail safe to parse. But this should always be in addition to user readable output, not as a replacement. |
|
This seems controversial. OK to close for now? |
|
I retract my argument that command line flags shouldn't be included in the output for one reason: Given such a change, would this patch be acceptable? If so, I'll revive it. (I'm bringing this back up because I'm writing a build tool at present, and I'm pretty much stuck when it comes to making cross-compiling sane because I can't grab this information from the compiler.) |
|
@alexrp - can you please rebase this taking in @klickverbot 's considerations. Some other notes:
|
|
ping @alexrp |
|
This is good to go with the following changes:
|
|
|
|
Thanks, I didn't realize that. I fine |
|
Yeah, I agree that |
|
Could we use |
|
@mathias-lang-sociomantic |
|
This PR would probably succeed if it had the following:
I'll revive it if someone wants to explain how to accomplish 3. |
|
Note, a PR was merged that added all versions to the output of |
That PR was #7084. Given that, the fact that @alexrp has not voiced a desire to continue pursuing this in quite some time, and the fact that there doesn't appear to be much demand from anyone else, I suggest this be closed. Are there any objections? |
No objections were raised. Closing. |
This is something I find myself desperately needing in my build system; it's much more robust to ask the compiler what the target configuration looks like than trying to do target triple hacks like in Autotools and such.