-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Replace static if checks for OS and IN_GCC #5772
Conversation
| enum TARGET_OPENBSD = xversion!`OpenBSD`; | ||
| enum TARGET_SOLARIS = xversion!`Solaris`; | ||
| enum TARGET_WINDOS = xversion!`Windows`; | ||
| shared static this() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an improvement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? This is how immutable variables are initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only when their values aren't known at runtime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the plan. :) I made these immutable runtime variables rather than enums because whenever dmd is turned into a cross-compiler, this shared static this can be easily modified to parse the cross-compilation command-line options at runtime and then set the target OS.
I should have mentioned that above, but wanted to make sure it passed the auto-tester first, added that now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the API we want for cross-compiling. All conditions should eventually be moved into target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, the same should also be done for global.params.isXXX too. Now you know all our plans for the target module. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My PR has nothing to do with ldc, which simply ignores these enums for its own runtime variables, and I don't really care what the plans are for ddmd.target. I specifically asked how Daniel planned to get rid of TARGET_* without using similar runtime variables to this PR. That is not answered anywhere in your three replies.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make them compile-time versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just make them compile-time versions.
I did, in one instance below, because of some non-portable code. He's even more against that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not answered anywhere in your three replies.
It is! In the first step.
The first step is to move all uses of TARGET_XXX into the ddmd.target module.
Once that is done then as far as I'm concerned it is gone from the frontend. Because ddmd.target is not a shared/common module.
|
Fixed the style issue and the bug Daniel pointed out, can't do anything about the remaining vague comments. |
|
What I'm trying to convey, is that I doubt any of these changes are going to be usable for the eventual runtime cross-compiling implementation. For example, the GCC varargs special case needs to either be pushed down to the glue layer, homogenized between frontends, or abstracted into The So it is at best, a negligible improvement to a part of the compiler source we plan to remove. |
That's fine, as the goal of this PR is to get rid of
Again, it gets rid of
If choosing Library.factory methods based on the host is wrong, the code is wrong now! All I'm replacing is a version check in As for whether this
It has not been removed and is still relied upon by dmd, though it cannot be used by ldc. If and when it's removed, you can be happy that it's not necessary. |
No, it's not. The code correctly chooses which library type based on the target. The target selection is currently limited to the current host, but that doesn't make selecting the library based on the target any less correct. While I appreciate your effort trying to improve the compiler, this amounts to a style change with a net negative effect (and some incorrect changes thrown in). Since this is not the direction we want to go, I don't see any point in merging these changes just to throw them out later. |
There is no reason for continued use of
Right, that's my point: it was correct but limited to the same target as the host before and it will be correct and limited after this PR, which changes nothing about host/target selection. If it's "wrong" or "incorrect" now, which you keep claiming but cannot back up with anything, it was the same before.
It's not a mere "style change," it's preferred usage by the language designer for the codebase he works on, the compiler. Now, who knows, maybe he doesn't feel as strongly about using
Lol, or it could just be merged now and then thrown out when you actually make those changes? Nah, that would make too much sense. |
|
@joakim-noah - We have a plan to deal with this. However this PR has nothing to do with it. I second the closing. |
There's no reason to change it to something worse just for the sake of changing it.
The cost is small, but so is the gain. The cost is pointless runtime branches and initialization, and replacement of
I don't know how I can be any clearer about this. The library format choice is based on target, not host - it is incorrect to choose based on host, which is what this pull does.
Take it however you like. This change doesn't add any functionality, doesn't fix any bugs, and doesn't get us closer to our design goals. That leaves style changes or churn...
Seems like throwing it out now gets to the same place with less steps. |
It was not always clear because you were not always this specific. We've been around this a couple times: you feel that choosing a target using a host version is "incorrect" but that it's not as bad if laundered through a As for the rest, I agree that |
All stdlib tests pass locally for me on linux/x64, now passed auto-tester too.
Update:
I went ahead and made the OS checks runtime variables because they will be used that way whenever dmd is turned into a cross-compiler for different OSs. However, the OMF/COFF/ELF/MACH library generation modules in the frontend will need to be made portable first, so those are versioned out for now.