Beispiel #1
0
    def needsBuild(self, newestInput):
        witness = self.newestOutput()
        if not self._newestOutput or witness.isNewerThan(self._newestOutput):
            self._newestOutput = witness
        if not witness.exists():
            return True, witness.path + ' does not exist'
        if newestInput and witness.isOlderThan(newestInput):
            return True, '{} is older than {}'.format(witness, newestInput)
        if self.subject.jni_config_dist and witness.isOlderThan(
                mx.distribution(self.subject.jni_config_dist).path):
            return True, '{} is older than {}'.format(
                witness,
                mx.distribution(self.subject.jni_config_dist).path)
        if self.subject.jni_config_path and witness.isOlderThan(
                self.subject.jni_config_path):
            return True, '{} is older than {}'.format(
                witness, self.subject.jni_config_path)

        previous_command = []
        command_file = self._get_command_file()
        if exists(command_file):
            with open(command_file) as f:
                previous_command = [l.rstrip('\r\n') for l in f.readlines()]
        if previous_command != self._get_image_command():
            return True, 'image command changed'
        return False, 'output is up to date'
Beispiel #2
0
    def load(dist, jdk, fatalIfNotCreated=True):
        """
        Unpickles the module descriptor corresponding to a given distribution.

        :param str dist: the distribution for which to read the pickled object
        :param JDKConfig jdk: used to resolve pickled references to JDK modules
        :param bool fatalIfNotCreated: specifies whether to abort if a descriptor has not been created yet
        """
        _, moduleDir, _ = get_java_module_info(dist, fatalIfNotModule=True)  # pylint: disable=unpacking-non-sequence
        path = moduleDir + '.pickled'
        if not exists(path):
            if fatalIfNotCreated:
                mx.abort(path + ' does not exist')
            else:
                return None
        with open(path, 'rb') as fp:
            jmd = pickle.load(fp)
        jdkmodules = {m.name: m for m in jdk.get_modules()}
        resolved = []
        for name in jmd.modulepath:
            if name.startswith('dist:'):
                distName = name[len('dist:'):]
                resolved.append(as_java_module(mx.distribution(distName), jdk))
            else:
                resolved.append(jdkmodules[name])
        jmd.modulepath = resolved
        jmd.dist = mx.distribution(jmd.dist)
        if not os.path.isabs(jmd.jarpath):
            jmd.jarpath = join(dirname(path), jmd.jarpath)
        return jmd
Beispiel #3
0
def setupNodeEnvironment(args):
    javaHome = _getJdkHome()
    _setEnvVar('JAVA_HOME', javaHome)
    if mx.suite('compiler', fatalIfMissing=False) is None:
        _setEnvVar('GRAAL_SDK_JAR_PATH', mx.distribution('sdk:GRAAL_SDK').path)
        _setEnvVar('TRUFFLE_JAR_PATH', mx.distribution('truffle:TRUFFLE_API').path)
    _setEnvVar('LAUNCHER_COMMON_JAR_PATH', mx.distribution('sdk:LAUNCHER_COMMON').path)
    _setEnvVar('TRUFFLENODE_JAR_PATH', mx.distribution('TRUFFLENODE').path)
    _setEnvVar('NODE_JVM_CLASSPATH', mx.classpath(['tools:CHROMEINSPECTOR', 'tools:TRUFFLE_PROFILER', 'TRUFFLENODE']))
    setLibraryPath()

    prevPATH = os.environ['PATH']
    _setEnvVar('PATH', "%s:%s" % (join(_suite.mxDir, 'fake_launchers'), prevPATH))

    args = args if args else []
    mode, vmArgs, progArgs = _parseArgs(args)

    if mx.suite('graal-enterprise', fatalIfMissing=False):
        # explicitly require the enterprise compiler configuration
        vmArgs += ['-Dgraal.CompilerConfiguration=enterprise']
    if mx.suite('compiler', fatalIfMissing=False):
        vmArgs += ['-Djvmci.Compiler=graal', '-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI']

    if isinstance(_suite, BinarySuite):
        mx.logv('%s is a binary suite' % _suite.name)
        tarfilepath = mx.distribution('TRUFFLENODE_GRAALVM_SUPPORT').path
        with tarfile.open(tarfilepath, 'r:') as tar:
            mx.logv('Extracting {} to {}'.format(tarfilepath, _suite.dir))
            tar.extractall(_suite.dir)

    return mode, vmArgs, progArgs
Beispiel #4
0
def mx_post_parse_cmd_line(opts):
    mx.add_ide_envvar('JVMCI_VERSION_CHECK')
    for dist in _suite.dists:
        dist.set_archiveparticipant(GraalArchiveParticipant(dist, isTest=dist.name.endswith('_TEST')))
    add_bootclasspath_append(mx.distribution('sdk:GRAAL_SDK'))
    add_bootclasspath_append(mx.distribution('truffle:TRUFFLE_API'))
    global _vm_prefix
    _vm_prefix = opts.vm_prefix
Beispiel #5
0
def setupNodeEnvironment(args, add_graal_vm_args=True):
    args = args if args else []
    mode, vmArgs, progArgs = _parseArgs(args)
    vmArgs += mx.java_debug_args()
    setLibraryPath()

    if mx.suite('vm', fatalIfMissing=False) is not None and mx.suite(
            'substratevm', fatalIfMissing=False) is not None:
        _prepare_svm_env()
        return mode, vmArgs, progArgs

    if mx.suite('vm', fatalIfMissing=False) is not None or mx.suite(
            'substratevm', fatalIfMissing=False) is not None:
        mx.warn(
            "Running on the JVM.\nIf you want to run on SubstrateVM, you need to dynamically import both '/substratevm' and '/vm'.\nExample: 'mx --env svm node'"
        )

    javaHome = _getJdkHome()
    _setEnvVar('JAVA_HOME', javaHome)
    if mx.suite('compiler', fatalIfMissing=False) is None:
        _setEnvVar('GRAAL_SDK_JAR_PATH', mx.distribution('sdk:GRAAL_SDK').path)
        _setEnvVar('TRUFFLE_JAR_PATH',
                   mx.distribution('truffle:TRUFFLE_API').path)
    _setEnvVar('LAUNCHER_COMMON_JAR_PATH',
               mx.distribution('sdk:LAUNCHER_COMMON').path)
    _setEnvVar('TRUFFLENODE_JAR_PATH', mx.distribution('TRUFFLENODE').path)
    node_jvm_cp = (os.environ['NODE_JVM_CLASSPATH'] +
                   os.pathsep) if 'NODE_JVM_CLASSPATH' in os.environ else ''
    node_cp = node_jvm_cp + mx.classpath(['TRUFFLENODE'] + (
        ['tools:CHROMEINSPECTOR', 'tools:TRUFFLE_PROFILER'] if mx.
        suite('tools', fatalIfMissing=False) is not None else []))
    _setEnvVar('NODE_JVM_CLASSPATH', node_cp)

    prevPATH = os.environ['PATH']
    _setEnvVar('PATH',
               "%s:%s" % (join(_suite.mxDir, 'fake_launchers'), prevPATH))

    if add_graal_vm_args:
        if mx.suite('graal-enterprise', fatalIfMissing=False):
            # explicitly require the enterprise compiler configuration
            vmArgs += ['-Dgraal.CompilerConfiguration=enterprise']
        if mx.suite('compiler', fatalIfMissing=False):
            vmArgs += [
                '-Djvmci.Compiler=graal', '-XX:+UnlockExperimentalVMOptions',
                '-XX:+EnableJVMCI'
            ]

    if isinstance(_suite, BinarySuite):
        mx.logv('%s is a binary suite' % _suite.name)
        tarfilepath = mx.distribution('TRUFFLENODE_GRAALVM_SUPPORT').path
        with tarfile.open(tarfilepath, 'r:') as tar:
            mx.logv('Extracting {} to {}'.format(tarfilepath, _suite.dir))
            tar.extractall(_suite.dir)

    return mode, vmArgs, progArgs
Beispiel #6
0
def setupNodeEnvironment(args, add_graal_vm_args=True):
    args = args if args else []
    mode, vmArgs, progArgs = _parseArgs(args)
    setLibraryPath()

    if _is_windows:
        processDevkitRoot()

    if mx.suite('vm', fatalIfMissing=False) is not None and mx.suite(
            'substratevm', fatalIfMissing=False) is not None:
        _prepare_svm_env()
        return mode, vmArgs, progArgs

    if mx.suite('vm', fatalIfMissing=False) is not None or mx.suite(
            'substratevm', fatalIfMissing=False) is not None:
        mx.warn(
            "Running on the JVM.\nIf you want to run on SubstrateVM, you need to dynamically import both '/substratevm' and '/vm'.\nExample: 'mx --env svm node'"
        )

    if mx.suite('compiler', fatalIfMissing=False) is None and not any(
            x.startswith('-Dpolyglot.engine.WarnInterpreterOnly')
            for x in vmArgs + get_jdk().java_args):
        vmArgs += ['-Dpolyglot.engine.WarnInterpreterOnly=false']

    _setEnvVar('JAVA_HOME', _java_home())
    # if mx.suite('compiler', fatalIfMissing=False) is None:
    #     _setEnvVar('GRAAL_SDK_JAR_PATH', mx.distribution('sdk:GRAAL_SDK').path)
    _setEnvVar('LAUNCHER_COMMON_JAR_PATH',
               mx.distribution('sdk:LAUNCHER_COMMON').path)
    _setEnvVar('TRUFFLENODE_JAR_PATH', mx.distribution('TRUFFLENODE').path)
    node_jvm_cp = (os.environ['NODE_JVM_CLASSPATH'] +
                   pathsep) if 'NODE_JVM_CLASSPATH' in os.environ else ''
    node_cp = node_jvm_cp + mx.classpath(
        ['TRUFFLENODE'] +
        (['tools:CHROMEINSPECTOR', 'tools:TRUFFLE_PROFILER', 'tools:INSIGHT']
         if mx.suite('tools', fatalIfMissing=False) is not None else []) +
        (['wasm:WASM'] if mx.suite('wasm', fatalIfMissing=False
                                   ) is not None else []))
    _setEnvVar('NODE_JVM_CLASSPATH', node_cp)

    prevPATH = os.environ['PATH']
    _setEnvVar(
        'PATH',
        "%s%s%s" % (join(_suite.mxDir, 'fake_launchers'), pathsep, prevPATH))

    if isinstance(_suite, BinarySuite):
        mx.logv('%s is a binary suite' % _suite.name)
        tarfilepath = mx.distribution('TRUFFLENODE_GRAALVM_SUPPORT').path
        with tarfile.open(tarfilepath, 'r:') as tar:
            mx.logv('Extracting {} to {}'.format(tarfilepath, _suite.dir))
            tar.extractall(_suite.dir)

    return mode, vmArgs, progArgs
Beispiel #7
0
def _unittest_config_participant(config):
    vmArgs, mainClass, mainClassArgs = config
    cpIndex, cp = mx.find_classpath_arg(vmArgs)
    if cp:
        cp = _uniqify(cp.split(os.pathsep))
        if isJDK8:
            # Remove entries from class path that are in Graal or on the boot class path
            redundantClasspathEntries = set()
            for dist in [entry.dist() for entry in _jvmci_classpath]:
                redundantClasspathEntries.update((d.output_dir() for d in dist.archived_deps() if d.isJavaProject()))
                redundantClasspathEntries.add(dist.path)
            cp = os.pathsep.join([e for e in cp if e not in redundantClasspathEntries])
            vmArgs[cpIndex] = cp
        else:
            redundantClasspathEntries = set()
            for dist in [entry.dist() for entry in _jvmci_classpath] + _bootclasspath_appends:
                redundantClasspathEntries.update(mx.classpath(dist, preferProjects=False, jdk=jdk).split(os.pathsep))
                redundantClasspathEntries.update(mx.classpath(dist, preferProjects=True, jdk=jdk).split(os.pathsep))
                if hasattr(dist, 'overlaps'):
                    for o in dist.overlaps:
                        path = mx.distribution(o).classpath_repr()
                        if path:
                            redundantClasspathEntries.add(path)

            # Remove entries from the class path that are in the deployed modules
            cp = [classpathEntry for classpathEntry in cp if classpathEntry not in redundantClasspathEntries]
            vmArgs[cpIndex] = os.pathsep.join(cp)

    if isJDK8:
        # Run the VM in a mode where application/test classes can
        # access JVMCI loaded classes.
        vmArgs.append('-XX:-UseJVMCIClassLoader')

    return (vmArgs, mainClass, mainClassArgs)
Beispiel #8
0
def runLLVMUnittests(unittest_runner):
    """runs the interop unit tests with a different unittest runner (e.g. AOT-based)"""
    libpath = mx_subst.path_substitutions.substitute(
        '-Dpolyglot.llvm.libraryPath=<path:SULONG_TEST_NATIVE>')
    libs = mx_subst.path_substitutions.substitute(
        '-Dpolyglot.llvm.libraries=<lib:sulongtest>')

    test_harness_dist = mx.distribution('SULONG_TEST')
    java_run_props = [
        x for x in mx.get_runtime_jvm_args(test_harness_dist)
        if x.startswith('-D')
    ]
    # necessary because mx native-unittest ignores config participants (GR-34875)
    java_run_props += [
        x for x in _unittest_config_participant(([], None, None))[0]
        if x.startswith('-D')
    ]

    test_suite = 'SULONG_EMBEDDED_TEST_SUITES'
    mx_sulong_suite_constituents.compileTestSuite(test_suite,
                                                  extra_build_args=[])

    run_args = [libpath, libs] + java_run_props
    build_args = ['--language:llvm'] + java_run_props
    unittest_runner(['com.oracle.truffle.llvm.tests.interop', '--run-args'] +
                    run_args + ['--build-args', '--initialize-at-build-time'] +
                    build_args)
