servo: Merge #14601 - Raise warning when OSMesa path is not set (from Wafflespeanut:osmesa); r=emilio
authorRavi Shankar <>
Thu, 15 Dec 2016 07:42:30 -0800
changeset 340352 aeb31d25b1a710e739a3e975e81544fd3743094d
parent 340351 5a1440c3e6b9c5b086b6d37c49444dfe42130de9
child 340353 a62cdcb41a5c99dcbf73ed90c50151d01d389399
push id31307
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
servo: Merge #14601 - Raise warning when OSMesa path is not set (from Wafflespeanut:osmesa); r=emilio In Ubuntu 14.04, I still get crashes due to non-existence of OsMesa library (#13515). It turned out that sometimes I have paths like `osmesa-src-<hash>` without `out/lib/gallium`. Now, we raise a warning whenever we don't find a proper path. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors <!-- Either: --> - [x] These changes do not require tests because it's related to mach. <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Source-Repo: Source-Revision: 44af5ea2e4ccb77f55dea5492408ebfcdeb73250
--- a/servo/python/servo/
+++ b/servo/python/servo/
@@ -49,23 +49,20 @@ def setlocale(name):
 def find_dep_path_newest(package, bin_path):
     deps_path = path.join(path.split(bin_path)[0], "build")
     candidates = []
     with cd(deps_path):
         for c in glob(package + '-*'):
             candidate_path = path.join(deps_path, c)
-            candidate_output = path.join(candidate_path, "output")
-            if path.exists(candidate_output):
-                candidates.append((path.getmtime(candidate_output), candidate_path))
-    candidates.sort(reverse=True)
+            if path.exists(path.join(candidate_path, "output")):
+                candidates.append(candidate_path)
     if candidates:
-        _, candidate_path = candidates[0]
-        return candidate_path
+        return max(candidates, key=lambda c: path.getmtime(path.join(c, "output")))
     return None
 def archive_deterministically(dir_to_archive, dest_archive, prepend_path=None):
     """Create a .tar.gz archive in a deterministic (reproducible) manner.
     See for more details."""
@@ -216,24 +213,29 @@ def is_macosx():
 def is_linux():
     return sys.platform.startswith('linux')
 def set_osmesa_env(bin_path, env):
     """Set proper LD_LIBRARY_PATH and DRIVE for software rendering on Linux and OSX"""
     if is_linux():
-        osmesa_path = path.join(find_dep_path_newest('osmesa-src', bin_path), "out", "lib", "gallium")
+        dep_path = find_dep_path_newest('osmesa-src', bin_path)
+        if not dep_path:
+            return None
+        osmesa_path = path.join(dep_path, "out", "lib", "gallium")
         env["LD_LIBRARY_PATH"] = osmesa_path
         env["GALLIUM_DRIVER"] = "softpipe"
     elif is_macosx():
         osmesa_path = path.join(find_dep_path_newest('osmesa-src', bin_path),
                                 "out", "src", "gallium", "targets", "osmesa", ".libs")
         glapi_path = path.join(find_dep_path_newest('osmesa-src', bin_path),
                                "out", "src", "mapi", "shared-glapi", ".libs")
+        if not (osmesa_path and glapi_path):
+            return None
         env["DYLD_LIBRARY_PATH"] = osmesa_path + ":" + glapi_path
         env["GALLIUM_DRIVER"] = "softpipe"
     return env
 class BuildNotFound(Exception):
     def __init__(self, message):
         self.message = message
--- a/servo/python/servo/
+++ b/servo/python/servo/
@@ -729,18 +729,19 @@ class MachCommands(CommandBase):
         return check_call(
             [run_file, "|".join(tests), bin_path, base_dir])
     def set_software_rendering_env(self, use_release):
         # On Linux and mac, find the OSMesa software rendering library and
         # add it to the dynamic linker search path.
-            args = [self.get_binary_path(use_release, not use_release)]
-            set_osmesa_env(args[0], os.environ)
+            bin_path = self.get_binary_path(use_release, not use_release)
+            if not set_osmesa_env(bin_path, os.environ):
+                print("Warning: Cannot set the path to OSMesa library.")
         except BuildNotFound:
             # This can occur when cross compiling (e.g. arm64), in which case
             # we won't run the tests anyway so can safely ignore this step.
 def create_parser_create():
     import argparse