hotspot/.mx.jvmci/mx_jvmci.py
changeset 45361 73e69e047396
parent 45238 ddc52d9c74e4
equal deleted inserted replaced
45360:71093c519b3e 45361:73e69e047396
   156     jdkBuildDir = _get_jdk_build_dir()
   156     jdkBuildDir = _get_jdk_build_dir()
   157     if not exists(jdkBuildDir):
   157     if not exists(jdkBuildDir):
   158         # JDK9 must be bootstrapped with a JDK8
   158         # JDK9 must be bootstrapped with a JDK8
   159         compliance = mx.JavaCompliance('8')
   159         compliance = mx.JavaCompliance('8')
   160         jdk8 = mx.get_jdk(compliance.exactMatch, versionDescription=compliance.value)
   160         jdk8 = mx.get_jdk(compliance.exactMatch, versionDescription=compliance.value)
   161         cmd = ['sh', 'configure', '--with-debug-level=' + _vm.debugLevel, '--with-native-debug-symbols=external', '--disable-precompiled-headers',
   161         cmd = ['sh', 'configure', '--with-debug-level=' + _vm.debugLevel, '--with-native-debug-symbols=external', '--disable-precompiled-headers', '--with-jvm-features=graal',
   162                '--with-jvm-variants=' + _vm.jvmVariant, '--disable-warnings-as-errors', '--with-boot-jdk=' + jdk8.home]
   162                '--with-jvm-variants=' + _vm.jvmVariant, '--disable-warnings-as-errors', '--with-boot-jdk=' + jdk8.home, '--with-jvm-features=graal']
   163         mx.run(cmd, cwd=_jdkSourceRoot)
   163         mx.run(cmd, cwd=_jdkSourceRoot)
   164     cmd = [mx.gmake_cmd(), 'CONF=' + _vm.debugLevel]
   164     cmd = [mx.gmake_cmd(), 'CONF=' + _vm.debugLevel]
   165     if mx.get_opts().verbose:
   165     if mx.get_opts().verbose:
   166         cmd.append('LOG=debug')
   166         cmd.append('LOG=debug')
   167     cmd.extend(args)
   167     cmd.extend(args)
   173         mx.log('Working directory: ' + _jdkSourceRoot)
   173         mx.log('Working directory: ' + _jdkSourceRoot)
   174         mx.log('Command line: ' + ' '.join(cmd))
   174         mx.log('Command line: ' + ' '.join(cmd))
   175         mx.log('-----------------------------------------------------')
   175         mx.log('-----------------------------------------------------')
   176 
   176 
   177     mx.run(cmd, cwd=_jdkSourceRoot)
   177     mx.run(cmd, cwd=_jdkSourceRoot)
   178 
       
   179     if 'images' in cmd:
       
   180         jdkImageDir = join(jdkBuildDir, 'images', 'jdk')
       
   181 
       
   182         # The OpenJDK build creates an empty cacerts file so copy one from
       
   183         # the default JDK (which is assumed to be an OracleJDK)
       
   184         srcCerts = join(mx.get_jdk(tag='default').home, 'lib', 'security', 'cacerts')
       
   185         if not exists(srcCerts):
       
   186             # Might be building with JDK8 which has cacerts under jre/
       
   187             srcCerts = join(mx.get_jdk(tag='default').home, 'jre', 'lib', 'security', 'cacerts')
       
   188         dstCerts = join(jdkImageDir, 'lib', 'security', 'cacerts')
       
   189         if srcCerts != dstCerts:
       
   190             shutil.copyfile(srcCerts, dstCerts)
       
   191 
       
   192         _create_jdk_bundle(jdkBuildDir, _vm.debugLevel, jdkImageDir)
       
   193 
       
   194 def _get_jdk_bundle_arches():
       
   195     """
       
   196     Gets a list of names that will be the part of a JDK bundle's file name denoting the architecture.
       
   197     The first element in the list is the canonical name. Symlinks should be created for the
       
   198     remaining names.
       
   199     """
       
   200     cpu = mx.get_arch()
       
   201     if cpu == 'amd64':
       
   202         return ['x64', 'x86_64', 'amd64']
       
   203     elif cpu == 'sparcv9':
       
   204         return ['sparcv9']
       
   205     mx.abort('Unsupported JDK bundle arch: ' + cpu)
       
   206 
       
   207 def _create_jdk_bundle(jdkBuildDir, debugLevel, jdkImageDir):
       
   208     """
       
   209     Creates a tar.gz JDK archive, an accompanying tar.gz.sha1 file with its
       
   210     SHA1 signature plus symlinks to the archive for non-canonical architecture names.
       
   211     """
       
   212 
       
   213     arches = _get_jdk_bundle_arches()
       
   214     jdkTgzPath = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arches[0]))
       
   215     with mx.Archiver(jdkTgzPath, kind='tgz') as arc:
       
   216         mx.log('Creating ' + jdkTgzPath)
       
   217         for root, _, filenames in os.walk(jdkImageDir):
       
   218             for name in filenames:
       
   219                 f = join(root, name)
       
   220                 arcname = 'jdk1.9.0/' + os.path.relpath(f, jdkImageDir)
       
   221                 arc.zf.add(name=f, arcname=arcname, recursive=False)
       
   222 
       
   223     with open(jdkTgzPath + '.sha1', 'w') as fp:
       
   224         mx.log('Creating ' + jdkTgzPath + '.sha1')
       
   225         fp.write(mx.sha1OfFile(jdkTgzPath))
       
   226 
       
   227     def _create_link(source, link_name):
       
   228         if exists(link_name):
       
   229             os.remove(link_name)
       
   230         mx.log('Creating ' + link_name + ' -> ' + source)
       
   231         os.symlink(source, link_name)
       
   232 
       
   233     for arch in arches[1:]:
       
   234         link_name = join(_suite.get_output_root(), 'jdk-bundles', 'jdk9-{}-{}-{}.tar.gz'.format(debugLevel, _get_openjdk_os(), arch))
       
   235         jdkTgzName = os.path.basename(jdkTgzPath)
       
   236         _create_link(jdkTgzName, link_name)
       
   237         _create_link(jdkTgzName + '.sha1', link_name + '.sha1')
       
   238 
   178 
   239 def _runmultimake(args):
   179 def _runmultimake(args):
   240     """run the JDK make process for one or more configurations"""
   180     """run the JDK make process for one or more configurations"""
   241 
   181 
   242     jvmVariantsDefault = ','.join(_jdkJvmVariants)
   182     jvmVariantsDefault = ','.join(_jdkJvmVariants)
   361                         out.element('type', data='2' if isdir(f) else '1')
   301                         out.element('type', data='2' if isdir(f) else '1')
   362                         out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(f, eclProjectDir))
   302                         out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(f, eclProjectDir))
   363                         out.close('link')
   303                         out.close('link')
   364 
   304 
   365                     out.open('link')
   305                     out.open('link')
   366                     out.element('name', data='generated')
   306                     out.element('name', data='gensrc')
   367                     out.element('type', data='2')
   307                     out.element('type', data='2')
   368                     generated = join(_get_hotspot_build_dir(jvmVariant, debugLevel), 'generated')
   308                     generated = join(_get_hotspot_build_dir(jvmVariant, debugLevel), 'gensrc')
   369                     out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(generated, eclProjectDir))
   309                     out.element('locationURI', data=mx.get_eclipse_project_rel_locationURI(generated, eclProjectDir))
   370                     out.close('link')
   310                     out.close('link')
   371 
   311 
   372                     out.close('linkedResources')
   312                     out.close('linkedResources')
   373                 out.close('projectDescription')
   313                 out.close('projectDescription')
   678 _jvmci_bootclasspath_prepends = []
   618 _jvmci_bootclasspath_prepends = []
   679 
   619 
   680 def _get_hotspot_build_dir(jvmVariant=None, debugLevel=None):
   620 def _get_hotspot_build_dir(jvmVariant=None, debugLevel=None):
   681     """
   621     """
   682     Gets the directory in which a particular HotSpot configuration is built
   622     Gets the directory in which a particular HotSpot configuration is built
   683     (e.g., <JDK_REPO_ROOT>/build/macosx-x86_64-normal-server-release/hotspot/bsd_amd64_compiler2)
   623     (e.g., <JDK_REPO_ROOT>/build/macosx-x86_64-normal-server-release/hotspot/variant-<variant>)
   684     """
   624     """
   685     if jvmVariant is None:
   625     if jvmVariant is None:
   686         jvmVariant = _vm.jvmVariant
   626         jvmVariant = _vm.jvmVariant
   687 
   627 
   688     os = mx.get_os()
   628     name = 'variant-{}'.format(jvmVariant)
   689     if os == 'darwin':
       
   690         os = 'bsd'
       
   691     arch = mx.get_arch()
       
   692     buildname = {'client': 'compiler1', 'server': 'compiler2'}.get(jvmVariant, jvmVariant)
       
   693 
       
   694     name = '{}_{}_{}'.format(os, arch, buildname)
       
   695     return join(_get_jdk_build_dir(debugLevel=debugLevel), 'hotspot', name)
   629     return join(_get_jdk_build_dir(debugLevel=debugLevel), 'hotspot', name)
   696 
   630 
   697 class JVMCI9JDKConfig(mx.JDKConfig):
   631 class JVMCI9JDKConfig(mx.JDKConfig):
   698     def __init__(self, debugLevel):
   632     def __init__(self, debugLevel):
   699         self.debugLevel = debugLevel
   633         self.debugLevel = debugLevel