Beispiel #9
0
def test_ruby(args):
    if len(args) < 1 or len(args) > 2:
        mx.abort(
            'mx svm_test_ruby <ruby_svm_image_path> [<debug_build>=release]')

    aot_bin = args[0]
    debug_build = args[1] if len(args) >= 2 else 'release'

    ruby_version = None
    if not ruby_version and os.environ.has_key('TRUFFLE_RUBY_VERSION'):
        ruby_version = os.environ['TRUFFLE_RUBY_VERSION']
    truffleruby_suite = ensure_trufflelanguage('truffleruby', ruby_version)

    suite_dir = truffleruby_suite.dir
    distsToExtract = ['TRUFFLERUBY-ZIP', 'TRUFFLERUBY-SPECS']
    lib = join(suite_dir, 'lib')
    if not exists(lib):
        # Binary suite, extract the distributions
        for dist_name in distsToExtract:
            mx.log('Extract distribution {} to {}'.format(
                dist_name, suite_dir))
            dist = mx.distribution(dist_name)
            with tarfile.open(dist.path, 'r:') as archive:
                archive.extractall(suite_dir)

    mx.command_function('ruby_testdownstream_aot')(
        [aot_bin, 'spec', debug_build])
Beispiel #10
0
def _build(args, debug, shared_library, threading, parallelism, debug_mode,
           output_dir):
    _mxrun([
        './configure', '--partly-static', '--build-only-native',
        '--without-dtrace', '--without-snapshot', '--shared-zlib',
        '--shared-graalvm',
        _getJdkHome(), '--shared-trufflejs',
        mx.distribution('graal-js:GRAALJS').path
    ] + debug + shared_library + threading,
           cwd=_suite.dir,
           verbose=True)

    _mxrun([mx.gmake_cmd(), '-j%d' % parallelism],
           cwd=_suite.dir,
           verbose=True)

    if _currentOs == 'darwin':
        nodePath = join(_suite.dir, 'out',
                        'Debug' if debug_mode else 'Release', 'node')
        _mxrun([
            'install_name_tool', '-add_rpath',
            join(_getJdkHome(), 'jre', 'lib'), nodePath
        ],
               verbose=True)

    _createSymLinks()
Beispiel #11
0
def jacocoreport(args):
    """create a JaCoCo coverage report

    Creates the report from the 'jacoco.exec' file in the current directory.
    Default output directory is 'coverage', but an alternative can be provided as an argument."""

    dist_name = "MX_JACOCO_REPORT"
    mx.command_function("build")(['--dependencies', dist_name])
    dist = mx.distribution(dist_name)
    jdk = mx.get_jdk(dist.javaCompliance)

    parser = ArgumentParser(prog='mx jacocoreport')
    parser.add_argument('--format',
                        help='Export format (HTML or XML)',
                        default='html',
                        choices=['html', 'xml'])
    parser.add_argument('--omit-excluded',
                        action='store_true',
                        help='omit excluded files from report')
    parser.add_argument('output_directory',
                        help='Output directory',
                        default='coverage',
                        nargs='?')
    args = parser.parse_args(args)

    # list of strings of the form "project-dir:binary-dir"
    includedirs = []
    for p in mx.projects():
        projsetting = getattr(p, 'jacoco', '')
        if projsetting in ('include', '') and _jacoco_is_package_whitelisted(
                p.name):
            if isinstance(p, mx.ClasspathDependency):
                if args.omit_excluded and p.is_test_project(
                ):  # skip test projects when omit-excluded
                    continue
                source_dirs = []
                if p.isJavaProject():
                    source_dirs += p.source_dirs() + [p.source_gen_dir()]
                includedirs.append(
                    ":".join([p.dir, p.classpath_repr(jdk)] + source_dirs))

    def _run_reporter(extra_args=None):
        mx.run_java([
            '-cp',
            mx.classpath([dist_name],
                         jdk=jdk), '-jar', dist.path, '--in', JACOCO_EXEC,
            '--out', args.output_directory, '--format', args.format
        ] + (extra_args or []) + sorted(includedirs),
                    jdk=jdk,
                    addDefaultArgs=False)

    if not args.omit_excluded:
        _run_reporter()
    else:
        with tempfile.NamedTemporaryFile(suffix="jacoco-report-exclude",
                                         mode="w") as fp:
            excludes, _ = _jacoco_excludes_includes()
            fp.writelines((e + "\n" for e in excludes))
            fp.flush()
            _run_reporter(['--exclude-file', fp.name])
Beispiel #12
0
    def _get_image_command(self):
        command = list(self.subject.get_image_builder_jvm_args())
        command += ['--']
        command += ['-H:Path=' + self.subject.get_output_root()]
        command += ['-H:Name=' + self.subject.get_image_builder_binary_name()]

        def _dep_name(dep):
            if dep.isProject():
                return dep.name
            else:
                return dep.suite.name + ':' + dep.name

        command += ['-H:Projects=' + ','.join((_dep_name(d) for d in self.subject.deps))]
        if self.subject.build_args:
            command += self.subject.build_args
        if self.subject.jni_config_dist:
            tarfilepath = mx.distribution(self.subject.jni_config_dist).path
            with tarfile.open(tarfilepath, 'r:') as tar:
                mx.logv("Extracting jni config file '{}' from '{}' to '{}'".format(self.subject.jni_config_file, tarfilepath, self.subject.get_output_root()))
                tar.extract(self.subject.jni_config_file, self.subject.get_output_root())
        if self.subject.jni_config_path:
            command += ['-H:JNIConfigurationFiles=' + self.subject.jni_config_path]
        if self.subject.features:
            command += ['-H:Features=' + ','.join(self.subject.features)]
        if self.subject.type == SVMImageProject.Type.SHARED_LIBRARY:
            command += ['-H:Kind=SHARED_LIBRARY']
        elif self.subject.type == SVMImageProject.Type.EXECUTABLE:
            command += ['-H:Class=' + self.subject.main_class]
            command += ['-H:Kind=EXECUTABLE']
        else:
            mx.abort("Unsupported type: " + str(self.subject.type))
        command += list(self.subject.get_image_builder_args())
        return command
Beispiel #13
0
    def build(self):
        outputDir = self.subject.output_dir()
        snapshotToolDistribution = 'graal-js:TRUFFLE_JS_SNAPSHOT_TOOL'
        pythonCmd = join(_suite.mxDir, 'python2/python')

        moduleSet = self.modulesToSnapshot()

        outputDirBin = join(outputDir, 'lib')
        mx.ensure_dir_exists(outputDirBin)

        macroFiles = []
        # Lttng is disabled by default on all platforms
        macroFiles.append('src/nolttng_macros.py')
        # performance counters are enabled by default only on Windows
        if _currentOs is not 'windows':
            macroFiles.append('src/noperfctr_macros.py')
        # DTrace is disabled explicitly by the --without-dtrace option
        # ETW is enabled by default only on Windows
        if _currentOs is not 'windows':
            macroFiles.append('src/notrace_macros.py')

        mx.run([pythonCmd, 'tools/expand-js-modules.py', outputDir] + [join('lib', m) for m in moduleSet] + macroFiles,
               cwd=_suite.dir)
        if not (hasattr(self.args, "jdt") and self.args.jdt and not self.args.force_javac):
            mx.run_java(['-cp', mx.classpath([snapshotToolDistribution]), mx.distribution(snapshotToolDistribution).mainClass,
                     '--binary', '--outdir=' + outputDirBin, '--indir=' + outputDirBin] + ['--file=' + m for m in moduleSet],
                    cwd=outputDirBin)
        mx.run([pythonCmd, join(_suite.dir, 'tools/snapshot2c.py'), 'node_snapshots.h'] + [join('lib', m + '.bin') for m in moduleSet],
               cwd=outputDir)
