-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add support for building for Windows ARM64 devices #3430
base: dev
Are you sure you want to change the base?
Add support for building for Windows ARM64 devices #3430
Conversation
Filed as internal issue #USD-10450 ❗ Please make sure that a signed CLA has been submitted! |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
CLA sorted - approved by Tim Palmer |
Any reason why the testWrapper.py change you mentioned isn't included here? Otherwise, lgtm |
I figured it was more related to the version of python I have installed ( |
build_scripts/build_usd.py
Outdated
@@ -393,7 +393,10 @@ def RunCMake(context, force, extraArgs = None): | |||
|
|||
# Note - don't want to add -A (architecture flag) if generator is, ie, Ninja | |||
if IsVisualStudio2019OrGreater() and "Visual Studio" in generator: | |||
generator = generator + " -A x64" | |||
if "ARM" in os.environ.get('PROCESSOR_IDENTIFIER'): |
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.
Could the platform
module be used here?
https://docs.python.org/3/library/platform.html#module-platform
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.
(repost from correct account)
It could be, but problems arise when running an emulated x64 version of python (which is easy to do by mistake, as that's what the website gives you by default).
This way checks the name of the processor directly, which is not affected by emulation.
"Python is currently switched off due to lack of support for PySide on these devices. I am looking at that seperately." Hi @anthony-linaro , per our call yesterday, you also mentioned that the python bindings are failing to compile -- can you post the error messages you are seeing there? "I also had to disable imaging, as building boost appears to be broken... " @sunyab , is it expected that the command line
would attempt to build boost in v24.11+ ? Thanks all! |
Hi @asluk - I have tried to reproduce the compilation errors, but am unable, so will chalk it down to an env issue - with things set up properly, I have most of the tests passing. However, when I run
I have attached the output file from the tests to this comment. Are these tests expected to fail? If not, do you have any idea why they might be? All env paths are set as instructed after build ( |
@anthony-linaro I don't think those test failures are expected -- can you try rebasing your branch to be on top of the "dev" branch? That is the most up to date commit. Thanks and happy new year! |
(sorry for the late reply, was out on vacation) Yes, I would expect that to build boost in v24.11+. When imaging is enabled the |
Hi @anthony-linaro, the |
Hi both, thanks for the responses! @sunyab You're right, those python issues are now fixed, thanks to the suggestion from @asluk to merge dev. Sadly, the list of errors has now changed, and I now get this:
I have once again attached the logs: LastTest.log Any suggestions of where I could start to look? It looks like it's not seeing the "Tf" python module. The path variable is correct, and added as specified when building (ie, modified PATH and PYTHONPATH) - is there another one that got missed somewhere? Was there an extra step required between |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
build_scripts/build_usd.py
Outdated
@@ -393,7 +393,10 @@ def RunCMake(context, force, extraArgs = None): | |||
|
|||
# Note - don't want to add -A (architecture flag) if generator is, ie, Ninja | |||
if IsVisualStudio2019OrGreater() and "Visual Studio" in generator: | |||
generator = generator + " -A x64" | |||
if "ARM" in os.environ.get('PROCESSOR_IDENTIFIER'): |
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.
It might be good to follow the convention in apple_utils.py and extract this into GetHostArch https://github.com/PixarAnimationStudios/OpenUSD/blob/release/build_scripts/apple_utils.py#L66
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.
Is the suggestion here to write a whole new windows_utils.py
(and extract/refactor some things like IsVisualStudioXXXXOrGreater()
which are windows only), or just add a function to build_usd.py
called something along the lines of GetWindowsHostArch()
?
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'm not sure I'd advocate for another file necessarily (though it is the route I would take myself)
But just extracting the heuristics for detecting arm into a function somewhere in this file itself should be fine?
I just imagine that in the future, we'll need to modify the build parameters for certain dependencies etc based on the current arch, and so it'd be nice to have it as a function from the get go.
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 have now moved it out to a seperate function - it should now reliably detect ARM or x64
Critique very much welcome - I've never been much of a python dev
I didn't add support for ARM64EC, as I didn't have a use-case for it - if
you guys have one internally I'm unaware of, I can try and add support.
The biggest issue with ARM64EC will likely be around the use of any
intrinsics - as it defines both _M_ARM64EC, and _M_X64, use of intrinsics
that could be considered "safely" gated behind _M_X64 (or similar) are
suddenly not so safe, so I'd need to go over the source with a fine tooth
comb. Not impossible, but requires substantially more work than a plain old
ARM64 enablement.
|
That's fair. At the very least, I'd suggest then adding a caveat to the README somewhere to document that EC isn't supported yet? |
Also mention incompatibility with ARM64EC
Good idea - I have updated the README.md file to reflect the work done on this PR |
/AzurePipelines run |
Azure Pipelines successfully started running 1 pipeline(s). |
I think the testUsdResolverExample failure is expected, and/or might need the example resolver to be bootstrapped in PATH and PYTHONPATH as well (@sunyab or @pmolodo , do you remember the incantation for that?) @tallytalwar , looks like the usdchecker rules are failing (also affects testUsdUtilsCreateNewUsdzPackageEditInPlace), but I'm not sure why-- does anything in the log stand out to you or have a clear root cause in your experience? (e.g., Shader </World/simpleMaterial/boardMat/PBRShader> has invalid shader node. (fails 'ShaderPropertyTypeConformanceChecker')) It's not clear to me what the testPlug failure is. |
@asluk all the usdchecker tests (both old <13 and new framework >=13) are failing because its not able to find any of the usdShaders, example UsdPreviewSurface etc in sdr: New compliance checker failing here: https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/usdValidation/usdShadeValidators/validators.cpp#L341-L353 Both these point to a build issue which is not picking up some plugins example, usdShaders here: https://github.com/PixarAnimationStudios/OpenUSD/tree/dev/pxr/usdImaging/plugin/usdShaders Maybe the testPlug failure also points to that :/ |
Thanks @tallytalwar ! Is there something additional in PATH or PYTHONPATH etc that @anthony-linaro needs to do to detect the shaders? @anthony-linaro , can you post the relevant bits from your PATH and PYTHONPATH when running tests? |
Ahh I see.. I think the "--no-imaging" arg to the build script doesn't build pxr/usdImaging which is where these shader plugins live. From the PR description:
|
Thanks @tallytalwar .... @anthony-linaro , those failures are expected then ... @tallytalwar , is it worth a separate PR disabling some cases in the usdchecker tests when Imaging is not enabled in the build? |
@asluk yes definitely. I was planning to do that, but a PR will also be appreciated. Will sync it in for internal consumption promptly. |
So, we would consider this ready to go then? Or is there a requirement to fix the imaging first? |
@anthony-linaro can you try running just testPlug to see if you can get more output from it? something like ctest -R testPlug Overall I think this is generally ready to go, but defer to @sunyab as to next steps. Thanks all! |
@asluk Full output:
|
Thanks @anthony-linaro -- I can't think of something that would cause this, and I don't think that the warning is what is causing the failure. Also I'd expect many more tests to be broken if plugins were broken. @sunyab , any ideas on how we can get more diagnostics on the failure? Maybe run with TF_DEBUG=PLUG* in the environment? Thanks! |
@anthony-linaro can you set TF_DEBUG to be "PLUG*" in the environment ? Here is my LastTest.log file that gets output from ctest, when running the test successfully on Windows x86_64 |
@asluk Attached: Looks like it's failing on |
Thanks @anthony-linaro -- I suspect it's something else-- I do see usdShadeValidators in your output so I wonder if it's what @tallytalwar suspects as well, that running the tests in a no-imaging build will fail due to the shaders not being available. I'll try to repro on Windows x86_64 with imaging disabled. |
There's an open issue for checkers failing without imaging for reference |
confirmed that testPlug does pass for me with a --no-imaging --tests build on Windows x86_64 with python 3.11 -- I am at commit 67e851b , which is the current Pixar "dev" branch -- @anthony-linaro , can you rebase on top of that? (these tests fail for me) The following tests FAILED: |
All tests pass for me with --imaging with python 3.10 in dev, windows x86_64 with python 3.11 in dev, windows x86_64 these --imaging tests fail The following tests FAILED: @anthony-linaro , if testPlug still fails for you after rebasing, can you try commenting out blocks of test_ErrorCases in testPlug.py until it passes, to keep zeroing in on specifics? It looks like TestPlugDsoUnloadable is expected to fail to load, but not to crash, and I'm not sure if any ARM64 specifics with how TestPlugDsoUnloadable gets compiled may be in play-- these compiler flags may need tweaking for ARM64 - https://github.com/PixarAnimationStudios/OpenUSD/blob/dev/pxr/base/plug/CMakeLists.txt#L105 |
small update-- I am now getting the same test results with --imaging builds on Windows x86_64 with python 3.10 and 3.11 in the dev branch -- testUsdZipFile , testUsdviewNavigationKeys , and testUsdResolverExample are the known failures for that. (My previous python 3.10 test run was implicitly excluding tests that are known to fail on Windows). testPlug is the only real test that needs further investigation in this PR, and I think the approach I recommended for zeroing in on the error cases and compiler flags for the deliberately "bad" plugins being processed in that test should get the PR over the hump. all the other failing tests in the PR are from the missing usdShaders in --no-imaging builds, that is tracked in #3055 |
@asluk My error list after merging dev now looks like:
So looks like |
thanks for the update @anthony-linaro -- yep, I think once you start disabling error cases in testPlug.py, we'll get a more targeted sense of the actual severity and root causes of what it's reporting -- cc @sunyab 🙏🏼 |
I've spent an amount of time debugging this, and have narrowed it down to an interesting difference in behaviour, which I'm not entirely sure on why it's happening - I will continue to try and debug, but thought I would update here. The issue is actually coming from the On ARM64 however, there is an I'm not entirely sure what's going on here - by all documentation, this function should just fail, and return |
Thanks for digging into it @anthony-linaro -- I suspect someone from Microsoft would have more info on why the exception is not being caught. If you comment out
does the rest of testPlug pass? If so, @sunyab , is there a way to conditionally skip that case behind some sort of Arch query in Python? |
Sure, that test case could certainly be skipped over using the same logic to detect whether we're in a Windows ARM64 environment as in build_usd.py -- we wouldn't need anything from the Arch library itself (which isn't wrapped to Python anyway). The main trickiness with TestPlugDsoUnloadable is its intentional use of an unresolved external symbol. I didn't see anything in the LoadLibrary docs that explicitly mention that loading such a library will result in the function returning NULL, so I guess technically its undefined behavior? At the same time, it feels like it'd be pretty weird if the behavior differed between ARM and x64 for this particular case. One thing I'm kind of curious about is whether moving this code in OpenUSD/pxr/base/plug/testenv/TestPlugDsoUnloadable.cpp Lines 22 to 23 in 6284755
to within the TF_REGISTRY_FUNCTION block here:
makes a difference. I have no real reason to think it should, I'm just throwing stuff against the wall. |
The intended behaviour of the function is mentioned here:
https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya#return-value
The intention, as I understand it, is that you call the function, and if it
returns a null pointer, then you call "GetLastError()" for more
information. This is how it has worked when I have used it previously (for
example, if a DLL had a DEPENDENTLOADFLAG=0x2000, which I encountered last
week). Catching an access violation exception from inside a Win32 API would
be unusual, AIUI, as they are designed to be called from C, too.
Perhaps it is undefined behaviour, but the documentation doesn't make it
clear either way.
I will try the rearrangement inside the plugin tomorrow.
Oddly - this all seems to happen before testPlug - in my testing I even
went as far as emptying testPlug.py of anything but a "hello world" print,
yet I still hit the error. Is the python compiled, and so requires a
rebuild for changes to apply? There is also the possibility I did something
wrong there, of course
|
@anthony-linaro , yes OpenUSD needs to be incrementally "rebuilt" in order for modified tests to get re-installed to the location from which they are run. |
Description of Change(s)
Add support for Windows ARM64 devices.
This was tested using the following command line:
Python is currently switched off due to lack of support for PySide on these devices. I am looking at that seperately.
I also had to disable imaging, as building boost appears to be broken when using newer CMake versions (similar issue to #3285)
TBB is set to OneTBB, as 2020u3 doesn't support these devices.
I also had to make a small modification in
testWrapper.py
, and change line 134 topathPattern = pathPattern + r'(\S*)'
, as otherwise the escape sequence was invalid.Checklist
[x] I have created this PR based on the dev branch
[x] I have followed the coding conventions
[ ] I have added unit tests that exercise this functionality (Reference:testing guidelines)
[x] I have verified that all unit tests pass with the proposed changes
[x] I have submitted a signed Contributor License Agreement (Reference:
Contributor License Agreement instructions)