Bug 1302704 - part 6 - enforce identical profiles for gkrust and gkrust-gtest; r=chmanchester
authorNathan Froyd <froydnj@mozilla.com>
Thu, 23 Feb 2017 10:35:06 -0500
changeset 344599 e71b6d1907a868c5aa67913755de36dc151a8cb3
parent 344598 7cbbf867604cadcc1f083848cd42222997aad251
child 344600 513ff147aa6c87a74fee27bd1ab7b0ac3dc095f3
push id31414
push usercbook@mozilla.com
push dateFri, 24 Feb 2017 10:47:41 +0000
treeherdermozilla-central@be661bae6cb9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerschmanchester
bugs1302704
milestone54.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1302704 - part 6 - enforce identical profiles for gkrust and gkrust-gtest; r=chmanchester Cargo hashes various compilation settings into the dependency graph for dependent libraries. So if the compilation settings for gkrust and gkrust-gtest are different, their dependencies will likewise be different. The setup we've created in the previous patches depends on the compilation settings being identical, so we should enforce that at the moz.build level.
python/mozbuild/mozbuild/frontend/emitter.py
python/mozbuild/mozbuild/test/backend/data/rust-library-features/Cargo.toml
python/mozbuild/mozbuild/test/backend/data/rust-library-features/moz.build
python/mozbuild/mozbuild/test/backend/data/rust-library/Cargo.toml
python/mozbuild/mozbuild/test/backend/data/rust-library/moz.build
python/mozbuild/mozbuild/test/backend/test_recursivemake.py
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -460,16 +460,44 @@ class TreeMetadataEmitter(LoggingMixin):
 
             panic = profile.get('panic', None)
             if panic != 'abort':
                 raise SandboxValidationError(
                     ('Cargo.toml for %s does not specify `panic = "abort"`'
                      ' in [profile.%s] section') % (libname, profile_name),
                     context)
 
+            # gkrust and gkrust-gtest must have the exact same profile settings
+            # for our almost-workspaces configuration to work properly.
+            if libname in ('gkrust', 'gkrust-gtest'):
+                if profile_name == 'dev':
+                    expected_profile = {
+                        'opt-level': 1,
+                        'debug': True,
+                        'rpath': False,
+                        'lto': False,
+                        'debug-assertions': True,
+                        'codegen-units': 1,
+                        'panic': 'abort',
+                    }
+                else:
+                    expected_profile = {
+                        'opt-level': 2,
+                        'debug': True,
+                        'rpath': False,
+                        'lto': True,
+                        'debug-assertions': False,
+                        'panic': 'abort',
+                    }
+
+                if profile != expected_profile:
+                    raise SandboxValidationError(
+                        'Cargo profile.%s for %s is incorrect' % (profile_name, libname),
+                        context)
+
         cargo_target_dir = context.get('RUST_LIBRARY_TARGET_DIR', '.')
 
         dependencies = set(config.get('dependencies', {}).iterkeys())
 
         features = context.get(cls.FEATURES_VAR, [])
         unique_features = set(features)
         if len(features) != len(unique_features):
             raise SandboxValidationError(
--- a/python/mozbuild/mozbuild/test/backend/data/rust-library-features/Cargo.toml
+++ b/python/mozbuild/mozbuild/test/backend/data/rust-library-features/Cargo.toml
@@ -1,10 +1,10 @@
 [package]
-name = "gkrust"
+name = "feature-library"
 version = "0.1.0"
 authors = [
   "Nobody <nobody@mozilla.org>",
 ]
 
 [lib]
 crate-type = ["staticlib"]
 
--- a/python/mozbuild/mozbuild/test/backend/data/rust-library-features/moz.build
+++ b/python/mozbuild/mozbuild/test/backend/data/rust-library-features/moz.build
@@ -11,9 +11,9 @@ def Library(name):
 def RustLibrary(name, features):
     '''Template for Rust libraries.'''
     Library(name)
 
     IS_RUST_LIBRARY = True
     RUST_LIBRARY_FEATURES = features
 
 
-RustLibrary('gkrust', ['musthave', 'cantlivewithout'])
+RustLibrary('feature-library', ['musthave', 'cantlivewithout'])
--- a/python/mozbuild/mozbuild/test/backend/data/rust-library/Cargo.toml
+++ b/python/mozbuild/mozbuild/test/backend/data/rust-library/Cargo.toml
@@ -1,10 +1,10 @@
 [package]
-name = "gkrust"
+name = "test-library"
 version = "0.1.0"
 authors = [
   "Nobody <nobody@mozilla.org>",
 ]
 
 [lib]
 crate-type = ["staticlib"]
 
--- a/python/mozbuild/mozbuild/test/backend/data/rust-library/moz.build
+++ b/python/mozbuild/mozbuild/test/backend/data/rust-library/moz.build
@@ -10,9 +10,9 @@ def Library(name):
 @template
 def RustLibrary(name):
     '''Template for Rust libraries.'''
     Library(name)
 
     IS_RUST_LIBRARY = True
 
 
-RustLibrary('gkrust')
+RustLibrary('test-library')
--- a/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
+++ b/python/mozbuild/mozbuild/test/backend/test_recursivemake.py
@@ -757,63 +757,63 @@ class TestRecursiveMakeBackend(BackendTe
     def test_rust_library(self):
         """Test that a Rust library is written to backend.mk correctly."""
         env = self._consume('rust-library', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
 
         expected = [
-            'RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libgkrust.a',
+            'RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libtest_library.a',
             'CARGO_FILE := $(srcdir)/Cargo.toml',
             'CARGO_TARGET_DIR := %s' % env.topobjdir,
         ]
 
         self.assertEqual(lines, expected)
 
     def test_host_rust_library(self):
         """Test that a Rust library is written to backend.mk correctly."""
         env = self._consume('host-rust-library', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
 
         expected = [
-            'HOST_RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libhostrusttool.a',
+            'HOST_RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libhostrusttool.a',
             'CARGO_FILE := $(srcdir)/Cargo.toml',
             'CARGO_TARGET_DIR := %s' % env.topobjdir,
         ]
 
         self.assertEqual(lines, expected)
 
     def test_host_rust_library_with_features(self):
         """Test that a host Rust library with features is written to backend.mk correctly."""
         env = self._consume('host-rust-library-features', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
 
         expected = [
-            'HOST_RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libhostrusttool.a',
+            'HOST_RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libhostrusttool.a',
             'CARGO_FILE := $(srcdir)/Cargo.toml',
             'CARGO_TARGET_DIR := %s' % env.topobjdir,
             'HOST_RUST_LIBRARY_FEATURES := musthave cantlivewithout',
         ]
 
         self.assertEqual(lines, expected)
 
     def test_rust_library_with_features(self):
         """Test that a Rust library with features is written to backend.mk correctly."""
         env = self._consume('rust-library-features', RecursiveMakeBackend)
 
         backend_path = mozpath.join(env.topobjdir, 'backend.mk')
         lines = [l.strip() for l in open(backend_path, 'rt').readlines()[2:]]
 
         expected = [
-            'RUST_LIBRARY_FILE := x86_64-unknown-linux-gnu/release/libgkrust.a',
+            'RUST_LIBRARY_FILE := ./x86_64-unknown-linux-gnu/release/libfeature_library.a',
             'CARGO_FILE := $(srcdir)/Cargo.toml',
             'CARGO_TARGET_DIR := %s' % env.topobjdir,
             'RUST_LIBRARY_FEATURES := musthave cantlivewithout',
         ]
 
         self.assertEqual(lines, expected)
 
     def test_rust_programs(self):