-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
macOS force arch #556
base: develop
Are you sure you want to change the base?
macOS force arch #556
Conversation
I think a best-effort basis is what we've done for some similar hackery on Windows. It's almost impossible to test this in CI. Is there no way to do this other than trying to run |
I thought pch files were Clang and gch files were GCC, and I found a gch file, but yes I can test. I couldn’t file a cli tool to dump the target of a pch file, so I resorted to invoking it directly. I’ll look at checking bin/stansummary or similar since it’s also arch dependent (while stanc is x86 in any case I think). I’ll get it looking a bit nicer and tested locally at least and then undraft the PR. |
Hi, @maedoc. I just wanted to say thanks again, given that we started from your cmdstan wrapper. Of course, we'll be eager to merge anything that reduces the number of PCH errors we get. |
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 LGTM. I don't think we have any solid way of testing this (see: open request for M1 runners actions/runner-images#2187), but if you're able to confirm it works locally I think that this is the right move.
Do you happen to know if arch
also will effect which C++ compilers get used, etc? E.g., if I have my CXX
variable set to an x86 compiler running under rosetta, what will this change do?
Good point 👍 If the arch of the argument to |
Yeah, unsure how to handle this. I think a simple check that says if the arch of the compiler doesn't match the arch of stansummary, fail with a nice error message? This should only trigger if |
Actually, if all:
file $(shell which $(CXX))
$(CXX) -v with invocations like
all produce the right output. In summary, I think the implemented approach is sound and macOS' behavior is kind-of sane, and so we avoid just the issue of a mismatch between the compiled CmdStan arch and the implicit arch when invoking make from Python. edit for formatting |
I guess the concern is if they installed cmdstan with something set for CXX that is arm64-based, and then later are trying to use a CXX which is x86, won't that lead to the PCH error this PR is trying to avoid? |
Ah I see what you mean. Like building CmdStan with |
It seems like an easy thing to detect and (at least) issue a warning about, though. Would you mind adding that? |
Sure, can you link to an example? I couldn't find anything in the codebase which shows how an CXX is specified. I thought it'd be |
I'm seeing the definition of I think we need to check both |
Here for instance. Is that a typo or it's something else? I can add the check for env var as well yes. |
Yeah that is incorrect. I think the semantics of mypy’s typing mean that it doesn’t notice that because elsewhere it is declared to be Any |
I don't currently have time to finish this (before September at earliest), in case someone else wants to pick it up. |
I’m not sure if we have a cmdstanpy dev with an M1/2 machine, so happy to wait. We can push this out of the 1.0.2 milestone |
Submission Checklist
Summary
This is a WIP to force the architecture for invoking the Make toolchain on macOS, to avoid annoying errors about incompatible PCH files, when running (a) make from arm64 on a x86_64 compiled cmdstan and (b) vice versa.
This is WIP w/o tests yet to ask for initial feedback: (a) is this useful/desirable and (b) does it want full tests (i.e. building two arch copies) or can exist on a best effort basis?
Copyright and Licensing
Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): myself
By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses: