示例#1
0
文件: mx_jvmci.py 项目: mearvk/JVM
def c1visualizer(args):
    """run the Cl Compiler Visualizer"""
    libpath = join(_suite.dir, 'lib')
    if mx.get_os() == 'windows':
        executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer.exe')
    else:
        executable = join(libpath, 'c1visualizer', 'bin', 'c1visualizer')

    # Check whether the current C1Visualizer installation is the up-to-date
    if exists(executable) and not exists(mx.library('C1VISUALIZER_DIST').get_path(resolve=False)):
        mx.log('Updating C1Visualizer')
        shutil.rmtree(join(libpath, 'c1visualizer'))

    archive = mx.library('C1VISUALIZER_DIST').get_path(resolve=True)

    if not exists(executable):
        zf = zipfile.ZipFile(archive, 'r')
        zf.extractall(libpath)

    if not exists(executable):
        mx.abort('C1Visualizer binary does not exist: ' + executable)

    if mx.get_os() != 'windows':
        # Make sure that execution is allowed. The zip file does not always specfiy that correctly
        os.chmod(executable, 0777)

    mx.run([executable])
def _run_netbeans_app(app_name, env=None, args=None):
    args = [] if args is None else args
    dist = app_name.upper() + '_DIST'
    name = app_name.lower()
    extractPath = join(_suite.get_output_root())
    if mx.get_os() == 'windows':
        executable = join(extractPath, name, 'bin', name + '.exe')
    else:
        executable = join(extractPath, name, 'bin', name)

    # Check whether the current installation is up-to-date
    if exists(executable) and not exists(mx.library(dist).get_path(resolve=False)):
        mx.log('Updating ' + app_name)
        shutil.rmtree(join(extractPath, name))

    archive = mx.library(dist).get_path(resolve=True)

    if not exists(executable):
        zf = zipfile.ZipFile(archive, 'r')
        zf.extractall(extractPath)

    if not exists(executable):
        mx.abort(app_name + ' binary does not exist: ' + executable)

    if mx.get_os() != 'windows':
        # Make sure that execution is allowed. The zip file does not always specfiy that correctly
        os.chmod(executable, 0777)
    mx.run([executable]+args, env=env)
示例#3
0
文件: mx_sulong.py 项目: lxp/sulong
def getSearchPathOption(lib_args=None):
    if lib_args is None:
        lib_args = ['-lgmp', '-lgfortran', '-lpcre']

    lib_names = []

    lib_aliases = {
        '-lc': ['libc.so.6', 'libc.dylib'],
        '-lstdc++': ['libstdc++.so.6', 'libstdc++.6.dylib'],
        '-lgmp': ['libgmp.so.10', 'libgmp.10.dylib'],
        '-lgfortran': ['libgfortran.so.3', 'libgfortran.3.dylib'],
        '-lpcre': ['libpcre.so.3', 'libpcre.dylib']
    }
    osStr = mx.get_os()
    index = {'linux': 0, 'darwin': 1}[mx.get_os()]
    if index is None:
        print osStr, "not supported!"

    for lib_arg in ['-lc', '-lstdc++'] + lib_args:
        if lib_arg in lib_aliases:
            lib_arg = lib_aliases[lib_arg][index]
        else:
            lib_arg = lib_arg[2:]
        lib_names.append(lib_arg)

    return '-Dsulong.DynamicNativeLibraryPath=' + ':'.join(lib_names)
示例#4
0
def getSearchPathOption(lib_args=None):
    if lib_args is None:
        lib_args = ["-lgmp", "-lgfortran", "-lpcre"]

    lib_names = []

    lib_aliases = {
        "-lc": ["libc.so.6", "libc.dylib"],
        "-lstdc++": ["libstdc++.so.6", "libstdc++.6.dylib"],
        "-lgmp": ["libgmp.so.10", "libgmp.10.dylib"],
        "-lgfortran": ["libgfortran.so.3", "libgfortran.3.dylib"],
        "-lpcre": ["libpcre.so.3", "libpcre.dylib"],
    }
    osStr = mx.get_os()
    index = {"linux": 0, "darwin": 1}[mx.get_os()]
    if index is None:
        print osStr, "not supported!"

    for lib_arg in ["-lc", "-lstdc++"] + lib_args:
        if lib_arg in lib_aliases:
            lib_arg = lib_aliases[lib_arg][index]
        else:
            lib_arg = lib_arg[2:]
        lib_names.append(lib_arg)

    return "-Dsulong.DynamicNativeLibraryPath=" + ":".join(lib_names)
示例#5
0
def pullInstallDragonEgg(args=None):
    """downloads and installs dragonegg (assumes that compatible GCC and G++ versions are installed)"""
    toolDir = join(_toolDir, "tools/dragonegg")
    mx.ensure_dir_exists(toolDir)
    url = "https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/dragonegg-3.2.src.tar.gz"
    localPath = pullsuite(toolDir, [url])
    tar(localPath, toolDir)
    os.remove(localPath)
    if mx.get_os() == "darwin":
        gccToolDir = join(_toolDir, "tools/gcc")
        url = "https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/gcc-4.6.4.tar.gz"
        localPath = pullsuite(gccToolDir, [url])
        tar(localPath, gccToolDir)
        os.remove(localPath)
        mx.run(
            ["patch", "-p1", _toolDir + "tools/dragonegg/dragonegg-3.2.src/Makefile", "mx.sulong/dragonegg-mac.patch"]
        )
    os.environ["GCC"] = getGCC()
    os.environ["CXX"] = getGPP()
    os.environ["CC"] = getGCC()
    pullLLVMBinaries()
    os.environ["LLVM_CONFIG"] = findLLVMProgram("llvm-config")
    print os.environ["LLVM_CONFIG"]
    compileCommand = ["make"]
    return mx.run(compileCommand, cwd=_toolDir + "tools/dragonegg/dragonegg-3.2.src")
示例#6
0
def svm_gate_body(args, tasks):
    # Debug GR-8964 on Darwin gates
    debug_gr_8964 = (mx.get_os() == 'darwin')
    build_native_image_image()
    with native_image_context(IMAGE_ASSERTION_FLAGS, debug_gr_8964=debug_gr_8964) as native_image:
        with Task('image demos', tasks, tags=[GraalTags.helloworld]) as t:
            if t:
                hello_path = svmbuild_dir()
                javac_image(native_image, hello_path)
                helloworld_internal(native_image, hello_path, javac_image_command(hello_path))
                cinterfacetutorial(native_image)

        with Task('native unittests', tasks, tags=[GraalTags.test]) as t:
            if t:
                native_junit(native_image)

        with Task('JavaScript', tasks, tags=[GraalTags.js]) as t:
            if t:
                js = build_js(native_image, debug_gr_8964=debug_gr_8964)
                test_run([js, '-e', 'print("hello:" + Array.from(new Array(10), (x,i) => i*i ).join("|"))'], 'hello:0|1|4|9|16|25|36|49|64|81\n')
                test_js(js, [('octane-richards', 1000, 100, 300)])

        with Task('Python', tasks, tags=[GraalTags.python]) as t:
            if t:
                python = build_python(native_image, debug_gr_8964=debug_gr_8964)
                test_python_smoke([python])

    with Task('maven plugin checks', tasks, tags=[GraalTags.maven]) as t:
        if t:
            maven_plugin_install([])
示例#7
0
文件: mx_jvmci.py 项目: mearvk/JVM
def relativeVmLibDirInJdk():
    mxos = mx.get_os()
    if mxos == 'darwin':
        return join('lib')
    if mxos == 'windows' or mxos == 'cygwin':
        return join('bin')
    return join('lib', mx.get_arch())
示例#8
0
def pullLLVMBinaries(args=None):
    """downloads the LLVM binaries"""
    toolDir = join(_toolDir, "tools/llvm")
    mx.ensure_dir_exists(toolDir)
    osStr = mx.get_os()
    arch = mx.get_arch()
    if osStr == 'windows':
        print 'windows currently only supported with cygwin!'
        return
    elif osStr == 'linux':
        if arch == 'amd64':
            urls = ['http://lafo.ssw.uni-linz.ac.at/sulong-deps/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz',
                    'http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz']
        else:
            urls = ['http://lafo.ssw.uni-linz.ac.at/sulong-deps/clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz',
                    'http://llvm.org/releases/3.2/clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz']
    elif osStr == 'darwin':
        urls = ['http://lafo.ssw.uni-linz.ac.at/sulong-deps/clang+llvm-3.2-x86_64-apple-darwin11.tar.gz',
                'http://llvm.org/releases/3.2/clang+llvm-3.2-x86_64-apple-darwin11.tar.gz']
    elif osStr == 'cygwin':
        urls = ['http://lafo.ssw.uni-linz.ac.at/sulong-deps/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz',
                'http://llvm.org/releases/3.2/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz']
    else:
        print osStr, arch, "not supported!"
    localPath = pullsuite(toolDir, urls)
    tar(localPath, toolDir, stripLevels=1)
    os.remove(localPath)
示例#9
0
文件: mx_jvmci.py 项目: mearvk/JVM
def _get_openjdk_os():
    # See: common/autoconf/platform.m4
    os = mx.get_os()
    if 'darwin' in os:
        os = 'macosx'
    elif 'linux' in os:
        os = 'linux'
    elif 'solaris' in os:
        os = 'solaris'
    elif 'cygwin' in os or 'mingw' in os:
        os = 'windows'
    return os
示例#10
0
def inspectoragent(args):
    """launch the Inspector agent

    Launch the Inspector agent.

    The agent listens on a given port for an incoming connection from
    a remote Inspector process."""

    cmd = mx.java().format_cmd(['-cp', mx.classpath(), 'com.sun.max.tele.channel.agent.InspectorAgent'] + args)
    if mx.get_os() == 'darwin':
        # The -E option propagates the environment variables into the sudo process
        mx.run(['sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X.\nPlease enter your "sudo" password:'] + cmd)
    else:
        mx.run(cmd)
示例#11
0
def _get_hotspot_build_dir(jvmVariant=None, debugLevel=None):
    """
    Gets the directory in which a particular HotSpot configuration is built
    (e.g., <JDK_REPO_ROOT>/build/macosx-x86_64-normal-server-release/hotspot/bsd_amd64_compiler2)
    """
    if jvmVariant is None:
        jvmVariant = _vm.jvmVariant

    os = mx.get_os()
    if os == 'darwin':
        os = 'bsd'
    arch = mx.get_arch()
    buildname = {'client': 'compiler1', 'server': 'compiler2'}.get(jvmVariant, jvmVariant)

    name = '{}_{}_{}'.format(os, arch, buildname)
    return join(_get_jdk_build_dir(debugLevel=debugLevel), 'hotspot', name)
示例#12
0
def hsdis(args, copyToDir=None):
    """download the hsdis library

    This is needed to support HotSpot's assembly dumping features.
    By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
    flavor = None
    if mx.get_arch() == "amd64":
        flavor = mx.get_env('HSDIS_SYNTAX')
        if flavor is None:
            flavor = 'intel'
        if 'att' in args:
            flavor = 'att'

    libpattern = mx.add_lib_suffix('hsdis-' + mx.get_arch() + '-' + mx.get_os() + '-%s')

    sha1s = {
        'att/hsdis-amd64-windows-%s.dll' : 'bcbd535a9568b5075ab41e96205e26a2bac64f72',
        'att/hsdis-amd64-linux-%s.so' : '36a0b8e30fc370727920cc089f104bfb9cd508a0',
        'att/hsdis-amd64-darwin-%s.dylib' : 'c1865e9a58ca773fdc1c5eea0a4dfda213420ffb',
        'intel/hsdis-amd64-windows-%s.dll' : '6a388372cdd5fe905c1a26ced614334e405d1f30',
        'intel/hsdis-amd64-linux-%s.so' : '0d031013db9a80d6c88330c42c983fbfa7053193',
        'intel/hsdis-amd64-darwin-%s.dylib' : '67f6d23cbebd8998450a88b5bef362171f66f11a',
        'hsdis-sparcv9-solaris-%s.so': '970640a9af0bd63641f9063c11275b371a59ee60',
        'hsdis-sparcv9-linux-%s.so': '0c375986d727651dee1819308fbbc0de4927d5d9',
    }

    if flavor:
        flavoredLib = flavor + "/" + libpattern
    else:
        flavoredLib = libpattern
    if flavoredLib not in sha1s:
        mx.warn("hsdis with flavor '{}' not supported on this plattform or architecture".format(flavor))
        return

    sha1 = sha1s[flavoredLib]
    lib = flavoredLib % (sha1)
    path = join(_suite.get_output_root(), lib)
    if not exists(path):
        sha1path = path + '.sha1'
        mx.download_file_with_sha1('hsdis', path, ['https://lafo.ssw.uni-linz.ac.at/pub/hsdis/' + lib], sha1, sha1path, True, True, sources=False)
    if copyToDir is not None and exists(copyToDir):
        destFileName = mx.add_lib_suffix('hsdis-' + mx.get_arch())
        mx.logv('Copying {} to {}'.format(path, copyToDir + os.sep + destFileName))
        shutil.copy(path, copyToDir + os.sep + destFileName)
示例#13
0
def pullInstallDragonEgg(args=None):
    """downloads and installs dragonegg (assumes that compatible GCC and G++ versions are installed)"""
    toolDir = join(_toolDir, "tools/dragonegg")
    mx.ensure_dir_exists(toolDir)
    url = 'http://llvm.org/releases/3.2/dragonegg-3.2.src.tar.gz'
    localPath = pullsuite(toolDir, [url])
    tar(localPath, toolDir)
    os.remove(localPath)
    if mx.get_os() == 'darwin':
        gccToolDir = join(_toolDir, "tools/gcc")
        url = 'http://ftpmirror.gnu.org/gcc/gcc-4.6.4/gcc-4.6.4.tar.gz'
        localPath = pullsuite(gccToolDir, [url])
        tar(localPath, gccToolDir)
        os.remove(localPath)
        mx.run(['patch', '-p1', _toolDir + 'tools/dragonegg/dragonegg-3.2.src/Makefile', 'mx.sulong/dragonegg-mac.patch'])
    os.environ['GCC'] = getGCC()
    os.environ['CXX'] = getGPP()
    os.environ['CC'] = getGCC()
    os.environ['LLVM_CONFIG'] = _toolDir + 'tools/llvm/bin/llvm-config'
    compileCommand = ['make']
    return mx.run(compileCommand, cwd=_toolDir + 'tools/dragonegg/dragonegg-3.2.src')
示例#14
0
def copylib(args):
    '''
    This supports a configuration where no explicit setting (e.g. LD_LIBRARY_PATH) is
    required at runtime for the libraries that are required by FastR, e.g. pcre.
    The easy case is when the libraries are already installed with the correct versions
    in one of the directories, e.g./usr/lib, that is searched by default by the system linker -
    in which case no configuration is required.

    Otherwise, since systems vary considerably in where such libraries are located, the general solution
    is to copy libraries located in non-system locations into the FastR 'lib' directory. N.B. GNU R is
    even more picky than FastR about library versions and depends on a larger set, so the local
    copy embedded in FastR is built using PKG_LDFLAGS_OVERRIDE to specify the location of necessary external
    libraries. However, the result of this analysis isn't captured anywhere, so we re-analyze here.
    If PKG_LDFLAGS_OVERRIDE is unset, we assume the libraries are located in the system directories
    and do nothing.
    '''
    if os.environ.has_key('PKG_LDFLAGS_OVERRIDE'):
        parts = os.environ['PKG_LDFLAGS_OVERRIDE'].split(' ')
        ext = '.dylib' if platform.system() == 'Darwin' else '.so'
        lib_prefix = 'lib' + args[0]
        plain_libpath = lib_prefix + ext
        for part in parts:
            path = part.strip('"').lstrip('-L')
            if os.path.exists(path):
                for f in os.listdir(path):
                    if f.startswith(lib_prefix):
                        if os.path.exists(os.path.join(path, plain_libpath)):
                            f = plain_libpath
                        target_dir = args[1]
                        if not os.path.exists(os.path.join(target_dir, f)):
                            _copylib(args[0], os.path.join(path, f), args[1])
                        return 0

    if os.environ.has_key('FASTR_RELEASE'):
        if args[0] == 'quadmath' and (mx.get_arch() == 'sparcv9' or mx.get_os() == 'solaris'):
            return 0
        mx.abort(args[0] + ' not found in PKG_LDFLAGS_OVERRIDE, but required with FASTR_RELEASE')

    mx.log(args[0] + ' not found in PKG_LDFLAGS_OVERRIDE, assuming system location')
    return 0
示例#15
0
def pullInstallDragonEgg(args=None):
    """downloads and installs dragonegg (assumes that compatible GCC and G++ versions are installed)"""
    toolDir = join(_toolDir, "dragonegg")
    mx.ensure_dir_exists(toolDir)
    url = 'https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/dragonegg-3.2.src.tar.gz'
    localPath = pullsuite(toolDir, [url])
    tar(localPath, toolDir)
    os.remove(localPath)
    if mx.get_os() == 'darwin':
        gccToolDir = join(_toolDir, "gcc")
        url = 'https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/gcc-4.6.4.tar.gz'
        localPath = pullsuite(gccToolDir, [url])
        tar(localPath, gccToolDir)
        os.remove(localPath)
        mx.run(['patch', '-p1', join(_toolDir, 'dragonegg', 'dragonegg-3.2.src', 'Makefile'), join('mx.sulong', 'dragonegg-mac.patch')])
    os.environ['GCC'] = getGCC()
    os.environ['CXX'] = getGPP()
    os.environ['CC'] = getGCC()
    pullLLVMBinaries()
    os.environ['LLVM_CONFIG'] = findLLVMProgramForDragonegg('llvm-config')
    compileCommand = ['make']
    return mx.run(compileCommand, cwd=join(_toolDir, 'dragonegg', 'dragonegg-3.2.src'))
示例#16
0
def pullLLVMBinaries(args=None):
    """downloads the LLVM binaries"""
    toolDir = join(_toolDir, "tools/llvm")
    mx.ensure_dir_exists(toolDir)
    osStr = mx.get_os()
    arch = mx.get_arch()
    if osStr == "windows":
        print "windows currently only supported with cygwin!"
        return
    elif osStr == "linux":
        if arch == "amd64":
            urls = ["https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/clang+llvm-3.2-x86_64-linux-ubuntu-12.04.tar.gz"]
        else:
            urls = ["https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/clang+llvm-3.2-x86-linux-ubuntu-12.04.tar.gz"]
    elif osStr == "darwin":
        urls = ["https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/clang+llvm-3.2-x86_64-apple-darwin11.tar.gz"]
    elif osStr == "cygwin":
        urls = ["https://lafo.ssw.uni-linz.ac.at/pub/sulong-deps/clang+llvm-3.2-x86-mingw32-EXPERIMENTAL.tar.gz"]
    else:
        print osStr, arch, "not supported!"
    localPath = pullsuite(toolDir, urls)
    tar(localPath, toolDir, stripLevels=1)
    os.remove(localPath)
示例#17
0
def makegraaljdk(args):
    """make a JDK with Graal as the default top level JIT"""
    parser = ArgumentParser(prog='mx makegraaljdk')
    parser.add_argument('-f', '--force', action='store_true', help='overwrite existing GraalJDK')
    parser.add_argument('-a', '--archive', action='store', help='name of archive to create', metavar='<path>')
    parser.add_argument('dest', help='destination directory for GraalJDK', metavar='<path>')
    args = parser.parse_args(args)
    if isJDK8:
        dstJdk = os.path.abspath(args.dest)
        srcJdk = jdk.home
        if exists(dstJdk):
            if args.force:
                shutil.rmtree(dstJdk)
            else:
                mx.abort('Use --force to overwrite existing directory ' + dstJdk)
        mx.log('Creating {} from {}'.format(dstJdk, srcJdk))
        shutil.copytree(srcJdk, dstJdk)

        bootDir = mx.ensure_dir_exists(join(dstJdk, 'jre', 'lib', 'boot'))
        jvmciDir = join(dstJdk, 'jre', 'lib', 'jvmci')
        assert exists(jvmciDir), jvmciDir + ' does not exist'

        if mx.get_os() == 'darwin' or mx.get_os() == 'windows':
            jvmlibDir = join(dstJdk, 'jre', 'lib', 'server')
        else:
            jvmlibDir = join(dstJdk, 'jre', 'lib', mx.get_arch(), 'server')
        jvmlib = join(jvmlibDir, mx.add_lib_prefix(mx.add_lib_suffix('jvm')))
        assert exists(jvmlib), jvmlib + ' does not exist'

        with open(join(jvmciDir, 'compiler-name'), 'w') as fp:
            print >> fp, 'graal'
        vmName = 'Graal'
        mapFiles = set()
        for e in _jvmci_classpath:
            src = basename(e.get_path())
            mx.log('Copying {} to {}'.format(e.get_path(), jvmciDir))
            candidate = e.get_path() + '.map'
            if exists(candidate):
                mapFiles.add(candidate)
            with open(join(dstJdk, 'release'), 'a') as fp:
                d = e.dist()
                s = d.suite
                print >> fp, '{}={}'.format(d.name, s.vc.parent(s.dir))
                vmName = vmName + ':' + s.name + '_' + s.version()
            shutil.copyfile(e.get_path(), join(jvmciDir, src))
        for e in _bootclasspath_appends:
            src = basename(e.classpath_repr())
            mx.log('Copying {} to {}'.format(e.classpath_repr(), bootDir))
            candidate = e.classpath_repr() + '.map'
            if exists(candidate):
                mapFiles.add(candidate)

            with open(join(dstJdk, 'release'), 'a') as fp:
                s = e.suite
                print >> fp, '{}={}'.format(e.name, s.vc.parent(s.dir))
            shutil.copyfile(e.classpath_repr(), join(bootDir, src))

        out = mx.LinesOutputCapture()
        mx.run([jdk.java, '-version'], err=out)
        line = None
        pattern = re.compile(r'(.* )(?:Server|Graal) VM \(build.*')
        for line in out.lines:
            m = pattern.match(line)
            if m:
                with open(join(jvmlibDir, 'vm.properties'), 'w') as fp:
                    # Modify VM name in `java -version` to be Graal along
                    # with a suffix denoting the commit of each Graal jar.
                    # For example:
                    # Java HotSpot(TM) 64-Bit Graal:compiler_88847fb25d1a62977a178331a5e78fa5f8fcbb1a (build 25.71-b01-internal-jvmci-0.34, mixed mode)
                    print >> fp, 'name=' + m.group(1) + vmName
                line = True
                break
        if line is not True:
            mx.abort('Could not find "{}" in output of `java -version`:\n{}'.format(pattern.pattern, os.linesep.join(out.lines)))

        exe = join(dstJdk, 'bin', mx.exe_suffix('java'))
        with StdoutUnstripping(args=[], out=None, err=None, mapFiles=mapFiles) as u:
            mx.run([exe, '-XX:+BootstrapJVMCI', '-version'], out=u.out, err=u.err)
        if args.archive:
            mx.log('Archiving {}'.format(args.archive))
            create_archive(dstJdk, args.archive, basename(args.dest) + '/')
    else:
        mx.abort('Can only make GraalJDK for JDK 8 currently')
示例#18
0
def collectExcludes(path):
    def _collect(path, skip=None):
        for root, _, files in os.walk(path):
            if skip and skip(os.path.relpath(root, path)):
                continue
            for f in files:
                if f.endswith('.exclude'):
                    for line in open(os.path.join(root, f)):
                        yield line.strip()
    # use `yield from` in python 3.3
    for x in _collect(path, lambda p: p.startswith('os_arch')):
        yield x

    os_arch_root = os.path.join(path, 'os_arch')
    if os.path.exists(os_arch_root):
        try:
            os_path = next(x for x in (os.path.join(os_arch_root, os_dir) for os_dir in [mx.get_os(), 'others']) if os.path.exists(x))
            os_arch_path = next(x for x in (os.path.join(os_path, arch_dir) for arch_dir in [mx.get_arch(), 'others']) if os.path.exists(x))
            # use `yield from` in python 3.3
            for x in _collect(os_arch_path):
                yield x
        except StopIteration:
            pass
示例#19
0
def layout_native_image_root(native_image_root):
    def names_to_dists(dist_names):
        deps = [mx.dependency(dist_name) for dist_name in dist_names]
        return [
            dep for dep in deps if not dep.isDistribution() or dep.exists()
        ]

    def native_image_layout_dists(subdir, dist_names):
        native_image_layout(names_to_dists(dist_names), subdir,
                            native_image_root)

    def native_image_extract_dists(subdir, dist_names):
        native_image_extract(names_to_dists(dist_names), subdir,
                             native_image_root)

    native_image_layout_dists(join(
        'lib', 'graalvm'), ['substratevm:SVM_DRIVER', 'sdk:LAUNCHER_COMMON'])

    # Create native-image layout for sdk parts
    graal_sdk_dists = ['sdk:GRAAL_SDK']
    if svm_java80():
        native_image_layout_dists(join('lib', 'boot'), graal_sdk_dists)
        jvmci_dists = graalDistribution
    else:
        jvmci_dists = graalDistribution + graal_sdk_dists

    # Create native-image layout for compiler & jvmci parts
    native_image_layout_dists(join('lib', 'jvmci'), jvmci_dists)
    jdk_config = mx.get_jdk()
    if svm_java80():
        jvmci_path = join(jdk_config.home, 'jre', 'lib', 'jvmci')
        if os.path.isdir(jvmci_path):
            for symlink_name in os.listdir(jvmci_path):
                symlink_or_copy(
                    join(jvmci_path, symlink_name),
                    join(native_image_root, 'lib', 'jvmci', symlink_name))

    # Create native-image layout for truffle parts
    if mx.get_os(
    ) != 'windows':  # necessary until Truffle is fully supported (GR-7941)
        native_image_layout_dists(join(
            'lib', 'truffle'), ['truffle:TRUFFLE_API', 'truffle:TRUFFLE_NFI'])

    # Create native-image layout for tools parts
    for tool_name in tools_map:
        tool_descriptor = tools_map[tool_name]
        native_image_layout_dists(join('tools', tool_name, 'builder'),
                                  tool_descriptor.builder_deps)
        native_image_layout_dists(join('tools', tool_name),
                                  tool_descriptor.image_deps)
        native_image_extract_dists(join('tools', tool_name),
                                   tool_descriptor.native_deps)
        native_image_option_properties('tools', tool_name, native_image_root)

    # Create native-image layout for svm parts
    svm_subdir = join('lib', 'svm')
    native_image_layout_dists(svm_subdir, librarySupportDistribution)
    native_image_layout_dists(
        join(svm_subdir, 'builder'), svmDistribution + llvmDistributions +
        ['substratevm:POINTSTO', 'substratevm:OBJECTFILE'])
    clibraries_dest = join(native_image_root, join(svm_subdir, 'clibraries'))
    for clibrary_path in clibrary_paths():
        copy_tree(clibrary_path, clibraries_dest)
    lib_suffix = '.lib' if mx.get_os() == 'windows' else '.a'
    jdk_lib_subdir = ['jre', 'lib'] if svm_java80() else ['lib']
    jdk_lib_dir = join(jdk_config.home, *jdk_lib_subdir)
    jdk_libs = [
        join(jdk_lib_dir, lib) for lib in os.listdir(jdk_lib_dir)
        if lib.endswith(lib_suffix)
    ]
    for src_lib in jdk_libs:
        symlink_or_copy(src_lib, join(clibraries_dest, platform_name()))
示例#20
0
文件: mx_tools.py 项目: zhanzr/graal
        truffle_jars=['tools:TRUFFLE_PROFILER'],
        support_distributions=['tools:TRUFFLE_PROFILER_GRAALVM_SUPPORT'],
        include_by_default=True,
    ))

mx_sdk.register_graalvm_component(
    mx_sdk.GraalVmJdkComponent(
        suite=_suite,
        name='VisualVM',
        short_name='vvm',
        dir_name='visualvm',
        license_files=[],
        third_party_license_files=[],
        support_distributions=['tools:VISUALVM_GRAALVM_SUPPORT'],
        provided_executables=[
            'bin/<exe:{}>'.format('visualvm' if mx.get_os() ==
                                  'windows' else 'jvisualvm')
        ]))

for mode in ['jvm', 'native']:
    mx_sdk.add_graalvm_hostvm_config(
        mode + '-cpusampler-exclude-inlined-roots',
        launcher_args=[
            '--' + mode, '--cpusampler',
            '--cpusampler.Mode=exclude_inlined_roots'
        ])
    mx_sdk.add_graalvm_hostvm_config(
        mode + '-cpusampler-roots',
        launcher_args=['--' + mode, '--cpusampler', '--cpusampler.Mode=roots'])
    mx_sdk.add_graalvm_hostvm_config(mode + '-cpusampler-statements',
                                     launcher_args=[
示例#21
0
def hsdis(args, copyToDir=None):
    """download the hsdis library and copy it to a specific dir or to the current JDK

    This is needed to support HotSpot's assembly dumping features.
    On amd64 platforms, it downloads the Intel syntax version"""

    parser = ArgumentParser(prog='hsdis')
    args = parser.parse_args(args)

    hsdis_syntax = mx.get_env('HSDIS_SYNTAX')
    if hsdis_syntax:
        mx.warn(
            "The 'hsdis' function ignores the value of the 'HSDIS_SYNTAX' environment variable: "
            + hsdis_syntax)

    hsdis_lib_name = 'HSDIS'
    hsdis_lib = mx.library(hsdis_lib_name)

    if hsdis_lib.optional:
        mx.abort('hsdis is not supported on this platform or architecture')

    hsdis_lib_path = hsdis_lib.get_path(resolve=True)
    hsdis_lib_files = os.listdir(hsdis_lib_path)
    if len(hsdis_lib_files) != 1:
        mx.abort(
            "hsdis library '{}' does not contain a single file: {}".format(
                hsdis_lib_name, hsdis_lib_files))
    hsdis_lib_file = join(hsdis_lib_path, hsdis_lib_files[0])

    overwrite = True
    if copyToDir is None:
        # Try install hsdis into JAVA_HOME
        overwrite = False
        jdk = mx.get_jdk()
        base = jdk.home
        if exists(join(base, 'jre')):
            base = join(base, 'jre')
        if mx.get_os() == 'darwin':
            copyToDir = join(base, 'lib')
        elif mx.get_os() == 'windows':
            copyToDir = join(base, 'bin')
        else:
            if jdk.javaCompliance >= '11':
                copyToDir = join(base, 'lib')
            else:
                copyToDir = join(base, 'lib', mx.get_arch())

    if exists(copyToDir):
        dest = join(copyToDir, mx.add_lib_suffix('hsdis-' + mx.get_arch()))
        if exists(dest) and not overwrite:
            import filecmp
            # Only issue warning if existing lib is different
            if filecmp.cmp(hsdis_lib_file, dest) is False:
                mx.warn('Not overwriting existing {} with {}'.format(
                    dest, hsdis_lib_file))
        else:
            try:
                shutil.copy(hsdis_lib_file, dest)
                mx.log('Copied {} to {}'.format(hsdis_lib_file, dest))
            except IOError as e:
                mx.warn('Could not copy {} to {}: {}'.format(
                    hsdis_lib_file, dest, str(e)))
示例#22
0
def __get_svm_binary_from_graalvm():
    vmdir = os.path.join(mx.suite("truffle").dir, "..", "vm")
    return os.path.join(vmdir, "mxbuild",
                        "-".join([mx.get_os(), mx.get_arch()]),
                        "graalpython.image", "graalpython")
示例#23
0
 def rm_links(self):
     if mx.get_os() == 'windows':
         return
     for _, dest in self.subject.links:
         if os.path.lexists(dest):
             os.unlink(dest)
示例#24
0
 def build(self):
     if mx.get_os() == 'windows':
         mx.warn('Skip adding symlinks to the latest GraalVM (Platform Windows)')
         return
     self.rm_links()
     self.add_links()
示例#25
0
def _host_os_supported():
    return mx.get_os() == 'linux' or mx.get_os() == 'darwin'
示例#26
0
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# ----------------------------------------------------------------------------------------------------

import mx, mx_gate, mx_subst, mx_sdk, mx_graal_js, os, shutil, tarfile, tempfile

import mx_graal_nodejs_benchmark

from mx import BinarySuite
from mx_gate import Task
from argparse import ArgumentParser
from os.path import exists, join

_suite = mx.suite('graal-nodejs')
_currentOs = mx.get_os()
_currentArch = mx.get_arch()
_jdkHome = None


class GraalNodeJsTags:
    allTests = 'all'
    unitTests = 'unit'
    jniProfilerTests = 'jniprofiler'


def _graal_nodejs_post_gate_runner(args, tasks):
    _setEnvVar('NODE_INTERNAL_ERROR_CHECK', 'true')
    with Task('UnitTests',
              tasks,
              tags=[GraalNodeJsTags.allTests, GraalNodeJsTags.unitTests]) as t:
示例#27
0
def inspect(args):
    """launch a given program under the Inspector

    Run Maxine under the Inspector. The arguments accepted by this command
    are those accepted by the 'mx vm' command plus the Inspector specific
    options. To debug a program in the Inspector, simply replace 'vm' on the
    command line that launches the program with 'inspect'.

    Use "mx inspect --help" to see what the Inspector options are. These options
    must be specified with a '--' prefix so that they can be distinguished from
    the VM options.

    The inspect command also accepts the same system property related options
    as the 'image' command except that a '--' prefix must be used (e.g.
    '--os Darwin --bits 32'). Use "mx help image" for more detail.

    Use "mx vm -help" to see what the VM options are."""

    saveClassDir = join(_vmdir, 'inspected_classes')
    maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split()
    vmArgs = ['-XX:SaveClassDir=' + saveClassDir, '-XX:+TrapOnError'] + maxvmOptions
    insArgs = ['-vmdir=' + _vmdir]
    if not isdir(saveClassDir):
        os.makedirs(saveClassDir)
    sysProps = []
    sysProps += ['-Xbootclasspath/a:' + mx.distribution('GRAAL').path]
    insCP = []

    cwdArgs = check_cwd_change(args)
    cwd = cwdArgs[0]
    args = cwdArgs[1]

    i = 0
    remote = False
    while i < len(args):
        arg = args[i]
        if arg.startswith('-XX:LogFile='):
            logFile = arg.split('=', 1)[1]
            vmArgs += [arg]
            os.environ['TELE_LOG_FILE'] = 'tele-' + logFile
        elif arg in ['-cp', '-classpath']:
            vmArgs += [arg, args[i + 1]]
            insCP += [mx.expand_project_in_class_path_arg(args[i + 1])]
            i += 1
        elif arg == '-jar':
            vmArgs += ['-jar', args[i + 1]]
            insCP += [args[i + 1]]
            i += 1
        elif arg == '--remote':
            remote = True
        elif arg in ['--platform', '--cpu', '--isa', '--os', '--endianness', '--bits', '--page', '--nsig']:
            name = arg.lstrip('-')
            i += 1
            value = args[i]
            sysProps += ['-Dmax.' + name + '=' + value]
        elif arg.startswith('--cp='):
            insCP += [arg[len('--cp='):]]
        elif arg.startswith('--'):
            # chomp leading '-'
            insArgs += [arg[1:]]
        elif arg.startswith('-XX:SaveClassDir='):
            vmArgs += [arg]
            saveClassDir = arg.split('=', 1)[1]
            if not isdir(saveClassDir):
                os.makedirs(saveClassDir)
        elif arg.startswith('-'):
            vmArgs += [arg]
        else:
            # This is the main class argument; copy it and any following
            # arguments to the VM verbatim
            vmArgs += args[i:]
            break
        i += 1

    insCP += [saveClassDir]
    insCP = pathsep.join(insCP)
    insArgs += ['-cp=' + insCP]

    mx.expand_project_in_args(vmArgs)

    cmd = mx.java().format_cmd(sysProps + ['-cp', sanitized_classpath() + pathsep + insCP, 'com.sun.max.ins.MaxineInspector'] +
                              insArgs + ['-a=' + ' '.join(vmArgs)])

    if mx.get_os() == 'darwin' and not remote:
        # The -E option propagates the environment variables into the sudo process
        mx.run(['sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X.\nPlease enter your "sudo" password:'] + cmd, cwd=cwd)
    else:
        mx.run(cmd, cwd=cwd)
示例#28
0
_vmdir = None

# Set LD_LIBRARY_PATH to make dlopen work
#
# `DT_RPATH` is deprecated and replaced by `DT_RUNPATH`.  However
# `DT_RUNPATH` is not transitive and thus it's not propagated through
# maxvm to `dlopen` when loading `libjava.so`.  As a result, when
# loading `libjava.so` and chain-loading `libjvm.so` MaxineVM fails
# (unless `libjava.so` sets `DT_RUNPATH`, which it should NOT anymore).
# To overcome this issue we set `LD_LIBRARY_PATH`
# accordingly. Consequently the use of `-rpath` when linking maxvm (see
# `com.oracle.max.vm.native/platform/platform.mk`) is redundant now.
ldenv = os.environ
platform = platform.system()
if platform == "Linux":
    ldenv['LD_LIBRARY_PATH'] = ldenv['MAXINE_HOME'] + "/com.oracle.max.vm.native/generated/" + mx.get_os()
elif platform == "Darwin":
    ldenv['LD_LIBRARY_PATH'] = ldenv['MAXINE_HOME'] + "/com.oracle.max.vm.native/build/" + mx.get_os() +"/substrate"


def c1x(args):
    """alias for "mx olc -c=C1X ..." """
    olc(['-c=C1X'] + args)

def _configs():
    class Configs:
        def __init__(self):
            self.configs = dict()

        def eat(self, line):
            (k, v) = line.split('#')
示例#29
0
# Set LD_LIBRARY_PATH to make dlopen work
#
# `DT_RPATH` is deprecated and replaced by `DT_RUNPATH`.  However
# `DT_RUNPATH` is not transitive and thus it's not propagated through
# maxvm to `dlopen` when loading `libjava.so`.  As a result, when
# loading `libjava.so` and chain-loading `libjvm.so` MaxineVM fails
# (unless `libjava.so` sets `DT_RUNPATH`, which it should NOT anymore).
# To overcome this issue we set `LD_LIBRARY_PATH`
# accordingly. Consequently the use of `-rpath` when linking maxvm (see
# `com.oracle.max.vm.native/platform/platform.mk`) is redundant now.
ldenv = os.environ
platform = platform.system()
if platform == "Linux":
    ldenv['LD_LIBRARY_PATH'] = ldenv[
        'MAXINE_HOME'] + "/com.oracle.max.vm.native/generated/" + mx.get_os()
elif platform == "Darwin":
    ldenv['LD_LIBRARY_PATH'] = ldenv[
        'MAXINE_HOME'] + "/com.oracle.max.vm.native/build/" + mx.get_os(
        ) + "/substrate"


def c1x(args):
    """alias for "mx olc -c=C1X ..." """
    olc(['-c=C1X'] + args)


def _configs():
    class Configs:
        def __init__(self):
            self.configs = dict()
示例#30
0
def inspect(args):
    """launch a given program under the Inspector

    Run Maxine under the Inspector. The arguments accepted by this command
    are those accepted by the 'mx vm' command plus the Inspector specific
    options. To debug a program in the Inspector, simply replace 'vm' on the
    command line that launches the program with 'inspect'.

    Use "mx inspect --help" to see what the Inspector options are. These options
    must be specified with a '--' prefix so that they can be distinguished from
    the VM options.

    The inspect command also accepts the same system property related options
    as the 'image' command except that a '--' prefix must be used (e.g.
    '--os Darwin --bits 32'). Use "mx help image" for more detail.

    Use "mx vm -help" to see what the VM options are."""

    saveClassDir = join(_vmdir, 'inspected_classes')
    maxvmOptions = os.getenv('MAXVM_OPTIONS', '').split()
    vmArgs = ['-XX:SaveClassDir=' + saveClassDir, '-XX:+TrapOnError'] + maxvmOptions
    insArgs = ['-vmdir=' + _vmdir]
    if not isdir(saveClassDir):
        os.makedirs(saveClassDir)
    sysProps = []
    insCP = []

    i = 0
    remote = False
    while i < len(args):
        arg = args[i]
        if arg.startswith('-XX:LogFile='):
            logFile = arg.split('=', 1)[1]
            vmArgs += [arg]
            os.environ['TELE_LOG_FILE'] = 'tele-' + logFile
        elif arg in ['-cp', '-classpath']:
            vmArgs += [arg, args[i + 1]]
            insCP += [mx.expand_project_in_class_path_arg(args[i + 1])]
            i += 1
        elif arg == '-jar':
            vmArgs += ['-jar', args[i + 1]]
            insCP += [args[i + 1]]
            i += 1
        elif arg == '--remote':
            remote = True
        elif arg in ['--platform', '--cpu', '--isa', '--os', '--endianness', '--bits', '--page', '--nsig']:
            name = arg.lstrip('-')
            i += 1
            value = args[i]
            sysProps += ['-Dmax.' + name + '=' + value]
        elif arg.startswith('--cp='):
            insCP += [arg[len('--cp='):]]
        elif arg.startswith('--'):
            # chomp leading '-'
            insArgs += [arg[1:]]
        elif arg.startswith('-XX:SaveClassDir='):
            vmArgs += [arg]
            saveClassDir = arg.split('=', 1)[1]
            if not isdir(saveClassDir):
                os.makedirs(saveClassDir)
        elif arg.startswith('-'):
            vmArgs += [arg]
        else:
            # This is the main class argument; copy it and any following
            # arguments to the VM verbatim
            vmArgs += args[i:]
            break
        i += 1

    insCP += [saveClassDir]
    insCP = pathsep.join(insCP)
    insArgs += ['-cp=' + insCP]

    mx.expand_project_in_args(vmArgs)

    cmd = mx.java().format_cmd(sysProps + ['-cp', mx.classpath() + pathsep + insCP, 'com.sun.max.ins.MaxineInspector'] +
                              insArgs + ['-a=' + ' '.join(vmArgs)])

    if mx.get_os() == 'darwin' and not remote:
        # The -E option propagates the environment variables into the sudo process
        mx.run(['sudo', '-E', '-p', 'Debugging is a privileged operation on Mac OS X.\nPlease enter your "sudo" password:'] + cmd)
    else:
        mx.run(cmd)
示例#31
0
def copylib(args):
    '''
    This supports a configuration where no explicit setting (e.g. LD_LIBRARY_PATH) is
    required at runtime for the libraries that are required by FastR, e.g. pcre.
    The easy case is when the libraries are already installed with the correct versions
    in one of the directories, e.g./usr/lib, that is searched by default by the system linker -
    in which case no configuration is required.

    Otherwise, since systems vary considerably in where such libraries are located, the general solution
    is to copy libraries located in non-system locations into the FastR 'lib' directory. N.B. GNU R is
    even more picky than FastR about library versions and depends on a larger set, so the local
    copy embedded in FastR is built using PKG_LDFLAGS_OVERRIDE to specify the location of necessary external
    libraries. However, the result of this analysis isn't captured anywhere, so we re-analyze here.
    If PKG_LDFLAGS_OVERRIDE is unset, we assume the libraries are located in the system directories
    and do nothing.
    '''
    if 'PKG_LDFLAGS_OVERRIDE' in os.environ:
        parts = os.environ['PKG_LDFLAGS_OVERRIDE'].split(' ')
        ext = 'dylib' if platform.system() == 'Darwin' else 'so'
        lib_prefix = 'lib' + args[0] + '.'
        ver_env_key = 'FASTR_LIB' + args[0].upper() + '_VER'
        if ver_env_key in os.environ:
            lib_prefix += os.environ[ver_env_key] + '.'
        plain_libpath_base = lib_prefix + ext
        for part in parts:
            path = part.strip('"').lstrip('-L')
            if os.path.exists(path):
                for f in os.listdir(path):
                    if f.startswith(lib_prefix):
                        if os.path.exists(
                                os.path.join(path, plain_libpath_base)):
                            f = plain_libpath_base
                        target_dir = args[1]
                        target = os.path.join(path, f)
                        if not os.path.exists(os.path.join(target_dir, f)):
                            if os.path.islink(target):
                                link_target = os.path.join(
                                    path, os.readlink(target))
                                mx.log('link target: ' + link_target)
                                if link_target == '/usr/lib/libSystem.B.dylib' or link_target == '/usr/lib/libSystem.dylib':
                                    # simply copy over the link to the system library
                                    os.symlink(
                                        link_target,
                                        os.path.join(target_dir,
                                                     plain_libpath_base))
                                    return 0
                            _copylib(args[0], target, plain_libpath_base,
                                     args[1])
                        return 0

    if 'FASTR_RELEASE' in os.environ:
        # if args[0] == 'quadmath' and (mx.get_arch() == 'sparcv9' or mx.get_os() == 'solaris'):
        if mx.get_arch() == 'sparcv9' or mx.get_os() == 'solaris':
            return 0
        if os.environ.get('FASTR_RELEASE') == 'dev':
            mx.log(
                args[0] +
                ' not found in PKG_LDFLAGS_OVERRIDE, but required with FASTR_RELEASE'
            )
            mx.log(
                'the resulting FastR release build will not be portable to another system'
            )
        else:
            mx.abort(
                args[0] +
                ' not found in PKG_LDFLAGS_OVERRIDE, but required with FASTR_RELEASE'
            )

    mx.log(args[0] +
           ' not found in PKG_LDFLAGS_OVERRIDE, assuming system location')
    return 0
示例#32
0
def mx_post_parse_cmd_line(opts):
    global _vmdir
    if opts.vmdir is None:
        _vmdir = join(_maxine_home, 'com.oracle.max.vm.native', 'generated',  mx.get_os())
    else:
        _vmdir = opts.vmdir
示例#33
0
def _substratevm_clibrary_path():
    clibrary_subdir = join('clibraries', mx.get_os() + "-" + mx.get_arch())
    return ','.join((join(root, clibrary_subdir) for root in clibrary_roots))
示例#34
0
 def target(self):
     return '{}-{}'.format(mx.get_os(), self.target_arch)
示例#35
0
def hsdis(args, copyToDir=None):
    """download the hsdis library

    This is needed to support HotSpot's assembly dumping features.
    By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
    flavor = None
    if mx.get_arch() == "amd64":
        flavor = mx.get_env('HSDIS_SYNTAX')
        if flavor is None:
            flavor = 'intel'
        if 'att' in args:
            flavor = 'att'

    libpattern = mx.add_lib_suffix('hsdis-' + mx.get_arch() + '-' +
                                   mx.get_os() + '-%s')

    sha1s = {
        'att/hsdis-amd64-windows-%s.dll':
        'bcbd535a9568b5075ab41e96205e26a2bac64f72',
        'att/hsdis-amd64-linux-%s.so':
        '36a0b8e30fc370727920cc089f104bfb9cd508a0',
        'att/hsdis-amd64-darwin-%s.dylib':
        'c1865e9a58ca773fdc1c5eea0a4dfda213420ffb',
        'intel/hsdis-amd64-windows-%s.dll':
        '6a388372cdd5fe905c1a26ced614334e405d1f30',
        'intel/hsdis-amd64-linux-%s.so':
        '0d031013db9a80d6c88330c42c983fbfa7053193',
        'intel/hsdis-amd64-darwin-%s.dylib':
        '67f6d23cbebd8998450a88b5bef362171f66f11a',
        'hsdis-sparcv9-solaris-%s.so':
        '970640a9af0bd63641f9063c11275b371a59ee60',
        'hsdis-sparcv9-linux-%s.so':
        '0c375986d727651dee1819308fbbc0de4927d5d9',
    }

    if flavor:
        flavoredLib = flavor + "/" + libpattern
    else:
        flavoredLib = libpattern
    if flavoredLib not in sha1s:
        mx.warn(
            "hsdis with flavor '{}' not supported on this plattform or architecture"
            .format(flavor))
        return

    sha1 = sha1s[flavoredLib]
    lib = flavoredLib % (sha1)
    path = join(_suite.get_output_root(), lib)
    if not exists(path):
        sha1path = path + '.sha1'
        mx.download_file_with_sha1(
            'hsdis',
            path, ['https://lafo.ssw.uni-linz.ac.at/pub/hsdis/' + lib],
            sha1,
            sha1path,
            True,
            True,
            sources=False)
    if copyToDir is not None and exists(copyToDir):
        destFileName = mx.add_lib_suffix('hsdis-' + mx.get_arch())
        mx.logv('Copying {} to {}'.format(path,
                                          copyToDir + os.sep + destFileName))
        shutil.copy(path, copyToDir + os.sep + destFileName)
示例#36
0
def run_shared_lib_test(args=None):
    mx.run_mx([
        "--dynamicimports", "/substratevm,/vm", "build",
        "--force-deprecation-as-warning", "--dependencies",
        "GRAAL_MANAGEMENT,POLYGLOT_NATIVE_API_HEADERS,libpolyglot.so.image"
    ],
              nonZeroIsFatal=True)
    vmdir = os.path.join(mx.suite("truffle").dir, "..", "vm")
    svm_lib_path = os.path.join(vmdir, "mxbuild",
                                "-".join([mx.get_os(),
                                          mx.get_arch()]),
                                "libpolyglot.so.image")
    fd = name = progname = None
    try:
        fd, name = tempfile.mkstemp(suffix='.c')
        os.write(
            fd, """
        #include "stdio.h"
        #include "polyglot_api.h"

        #define assert_ok(msg, f) { if (!(f)) { \\
             const poly_extended_error_info* error_info; \\
             poly_get_last_error_info(isolate_thread, &error_info); \\
             fprintf(stderr, "%s\\n", error_info->error_message); \\
             return fprintf(stderr, "%s\\n", msg); } } while (0)

        poly_isolate global_isolate;
        poly_thread isolate_thread;
        poly_engine engine;
        poly_context context;

        static poly_status create_context() {
            poly_status status;

            if (poly_attach_thread(global_isolate, &isolate_thread)) {
                return poly_generic_failure;
            }

            poly_engine_builder engine_builder;
            status = poly_create_engine_builder(isolate_thread, &engine_builder);
            if (status != poly_ok) {
                return status;
            }
            status = poly_engine_builder_build(isolate_thread, engine_builder, &engine);
            if (status != poly_ok) {
                return status;
            }
            poly_context_builder builder;
            status = poly_create_context_builder(isolate_thread, NULL, 0, &builder);
            if (status != poly_ok) {
                return status;
            }
            status = poly_context_builder_engine(isolate_thread, builder, engine);
            if (status != poly_ok) {
                return status;
            }
            status = poly_context_builder_option(isolate_thread, builder, "python.VerboseFlag", "true");
            if (status != poly_ok) {
            return status;
            }
            status = poly_context_builder_allow_io(isolate_thread, builder, true);
            if (status != poly_ok) {
            return status;
            }
            status = poly_context_builder_build(isolate_thread, builder, &context);
            if (status != poly_ok) {
                return status;
            }

            poly_destroy_handle(isolate_thread, engine_builder);
            poly_destroy_handle(isolate_thread, builder);

            return poly_ok;
        }

        static poly_status tear_down_context() {
            poly_status status = poly_context_close(isolate_thread, context, true);
            if (status != poly_ok) {
                return status;
            }

            status = poly_destroy_handle(isolate_thread, context);
            if (status != poly_ok) {
                return status;
            }

            status = poly_engine_close(isolate_thread, engine, true);
            if (status != poly_ok) {
                return status;
            }

            status = poly_destroy_handle(isolate_thread, engine);
            if (status != poly_ok) {
                return status;
            }

            if (poly_detach_thread(isolate_thread)) {
                return poly_ok;
            }

            return poly_ok;
        }

        static int test_basic_python_function() {
            assert_ok("Context creation failed.", create_context() == poly_ok);

            poly_value func;
            assert_ok("function eval failed", poly_context_eval(isolate_thread, context, "python", "test_func", "def test_func(x):\\n  return x * x\\ntest_func", &func) == poly_ok);
            int32_t arg_value = 42;
            poly_value primitive_object;
            assert_ok("create argument failed", poly_create_int32(isolate_thread, context, arg_value, &primitive_object) == poly_ok);
            poly_value arg[1] = {primitive_object};
            poly_value value;
            assert_ok("invocation was unsuccessful", poly_value_execute(isolate_thread, func, arg, 1, &value) == poly_ok);

            int32_t result_value;
            poly_value_as_int32(isolate_thread, value, &result_value);

            assert_ok("primitive free failed", poly_destroy_handle(isolate_thread, primitive_object) == poly_ok);
            assert_ok("value free failed", poly_destroy_handle(isolate_thread, value) == poly_ok);
            assert_ok("value computation was incorrect", result_value == 42 * 42);
            assert_ok("func free failed", poly_destroy_handle(isolate_thread, func) == poly_ok);
            assert_ok("Context tear down failed.", tear_down_context() == poly_ok);
            return 0;
        }

        int32_t main(int32_t argc, char **argv) {
            poly_isolate_params isolate_params = {};
            if (poly_create_isolate(&isolate_params, &global_isolate)) {
                return 1;
            }
            return test_basic_python_function();
        }
        """)
        os.close(fd)
        progname = os.path.join(_suite.dir, "graalpython-embedded-tool")
        mx.log("".join([
            "Running ", "'clang",
            "-I%s" % svm_lib_path,
            "-L%s" % svm_lib_path, name, "-o", progname, "-lpolyglot"
        ]))
        mx.run([
            "clang",
            "-I%s" % svm_lib_path,
            "-L%s" % svm_lib_path, name,
            "-o%s" % progname, "-lpolyglot"
        ],
               nonZeroIsFatal=True)
        mx.log("Running " + progname + " with LD_LIBRARY_PATH " + svm_lib_path)
        mx.run(["ls", "-l", progname])
        mx.run(["ls", "-l", svm_lib_path])
        run_env = {
            "LD_LIBRARY_PATH": svm_lib_path,
            "GRAAL_PYTHONHOME": os.environ["GRAAL_PYTHONHOME"]
        }
        print(run_env)
        mx.run([progname], env=run_env)
    finally:
        try:
            os.unlink(progname)
        except:
            pass
        try:
            os.close(fd)
        except:
            pass
        try:
            os.unlink(name)
        except:
            pass
示例#37
0
def platform_name():
    return mx.get_os() + "-" + mx.get_arch()
示例#38
0
def platform_name():
    return mx.get_os() + "-" + mx.get_arch()
示例#39
0
def _host_os_supported():
    return mx.get_os() == 'linux' or mx.get_os() == 'darwin' or mx.get_os() == 'windows'
示例#40
0
 def machineOs(self):
     return mx.get_os()
示例#41
0
def layout_native_image_root(native_image_root):
    def names_to_dists(dist_names):
        return [mx.dependency(dist_name) for dist_name in dist_names]

    def native_image_layout_dists(subdir, dist_names):
        native_image_layout(names_to_dists(dist_names), subdir,
                            native_image_root)

    def native_image_extract_dists(subdir, dist_names):
        native_image_extract(names_to_dists(dist_names), subdir,
                             native_image_root)

    native_image_layout_dists(join(
        'lib', 'graalvm'), ['substratevm:SVM_DRIVER', 'sdk:LAUNCHER_COMMON'])

    # Create native-image layout for sdk parts
    graal_sdk_dists = ['sdk:GRAAL_SDK']
    if svm_java80():
        native_image_layout_dists(join('lib', 'boot'), graal_sdk_dists)
        jvmci_dists = graalDistribution
    else:
        jvmci_dists = graalDistribution + graal_sdk_dists

    # Create native-image layout for compiler & jvmci parts
    native_image_layout_dists(join('lib', 'jvmci'), jvmci_dists)
    if svm_java80():
        jdk_config = mx.get_jdk()
        jvmci_path = join(jdk_config.home, 'jre', 'lib', 'jvmci')
        if os.path.isdir(jvmci_path):
            for symlink_name in os.listdir(jvmci_path):
                symlink_or_copy(
                    join(jvmci_path, symlink_name),
                    join(native_image_root, 'lib', 'jvmci', symlink_name))

    # Create native-image layout for truffle parts
    if mx.get_os(
    ) != 'windows':  # necessary until Truffle is fully supported (GR-7941)
        native_image_layout_dists(join(
            'lib', 'truffle'), ['truffle:TRUFFLE_API', 'truffle:TRUFFLE_NFI'])

    # Create native-image layout for tools parts
    for tool_name in tools_map:
        tool_descriptor = tools_map[tool_name]
        native_image_layout_dists(join('tools', tool_name, 'builder'),
                                  tool_descriptor.builder_deps)
        native_image_layout_dists(join('tools', tool_name),
                                  tool_descriptor.image_deps)
        native_image_extract_dists(join('tools', tool_name),
                                   tool_descriptor.native_deps)
        native_image_option_properties('tools', tool_name, native_image_root)

    # Create native-image layout for svm parts
    svm_subdir = join('lib', 'svm')
    native_image_layout_dists(svm_subdir, librarySupportDistribution)
    native_image_layout_dists(
        join(svm_subdir, 'builder'),
        svmDistribution + ['substratevm:POINTSTO', 'substratevm:OBJECTFILE'])
    for clibrary_path in clibrary_paths():
        from distutils.errors import DistutilsFileError  # pylint: disable=no-name-in-module
        try:
            copy_tree(clibrary_path,
                      join(native_image_root, join(svm_subdir, 'clibraries')))
        except DistutilsFileError:
            # ignore until GR-7932 is resolved
            pass