Beispiel #14
0
def _build(args, debug, shared_library, threading, parallelism, debug_mode,
           output_dir):
    _mxrun([
        './configure', '--partly-static', '--build-only-native',
        '--without-dtrace', '--without-snapshot', '--shared-graalvm',
        _getJdkHome(), '--shared-trufflejs',
        mx.distribution('graal-js:GRAALJS').path
    ] + debug + shared_library + threading,
           cwd=_suite.dir,
           verbose=True)

    verbose = 'V={}'.format('1' if mx.get_opts().verbose else '')
    _mxrun([mx.gmake_cmd(), '-j%d' % parallelism, verbose],
           cwd=_suite.dir,
           verbose=True)

    # put headers for native modules into out/headers
    _setEnvVar('HEADERS_ONLY', '1')
    out = None if mx.get_opts().verbose else open(os.devnull, 'w')
    _mxrun([
        join(_suite.mxDir, 'python2', 'python'), 'tools/install.py', 'install',
        'out/headers', '/'
    ],
           out=out)

    if _currentOs == 'darwin':
        nodePath = join(_suite.dir, 'out',
                        'Debug' if debug_mode else 'Release', 'node')
        _mxrun([
            'install_name_tool', '-add_rpath',
            join(_getJdkHome(), 'jre', 'lib'), nodePath
        ],
               verbose=True)

    _createSymLinks()
        def dist(self):
            """
            Gets the `JARDistribution` that creates the Graal module jar.

            :rtype: `JARDistribution
            """
            return mx.distribution(self._name)
Beispiel #16
0
def jacocoreport(args):
    """create a JaCoCo coverage report

    Creates the report from the 'jacoco.exec' file in the current directory.
    Default output directory is 'coverage', but an alternative can be provided as an argument."""

    dist_name = "MX_JACOCO_REPORT"
    dist = mx.distribution(dist_name)
    jdk = mx.get_jdk(dist.javaCompliance)

    out = 'coverage'
    if len(args) == 1:
        out = args[0]
    elif len(args) > 1:
        mx.abort('jacocoreport takes only one argument : an output directory')

    # list of strings of the form "project-dir:binary-dir"
    includedirs = []
    for p in mx.projects():
        projsetting = getattr(p, 'jacoco', '')
        if projsetting == 'include' or projsetting == '':
            if isinstance(p, mx.ClasspathDependency):
                includedirs.append(p.dir + ":" + p.classpath_repr(jdk))

    mx.run_java([
        '-cp',
        mx.classpath([dist_name], jdk=jdk), '-jar', dist.path, '--in',
        'jacoco.exec', '--out', out
    ] + sorted(includedirs),
                jdk=jdk)
Beispiel #17
0
def _unittest_config_participant(config):
    vmArgs, mainClass, mainClassArgs = config
    cpIndex, cp = mx.find_classpath_arg(vmArgs)
    if cp:
        cp = _uniqify(cp.split(os.pathsep))
        if isJDK8:
            # Remove entries from class path that are in Graal or on the boot class path
            redundantClasspathEntries = set()
            for dist in [entry.dist() for entry in _jvmci_classpath]:
                redundantClasspathEntries.update((d.output_dir() for d in dist.archived_deps() if d.isJavaProject()))
                redundantClasspathEntries.add(dist.path)
            cp = os.pathsep.join([e for e in cp if e not in redundantClasspathEntries])
            vmArgs[cpIndex] = cp
        else:
            redundantClasspathEntries = set()
            for dist in [entry.dist() for entry in _jvmci_classpath] + _bootclasspath_appends:
                redundantClasspathEntries.update(mx.classpath(dist, preferProjects=False, jdk=jdk).split(os.pathsep))
                redundantClasspathEntries.update(mx.classpath(dist, preferProjects=True, jdk=jdk).split(os.pathsep))
                if hasattr(dist, 'overlaps'):
                    for o in dist.overlaps:
                        path = mx.distribution(o).classpath_repr()
                        if path:
                            redundantClasspathEntries.add(path)

            # Remove entries from the class path that are in the deployed modules
            cp = [classpathEntry for classpathEntry in cp if classpathEntry not in redundantClasspathEntries]
            vmArgs[cpIndex] = os.pathsep.join(cp)

    if isJDK8:
        # Run the VM in a mode where application/test classes can
        # access JVMCI loaded classes.
        vmArgs.append('-XX:-UseJVMCIClassLoader')

    return (vmArgs, mainClass, mainClassArgs)
Beispiel #18
0
def jacocoreport(args):
    """create a JaCoCo coverage report

    Creates the report from the 'jacoco.exec' file in the current directory.
    Default output directory is 'coverage', but an alternative can be provided as an argument."""

    dist_name = "MX_JACOCO_REPORT"
    dist = mx.distribution(dist_name)
    jdk = mx.get_jdk(dist.javaCompliance)

    parser = ArgumentParser(prog='mx jacocoreport')
    parser.add_argument('--format',
                        help='Export format (HTML or XML)',
                        default='html',
                        choices=['html', 'xml'])
    parser.add_argument('output_directory',
                        help='Output directory',
                        default='coverage',
                        nargs='?')
    args = parser.parse_args(args)

    # list of strings of the form "project-dir:binary-dir"
    includedirs = []
    for p in mx.projects():
        projsetting = getattr(p, 'jacoco', '')
        if projsetting == 'include' or projsetting == '':
            if isinstance(p, mx.ClasspathDependency):
                includedirs.append(p.dir + ":" + p.classpath_repr(jdk))

    mx.run_java([
        '-cp',
        mx.classpath([dist_name], jdk=jdk), '-jar', dist.path, '--in',
        'jacoco.exec', '--out', args.output_directory, '--format', args.format
    ] + sorted(includedirs),
                jdk=jdk)
Beispiel #19
0
 def prepare_env(self, env):
     super(ClangVm, self).prepare_env(env)
     env["CXXFLAGS"] = env.get("CXXFLAGS", "") + " -stdlib=libc++"
     if "LIBCXXPATH" not in env:
         env["LIBCXXPATH"] = os.path.join(
             mx.distribution("LLVM_TOOLCHAIN").get_output(), "lib")
     return env
Beispiel #20
0
def mx_post_parse_cmd_line(opts):
    mx_fastr_dists.mx_post_parse_cmd_line(opts)
    if mx.suite("sulong", fatalIfMissing=False) and not _fastr_suite.isBinarySuite():
        # native.recommended runs FastR, it already has a build dependency to the FASTR distribution
        # if we are running with sulong we also need the SULONG distribution
        rec = mx.project('com.oracle.truffle.r.native.recommended')
        rec.buildDependencies += [mx.distribution('SULONG')]
