-
Notifications
You must be signed in to change notification settings - Fork 127
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
Fix: Loading library on Aarch64 fails because pylink attempts to load 32-bit library #182
Changes from 4 commits
59283b6
23ef04e
9481ae0
43f3c01
e73700f
68df019
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -138,6 +138,22 @@ def get_appropriate_windows_sdk_name(cls): | |||||||||||||
else: | ||||||||||||||
return Library.WINDOWS_32_JLINK_SDK_NAME | ||||||||||||||
|
||||||||||||||
@classmethod | ||||||||||||||
def can_load_library(cls, dllpath): | ||||||||||||||
"""Test whether a library is the correct architecture to load. | ||||||||||||||
|
||||||||||||||
Args: | ||||||||||||||
dllpath: A path to a library. | ||||||||||||||
|
||||||||||||||
Returns: | ||||||||||||||
True if the library could be successfully loaded, False if not. | ||||||||||||||
""" | ||||||||||||||
try: | ||||||||||||||
ctypes.CDLL(dllpath) | ||||||||||||||
return True | ||||||||||||||
except: | ||||||||||||||
return False | ||||||||||||||
|
||||||||||||||
@classmethod | ||||||||||||||
def find_library_windows(cls): | ||||||||||||||
"""Loads the SEGGER DLL from the windows installation directory. | ||||||||||||||
|
@@ -202,6 +218,8 @@ def find_library_linux(cls): | |||||||||||||
|
||||||||||||||
for fname in fnames: | ||||||||||||||
fpath = os.path.join(directory_name, fname) | ||||||||||||||
if not cls.can_load_library(fpath): | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this check actually occur after the OS check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, should only be checked on 64 bit OSes. Changed |
||||||||||||||
continue | ||||||||||||||
if util.is_os_64bit(): | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
if '_x86' not in fname: | ||||||||||||||
yield fpath | ||||||||||||||
|
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 there a specific error we could catch here instead of a raw
except
?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.
Let's try catching
OSError
, that's what we get in this scenario