Closed Bug 1337895 Opened 3 years ago Closed 3 years ago
Allow cross-compiling rust crates
59 bytes, text/x-review-board-request
Right now if you try to do a linux32 taskcluster build, the job runs on a linux64 machine in AWS, so we are effectively cross-compiling from linux64 to linux32. If you then try to build rust code that uses the pkg-config crate, it fails because in the default configuration pkg-config throws an error if it detects cross-compilation . Right now we're not hitting this scenario in any of our builds, but if we try to enable 32-bit linux QuantumRender builds, we hit this problem. An example error can be seen in bug 1336479 comment 1. I suspect the mozjs-sys crate will have the same problem if built for linux32 in automation, because it also uses libc which uses pkg-config. The solution seems to be pretty simple: set the PKG_CONFIG_ALLOW_CROSS=1 environment variable, and pkg-config is happy. I verified that doing this fixes the linux32-qr builds as well.  https://hg.mozilla.org/mozilla-central/file/5e17f9181c6c/third_party/rust/pkg-config/src/lib.rs#l82
froydnj and I were talking about something similar on IRC yesterday--we should find a way to ensure that -sys crates we're linking aren't pulling in extraneous copies of libs that we already have in Gecko, or adding new dependencies on system libraries. For example, the mozjs-sys crate uses libz-sys, and Gecko already ships a zlib. That might be fine for standalone JS builds, but for Gecko we should definitely not be linking against system zlib.
That seems a bit orthogonal, but I agree. In the case of extraneous copies of libs that we already have, I guess it's up to whoever is adding the code, or the reviewer, to catch that and try to avoid it. In the webrender case we were at one point pulling in servo-freetype-sys which is all of freetype. We no longer do that - we discovered we didn't really need it for anything and so we were able to add a feature that made that dependency optional. In the "linking against system libs" case again for webrender we have that problem, and we had to explicitly add stuff to a moz.build file  to allow the build to work. I presume these cases should be easier to catch since it requires explicitly capturing.  http://searchfox.org/mozilla-central/rev/672c83ed65da286b68be1d02799c35fdd14d0134/toolkit/library/moz.build#389
Comment on attachment 8835027 [details] Bug 1337895 - Make the pkg-config rust crate happy when cross-compiling. https://reviewboard.mozilla.org/r/110730/#review112104
Attachment #8835027 - Flags: review?(nfroyd) → review+
Pushed by email@example.com: https://hg.mozilla.org/integration/autoland/rev/43233b308b2d Make the pkg-config rust crate happy when cross-compiling. r=froydnj
You need to log in before you can comment on or make changes to this bug.