-
Notifications
You must be signed in to change notification settings - Fork 133
FIX: building on Windows-ARM64 #391
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
Conversation
|
|
|
As of 6f3a09e I've gotten IDK if the problem lies with how the test fixture was written (#352; installing a local Cython package in editable mode), said test Cython package, or with Cython itself – but I guess that was the original intent behind #390, to make sure that Cython works reliably on the platform so downstream applications can use it. Guess that it's our turn to turn off some tests so that we can proceed. ;) |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
==========================================
+ Coverage 87.56% 90.25% +2.68%
==========================================
Files 18 20 +2
Lines 1641 2073 +432
Branches 348 447 +99
==========================================
+ Hits 1437 1871 +434
- Misses 149 151 +2
+ Partials 55 51 -4 see 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
|
From a quick look, you may have been failing to link to the Python library I think. Although I'm not sure why. I don't think there's huge issues with Cython on Windows ARM in general. The vast majority of our own test suite works. Apart from the line_profiler test, the only other issue we ran into was an MSVC compiler bug when constructing large tuples or lists, which affected 2 or 3 tests. |
|
... you're right, in hindsight it should've been obvious that (most of) Cython works as intended since the build for In any case thanks for the input and for writing the initial issue! * The caveat of course being that the wheel builds EDIT: crucial typo... but you probably guessed what was meant anyway. |
|
I will need to think about how to incorporate this CI change into my xcookie CI templates so I we can continue to maintain this as the CI updates. Shouldn't be too hard. I'm also noticing that we don't seem to have Linux ARM64 builds, and I don't remember if there was a reason they were turned off, or they were just never enabled. |
|
Yes - if I point our CI at this patch commit then it runs successfully (at least on 3.13; we skip most profiling on 3.12 because it was awkwardly caught between the old system and sys.monitoring, but that isn't your fault...) |
This reverts commit 3d47c90.
|
A couple things:
EDIT: and of course building more Linux wheels will probably lengthen the pipeline duration (by 50% since we're building and testing for one more |
|
Hold on, I noticed that for some reasons we stopped building Linux-i686 wheels after merging #369. Was that because of the |
line_profiler/c_trace_callbacks.h
Outdated
| } _Py_atomic_int; | ||
| # define _Py_atomic_load_relaxed(foo) (0) | ||
| # define _Py_atomic_store_relaxed(foo, bar) (0) | ||
| # include "internal/pycore_interp.h" |
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 line 51 is included, and then included again unconditionally on 53.
.github/workflows/tests.yml
Outdated
| CIBW_ARCHS_LINUX: ${{ matrix.arch }} | ||
| CIBW_ENVIRONMENT: PYTHONUTF8=1 | ||
| PYTHONUTF8: '1' | ||
| # `msvc-dev-cmd` sets this envvar, which intereferes with |
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.
| # `msvc-dev-cmd` sets this envvar, which intereferes with | |
| # `msvc-dev-cmd` sets this envvar, which interferes with |
line_profiler/c_trace_callbacks.h
Outdated
| volatile int _value; | ||
| } _Py_atomic_int; | ||
| # define _Py_atomic_load_relaxed(foo) (0) | ||
| # define _Py_atomic_store_relaxed(foo, bar) (0) |
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.
So explain to me again why we are defining these here. Is anything in our library actually using these structures, or is this all just to make the compiler happy and ultimately this code is unused?
IIUC, maybe it makes sense to make these fail a little louder if they are ever used?
Would something like this make sense?
/* If any stub is referenced, fail the build with an unresolved external.
* This ensures we never ship wheels that "use" these placeholders. */
#ifdef _MSC_VER
__declspec(dllimport) void lp_link_error__stubbed_cpython_atomic_LOAD_relaxed_was_used_this_is_a_bug(void);
__declspec(dllimport) void lp_link_error__stubbed_cpython_atomic_STORE_relaxed_was_used_this_is_a_bug(void);
#else
extern void lp_link_error__stubbed_cpython_atomic_LOAD_relaxed_was_used_this_is_a_bug(void);
extern void lp_link_error__stubbed_cpython_atomic_STORE_relaxed_was_used_this_is_a_bug(void);
#endif
#define _LP_ATOMIC_PANIC_LOAD_EXPR() (lp_link_error__stubbed_cpython_atomic_LOAD_relaxed_was_used_this_is_a_bug(), 0)
#define _LP_ATOMIC_PANIC_STORE_STMT() do { lp_link_error__stubbed_cpython_atomic_STORE_relaxed_was_used_this_is_a_bug(); } while (0)
/* Panic-on-use shims (expression/statement forms) */
#undef _Py_atomic_load_relaxed
#undef _Py_atomic_store_relaxed
#define _Py_atomic_load_relaxed(obj) ((void)(obj), _LP_ATOMIC_PANIC_LOAD_EXPR())
#define _Py_atomic_store_relaxed(obj,val) do { (void)(obj); (void)(val); _LP_ATOMIC_PANIC_STORE_STMT(); } while (0)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.
- We need
PyInterpreterState's declaration (i.e.struct _is) frominternals/pycore_interp.h. Other than the concrete declaration ofPyFrameObject(frominternals/pycore_frame.h)#includedinPython_wrapper.h, this is the only otherinternals/pycore_*API that we use in the project. - In Python 3.12, said header file
#include internals/pycore_atomic.hand uses these names therefrom:_Py_atomic_addressis directly used in the declaration.- We don't actually need
_Py_atomic_load_relaxed()and_Py_atomic_store_relaxed()per se (they aren't related to the declaration), but the names have to be available because they are used in macros defined below ininternals/pycore_frame.h.
- The header file also
#include internals/pycore_ceval_state.h, which uses_Py_atomic_int.
In principle it's "safe" to keep things as-is since we're only doing this for 3.12, which is ossified at this point. But yes it'd be nicer to have some failsafes.
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.
Thanks for the changes. I think this makes it clearer what the workaround is just by reading the code.
Co-authored-by: Jon Crall <erotemic@gmail.com>
|
Thanks for the review! |
Closes #390... hopefully
pyproject.toml::[tool.cibuildwheel.windows]to also target ARM64.windows-11-armjob for eachwindows-latest(i.e. x64) CI job in.github/workflows/test.yml::test_binpy_wheelsexcept for the following Python versions:3.8, becausecibuildwheeldoesn't support that)3.9and.10, because apparently3.11is the oldest version available on the required machinesline_profiler/c_trace_callback.hto:#undefhacks required on3.12when we're actually on3.12, and only use the#undef HAVE_STD_ATOMIChack on Linux where it is necessarycpython/Include/internal/pycore_atomic.hwhen on3.12 + Windows + ARM64, so that the problematic definitions in said files will not be included by the preprocessorUpdated(EDIT: fixed; it was a CI problem, not a code/test/Cython problem)tests/test_cython.pyso that the tests can be skipped when on Windows-ARM64, which didn't seem to agree with installing Cython packages in an editable manner