Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

OpenSuse Tumbleweed gcc (v. 5.1.1) -dumpversion issues #25671

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
7 changes: 5 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -527,8 +527,11 @@ def configure_node(o):
o['variables']['clang'] = 1 if is_clang else 0

if not is_clang and cc_version != 0:
o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1]

try:
o['variables']['gcc_version'] = 10 * cc_version[0] + cc_version[1]
except IndexError:

Choose a reason for hiding this comment

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

If we are expecting at least one element then we can do if len(cc_version) == 2: ... else: ...

Copy link
Contributor

Choose a reason for hiding this comment

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

Or:

o['variables']['gcc_version'] = 10 * cc_version[0]
if len(cc_version) >= 2:
  o['variables']['gcc_version'] += cc_version[1]
else:
  print 'Warning: no gcc minor version found, assuming 0'

Choose a reason for hiding this comment

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

Ya something like this. I didn't have a computer at that moment, so couldn't express myself clearly. Sorry.

Copy link
Author

Choose a reason for hiding this comment

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

o['variables']['gcc_version'] = 10 * cc_version[0]
This line always run, because cc_version[0] refers the major version of gcc.
Now I think, we only need to check if cc_version[1] exists. If exists, use your value, if not exists show a warning message. Like the code above.
I've used try .. except because Python encourages use of try.
I've tested if .. else way and my try ... except way, both ways have solved this issue.

Choose a reason for hiding this comment

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

I agree that Python encourages EAFP: Easier to ask for forgiveness than permission. But I wanted to make sure that the code is easily understandable. Anyway I am not going to hold this PR with this discussion. Please continue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed. Will land as is.

o['variables']['gcc_version'] = 10 * cc_version[0]

# clang has always supported -fvisibility=hidden, right?
if not is_clang and cc_version < (4,0,0):
o['variables']['visibility'] = ''
Expand Down