Beispiel #21
0
    def build(self):
        outputDir = self.subject.output_dir()
        snapshotToolDistribution = 'graal-js:TRUFFLE_JS_SNAPSHOT_TOOL'

        moduleSet = self.modulesToSnapshot()

        outputDirBin = join(outputDir, 'lib')
        mx.ensure_dir_exists(outputDirBin)

        macroFiles = [join('tools', 'js2c_macros', 'check_macros.py')]
        # DTrace is disabled explicitly by the --without-dtrace option
        # ETW is enabled by default only on Windows
        if not _is_windows:
            macroFiles.append(join('tools', 'js2c_macros',
                                   'notrace_macros.py'))

        mx.run(python_cmd() +
               [join('tools', 'expand-js-modules.py'), outputDir] +
               [join('lib', m) for m in moduleSet] + macroFiles,
               cwd=_suite.dir)
        if not (hasattr(self.args, "jdt") and self.args.jdt
                and not self.args.force_javac):
            mx.run_java([
                '-cp',
                mx.classpath([snapshotToolDistribution]),
                mx.distribution(snapshotToolDistribution).mainClass,
                '--binary', '--wrapped', '--outdir=' + outputDirBin,
                '--indir=' + outputDirBin
            ] + ['--file=' + m for m in moduleSet],
                        cwd=outputDirBin)
        mx.run(
            python_cmd() +
            [join(_suite.dir, 'tools', 'snapshot2c.py'), 'node_snapshots.h'] +
            [join('lib', m + '.bin') for m in moduleSet],
            cwd=outputDir)
Beispiel #22
0
def _alldeps(args):
    parser = ArgumentParser(prog='mx mxt-alldeps')
    parser.add_argument('--kind',
                        action='store',
                        help='project, dist or library',
                        default='project')
    parser.add_argument('--name',
                        action='store',
                        help='name of entity',
                        required=True)
    parser.add_argument('--includeLibs',
                        action='store_true',
                        help='includeLibs')
    parser.add_argument('--ignoreSelf', action='store_true', help='ignoreSelf')
    args = parser.parse_args(args)
    entity = None
    if args.kind == 'project':
        entity = mx.project(args.name)
    elif args.kind == 'library':
        entity = mx.library(args.name)
    elif args.kind == 'dist':
        entity = mx.distribution(args.name)
    else:
        mx.abort('illegal kind: ' + args.kind)

    in_deps = []
    deps = entity.all_deps(in_deps,
                           includeLibs=args.includeLibs,
                           includeSelf=not args.ignoreSelf)
    print('alldeps:')
    for d in deps:
        print(d.__class__.__name__, ":", d.name)
Beispiel #23
0
def test(args):
    """run some or all of the Maxine tests

    The Maxine sources include a variety of tests that can be run by a
    special launcher. These include JUnit tests, VM micro tests, certain
    benchmark suites and output comparison tests, amongst others.

    Use "mx test -help" to see what other options this command accepts."""
    maxineTesterDir = join(_maxine_home, 'maxine-tester')
    if isdir(maxineTesterDir):
        for root, _, files in os.walk(maxineTesterDir):
            for name in files:
                if name.rsplit(', ', 1) in ['stdout', 'stderr', 'passed', 'failed', 'command']:
                    os.remove(join(root, name))
    else:
        os.mkdir(maxineTesterDir)

    class Tee:
        def __init__(self, f):
            self.f = f
        def eat(self, line):
            mx.log(line.rstrip())
            self.f.write(line)

    console = join(maxineTesterDir, 'console')
    with open(console, 'w', 0) as f:
        tee = Tee(f)
        java = mx.java()
        mx.run_java(['-cp', sanitized_classpath(), 'test.com.sun.max.vm.MaxineTester', '-output-dir=maxine-tester',
                      '-graal-jar=' + mx.distribution('GRAAL').path,
                      '-refvm=' + java.java, '-refvm-args=' + ' '.join(java.java_args)] + args, out=tee.eat, err=subprocess.STDOUT)
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:
        if t:
            _setEnvVar('NODE_JVM_CLASSPATH', mx.distribution('graal-js:TRUFFLE_JS_TESTS').path)
            commonArgs = ['-ea', '-esa']
            unitTestDir = join('test', 'graal')
            mx.run(['rm', '-rf', 'node_modules', 'build'], cwd=unitTestDir)
            npm(['--scripts-prepend-node-path=auto', 'install', '--nodedir=' + _suite.dir] + commonArgs, cwd=unitTestDir)
            npm(['--scripts-prepend-node-path=auto', 'test'] + commonArgs, cwd=unitTestDir)

    with Task('TestNpm', tasks, tags=[GraalNodeJsTags.allTests]) as t:
        if t:
            tmpdir = tempfile.mkdtemp()
            try:
                npm(['init', '-y'], cwd=tmpdir)
                npm(['--scripts-prepend-node-path=auto', 'install', '--nodedir=' + _suite.dir, '--build-from-source', 'microtime'], cwd=tmpdir)
                node(['-e', 'console.log(require("microtime").now());'], cwd=tmpdir)
            finally:
                mx.rmtree(tmpdir)

    with Task('JniProfilerTests', tasks, tags=[GraalNodeJsTags.allTests, GraalNodeJsTags.jniProfilerTests]) as t:
        if t:
            commonArgs = ['-ea', '-esa']
            unitTestDir = join(mx.project('com.oracle.truffle.trufflenode.jniboundaryprofiler').dir, 'tests')
            mx.run(['rm', '-rf', 'node_modules', 'build'], cwd=unitTestDir)
            npm(['--scripts-prepend-node-path=auto', 'install', '--nodedir=' + _suite.dir] + commonArgs, cwd=unitTestDir)
            node(['-profile-native-boundary', 'test.js'] + commonArgs, cwd=unitTestDir)
Beispiel #25
0
 def createCommandLineArgs(self, benchmarks, bm_suite_args):
     benchmarks = benchmarks if benchmarks is not None else self.benchmarkList(bm_suite_args)
     jdk = mx.get_jdk(mx.distribution(BENCHMARKCASES_DISTRIBUTION).javaCompliance)
     vm_args = self.vmArgs(bm_suite_args) + mx.get_runtime_jvm_args([BENCHMARKCASES_DISTRIBUTION], jdk=jdk)
     run_args = ["--warmup-iterations", str(MEMORY_WARMUP_ITERATIONS),
                 "--result-iterations", str(self.getExtraIterationCount(MEMORY_WARMUP_ITERATIONS))]
     return vm_args + [MEMORY_PROFILER_CLASS_NAME] + run_args + benchmarks
Beispiel #26
0
def suite_native_image_root(suite=None):
    if not suite:
        suite = svm_suite()
    llvm = all([mx.distribution(dist).exists() for dist in llvmDistributions])
    root_dir = join(svmbuild_dir(suite), ('llvm-' if llvm else '') +
                    'native-image-root-' + str(svm_java_compliance()))
    rev_file_name = join(root_dir, 'rev')
    rev_value = suite.vc.parent(suite.vc_dir)

    def write_rev_file():
        mkpath(root_dir)
        with open(rev_file_name, 'w') as rev_file:
            rev_file.write(rev_value)

    if exists(root_dir):
        try:
            with open(rev_file_name, 'r') as rev_file:
                prev_rev_value = rev_file.readline()
        except:
            prev_rev_value = 'nothing'
        if prev_rev_value != rev_value:
            mx.warn(
                'Rebuilding native-image-root as working directory revision changed from '
                + prev_rev_value + ' to ' + rev_value)
            remove_tree(root_dir)
            layout_native_image_root(root_dir)
            write_rev_file()
    else:
        layout_native_image_root(root_dir)
        write_rev_file()
    return root_dir