示例#42
0
def platform_subdir():
    return mx.get_os() + "-" + mx.get_arch()
示例#43
0
    lib_javavm_cp = '${GRAALVM_HOME}/lib/graalvm/lib-javavm.jar'

espresso_library_config = mx_sdk_vm.LanguageLibraryConfig(
    language='java',
    jar_distributions=['espresso:LIB_JAVAVM'],
    build_args=[
        '-H:-JNIExportSymbols',
        '-R:+EnableSignalHandling',
        '-R:+InstallSegfaultHandler',
        '--features=com.oracle.truffle.espresso.ref.FinalizationFeature',
    ],
)

if mx_sdk_vm.base_jdk_version() not in (11, 17):
    _espresso_stability = "experimental"
elif mx.get_os() != "linux" or mx.get_arch() != "amd64":
    _espresso_stability = "experimental"
else:
    _espresso_stability = "supported"

mx_sdk_vm.register_graalvm_component(
    mx_sdk_vm.GraalVmLanguage(
        suite=_suite,
        name='Java on Truffle',
        short_name='java',
        installable_id='espresso',
        installable=True,
        license_files=['LICENSE_JAVAONTRUFFLE'],
        third_party_license_files=[],
        dependencies=['Truffle', 'nfi-libffi', 'ejvm'],
        truffle_jars=['espresso:ESPRESSO'],
示例#44
0
def hsdis(args, copyToDir=None):
    """download the hsdis library

    This is needed to support HotSpot's assembly dumping features.
    By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
    flavor = None
    if mx.get_arch() == "amd64":
        flavor = mx.get_env('HSDIS_SYNTAX')
        if flavor is None:
            flavor = 'intel'
        if 'att' in args:
            flavor = 'att'

    libpattern = mx.add_lib_suffix('hsdis-' + mx.get_arch() + '-' +
                                   mx.get_os() + '-%s')

    sha1s = {
        r'att\hsdis-amd64-windows-%s.dll':
        'bcbd535a9568b5075ab41e96205e26a2bac64f72',
        r'att/hsdis-amd64-linux-%s.so':
        '36a0b8e30fc370727920cc089f104bfb9cd508a0',
        r'att/hsdis-amd64-darwin-%s.dylib':
        'c1865e9a58ca773fdc1c5eea0a4dfda213420ffb',
        r'intel\hsdis-amd64-windows-%s.dll':
        '6a388372cdd5fe905c1a26ced614334e405d1f30',
        r'intel/hsdis-amd64-linux-%s.so':
        '0d031013db9a80d6c88330c42c983fbfa7053193',
        r'intel/hsdis-amd64-darwin-%s.dylib':
        '67f6d23cbebd8998450a88b5bef362171f66f11a',
        r'hsdis-sparcv9-solaris-%s.so':
        '970640a9af0bd63641f9063c11275b371a59ee60',
        r'hsdis-sparcv9-linux-%s.so':
        '0c375986d727651dee1819308fbbc0de4927d5d9',
        r'hsdis-aarch64-linux-%s.so':
        'fcc9b70ac91c00db8a50b0d4345490a68e3743e1',
    }

    if flavor:
        flavoredLib = join(flavor, libpattern)
    else:
        flavoredLib = libpattern
    if flavoredLib not in sha1s:
        mx.warn(
            "hsdis with flavor '{}' not supported on this platform or architecture"
            .format(flavor))
        return

    sha1 = sha1s[flavoredLib]
    lib = flavoredLib % (sha1)
    path = join(_suite.get_output_root(), lib)
    if not exists(path):
        sha1path = path + '.sha1'
        mx.download_file_with_sha1(
            'hsdis',
            path, [
                rewriteurl(
                    'https://lafo.ssw.uni-linz.ac.at/pub/graal-external-deps/hsdis/'
                    + lib.replace(os.sep, '/'))
            ],
            sha1,
            sha1path,
            True,
            True,
            sources=False)

    overwrite = True
    if copyToDir is None:
        # Try install hsdis into JAVA_HOME
        overwrite = False
        jdk = mx.get_jdk()
        base = jdk.home
        if exists(join(base, 'jre')):
            base = join(base, 'jre')
        if mx.get_os() == 'darwin':
            copyToDir = join(base, 'lib')
        elif mx.get_os() == 'windows':
            copyToDir = join(base, 'bin')
        else:
            if jdk.javaCompliance >= '11':
                copyToDir = join(base, 'lib')
            else:
                copyToDir = join(base, 'lib', mx.get_arch())

    if exists(copyToDir):
        dest = join(copyToDir, mx.add_lib_suffix('hsdis-' + mx.get_arch()))
        if exists(dest) and not overwrite:
            import filecmp
            # Only issue warning if existing lib is different
            if filecmp.cmp(path, dest) is False:
                mx.warn('Not overwriting existing {} with {}'.format(
                    dest, path))
        else:
            try:
                shutil.copy(path, dest)
                mx.log('Copied {} to {}'.format(path, dest))
            except IOError as e:
                mx.warn('Could not copy {} to {}: {}'.format(
                    path, dest, str(e)))
示例#45
0
def mx_post_parse_cmd_line(opts):
    global _vmdir
    if opts.vmdir is None:
        _vmdir = join(_maxine_home, 'com.oracle.max.vm.native', 'generated',  mx.get_os())
    else:
        _vmdir = opts.vmdir
示例#46
0
],
                             _suite,
                             env_file=False)
mx_sdk_vm.register_vm_config('ce', [
    'bgraalvm-native-binutil', 'bgraalvm-native-clang',
    'bgraalvm-native-clang++', 'bgraalvm-native-ld', 'bjs', 'blli',
    'bnative-image', 'btruffleruby', 'bwasm', 'cmp', 'gwa', 'js', 'lg', 'llp',
    'nfi', 'ni', 'nil', 'pbm', 'rby', 'rbyl', 'rgx', 'sdk', 'llrc', 'llrn',
    'llrl', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm',
    'tfl', 'tflm'
],
                             _suite,
                             env_file='polybench-ce')
# pylint: enable=line-too-long

if mx.get_os() == 'windows':
    mx_sdk_vm.register_vm_config('svm', [
        'bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gvm',
        'nfi', 'ni', 'nil', 'nju', 'nic', 'poly', 'polynative', 'rgx', 'sdk',
        'snative-image-agent', 'snative-image-diagnostics-agent', 'svm', 'tfl',
        'tflm'
    ],
                                 _suite,
                                 env_file=False)
else:
    mx_sdk_vm.register_vm_config('svm', [
        'bnative-image', 'bnative-image-configure', 'bpolyglot', 'cmp', 'gu',
        'gvm', 'nfi', 'ni', 'nil', 'nju', 'nic', 'poly', 'polynative', 'rgx',
        'sdk', 'snative-image-agent', 'snative-image-diagnostics-agent', 'svm',
        'svml', 'tfl', 'tflm'
    ],
示例#47
0
def graalvm_svm():
    """
    Gives access to image building withing the GraalVM release. Requires dynamic import of substratevm.
    """
    native_image_cmd = join(mx_sdk_vm_impl.graalvm_output(), 'bin', 'native-image') + ('.cmd' if mx.get_os() == 'windows' else '')
    svm = mx.suite('substratevm')
    if not exists(native_image_cmd) or not svm:
        mx.abort("Image building not accessible in GraalVM {}. Build GraalVM with native-image support".format(mx_sdk_vm_impl.graalvm_dist_name()))
    # useful to speed up image creation during development
    hosted_assertions = mx.get_env("DISABLE_SVM_IMAGE_HOSTED_ASSERTIONS", "false") != "true"
    @contextmanager
    def native_image_context(common_args=None, hosted_assertions=hosted_assertions):
        with svm.extensions.native_image_context(common_args, hosted_assertions, native_image_cmd=native_image_cmd) as native_image:
            yield native_image
    return native_image_context, svm.extensions
示例#48
0
# questions.
#
# ----------------------------------------------------------------------------------------------------

import mx, mx_gate, mx_subst, mx_sdk, mx_sdk_vm, mx_graal_js, os, tarfile, tempfile, subprocess, sys

import mx_graal_nodejs_benchmark

from mx import BinarySuite, TimeStampFile
from mx_gate import Task
from argparse import ArgumentParser
from os.path import exists, join, isdir, pathsep, sep
from mx_graal_js import get_jdk

_suite = mx.suite('graal-nodejs')
_current_os = mx.get_os()
_is_windows = _current_os == 'windows'
_current_arch = mx.get_arch()
_config_files = [join(_suite.dir, f) for f in ('configure', 'configure.py')]
_generated_config_files = [
    join(_suite.dir, f)
    for f in ('config.gypi', 'config.status', 'configure.pyc', 'config.mk',
              'icu_config.gypi')
]


class GraalNodeJsTags:
    allTests = 'all'
    unitTests = 'unit'
    jniProfilerTests = 'jniprofiler'
    windows = 'windows'  # we cannot run `node-gyp` in our CI unless we install the "Visual Studio Build Tools" (using the "Visual C++ build tools" workload)
示例#49
0
_maxine_home = dirname(dirname(__file__))
_vmdir = None

# Set LD_LIBRARY_PATH to make dlopen work
#
# `DT_RPATH` is deprecated and replaced by `DT_RUNPATH`.  However
# `DT_RUNPATH` is not transitive and thus it's not propagated through
# maxvm to `dlopen` when loading `libjava.so`.  As a result, when
# loading `libjava.so` and chain-loading `libjvm.so` MaxineVM fails
# (unless `libjava.so` sets `DT_RUNPATH`, which it should NOT anymore).
# To overcome this issue we set `LD_LIBRARY_PATH`
# accordingly. Consequently the use of `-rpath` when linking maxvm (see
# `com.oracle.max.vm.native/platform/platform.mk`) is redundant now.
ldenv = os.environ
ldenv['LD_LIBRARY_PATH'] = ldenv[
    'MAXINE_HOME'] + "/com.oracle.max.vm.native/generated/" + mx.get_os()


def c1x(args):
    """alias for "mx olc -c=C1X ..." """
    olc(['-c=C1X'] + args)


def _configs():
    class Configs:
        def __init__(self):
            self.configs = dict()

        def eat(self, line):
            (k, v) = line.split('#')
            self.configs[k] = v.rstrip()
示例#50
0
文件: mx_truffle.py 项目: cliid/graal
    def __init__(self, suite, name, deps, workingSets, **kwargs):
        subDir = 'src'
        srcDirs = ['patches']
        d = mx.join(suite.dir, subDir, name)
        super(LibffiBuilderProject,
              self).__init__(suite, name, subDir, srcDirs, deps, workingSets,
                             d, **kwargs)

        self.out_dir = self.get_output_root()
        if mx.get_os() == 'windows':
            self.delegate = mx_native.DefaultNativeProject(
                suite,
                name,
                subDir, [], [],
                None,
                mx.join(self.out_dir, 'libffi-3.3'),
                'static_lib',
                deliverable='ffi',
                cflags=['-MD', '-O2', '-DFFI_BUILDING_DLL'])
            self.delegate._source = dict(
                tree=['include', 'src',
                      mx.join('src', 'x86')],
                files={
                    '.h': [
                        mx.join('include', 'ffi.h'),
                        mx.join('include', 'ffitarget.h'),
                        mx.join('src', 'fficonfig.h'),
                        mx.join('src', 'ffi_common.h')
                    ],
                    '.c': [
                        mx.join('src', 'closures.c'),
                        mx.join('src', 'prep_cif.c'),
                        mx.join('src', 'raw_api.c'),
                        mx.join('src', 'types.c'),
                        mx.join('src', 'x86', 'ffiw64.c')
                    ],
                    '.S': [mx.join('src', 'x86', 'win64_intel.S')]
                })
        else:

            class LibtoolNativeProject(
                    mx.NativeProject,  # pylint: disable=too-many-ancestors
                    mx_native.NativeDependency):
                include_dirs = property(
                    lambda self: [mx.join(self.getOutput(), 'include')])
                libs = property(
                    lambda self:
                    [next(self.getArchivableResults(single=True))[0]])

                def getArchivableResults(self, use_relpath=True, single=False):
                    for file_path, archive_path in super(
                            LibtoolNativeProject,
                            self).getArchivableResults(use_relpath):
                        path_in_lt_objdir = mx.basename(
                            mx.dirname(file_path)) == '.libs'
                        yield file_path, mx.basename(
                            archive_path
                        ) if path_in_lt_objdir else archive_path
                        if single:
                            assert path_in_lt_objdir, 'the first build result must be from LT_OBJDIR'
                            break

            self.delegate = LibtoolNativeProject(
                suite, name, subDir, [], [], None,
                ['.libs/libffi.a', 'include/ffi.h', 'include/ffitarget.h'],
                mx.join(self.out_dir, 'libffi-build'),
                mx.join(self.out_dir, 'libffi-3.3'))
            self.delegate.buildEnv = dict(
                SOURCES=mx.basename(self.delegate.dir),
                OUTPUT=mx.basename(self.delegate.getOutput()),
                CONFIGURE_ARGS=' '.join([
                    '--disable-dependency-tracking',
                    '--disable-shared',
                    '--with-pic',
                    'CFLAGS="{}"'.format(' '.join(['-g', '-O3'] + (
                        ['-m64'] if mx.get_os() == 'solaris' else []))),
                    'CPPFLAGS="-DNO_JAVA_RAW_API"',
                ]))

        self.include_dirs = self.delegate.include_dirs
        self.libs = self.delegate.libs
示例#51
0
 def machineOs(self):
     return mx.get_os()