Mercurial > hg > graal-compiler
comparison mx/mx_graal.py @ 21892:9fe51d8fae0f
Merge with 878786299d2d72bf0bdbd4002ccffcd1fad69b7a
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Tue, 09 Jun 2015 19:07:39 -0700 |
parents | 894f82515e38 543f150e7fa0 |
children | cf7b06489764 |
comparison
equal
deleted
inserted
replaced
21891:ccaf9eb1f5eb | 21892:9fe51d8fae0f |
---|---|
548 shutil.copyfile(src, tmp) | 548 shutil.copyfile(src, tmp) |
549 os.close(fd) | 549 os.close(fd) |
550 shutil.move(tmp, dstLib) | 550 shutil.move(tmp, dstLib) |
551 os.chmod(dstLib, permissions) | 551 os.chmod(dstLib, permissions) |
552 | 552 |
553 def _filterJVMCIServices(serviceImplNames, classpath): | 553 def _filterJVMCIServices(servicesMap, classpath): |
554 """ | 554 """ |
555 Filters and returns the names in 'serviceImplNames' that denote | 555 Filters and returns the names in 'serviceImplNames' that denote |
556 types available in 'classpath' implementing or extending | 556 types available in 'classpath' implementing or extending |
557 com.oracle.jvmci.service.Service. | 557 com.oracle.jvmci.service.Service. |
558 """ | 558 """ |
559 _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__)) | 559 _, binDir = mx._compile_mx_class('FilterTypes', os.pathsep.join(classpath), myDir=dirname(__file__)) |
560 cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serviceImplNames | 560 serialized = [k + '=' + ','.join(v) for k, v in servicesMap.iteritems()] |
561 services = subprocess.check_output(cmd) | 561 cmd = [mx.java().java, '-cp', mx._cygpathU2W(os.pathsep.join([binDir] + classpath)), 'FilterTypes', 'com.oracle.jvmci.service.Service'] + serialized |
562 if len(services) == 0: | 562 serialized = subprocess.check_output(cmd) |
563 return [] | 563 if len(serialized) == 0: |
564 return services.split('|') | 564 return {} |
565 servicesMap = {} | |
566 for e in serialized.split(' '): | |
567 k, v = e.split('=') | |
568 impls = v.split(',') | |
569 servicesMap[k] = impls | |
570 return servicesMap | |
565 | 571 |
566 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, cleanDestination=True): | 572 def _extractJVMCIFiles(jdkJars, jvmciJars, servicesDir, optionsDir, cleanDestination=True): |
567 if cleanDestination: | 573 if cleanDestination: |
568 if exists(servicesDir): | 574 if exists(servicesDir): |
569 shutil.rmtree(servicesDir) | 575 shutil.rmtree(servicesDir) |
600 targetpath = join(optionsDir, filename) | 606 targetpath = join(optionsDir, filename) |
601 optionsFiles.append(filename) | 607 optionsFiles.append(filename) |
602 with zf.open(member) as optionsFile, \ | 608 with zf.open(member) as optionsFile, \ |
603 file(targetpath, "wb") as target: | 609 file(targetpath, "wb") as target: |
604 shutil.copyfileobj(optionsFile, target) | 610 shutil.copyfileobj(optionsFile, target) |
605 jvmciServices = _filterJVMCIServices(servicesMap.keys(), jdkJars) | 611 servicesMap = _filterJVMCIServices(servicesMap, jdkJars) |
606 for serviceName in jvmciServices: | 612 for serviceName, serviceImpls in servicesMap.iteritems(): |
607 serviceImpls = servicesMap[serviceName] | |
608 fd, tmp = tempfile.mkstemp(prefix=serviceName) | 613 fd, tmp = tempfile.mkstemp(prefix=serviceName) |
609 f = os.fdopen(fd, 'w+') | 614 f = os.fdopen(fd, 'w+') |
610 for serviceImpl in serviceImpls: | 615 for serviceImpl in serviceImpls: |
611 f.write(serviceImpl + os.linesep) | 616 f.write(serviceImpl + os.linesep) |
612 target = join(servicesDir, serviceName) | 617 target = join(servicesDir, serviceName) |
613 f.close() | 618 f.close() |
614 shutil.move(tmp, target) | 619 shutil.move(tmp, target) |
615 if mx.get_os() != 'windows': | 620 if mx.get_os() != 'windows': |
616 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) | 621 os.chmod(target, JDK_UNIX_PERMISSIONS_FILE) |
617 return (jvmciServices, optionsFiles) | |
618 | 622 |
619 def _updateJVMCIFiles(jdkDir): | 623 def _updateJVMCIFiles(jdkDir): |
620 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') | 624 jreJVMCIDir = join(jdkDir, 'jre', 'lib', 'jvmci') |
621 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')] | 625 jvmciJars = [join(jreJVMCIDir, e) for e in os.listdir(jreJVMCIDir) if e.endswith('.jar')] |
622 jreJVMCIServicesDir = join(jreJVMCIDir, 'services') | 626 jreJVMCIServicesDir = join(jreJVMCIDir, 'services') |
827 cached_graal_version = most_recent_tag_version | 831 cached_graal_version = most_recent_tag_version |
828 else: | 832 else: |
829 major, minor = map(int, most_recent_tag_version.split('.')) | 833 major, minor = map(int, most_recent_tag_version.split('.')) |
830 cached_graal_version = str(major) + '.' + str(minor + 1) + '-' + dev_suffix | 834 cached_graal_version = str(major) + '.' + str(minor + 1) + '-' + dev_suffix |
831 else: | 835 else: |
832 cached_graal_version = 'unknown-{0}-{1}'.format(platform.node(), time.strftime('%Y-%m-%d_%H-%M-%S_%Z')) | 836 cached_graal_version = 'unknown-{0}'.format(platform.node()) |
833 | 837 |
834 return cached_graal_version | 838 return cached_graal_version |
835 | 839 |
836 def build(args, vm=None): | 840 def build(args, vm=None): |
837 """build the VM binary | 841 """build the VM binary |
838 | 842 |
839 The global '--vm' and '--vmbuild' options select which VM type and build target to build.""" | 843 The global '--vm' and '--vmbuild' options select which VM type and build target to build.""" |
840 | |
841 # Turn all jdk distributions into non HotSpot; this is only necessary as long we support building/exporting JVMCI with make and mx | |
842 if not ("-m" in args or "--use-make" in args): | |
843 for jdkDist in _jdkDeployedDists: | |
844 if jdkDist.partOfHotSpot: | |
845 jdkDist.partOfHotSpot = False | |
846 | 844 |
847 # Override to fail quickly if extra arguments are given | 845 # Override to fail quickly if extra arguments are given |
848 # at the end of the command line. This allows for a more | 846 # at the end of the command line. This allows for a more |
849 # helpful error message. | 847 # helpful error message. |
850 class AP(ArgumentParser): | 848 class AP(ArgumentParser): |
858 ' mx --vmbuild ' + firstBuildTarget + ' build') | 856 ' mx --vmbuild ' + firstBuildTarget + ' build') |
859 return result | 857 return result |
860 | 858 |
861 # Call mx.build to compile the Java sources | 859 # Call mx.build to compile the Java sources |
862 parser = AP() | 860 parser = AP() |
863 parser.add_argument('--export-dir', help='directory to which JVMCI and Graal jars and jvmci.options will be copied', metavar='<path>') | |
864 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') | 861 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') |
865 parser.add_argument('-m', '--use-make', action='store_true', help='Use the jvmci.make file to build and export JVMCI') | 862 |
866 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) | 863 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) |
867 assert len(opts2.remainder) == 0 | 864 assert len(opts2.remainder) == 0 |
868 | |
869 if opts2.export_dir is not None: | |
870 if not exists(opts2.export_dir): | |
871 os.makedirs(opts2.export_dir) | |
872 else: | |
873 assert os.path.isdir(opts2.export_dir), '{0} is not a directory'.format(opts2.export_dir) | |
874 | |
875 defsPath = join(_graal_home, 'make', 'defs.make') | |
876 with open(defsPath) as fp: | |
877 defs = fp.read() | |
878 jvmciJars = [] | |
879 jdkJars = [] | |
880 for jdkDist in _jdkDeployedDists: | |
881 dist = mx.distribution(jdkDist.name) | |
882 jdkJars.append(join(_graal_home, dist.path)) | |
883 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) | |
884 if jdkDist.isExtension: | |
885 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_EXT_DIR)/' + basename(dist.path) | |
886 elif jdkDist.usesJVMCIClassLoader: | |
887 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_DIR)/' + basename(dist.path) | |
888 jvmciJars.append(dist.path) | |
889 else: | |
890 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) | |
891 if defLine not in defs: | |
892 mx.abort('Missing following line in ' + defsPath + '\n' + defLine) | |
893 shutil.copy(dist.path, opts2.export_dir) | |
894 | |
895 services, optionsFiles = _extractJVMCIFiles(jdkJars, jvmciJars, join(opts2.export_dir, 'services'), join(opts2.export_dir, 'options')) | |
896 if not opts2.use_make: | |
897 for service in services: | |
898 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_SERVICES_DIR)/' + service | |
899 if defLine not in defs: | |
900 mx.abort('Missing following line in ' + defsPath + ' for service from ' + dist.name + '\n' + defLine) | |
901 for optionsFile in optionsFiles: | |
902 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_JVMCI_OPTIONS_DIR)/' + optionsFile | |
903 if defLine not in defs: | |
904 mx.abort('Missing following line in ' + defsPath + ' for options from ' + dist.name + '\n' + defLine) | |
905 jvmciOptions = join(_graal_home, 'jvmci.options') | |
906 if exists(jvmciOptions): | |
907 shutil.copy(jvmciOptions, opts2.export_dir) | |
908 | 865 |
909 if not _vmSourcesAvailable or not opts2.native: | 866 if not _vmSourcesAvailable or not opts2.native: |
910 return | 867 return |
911 | 868 |
912 builds = [_vmbuild] | 869 builds = [_vmbuild] |
967 mustBuild = True | 924 mustBuild = True |
968 else: | 925 else: |
969 mustBuild = False | 926 mustBuild = False |
970 timestamp = os.path.getmtime(timestampFile) | 927 timestamp = os.path.getmtime(timestampFile) |
971 sources = [] | 928 sources = [] |
972 for d in ['src', 'make', join('graal', 'com.oracle.jvmci.hotspot', 'src_gen', 'hotspot')]: | 929 for d in ['src', 'make', join('jvmci', 'com.oracle.jvmci.hotspot', 'src_gen', 'hotspot')]: |
973 for root, dirnames, files in os.walk(join(_graal_home, d)): | 930 for root, dirnames, files in os.walk(join(_graal_home, d)): |
974 # ignore <graal>/src/share/tools | 931 # ignore <graal>/src/share/tools |
975 if root == join(_graal_home, 'src', 'share'): | 932 if root == join(_graal_home, 'src', 'share'): |
976 dirnames.remove('tools') | 933 dirnames.remove('tools') |
977 sources += [join(root, name) for name in files] | 934 sources += [join(root, name) for name in files] |
1052 if build == 'jvmg': | 1009 if build == 'jvmg': |
1053 # We want ALL the symbols when debugging on Solaris | 1010 # We want ALL the symbols when debugging on Solaris |
1054 setMakeVar('STRIP_POLICY', 'no_strip') | 1011 setMakeVar('STRIP_POLICY', 'no_strip') |
1055 # This removes the need to unzip the *.diz files before debugging in gdb | 1012 # This removes the need to unzip the *.diz files before debugging in gdb |
1056 setMakeVar('ZIP_DEBUGINFO_FILES', '0', env=env) | 1013 setMakeVar('ZIP_DEBUGINFO_FILES', '0', env=env) |
1057 if opts2.use_make: | 1014 |
1058 setMakeVar('JVMCI_USE_MAKE', '1') | 1015 if buildSuffix == "1": |
1016 setMakeVar("JVM_VARIANTS", "client") | |
1017 elif buildSuffix == "": | |
1018 setMakeVar("JVM_VARIANTS", "server") | |
1019 | |
1059 # Clear this variable as having it set can cause very confusing build problems | 1020 # Clear this variable as having it set can cause very confusing build problems |
1060 env.pop('CLASSPATH', None) | 1021 env.pop('CLASSPATH', None) |
1061 | 1022 |
1062 # Issue an env prefix that can be used to run the make on the command line | 1023 # Issue an env prefix that can be used to run the make on the command line |
1063 if not mx._opts.verbose: | 1024 if not mx._opts.verbose: |
1064 mx.log('--------------- make command line ----------------------') | 1025 mx.log('--------------- make command line ----------------------') |
1065 | 1026 |
1066 envPrefix = ' '.join([key + '=' + env[key] for key in env.iterkeys() if not os.environ.has_key(key) or env[key] != os.environ[key]]) | 1027 envPrefix = ' '.join([key + '=' + env[key] for key in env.iterkeys() if not os.environ.has_key(key) or env[key] != os.environ[key]]) |
1067 if len(envPrefix): | 1028 if len(envPrefix): |
1068 mx.log('env ' + envPrefix + ' \\') | 1029 mx.log('env ' + envPrefix + ' \\') |
1069 makeTarget = "all_" + build + buildSuffix if opts2.use_make else build + buildSuffix | 1030 |
1070 runCmd.append(makeTarget) | 1031 runCmd.append(build + buildSuffix) |
1032 runCmd.append("docs") | |
1033 runCmd.append("export_" + build) | |
1071 | 1034 |
1072 if not mx._opts.verbose: | 1035 if not mx._opts.verbose: |
1073 mx.log(' '.join(runCmd)) | 1036 mx.log(' '.join(runCmd)) |
1074 mx.log('--------------------------------------------------------') | 1037 mx.log('--------------------------------------------------------') |
1075 mx.run(runCmd, err=filterXusage, env=env) | 1038 mx.run(runCmd, err=filterXusage, env=env) |
1176 if '-version' in args: | 1139 if '-version' in args: |
1177 ignoredArgs = args[args.index('-version') + 1:] | 1140 ignoredArgs = args[args.index('-version') + 1:] |
1178 if len(ignoredArgs) > 0: | 1141 if len(ignoredArgs) > 0: |
1179 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) | 1142 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) |
1180 | 1143 |
1181 if vm == 'original': | 1144 # Unconditionally prepend Truffle to the boot class path. |
1182 truffle_jar = mx.archive(['@TRUFFLE'])[0] | 1145 # This used to be done by the VM itself but was removed to |
1183 args = ['-Xbootclasspath/p:' + truffle_jar] + args | 1146 # separate the VM from Truffle. |
1147 truffle_jar = mx.archive(['@TRUFFLE'])[0] | |
1148 args = ['-Xbootclasspath/p:' + truffle_jar] + args | |
1184 | 1149 |
1185 args = mx.java().processArgs(args) | 1150 args = mx.java().processArgs(args) |
1186 return (pfx, exe, vm, args, cwd) | 1151 return (pfx, exe, vm, args, cwd) |
1187 | 1152 |
1188 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): | 1153 def vm(args, vm=None, nonZeroIsFatal=True, out=None, err=None, cwd=None, timeout=None, vmbuild=None): |