Beispiel #27
0
def mx_post_parse_cmd_line(opts):
    mx.add_ide_envvar('JVMCI_VERSION_CHECK')
    for dist in _suite.dists:
        dist.set_archiveparticipant(GraalArchiveParticipant(dist, isTest=dist.name.endswith('_TEST')))
    add_bootclasspath_append(mx.distribution('truffle:TRUFFLE_API'))
    global _vm_prefix
    _vm_prefix = opts.vm_prefix
Beispiel #28
0
def test(args):
    """run some or all of the Maxine tests


    The Maxine sources include a variety of tests that can be run by a
    special launcher. These include JUnit tests, VM micro tests, certain
    benchmark suites and output comparison tests, amongst others.

    Use "mx test -help" to see what other options this command accepts."""
    maxineTesterDir = join(_maxine_home, 'maxine-tester')
    if isdir(maxineTesterDir):
        for root, _, files in os.walk(maxineTesterDir):
            for name in files:
                if name.rsplit(', ', 1) in ['stdout', 'stderr', 'passed', 'failed', 'command']:
                    os.remove(join(root, name))
    else:
        os.mkdir(maxineTesterDir)

    class Tee:
        def __init__(self, f):
            self.f = f
        def eat(self, line):
            mx.log(line.rstrip())
            self.f.write(line)

    console = join(maxineTesterDir, 'console')
    with open(console, 'w', 0) as f:
        tee = Tee(f)
        java = mx.java()
        mx.run_java(['-cp', sanitized_classpath(), 'test.com.sun.max.vm.MaxineTester', '-output-dir=maxine-tester',
                      '-graal-jar=' + mx.distribution('GRAAL').path,
                      '-refvm=' + java.java, '-refvm-args=' + ' '.join(java.java_args)] + args, out=tee.eat, err=subprocess.STDOUT)
Beispiel #29
0
def _unittest_config_participant(config):
    """modifies the classpath to use the Sulong distribution jars instead of the classfiles to enable the use of Java's ServiceLoader"""
    (vmArgs, mainClass, mainClassArgs) = config
    cpIndex, _ = mx.find_classpath_arg(vmArgs)
    junitCp = mx.classpath("com.oracle.mxtool.junit")
    sulongCp = ':'.join([mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag='jvmci')) for distr in sulongDistributions])
    vmArgs[cpIndex] = junitCp + ":" + sulongCp
    return (vmArgs, mainClass, mainClassArgs)
Beispiel #30
0
def mx_post_parse_cmd_line(opts):
    mx_fastr_dists.mx_post_parse_cmd_line(opts)
    mx_subst.results_substitutions.register_no_arg('graalvm_version', mx.suite('sdk').release_version())
    if mx.suite("sulong", fatalIfMissing=False) and not _fastr_suite.isBinarySuite():
        # native.recommended runs FastR, it already has a build dependency to the FASTR distribution
        # if we are running with sulong we also need the SULONG_NATIVE distribution
        rec = mx.project('com.oracle.truffle.r.native.recommended')
        rec.buildDependencies += [mx.distribution('SULONG_NATIVE')]
Beispiel #31
0
    def benchmarkList(self, _):
        jdk = mx.get_jdk(mx.distribution(BENCHMARKCASES_DISTRIBUTION).javaCompliance)
        jvm_args = mx.get_runtime_jvm_args([BENCHMARKCASES_DISTRIBUTION], jdk=jdk)
        args = jvm_args + [MEMORY_PROFILER_CLASS_NAME, "--list"]

        out = mx.OutputCapture()
        jdk.run_java(args, out=out)
        return out.data.split()
Beispiel #32
0
def getClasspathOptions():
    """gets the classpath of the Sulong distributions"""
    return [
        '-cp', ':'.join([
            mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag='jvmci'))
            for distr in sulongDistributions
        ])
    ]
Beispiel #33
0
def _brainfck_standalone_command(args):
    """Brainf*ck standalone command from distribution jars + arguments"""
    vm_args, args = mx.extract_VM_args(args,
                                       useDoubleDash=True,
                                       defaultAllVMArgs=False)
    return (vm_args + mx.get_runtime_jvm_args(
        ['BRAINFCK', 'BRAINFCK_LAUNCHER'], jdk=mx.get_jdk()) +
            [mx.distribution('BRAINFCK_LAUNCHER').mainClass] + args)
Beispiel #34
0
def unittest_use_distribution_jars(config):
    """use the distribution jars instead of the class files"""
    vmArgs, mainClass, mainClassArgs = config
    cpIndex, _ = mx.find_classpath_arg(vmArgs)
    junitCP = [mx.classpath("com.oracle.mxtool.junit")]
    rubyCP = [mx.classpath(mx.distribution(distr)) for distr in rubyDists]
    vmArgs[cpIndex] = ":".join(junitCP + rubyCP)
    return (vmArgs, mainClass, mainClassArgs)
Beispiel #35
0
def _espresso_standalone_command(args):
    """Espresso standalone command from distribution jars + arguments"""
    vm_args, args = mx.extract_VM_args(args,
                                       useDoubleDash=True,
                                       defaultAllVMArgs=False)
    return (vm_args + mx.get_runtime_jvm_args(
        ['ESPRESSO', 'ESPRESSO_LAUNCHER'], jdk=mx.get_jdk()) +
            [mx.distribution('ESPRESSO_LAUNCHER').mainClass] + args)
Beispiel #36
0
def getRemoteClasspathOption():
    return (
        "-Dsulong.TestRemoteBootPath=-Xbootclasspath/p:"
        + mx.distribution("truffle:TRUFFLE_API").path
        + " "
        + getLLVMRootOption()
        + " "
        + compilationSucceedsOption()
        + " -XX:-UseJVMCIClassLoader -Dsulong.Debug=false -Djvmci.Compiler=graal"
    )
Beispiel #37
0
def native_image_distributions():
    deps = [mx.distribution('GRAAL_MANAGEMENT')]
    for d in svm_suite().dists:
        if isinstance(d, str):
            name = d
        else:
            name = d.name
        if name.startswith("NATIVE_IMAGE"):
            deps.append(d)
    return deps
Beispiel #38
0
def setup_jruby_home():
    rubyZip = mx.distribution('RUBY-ZIP').path
    assert exists(rubyZip)
    extractPath = join(_suite.dir, 'mxbuild', 'ruby-zip-extracted')
    if TimeStampFile(extractPath).isOlderThan(rubyZip):
        if exists(extractPath):
            shutil.rmtree(extractPath)
        extractTarball(rubyZip, extractPath)
    env = os.environ.copy()
    env['JRUBY_HOME'] = extractPath
    return env
