Skip to content

Commit

Permalink
Catch Python exception in the event alignment can't be converted to int
Browse files Browse the repository at this point in the history
The user almost certainly has to be using a compiler wrapper script that
doesn't actually work if we land here.

Fixes: mesonbuild#12982
  • Loading branch information
tristan957 committed Apr 25, 2024
1 parent 3a94aef commit 0a432f1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mesonbuild/compilers/mixins/clike.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,9 +625,17 @@ def alignment(self, typename: str, prefix: str, env: 'Environment', *,
raise mesonlib.EnvironmentException('Could not compile alignment test.')
if res.returncode != 0:
raise mesonlib.EnvironmentException('Could not run alignment test binary.')
align = int(res.stdout)
if align == 0:
raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.')

align: int
try:
align = int(res.stdout)
if align == 0:
raise mesonlib.EnvironmentException(f'Could not determine alignment of {typename}. Sorry. You might want to file a bug.')
except ValueError:
# If we get here, the user is most likely using a script that is
# pretending to be a compiler.
raise mesonlib.EnvironmentException('Could not run alignment test binary.')

return align, res.cached

def get_define(self, dname: str, prefix: str, env: 'Environment',
Expand Down

0 comments on commit 0a432f1

Please sign in to comment.