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

Bootstrap: detect Windows based on sys.platform #73691

Merged
merged 1 commit into from
Jun 27, 2020
Merged
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
6 changes: 6 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ def default_build_triple():
ostype = require(["uname", "-s"], exit=required)
cputype = require(['uname', '-m'], exit=required)

# If we do not have `uname`, assume Windows.
if ostype is None or cputype is None:
return 'x86_64-pc-windows-msvc'

Expand Down Expand Up @@ -236,6 +237,11 @@ def default_build_triple():
if ostype.endswith('WOW64'):
cputype = 'x86_64'
ostype = 'pc-windows-gnu'
elif sys.platform == 'win32':
# Some Windows platforms might have a `uname` command that returns a
# non-standard string (e.g. gnuwin32 tools returns `windows32`). In
# these cases, fall back to using sys.platform.
return 'x86_64-pc-windows-msvc'
Copy link
Member

Choose a reason for hiding this comment

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

Hm, is there a reason not to directly compare with windows32 here? (FWIW windows32 to me sounds like a 32-bit platform, but maybe that's historical baggage or something?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's historical baggage of the gnuwin32 tools (they also return i686-pc for uname -m even on a 64-bit system). I didn't find a 64-bit equivalent, so this is probably not a reliable way to determine the actual architecture.

My thinking here was to provide a default for Windows platforms with any non-standard uname value (same as not having uname), but I can certainly change this to a direct comparison with windows32. What would be best?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, so I think this is probably fine -- we can always limit the scope later, if necessary, or add more conditionals.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review!

else:
err = "unknown OS type: {}".format(ostype)
sys.exit(err)
Expand Down