Beispiel #39
0
def _parseVmArgs(jdk, args, addDefaultArgs=True):
    args = mx.expand_project_in_args(args, insitu=False)
    jacocoArgs = mx_gate.get_jacoco_agent_args()
    if jacocoArgs:
        args = jacocoArgs + args

    # Support for -G: options
    def translateGOption(arg):
        if arg.startswith("-G:+"):
            if "=" in arg:
                mx.abort("Mixing + and = in -G: option specification: " + arg)
            arg = "-Dgraal." + arg[len("-G:+") :] + "=true"
        elif arg.startswith("-G:-"):
            if "=" in arg:
                mx.abort("Mixing - and = in -G: option specification: " + arg)
            arg = "-Dgraal." + arg[len("-G:+") :] + "=false"
        elif arg.startswith("-G:"):
            if "=" not in arg:
                mx.abort('Missing "=" in non-boolean -G: option specification: ' + arg)
            arg = "-Dgraal." + arg[len("-G:") :]
        return arg

    args = map(translateGOption, args)

    if "-G:+PrintFlags" in args and "-Xcomp" not in args:
        mx.warn("Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy")

    bcp = [mx.distribution("truffle:TRUFFLE_API").classpath_repr()]
    if _jvmciModes[_vm.jvmciMode]:
        bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists])

    args = ["-Xbootclasspath/p:" + os.pathsep.join(bcp)] + args

    # Remove JVMCI from class path. It's only there to support compilation.
    cpIndex, cp = mx.find_classpath_arg(args)
    if cp:
        jvmciLib = mx.library("JVMCI").path
        cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e != jvmciLib])
        args[cpIndex] = cp

    # Set the default JVMCI compiler
    jvmciCompiler = _compilers[-1]
    args = ["-Djvmci.compiler=" + jvmciCompiler] + args

    if "-version" in args:
        ignoredArgs = args[args.index("-version") + 1 :]
        if len(ignoredArgs) > 0:
            mx.log(
                "Warning: The following options will be ignored by the vm because they come after the '-version' argument: "
                + " ".join(ignoredArgs)
            )
    return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
Beispiel #40
0
def _parseVmArgs(jdk, args, addDefaultArgs=True):
    args = mx.expand_project_in_args(args, insitu=False)
    jacocoArgs = mx_gate.get_jacoco_agent_args()
    if jacocoArgs:
        args = jacocoArgs + args

    # Support for -G: options
    def translateGOption(arg):
        if arg.startswith('-G:+'):
            if '=' in arg:
                mx.abort('Mixing + and = in -G: option specification: ' + arg)
            arg = '-Dgraal.' + arg[len('-G:+'):] + '=true'
        elif arg.startswith('-G:-'):
            if '=' in arg:
                mx.abort('Mixing - and = in -G: option specification: ' + arg)
            arg = '-Dgraal.' + arg[len('-G:+'):] + '=false'
        elif arg.startswith('-G:'):
            if '=' not in arg:
                mx.abort('Missing "=" in non-boolean -G: option specification: ' + arg)
            arg = '-Dgraal.' + arg[len('-G:'):]
        return arg
    # add default graal.options.file and translate -G: options
    options_file = join(mx.primary_suite().dir, 'graal.options')
    options_file_arg = ['-Dgraal.options.file=' + options_file] if exists(options_file) else []
    args = options_file_arg + map(translateGOption, args)

    if '-G:+PrintFlags' in args and '-Xcomp' not in args:
        mx.warn('Using -G:+PrintFlags may have no effect without -Xcomp as Graal initialization is lazy')

    bcp = [mx.distribution('truffle:TRUFFLE_API').classpath_repr()]
    if _jvmciModes[_vm.jvmciMode]:
        bcp.extend([d.get_classpath_repr() for d in _bootClasspathDists])

    args = ['-Xbootclasspath/p:' + os.pathsep.join(bcp)] + args

    # Remove JVMCI from class path. It's only there to support compilation.
    cpIndex, cp = mx.find_classpath_arg(args)
    if cp:
        jvmciLib = mx.library('JVMCI').path
        cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e != jvmciLib])
        args[cpIndex] = cp

    # Set the default JVMCI compiler
    jvmciCompiler = _compilers[-1]
    args = ['-Djvmci.Compiler=' + jvmciCompiler] + args

    if '-version' in args:
        ignoredArgs = args[args.index('-version') + 1:]
        if  len(ignoredArgs) > 0:
            mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
    return jdk.processArgs(args, addDefaultArgs=addDefaultArgs)
Beispiel #41
0
    def load(dist, jdk):
        """
        Unpickles the module descriptor corresponding to a given distribution.

        :param str dist: the distribution for which to read the pickled object
        :param JDKConfig jdk: used to resolve pickled references to JDK modules
        """
        _, moduleDir, _ = get_java_module_info(dist, fatalIfNotModule=True)  # pylint: disable=unpacking-non-sequence
        path = moduleDir + '.pickled'
        if not exists(path):
            mx.abort(path + ' does not exist')
        with open(path, 'rb') as fp:
            jmd = pickle.load(fp)
        jdkmodules = {m.name: m for m in jdk.get_modules()}
        resolved = []
        for name in jmd.modulepath:
            if name.startswith('dist:'):
                distName = name[len('dist:'):]
                resolved.append(as_java_module(mx.distribution(distName), jdk))
            else:
                resolved.append(jdkmodules[name])
        jmd.modulepath = resolved
        jmd.dist = mx.distribution(jmd.dist)
        return jmd
Beispiel #42
0
def _alldeps(args):
    parser = ArgumentParser(prog='mx mxt-alldeps')
    parser.add_argument('--kind', action='store', help='project, dist or library', default='project')
    parser.add_argument('--name', action='store', help='name of entity', required=True)
    parser.add_argument('--includeLibs', action='store_true', help='includeLibs')
    parser.add_argument('--ignoreSelf', action='store_true', help='ignoreSelf')
    args = parser.parse_args(args)
    entity = None
    if args.kind == 'project':
        entity = mx.project(args.name)
    elif args.kind == 'library':
        entity = mx.library(args.name)
    elif args.kind == 'dist':
        entity = mx.distribution(args.name)
    else:
        mx.abort('illegal kind: ' + args.kind)

    in_deps = []
    deps = entity.all_deps(in_deps, includeLibs=args.includeLibs, includeSelf=not args.ignoreSelf)
    print 'alldeps:'
    for d in deps:
        print d.__class__.__name__, ":", d.name
Beispiel #43
0
def getClasspathOptions():
    """gets the classpath of the Sulong distributions"""
    return [
        "-cp",
        ":".join([mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag="jvmci")) for distr in sulongDistributions]),
    ]
Beispiel #44
0
 def dist(self):
     return mx.distribution(self._name)
