Skip to content
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

arch: patch compiler version #2297

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions devito/arch/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,6 @@ def __init__(self, **kwargs):
else:
raise NotImplementedError("Unsupported platform %s" % platform)

if self.suffix is not None:
try:
self.version = Version(str(float(self.suffix)))
except (TypeError, ValueError):
self.version = Version(self.suffix)
else:
# Knowing the version may still be useful to pick supported flags
self.version = sniff_compiler_version(self.CC)

self.__init_finalize__(**kwargs)

def __init_finalize__(self, **kwargs):
Expand All @@ -237,6 +228,21 @@ def __new_with__(self, **kwargs):
def name(self):
return self.__class__.__name__

@property
def version(self):
if self.suffix is not None:
try:
version = Version(str(float(self.suffix)))
except (TypeError, ValueError):
version = Version(self.suffix)
else:
try:
# Knowing the version may still be useful to pick supported flags
version = sniff_compiler_version(self.CC)
except (FileNotFoundError, OSError):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case of FileNotFoundError a sys.exit() will be called inside sniff_compiler_version and the program will abort, so we might have to tweak that too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we just remove this try-except and wait for the next use case to break

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to something bit simpler

version = Version("0")
return version

def get_version(self):
result, stdout, stderr = call_capture_output((self.cc, "--version"))
if result != 0:
Expand Down Expand Up @@ -945,6 +951,13 @@ def __lookup_cmds__(self):
self.MPICC = environ.get('MPICC', self.MPICC)
self.MPICXX = environ.get('MPICXX', self.MPICXX)

@property
def version(self):
"""
Custom compiler are assumed to be self-contained, hence no version.
"""
return Version("0")

def __new_with__(self, **kwargs):
return super().__new_with__(base=self._base, **kwargs)

Expand Down
Loading