Mercurial > hg > graal-compiler
comparison mx/commands.py @ 8930:f50d10434d3e
Merge
author | Lukas Stadler <lukas.stadler@jku.at> |
---|---|
date | Mon, 08 Apr 2013 19:37:23 +0200 |
parents | 8ddaac81cb21 |
children | 08a16c26907f |
comparison
equal
deleted
inserted
replaced
8929:0f18f7d5b396 | 8930:f50d10434d3e |
---|---|
64 | 64 |
65 def clean(args): | 65 def clean(args): |
66 """clean the GraalVM source tree""" | 66 """clean the GraalVM source tree""" |
67 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) | 67 opts = mx.clean(args, parser=ArgumentParser(prog='mx clean')) |
68 if opts.native: | 68 if opts.native: |
69 os.environ.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16') | 69 env = os.environ.copy() |
70 mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make')) | 70 env.update(ARCH_DATA_MODEL='64', LANG='C', HOTSPOT_BUILD_JOBS='16') |
71 mx.run([mx.gmake_cmd(), 'clean'], cwd=join(_graal_home, 'make'), env=env) | |
71 jdks = join(_graal_home, 'jdk' + str(mx.java().version)) | 72 jdks = join(_graal_home, 'jdk' + str(mx.java().version)) |
72 if exists(jdks): | 73 if exists(jdks): |
73 shutil.rmtree(jdks) | 74 shutil.rmtree(jdks) |
74 | 75 |
75 def export(args): | 76 def export(args): |
294 def _jdk(build='product', vmToCheck=None, create=False): | 295 def _jdk(build='product', vmToCheck=None, create=False): |
295 """ | 296 """ |
296 Get the JDK into which Graal is installed, creating it first if necessary. | 297 Get the JDK into which Graal is installed, creating it first if necessary. |
297 """ | 298 """ |
298 jdk = join(_graal_home, 'jdk' + str(mx.java().version), build) | 299 jdk = join(_graal_home, 'jdk' + str(mx.java().version), build) |
300 srcJdk = mx.java().jdk | |
299 jdkContents = ['bin', 'include', 'jre', 'lib'] | 301 jdkContents = ['bin', 'include', 'jre', 'lib'] |
300 if (exists(join(jdk, 'db'))): | 302 if exists(join(srcJdk, 'db')): |
301 jdkContents.append('db') | 303 jdkContents.append('db') |
302 if mx.get_os() != 'windows': | 304 if mx.get_os() != 'windows' and exists(join(srcJdk, 'man')): |
303 jdkContents.append('man') | 305 jdkContents.append('man') |
304 if create: | 306 if create: |
305 if not exists(jdk): | 307 if not exists(jdk): |
306 srcJdk = mx.java().jdk | |
307 mx.log('Creating ' + jdk + ' from ' + srcJdk) | 308 mx.log('Creating ' + jdk + ' from ' + srcJdk) |
308 os.makedirs(jdk) | 309 os.makedirs(jdk) |
309 for d in jdkContents: | 310 for d in jdkContents: |
310 src = join(srcJdk, d) | 311 src = join(srcJdk, d) |
311 dst = join(jdk, d) | 312 dst = join(jdk, d) |
318 jvmCfg = _vmCfgInJdk(jdk) | 319 jvmCfg = _vmCfgInJdk(jdk) |
319 if not exists(jvmCfg): | 320 if not exists(jvmCfg): |
320 mx.abort(jvmCfg + ' does not exist') | 321 mx.abort(jvmCfg + ' does not exist') |
321 | 322 |
322 defaultVM = None | 323 defaultVM = None |
324 jvmCfgLines = [] | |
323 with open(jvmCfg) as f: | 325 with open(jvmCfg) as f: |
324 for line in f: | 326 for line in f: |
325 if line.startswith('-') and defaultVM is None: | 327 if line.startswith('-') and defaultVM is None: |
326 parts = line.split() | 328 parts = line.split() |
327 assert len(parts) == 2, parts | 329 assert len(parts) == 2, parts |
328 assert parts[1] == 'KNOWN', parts[1] | 330 assert parts[1] == 'KNOWN', parts[1] |
329 defaultVM = parts[0][1:] | 331 defaultVM = parts[0][1:] |
332 jvmCfgLines += ['-' + defaultVM + '0 KNOWN\n'] | |
333 else: | |
334 jvmCfgLines += [line] | |
330 | 335 |
331 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg | 336 assert defaultVM is not None, 'Could not find default VM in ' + jvmCfg |
332 if mx.get_os() != 'windows': | 337 if mx.get_os() != 'windows': |
333 chmodRecursive(jdk, 0755) | 338 chmodRecursive(jdk, 0755) |
334 shutil.copytree(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), defaultVM + '0')) | 339 shutil.move(join(_vmLibDirInJdk(jdk), defaultVM), join(_vmLibDirInJdk(jdk), defaultVM + '0')) |
340 | |
335 | 341 |
336 with open(jvmCfg, 'w') as fp: | 342 with open(jvmCfg, 'w') as fp: |
337 print >> fp, '-' + defaultVM + '0 KNOWN' | 343 for line in jvmCfgLines: |
344 fp.write(line) | |
338 | 345 |
339 # Install a copy of the disassembler library | 346 # Install a copy of the disassembler library |
340 try: | 347 try: |
341 hsdis([], copyToDir=_vmLibDirInJdk(jdk)) | 348 hsdis([], copyToDir=_vmLibDirInJdk(jdk)) |
342 except SystemExit: | 349 except SystemExit: |
477 out.element('property', {'name' : 'jar.dir', 'value' : '${shared.dir}'}) | 484 out.element('property', {'name' : 'jar.dir', 'value' : '${shared.dir}'}) |
478 out.element('property', {'name' : 'jar.file', 'value' : '${jar.dir}/graal.jar'}) | 485 out.element('property', {'name' : 'jar.file', 'value' : '${jar.dir}/graal.jar'}) |
479 | 486 |
480 out.element('target', {'name' : 'main', 'depends' : 'jar'}) | 487 out.element('target', {'name' : 'main', 'depends' : 'jar'}) |
481 | 488 |
482 out.open('target', {'name' : 'compile'}) | 489 out.open('target', {'name' : 'compile', 'depends' : 'cleanclasses'}) |
483 out.element('mkdir', {'dir' : '${classes.dir}'}) | 490 out.element('mkdir', {'dir' : '${classes.dir}'}) |
484 out.open('javac', {'destdir' : '${classes.dir}', 'debug' : 'on', 'includeantruntime' : 'false', }) | 491 out.open('javac', {'destdir' : '${classes.dir}', 'debug' : 'on', 'includeantruntime' : 'false', }) |
485 for p in mx.sorted_deps(mx.distribution('GRAAL').deps): | 492 for p in mx.sorted_deps(mx.distribution('GRAAL').deps): |
486 out.element('src', {'path' : '${src.dir}/' + p.name}) | 493 out.element('src', {'path' : '${src.dir}/' + p.name}) |
487 out.element('compilerarg', {'value' : '-XDignore.symbol.file'}) | 494 out.element('compilerarg', {'value' : '-XDignore.symbol.file'}) |
498 out.open('target', {'name' : 'jar', 'depends' : 'compile'}) | 505 out.open('target', {'name' : 'jar', 'depends' : 'compile'}) |
499 out.element('mkdir', {'dir' : '${jar.dir}'}) | 506 out.element('mkdir', {'dir' : '${jar.dir}'}) |
500 out.element('jar', {'destfile' : '${jar.file}', 'basedir' : '${classes.dir}'}) | 507 out.element('jar', {'destfile' : '${jar.file}', 'basedir' : '${classes.dir}'}) |
501 out.close('target') | 508 out.close('target') |
502 | 509 |
503 out.open('target', {'name' : 'clean'}) | 510 out.open('target', {'name' : 'cleanclasses'}) |
504 out.element('delete', {'dir' : '${classes.dir}'}) | 511 out.element('delete', {'dir' : '${classes.dir}'}) |
505 out.element('delete', {'file' : '${jar.filr}'}) | 512 out.close('target') |
513 | |
514 out.open('target', {'name' : 'clean', 'depends' : 'cleanclasses'}) | |
515 out.element('delete', {'file' : '${jar.file}'}) | |
506 out.close('target') | 516 out.close('target') |
507 | 517 |
508 out.close('project') | 518 out.close('project') |
509 | 519 |
510 mx.update_file(args.buildfile, out.xml(indent=' ', newl='\n')) | 520 mx.update_file(args.buildfile, out.xml(indent=' ', newl='\n')) |
528 builds = ['product'] | 538 builds = ['product'] |
529 | 539 |
530 if vm is None: | 540 if vm is None: |
531 vm = _vm | 541 vm = _vm |
532 | 542 |
533 if vm == 'server': | 543 if vm == 'server' or vm == 'server0': |
534 buildSuffix = '' | 544 buildSuffix = '' |
535 elif vm == 'client': | 545 elif vm == 'client': |
536 buildSuffix = '1' | 546 buildSuffix = '1' |
537 elif vm == 'server0': | |
538 return | |
539 else: | 547 else: |
540 assert vm == 'graal', vm | 548 assert vm == 'graal', vm |
541 buildSuffix = 'graal' | 549 buildSuffix = 'graal' |
542 | 550 |
543 initantbuild([]) | 551 initantbuild([]) |
547 build = os.environ.get('IDE_BUILD_TARGET', 'product') | 555 build = os.environ.get('IDE_BUILD_TARGET', 'product') |
548 if len(build) == 0: | 556 if len(build) == 0: |
549 mx.log('[skipping build from IDE as IDE_BUILD_TARGET environment variable is ""]') | 557 mx.log('[skipping build from IDE as IDE_BUILD_TARGET environment variable is ""]') |
550 continue | 558 continue |
551 | 559 |
560 if vm == 'server0': | |
561 assert build == 'product', 'can not "build" a non-product server0' | |
562 | |
552 jdk = _jdk(build, create=True) | 563 jdk = _jdk(build, create=True) |
553 | 564 |
554 vmDir = join(_vmLibDirInJdk(jdk), vm) | 565 vmDir = join(_vmLibDirInJdk(jdk), vm) |
555 if not exists(vmDir): | 566 if not exists(vmDir): |
556 if mx.get_os() != 'windows': | 567 if mx.get_os() != 'windows': |
562 if not 'Xusage.txt' in line: | 573 if not 'Xusage.txt' in line: |
563 sys.stderr.write(line + os.linesep) | 574 sys.stderr.write(line + os.linesep) |
564 | 575 |
565 # Check if a build really needs to be done | 576 # Check if a build really needs to be done |
566 timestampFile = join(vmDir, '.build-timestamp') | 577 timestampFile = join(vmDir, '.build-timestamp') |
567 if opts2.force or not exists(timestampFile): | 578 if vm == 'server0': |
579 mustBuild = False | |
580 elif opts2.force or not exists(timestampFile): | |
568 mustBuild = True | 581 mustBuild = True |
569 else: | 582 else: |
570 mustBuild = False | 583 mustBuild = False |
571 timestamp = os.path.getmtime(timestampFile) | 584 timestamp = os.path.getmtime(timestampFile) |
572 sources = [] | 585 sources = [] |
606 cpus = multiprocessing.cpu_count() | 619 cpus = multiprocessing.cpu_count() |
607 runCmd = [mx.gmake_cmd()] | 620 runCmd = [mx.gmake_cmd()] |
608 if build == 'debug': | 621 if build == 'debug': |
609 build = 'jvmg' | 622 build = 'jvmg' |
610 runCmd.append(build + buildSuffix) | 623 runCmd.append(build + buildSuffix) |
611 env = os.environ | 624 env = os.environ.copy() |
612 env.setdefault('ARCH_DATA_MODEL', '64') | 625 env.setdefault('ARCH_DATA_MODEL', '64') |
613 env.setdefault('LANG', 'C') | 626 env.setdefault('LANG', 'C') |
614 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) | 627 env.setdefault('HOTSPOT_BUILD_JOBS', str(cpus)) |
615 env['ALT_BOOTDIR'] = jdk | 628 env['ALT_BOOTDIR'] = mx.java().jdk |
629 env['JAVA_HOME'] = jdk | |
616 if not env.has_key('OMIT_GRAAL'): | 630 if not env.has_key('OMIT_GRAAL'): |
617 env['GRAAL'] = join(_graal_home, 'graal') # needed for TEST_IN_BUILD | 631 env['GRAAL'] = join(_graal_home, 'graal') # needed for TEST_IN_BUILD |
618 env.setdefault('INSTALL', 'y') | 632 env.setdefault('INSTALL', 'y') |
619 if mx.get_os() == 'solaris' : | 633 if mx.get_os() == 'solaris' : |
620 # If using sparcWorks, setup flags to avoid make complaining about CC version | 634 # If using sparcWorks, setup flags to avoid make complaining about CC version |
636 | 650 |
637 # Clear these 2 variables as having them set can cause very confusing build problems | 651 # Clear these 2 variables as having them set can cause very confusing build problems |
638 env.pop('LD_LIBRARY_PATH', None) | 652 env.pop('LD_LIBRARY_PATH', None) |
639 env.pop('CLASSPATH', None) | 653 env.pop('CLASSPATH', None) |
640 | 654 |
641 mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage) | 655 mx.run(runCmd, cwd=join(_graal_home, 'make'), err=filterXusage, env=env) |
642 | 656 |
643 jvmCfg = _vmCfgInJdk(jdk) | 657 jvmCfg = _vmCfgInJdk(jdk) |
644 found = False | |
645 if not exists(jvmCfg): | 658 if not exists(jvmCfg): |
646 mx.abort(jvmCfg + ' does not exist') | 659 mx.abort(jvmCfg + ' does not exist') |
647 | 660 |
648 prefix = '-' + vm | 661 prefix = '-' + vm + ' ' |
649 vmKnown = prefix + ' KNOWN' | 662 vmKnown = prefix + 'KNOWN\n' |
663 lines = [] | |
664 found = False | |
650 with open(jvmCfg) as f: | 665 with open(jvmCfg) as f: |
651 for line in f: | 666 for line in f: |
652 if vmKnown == line.strip(): | 667 if line.strip() == vmKnown.strip(): |
653 found = True | 668 found = True |
654 break | 669 lines.append(line) |
670 | |
655 if not found: | 671 if not found: |
656 mx.log('Appending "' + prefix + ' KNOWN" to ' + jvmCfg) | 672 mx.log('Appending "' + prefix + 'KNOWN" to ' + jvmCfg) |
657 if mx.get_os() != 'windows': | 673 if mx.get_os() != 'windows': |
658 os.chmod(jvmCfg, 0755) | 674 os.chmod(jvmCfg, 0755) |
659 with open(jvmCfg, 'a') as f: | 675 with open(jvmCfg, 'w') as f: |
660 print >> f, vmKnown | 676 for line in lines: |
677 if line.startswith(prefix): | |
678 line = vmKnown | |
679 found = True | |
680 f.write(line) | |
681 if not found: | |
682 f.write(vmKnown) | |
661 | 683 |
662 if exists(timestampFile): | 684 if exists(timestampFile): |
663 os.utime(timestampFile, None) | 685 os.utime(timestampFile, None) |
664 else: | 686 else: |
665 file(timestampFile, 'a') | 687 file(timestampFile, 'a') |
1042 else: | 1064 else: |
1043 dacapos = benchmarks_in_group('dacapo') | 1065 dacapos = benchmarks_in_group('dacapo') |
1044 for dacapo in dacapos: | 1066 for dacapo in dacapos: |
1045 if dacapo not in sanitycheck.dacapoSanityWarmup.keys(): | 1067 if dacapo not in sanitycheck.dacapoSanityWarmup.keys(): |
1046 mx.abort('Unknown DaCapo : ' + dacapo) | 1068 mx.abort('Unknown DaCapo : ' + dacapo) |
1047 benchmarks += [sanitycheck.getDacapo(dacapo, sanitycheck.dacapoSanityWarmup[dacapo][sanitycheck.SanityCheckLevel.Benchmark])] | 1069 iterations = sanitycheck.dacapoSanityWarmup[dacapo][sanitycheck.SanityCheckLevel.Benchmark] |
1070 if (iterations > 0): | |
1071 benchmarks += [sanitycheck.getDacapo(dacapo, iterations)] | |
1048 | 1072 |
1049 if ('scaladacapo' in args or 'all' in args): | 1073 if ('scaladacapo' in args or 'all' in args): |
1050 benchmarks += sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) | 1074 benchmarks += sanitycheck.getScalaDacapos(level=sanitycheck.SanityCheckLevel.Benchmark) |
1051 else: | 1075 else: |
1052 scaladacapos = benchmarks_in_group('scaladacapo') | 1076 scaladacapos = benchmarks_in_group('scaladacapo') |
1053 for scaladacapo in scaladacapos: | 1077 for scaladacapo in scaladacapos: |
1054 if scaladacapo not in sanitycheck.dacapoScalaSanityWarmup.keys(): | 1078 if scaladacapo not in sanitycheck.dacapoScalaSanityWarmup.keys(): |
1055 mx.abort('Unknown Scala DaCapo : ' + scaladacapo) | 1079 mx.abort('Unknown Scala DaCapo : ' + scaladacapo) |
1056 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark])] | 1080 iterations = sanitycheck.dacapoScalaSanityWarmup[scaladacapo][sanitycheck.SanityCheckLevel.Benchmark] |
1081 if (iterations > 0): | |
1082 benchmarks += [sanitycheck.getScalaDacapo(scaladacapo, iterations)] | |
1057 | 1083 |
1058 #Bootstrap | 1084 #Bootstrap |
1059 if ('bootstrap' in args or 'all' in args): | 1085 if ('bootstrap' in args or 'all' in args): |
1060 benchmarks += sanitycheck.getBootstraps() | 1086 benchmarks += sanitycheck.getBootstraps() |
1061 #SPECjvm2008 | 1087 #SPECjvm2008 |