Bug 1375798 - Figure out host library/object prefix/suffixes and use them for libclang. r=mshal
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 23 Jun 2017 15:12:04 +0900
changeset 366528 a07449eb1876e36e9d735c338f7ab873cc6878df
parent 366527 8847981eee44dd2790d6628a1e791269696f015a
child 366529 07e0c4e4ae85eb5569be536b05c9d7357b1c7ca7
push id92008
push usercbook@mozilla.com
push dateThu, 29 Jun 2017 13:50:12 +0000
treeherdermozilla-inbound@6e0dd1705c75 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1375798
milestone56.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 1375798 - Figure out host library/object prefix/suffixes and use them for libclang. r=mshal The libclang test wants to find a libclang library for use for rust bindgen. But that's a host process, that needs a host libclang. However, we currently only have the target library/object prefix/suffixes. This works fine... except when cross-compiling. So we need to figure out the proper ones for the host, and use those instead. For that, we templatize library_name_info in order to get a separate set of library/object prefix/suffixes for the host and the target. And we use the host set for the libclang check. Ideally, the build system would also use the host set for host tools builds, but we'll leave that to a followup.
moz.configure
toolkit/moz.configure
--- a/moz.configure
+++ b/moz.configure
@@ -138,69 +138,83 @@ include('build/moz.configure/toolchain.c
         when='--enable-compile-environment')
 include('build/moz.configure/memory.configure',
         when='--enable-compile-environment')
 include('build/moz.configure/headers.configure',
         when='--enable-compile-environment')
 include('build/moz.configure/warnings.configure',
         when='--enable-compile-environment')
 
-@depends(target)
-def is_openbsd(target):
-    return target.kernel == 'OpenBSD'
+
+@depends(target, host)
+def is_openbsd(target, host):
+    return target.kernel == 'OpenBSD' or host.kernel == 'OpenBSD'
 
 option(env='SO_VERSION', nargs=1, default='1.0', when=is_openbsd,
        help='Shared library version for OpenBSD systems')
 
 @depends('SO_VERSION', when=is_openbsd)
 def so_version(value):
     return value
 
-@depends(target, c_compiler, so_version)
-def library_name_info(target, c_compiler, so_version):
-    if target.kernel == 'WINNT':
-        # There aren't artifacts for mingw builds, so it's OK that the results
-        # are inaccurate in that case.
-        if c_compiler and c_compiler.type not in ('msvc', 'clang-cl'):
+@template
+def library_name_info_template(host_or_target):
+    assert host_or_target in (host, target)
+    compiler = {
+        host: host_c_compiler,
+        target: c_compiler,
+    }[host_or_target]
+
+    @depends(host_or_target, compiler, so_version)
+    def library_name_info_impl(host_or_target, compiler, so_version):
+        if host_or_target.kernel == 'WINNT':
+            # There aren't artifacts for mingw builds, so it's OK that the
+            # results are inaccurate in that case.
+            if compiler and compiler.type not in ('msvc', 'clang-cl'):
+                return namespace(
+                    dll=namespace(prefix='', suffix='.dll'),
+                    lib=namespace(prefix='lib', suffix='a'),
+                    import_lib=namespace(prefix='lib', suffix='a'),
+                    rust_lib=namespace(prefix='', suffix='lib'),
+                    obj=namespace(prefix='', suffix='o'),
+                )
+
             return namespace(
                 dll=namespace(prefix='', suffix='.dll'),
+                lib=namespace(prefix='', suffix='lib'),
+                import_lib=namespace(prefix='', suffix='lib'),
+                rust_lib=namespace(prefix='', suffix='lib'),
+                obj=namespace(prefix='', suffix='obj'),
+            )
+
+        elif host_or_target.kernel == 'Darwin':
+            return namespace(
+                dll=namespace(prefix='lib', suffix='.dylib'),
                 lib=namespace(prefix='lib', suffix='a'),
-                import_lib=namespace(prefix='lib', suffix='a'),
-                rust_lib=namespace(prefix='', suffix='lib'),
+                import_lib=namespace(prefix=None, suffix=''),
+                rust_lib=namespace(prefix='lib', suffix='a'),
                 obj=namespace(prefix='', suffix='o'),
             )
+        elif so_version:
+            so = '.so.%s' % so_version
+        else:
+            so = '.so'
 
         return namespace(
-            dll=namespace(prefix='', suffix='.dll'),
-            lib=namespace(prefix='', suffix='lib'),
-            import_lib=namespace(prefix='', suffix='lib'),
-            rust_lib=namespace(prefix='', suffix='lib'),
-            obj=namespace(prefix='', suffix='obj'),
-        )
-
-    elif target.kernel == 'Darwin':
-        return namespace(
-            dll=namespace(prefix='lib', suffix='.dylib'),
+            dll=namespace(prefix='lib', suffix=so),
             lib=namespace(prefix='lib', suffix='a'),
             import_lib=namespace(prefix=None, suffix=''),
             rust_lib=namespace(prefix='lib', suffix='a'),
             obj=namespace(prefix='', suffix='o'),
         )
-    elif so_version:
-        so = '.so.%s' % so_version
-    else:
-        so = '.so'
+
+    return library_name_info_impl
 
-    return namespace(
-        dll=namespace(prefix='lib', suffix=so),
-        lib=namespace(prefix='lib', suffix='a'),
-        import_lib=namespace(prefix=None, suffix=''),
-        rust_lib=namespace(prefix='lib', suffix='a'),
-        obj=namespace(prefix='', suffix='o'),
-    )
+host_library_name_info = library_name_info_template(host)
+library_name_info = library_name_info_template(target)
 
 set_config('DLL_PREFIX', library_name_info.dll.prefix)
 set_config('DLL_SUFFIX', library_name_info.dll.suffix)
 set_config('LIB_PREFIX', library_name_info.lib.prefix)
 set_config('LIB_SUFFIX', library_name_info.lib.suffix)
 set_config('RUST_LIB_PREFIX', library_name_info.rust_lib.prefix)
 set_config('RUST_LIB_SUFFIX', library_name_info.rust_lib.suffix)
 set_config('OBJ_SUFFIX', library_name_info.obj.suffix)
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -691,17 +691,17 @@ with only_when(building_stylo_bindgen):
             To compile Stylo, please install version {} or greater of
             Clang + LLVM and ensure that the 'llvm-config' from that
             installation is first on your path.
 
             You can verify this by typing 'llvm-config --version'.
             '''.format(version, min_version)))
 
     @depends(llvm_config, '--with-libclang-path', '--with-clang-path',
-             library_name_info, host)
+             host_library_name_info, host)
     @imports('os.path')
     @imports(_from='textwrap', _import='dedent')
     def bindgen_config_paths(llvm_config, libclang_path, clang_path,
                              library_name_info, host):
         def search_for_libclang(path):
             # Try to ensure that the clang shared library that bindgen is going
             # to look for is actually present.  The files that we search for
             # mirror the logic in clang-sys/build.rs.