Ejemplo n.º 1
0
def mk_relative_osx(path, host_prefix, build_prefix, files):
    assert sys.platform == 'darwin'

    names = macho.otool(path)
    s = macho.install_name_change(path,
                                  partial(osx_ch_link,
                                          host_prefix=host_prefix,
                                          build_prefix=build_prefix,
                                          files=files),
                                  dylibs=names)

    if names:
        # Add an rpath to every executable to increase the chances of it
        # being found.
        rpath = os.path.join('@loader_path',
                     os.path.relpath(os.path.join(host_prefix, 'lib'),
                             os.path.dirname(path)), '').replace('/./', '/')
        macho.add_rpath(path, rpath, verbose=True)

        # 10.7 install_name_tool -delete_rpath causes broken dylibs, I will revisit this ASAP.
        # .. and remove config.build_prefix/lib which was added in-place of
        # DYLD_FALLBACK_LIBRARY_PATH since El Capitan's SIP.
        # macho.delete_rpath(path, config.build_prefix + '/lib', verbose = True)

    if s:
        # Skip for stub files, which have to use binary_has_prefix_files to be
        # made relocatable.
        assert_relative_osx(path, host_prefix)
Ejemplo n.º 2
0
def mk_relative_osx(path, prefix, build_prefix=None):
    '''
    if build_prefix is None, the_n this is a standard conda build. The path
    and all dependencies are in the build_prefix.

    if package is built in develop mode, build_prefix is specified. Object
    specified by 'path' needs to relink runtime dependences to libs found in
    build_prefix/lib/. Also, in develop mode, 'path' is not in 'build_prefix'
    '''
    if build_prefix is None:
        assert path.startswith(prefix + '/')
    else:
        prefix = build_prefix

    assert sys.platform == 'darwin' and is_obj(path)
    s = macho.install_name_change(path, partial(osx_ch_link, prefix=prefix))

    names = macho.otool(path)
    if names:
        # Add an rpath to every executable to increase the chances of it
        # being found.
        rpath = os.path.join('@loader_path',
                     os.path.relpath(os.path.join(prefix, 'lib'),
                             os.path.dirname(path)), '').replace('/./', '/')
        macho.add_rpath(path, rpath, verbose=True)

        # 10.7 install_name_tool -delete_rpath causes broken dylibs, I will revisit this ASAP.
        # .. and remove config.build_prefix/lib which was added in-place of
        # DYLD_FALLBACK_LIBRARY_PATH since El Capitan's SIP.
        # macho.delete_rpath(path, config.build_prefix + '/lib', verbose = True)

    if s:
        # Skip for stub files, which have to use binary_has_prefix_files to be
        # made relocatable.
        assert_relative_osx(path, prefix)
Ejemplo n.º 3
0
def get_linkages(obj_files, prefix):
    res = {}

    for f in obj_files:
        path = join(prefix, f)
        if sys.platform.startswith('linux'):
            res[f] = ldd(path)
        elif sys.platform.startswith('darwin'):
            links = otool(path)
            res[f] = [(basename(l['name']), l['name']) for l in links]

    return res
Ejemplo n.º 4
0
def get_linkages(obj_files, prefix, sysroot):
    res = {}

    for f in obj_files:
        path = join(prefix, f)
        # ldd quite often fails on foreign architectures.
        ldd_failed = False
        # Detect the filetype to emulate what the system-native tool does.
        klass = codefile_class(path)
        if klass == machofile:
            resolve_filenames = False
            recurse = False
        else:
            resolve_filenames = True
            recurse = True
        try:
            if sys.platform.startswith('linux'):
                res[f] = ldd(path)
            elif sys.platform.startswith('darwin'):
                links = otool(path)
                res[f] = [(basename(l['name']), l['name']) for l in links]
        except:
            ldd_failed = True
        finally:
            res_py = inspect_linkages(path, resolve_filenames=resolve_filenames,
                                      sysroot=sysroot, recurse=recurse)
            res_py = [(basename(lp), lp) for lp in res_py]
            if ldd_failed:
                res[f] = res_py
            else:
                if set(res[f]) != set(res_py):
                    print("WARNING: pyldd disagrees with ldd/otool. This will not cause any")
                    print("WARNING: problems for this build, but please file a bug at:")
                    print("WARNING: https://github.com/conda/conda-build")
                    print("WARNING: and (if possible) attach file {}".format(path))
                    print("WARNING: \nldd/otool gives:\n{}\npyldd gives:\n{}\n"
                          .format("\n".join(str(e) for e in res[f]), "\n".join(str(e)
                                                                               for e in res_py)))
                    print("Diffs\n{}".format(set(res[f]) - set(res_py)))
                    print("Diffs\n{}".format(set(res_py) - set(res[f])))
    return res
Ejemplo n.º 5
0
def mk_relative_osx(path, prefix, build_prefix=None):
    '''
    if build_prefix is None, the_n this is a standard conda build. The path
    and all dependencies are in the build_prefix.

    if package is built in develop mode, build_prefix is specified. Object
    specified by 'path' needs to relink runtime dependences to libs found in
    build_prefix/lib/. Also, in develop mode, 'path' is not in 'build_prefix'
    '''
    if build_prefix is None:
        assert path.startswith(prefix + '/')
    else:
        prefix = build_prefix

    assert sys.platform == 'darwin' and is_obj(path)
    s = macho.install_name_change(path, partial(osx_ch_link, prefix=prefix))

    names = macho.otool(path)
    if names:
        # Add an rpath to every executable to increase the chances of it
        # being found.
        rpath = os.path.join(
            '@loader_path',
            os.path.relpath(os.path.join(prefix, 'lib'),
                            os.path.dirname(path)), '').replace('/./', '/')
        macho.add_rpath(path, rpath, verbose=True)

        # 10.7 install_name_tool -delete_rpath causes broken dylibs, I will revisit this ASAP.
        # .. and remove config.build_prefix/lib which was added in-place of
        # DYLD_FALLBACK_LIBRARY_PATH since El Capitan's SIP.
        # macho.delete_rpath(path, config.build_prefix + '/lib', verbose = True)

    if s:
        # Skip for stub files, which have to use binary_has_prefix_files to be
        # made relocatable.
        assert_relative_osx(path, prefix)
Ejemplo n.º 6
0
def main(path):
    dylibs = macho.otool(path)
    macho.install_name_change(path, None, name_callback, dylibs, verbose=True)