-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement host_flag? macro method, not affected by cross-compilation #9049
Conversation
The `flag?` macro tells you information about the target architecture, but one may need to run a different command at compile time (so *on the host*), and it would be a different command depending on which OS it is.
This makes me wonder if we should be computing all of those things with macros. That said, this needs to also be added to the macro docs (search for def flag? and you'll find it). |
The bad thing here isn't really the macros but the shelling out :) Line 10 in f4b01c8
|
I realized it later, but that also made me think, maybe we should keep it undocumented for now. I don't know if we'll want to keep it, in this shape, or at all. First off, I'm thinking to resolve that particular example above with Then I also noticed that some important use cases are missing with this data representation. E.g. what if I want to check whether host OS differs from target OS? Should I go through every possible pair of flags and check if they're not equal? So yeah, I'm mostly hedging my bets at this point, because this will need a Crystal release before it can be used. |
@oprypin could you please fix the conflict so we can merge this? Thanks! |
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.
I've looked at the previous discussion in #7196 which also touched this. Seems this is on par with what we considered back then 👍
Still have two suggestions to improve this PR (but it's not a necessity).
@@ -11,6 +12,10 @@ class Crystal::Program | |||
@flags ||= flags_for_target(codegen_target) | |||
end | |||
|
|||
def host_flags | |||
@host_flags ||= flags_for_target(Config.default_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.
I'd also suggest to rename Config.default_target
to Config.host_target
because that's what it is.
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.
OK, didn't turn out too big.
Woops, pushed a bad commit previously, should be good now |
The
flag?
macro tells you information about the target architecture, but one may need to run a command at compile time (so on the host), and it would be a different command depending on which OS it is.Example: