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

add solaris rustbuild support #39759

Merged
merged 4 commits into from
Feb 13, 2017
Merged
Show file tree
Hide file tree
Changes from 3 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
17 changes: 16 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def build_triple(self):
try:
ostype = subprocess.check_output(['uname', '-s']).strip().decode(default_encoding)
cputype = subprocess.check_output(['uname', '-m']).strip().decode(default_encoding)
except (subprocess.CalledProcessError, WindowsError):
except subprocess.CalledProcessError:
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps this could remain the same? (or does it break solaris?)

Copy link
Contributor Author

@binarycrusader binarycrusader Feb 12, 2017

Choose a reason for hiding this comment

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

It can remain the same if you wish, it does not break Solaris (which is how I missed it the first time). Well, it doesn't break it when it works, but it could break if that error case is tripped. Let me check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, as I suspected if the execution of 'isainfo' fails then Python will trip over the Exception handler at runtime:

Traceback (most recent call last):
  File "./x.py", line 20, in <module>
    bootstrap.main()
  File "/builds/srwalker/rsdev/rust.git/src/bootstrap/bootstrap.py", line 492, in main
    rb.build = rb.build_triple()
  File "/builds/srwalker/rsdev/rust.git/src/bootstrap/bootstrap.py", line 358, in build_triple
    except (subprocess.CalledProcessError, WindowsError):
NameError: global name 'WindowsError' is not defined

...and annoyingly, despite pydoc's claims otherwise, Python doesn't raise CalledProcessError here; it raises an OSError() (if the command is missing for some reason). My guess is that it will only raise CalledProcessError() if execution of the command returns failure, as opposed to being unable to execute the process at all. So this should actually catch both CalledProcessError and OSError. I will apply that fix and your other requested change and try the full build again.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah so this clause was added in ad88d50 specifically for Windows, so it'd be great to at least have the Windows behavior here stay the same (although I'm not sure how to do that best)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WindowsError is just a subclass of OSError, so that would be the portable equivalent:

exception WindowsError
Raised when a Windows-specific error occurs or when the error number does not correspond to an errno value. The winerror and strerror values are created from the return values of the GetLastError() and FormatMessage() functions from the Windows Platform API. The errno value maps the winerror value to corresponding errno.h values. This is a subclass of OSError.

So I'll just change it to use that, avoiding the portability issues entirely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, as of Python 3.3, WindowsError was merged into OSError, so this definitely seems like the right fix:

Changed in version 3.3: EnvironmentError, IOError, WindowsError, socket.error, select.error and mmap.error have been merged into OSError, and the constructor may return a subclass.

if sys.platform == 'win32':
return 'x86_64-pc-windows-msvc'
err = "uname not found"
Expand Down Expand Up @@ -345,6 +345,21 @@ def build_triple(self):
ostype = 'unknown-openbsd'
elif ostype == 'NetBSD':
ostype = 'unknown-netbsd'
elif ostype == 'SunOS':
ostype = 'sun-solaris'
# On Solaris, uname -m will return a machine classification instead
# of a cpu type, so uname -p is recommended instead. However, the
# output from that option is too generic for our purposes (it will
# always emit 'i386' on x86/amd64 systems). As such, isainfo -k
# must be used instead.
try:
cputype = subprocess.check_output(['isainfo',
'-k']).strip().decode(default_encoding)
except (subprocess.CalledProcessError, OSError):
err = "isainfo not found"
if self.verbose:
raise Exception(err)
sys.exit(err)
elif ostype == 'Darwin':
ostype = 'apple-darwin'
elif ostype.startswith('MINGW'):
Expand Down
2 changes: 2 additions & 0 deletions src/libunwind/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ fn main() {
println!("cargo:rustc-link-lib=gcc_s");
} else if target.contains("openbsd") {
println!("cargo:rustc-link-lib=gcc");
} else if target.contains("solaris") {
println!("cargo:rustc-link-lib=gcc_s");
} else if target.contains("bitrig") {
println!("cargo:rustc-link-lib=c++abi");
} else if target.contains("dragonfly") {
Expand Down