Beispiel #45
0
def image(args):
    """build a boot image

    Run the BootImageGenerator to build a Maxine boot image. The classes
    and packages specified on the command line will be included in the
    boot image in addition to those found by the Package.java mechanism.
    Package names are differentiated from class names by being prefixed
    with '^'.

    The platform configuration for the generated image is auto-detected
    by native methods. However, the following system properties can be
    used to override the defaults:

    Name            | Description                   | Example values
    ================+===============================+================
    max.platform    | name of a preset platform     | solaris-amd64 linux-amd64 darwin-amd64
    max.cpu         | processor model               | AMD64 IA32 SPARCV9
    max.isa         | instruction set architecture  | AMD64 ARM PPC SPARC
    max.os          | operating system              | Darwin Linux Solaris
    max.endianness  | endianness                    | BIG LITTLE
    max.bits        | machine word size             | 64 32
    max.page        | page size                     | 4096 8192
    max.nsig        | number of signals             | 32

    These system properties can be specified as options to the image
    command (e.g. '-os Darwin -bits 32').

    An option starting with '@' denotes one of the preconfigured set of
    options described by running "mx options".

    An option starting with '--' is interpreted as a VM option of the same name
    after the leading '-' is removed. For example, to use the '-verbose:class'
    VM option to trace class loading while image building, specify '--verbose:class'.
    Note that not all VM options have an effect during image building.

    Use "mx image -help" to see what other options this command accepts."""

    systemProps = ['-esa']
    imageArgs = []
    i = 0
    while i < len(args):
        arg = args[i]
        if arg[0] == '@':
            name = arg.lstrip('@')
            configs = _configs()
            if not name in configs:
                mx.log()
                mx.abort('Invalid image configuration: ' + name)
            values = configs[name].split('@')
            del args[i]
            args[i:i] = values
            continue
        elif arg in ['-platform', '-cpu', '-isa', '-os', '-endianness', '-bits', '-page', '-nsig']:
            name = arg.lstrip('-')
            i += 1
            if i == len(args):
                mx.abort('Missing value for ' + arg)
            value = args[i]
            systemProps += ['-Dmax.' + name + '=' + value]
        elif arg.startswith('--XX:LogFile='):
            os.environ['MAXINE_LOG_FILE'] = arg.split('=', 1)[1]
        elif arg == '-vma':
            systemProps += ['-Dmax.permsize=2']
        else:
            imageArgs += [arg]
        i += 1

    mx.run_java(['-Xbootclasspath/a:' + mx.distribution('GRAAL').path] + systemProps + ['-cp', sanitized_classpath(), 'com.sun.max.vm.hosted.BootImageGenerator', '-trace=1', '-run=java'] + imageArgs)
Beispiel #46
0
def mx_post_parse_cmd_line(opts):
    add_bootclasspath_prepend(mx.distribution('truffle:TRUFFLE_API'))
Beispiel #47
0
 def dist(self):
     """
     Gets the `JARDistribution` deployed on the JVMCI class path.
     """
     return mx.distribution(self._name)
Beispiel #48
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)
Beispiel #49
0
def getClasspathOptions():
    """gets the classpath of the Sulong distributions"""
    return ['-cp', ':'.join([mx.classpath(mx.distribution(distr), jdk=mx.get_jdk(tag='jvmci')) for distr in sulongDistributions])]
Beispiel #50
0
def mx_post_parse_cmd_line(opts):
    dist = mx.distribution("TRUFFLE_TEST")
    dist.set_archiveparticipant(TruffleArchiveParticipant())
Beispiel #51
0
def _unittest_config_participant(config):
    vmArgs, mainClass, mainClassArgs = config
    cpIndex, cp = mx.find_classpath_arg(vmArgs)
    if cp:
        cp = _uniqify(cp.split(os.pathsep))
        if isJDK8:
            # Remove entries from class path that are in Graal or on the boot class path
            redundantClasspathEntries = set()
            for dist in [entry.dist() for entry in _jvmci_classpath]:
                redundantClasspathEntries.update((d.output_dir() for d in dist.archived_deps() if d.isJavaProject()))
                redundantClasspathEntries.add(dist.path)
            cp = os.pathsep.join([e for e in cp if e not in redundantClasspathEntries])
            vmArgs[cpIndex] = cp
        else:
            deployedModules = []
            redundantClasspathEntries = set()
            for dist in [entry.dist() for entry in _jvmci_classpath] + _bootclasspath_appends:
                deployedModule = as_java_module(dist, jdk)
                deployedModules.append(deployedModule)
                redundantClasspathEntries.update(mx.classpath(dist, preferProjects=False, jdk=jdk).split(os.pathsep))
                redundantClasspathEntries.update(mx.classpath(dist, preferProjects=True, jdk=jdk).split(os.pathsep))
                if hasattr(dist, 'overlaps'):
                    for o in dist.overlaps:
                        path = mx.distribution(o).classpath_repr()
                        if path:
                            redundantClasspathEntries.add(path)

            # Remove entries from the class path that are in the deployed modules
            cp = [classpathEntry for classpathEntry in cp if classpathEntry not in redundantClasspathEntries]
            vmArgs[cpIndex] = os.pathsep.join(cp)

            # Junit libraries are made into automatic modules so that they are visible to tests
            # patched into modules. These automatic modules must be declared to be read by
            # Graal which means they must also be made root modules (i.e., ``--add-modules``)
            # since ``--add-reads`` can only be applied to root modules.
            junitCp = [e.classpath_repr() for e in mx.classpath_entries(['JUNIT'])]
            junitModules = [_automatic_module_name(e) for e in junitCp]
            vmArgs.append('--module-path=' + os.pathsep.join(junitCp))
            vmArgs.append('--add-modules=' + ','.join(junitModules + [m.name for m in deployedModules]))
            for deployedModule in deployedModules:
                vmArgs.append('--add-reads=' + deployedModule.name + '=' + ','.join(junitModules))

            # Explicitly export concealed JVMCI packages required by Graal. Even though
            # normally exported via jdk.vm.ci.services.Services.exportJVMCITo(), the
            # Junit harness wants to access JVMCI classes (e.g., when loading classes
            # to find test methods) without going through that entry point.
            addedExports = {}
            for deployedModule in deployedModules:
                for concealingModule, packages in deployedModule.concealedRequires.iteritems():
                    if concealingModule == 'jdk.vm.ci':
                        for package in packages:
                            addedExports.setdefault(concealingModule + '/' + package, set()).add(deployedModule.name)

            pathToDep = {p.output_dir() if p.isJavaProject() else p.path: p for p in mx.dependencies() if p.isJavaProject() or p.isJARDistribution()}
            for classpathEntry in cp:
                # Export concealed packages used by the class path entry
                _add_exports_for_concealed_packages(classpathEntry, pathToDep, addedExports, 'ALL-UNNAMED', deployedModules)

                for deployedModule in deployedModules:
                    assert deployedModule.dist.path != classpathEntry, deployedModule.dist.path + ' should no longer be on the class path'
                    # Ensure the class path entry does not define packages already defined by the module.
                    # Packages definitions cannot be split between modules.
                    classpathEntryPackages = frozenset(_defined_packages(classpathEntry))
                    intersection = classpathEntryPackages.intersection(deployedModule.packages)
                    if intersection:
                        mx.abort(classpathEntry + ' cannot extend package(s) defined in the module ' + deployedModule.name + ': ' + ', '.join(intersection))

            vmArgs.extend(['--add-exports=' + export + '=' + ','.join(sorted(targets)) for export, targets in addedExports.iteritems()])

    if isJDK8:
        # Run the VM in a mode where application/test classes can
        # access JVMCI loaded classes.
        vmArgs.append('-XX:-UseJVMCIClassLoader')

    return (vmArgs, mainClass, mainClassArgs)
def mx_post_parse_cmd_line(opts):
    for dist in _suite.dists:
        dist.set_archiveparticipant(GraalArchiveParticipant(dist, isTest=dist.name.endswith('_TEST')))
    add_bootclasspath_append(mx.distribution('truffle:TRUFFLE_API'))