LEFT | RIGHT |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "a.h" | 5 #include "a.h" |
6 #include "arg.h" | 6 #include "arg.h" |
7 | 7 |
8 /* | 8 /* |
9 * Initialization for any invocation. | 9 * Initialization for any invocation. |
10 */ | 10 */ |
(...skipping 15 matching lines...) Expand all Loading... |
26 char *gochar; | 26 char *gochar; |
27 char *goversion; | 27 char *goversion; |
28 char *slash; // / for unix, \ for windows | 28 char *slash; // / for unix, \ for windows |
29 char *defaultcc; | 29 char *defaultcc; |
30 char *defaultcxx; | 30 char *defaultcxx; |
31 bool rebuildall; | 31 bool rebuildall; |
32 bool defaultclang; | 32 bool defaultclang; |
33 | 33 |
34 static bool shouldbuild(char*, char*); | 34 static bool shouldbuild(char*, char*); |
35 static void copy(char*, char*, int); | 35 static void copy(char*, char*, int); |
| 36 static void dopack(char*, char*, char**, int); |
36 static char *findgoversion(void); | 37 static char *findgoversion(void); |
37 | 38 |
38 // The known architecture letters. | 39 // The known architecture letters. |
39 static char *gochars = "568"; | 40 static char *gochars = "568"; |
40 | 41 |
41 // The known architectures. | 42 // The known architectures. |
42 static char *okgoarch[] = { | 43 static char *okgoarch[] = { |
43 // same order as gochars | 44 // same order as gochars |
44 "arm", | 45 "arm", |
45 "amd64", | 46 "amd64", |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 "$GOROOT/include/fmt.h", | 488 "$GOROOT/include/fmt.h", |
488 "$GOROOT/include/libc.h", | 489 "$GOROOT/include/libc.h", |
489 "$GOROOT/include/bio.h", | 490 "$GOROOT/include/bio.h", |
490 "$GOROOT/include/ar.h", | 491 "$GOROOT/include/ar.h", |
491 "$GOROOT/include/bootexec.h", | 492 "$GOROOT/include/bootexec.h", |
492 "$GOROOT/include/mach.h", | 493 "$GOROOT/include/mach.h", |
493 "$GOROOT/include/ureg_amd64.h", | 494 "$GOROOT/include/ureg_amd64.h", |
494 "$GOROOT/include/ureg_arm.h", | 495 "$GOROOT/include/ureg_arm.h", |
495 "$GOROOT/include/ureg_x86.h", | 496 "$GOROOT/include/ureg_x86.h", |
496 }}, | 497 }}, |
| 498 {"liblink", { |
| 499 "$GOROOT/include/u.h", |
| 500 "$GOROOT/include/utf.h", |
| 501 "$GOROOT/include/fmt.h", |
| 502 "$GOROOT/include/libc.h", |
| 503 "$GOROOT/include/bio.h", |
| 504 "$GOROOT/include/ar.h", |
| 505 "$GOROOT/include/link.h", |
| 506 "anames5.c", |
| 507 "anames6.c", |
| 508 "anames8.c", |
| 509 }}, |
497 {"cmd/cc", { | 510 {"cmd/cc", { |
498 "-pgen.c", | 511 "-pgen.c", |
499 "-pswt.c", | 512 "-pswt.c", |
500 }}, | 513 }}, |
501 {"cmd/gc", { | 514 {"cmd/gc", { |
502 "-cplx.c", | 515 "-cplx.c", |
503 "-pgen.c", | 516 "-pgen.c", |
504 "-plive.c", | 517 "-plive.c", |
505 "-popt.c", | 518 "-popt.c", |
506 "-y1.tab.c", // makefile dreg | 519 "-y1.tab.c", // makefile dreg |
507 "opnames.h", | 520 "opnames.h", |
508 }}, | 521 }}, |
509 {"cmd/5c", { | 522 {"cmd/5c", { |
510 "../cc/pgen.c", | 523 "../cc/pgen.c", |
511 "../cc/pswt.c", | 524 "../cc/pswt.c", |
512 "../5l/enam.c", | |
513 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a", | 525 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a", |
514 }}, | 526 }}, |
515 {"cmd/6c", { | 527 {"cmd/6c", { |
516 "../cc/pgen.c", | 528 "../cc/pgen.c", |
517 "../cc/pswt.c", | 529 "../cc/pswt.c", |
518 "../6l/enam.c", | |
519 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a", | 530 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a", |
520 }}, | 531 }}, |
521 {"cmd/8c", { | 532 {"cmd/8c", { |
522 "../cc/pgen.c", | 533 "../cc/pgen.c", |
523 "../cc/pswt.c", | 534 "../cc/pswt.c", |
524 "../8l/enam.c", | |
525 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a", | 535 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libcc.a", |
526 }}, | 536 }}, |
527 {"cmd/5g", { | 537 {"cmd/5g", { |
528 "../gc/cplx.c", | 538 "../gc/cplx.c", |
529 "../gc/pgen.c", | 539 "../gc/pgen.c", |
530 "../gc/plive.c", | 540 "../gc/plive.c", |
531 "../gc/popt.c", | 541 "../gc/popt.c", |
532 "../gc/popt.h", | 542 "../gc/popt.h", |
533 "../5l/enam.c", | |
534 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", | 543 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", |
535 }}, | 544 }}, |
536 {"cmd/6g", { | 545 {"cmd/6g", { |
537 "../gc/cplx.c", | 546 "../gc/cplx.c", |
538 "../gc/pgen.c", | 547 "../gc/pgen.c", |
539 "../gc/plive.c", | 548 "../gc/plive.c", |
540 "../gc/popt.c", | 549 "../gc/popt.c", |
541 "../gc/popt.h", | 550 "../gc/popt.h", |
542 "../6l/enam.c", | |
543 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", | 551 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", |
544 }}, | 552 }}, |
545 {"cmd/8g", { | 553 {"cmd/8g", { |
546 "../gc/cplx.c", | 554 "../gc/cplx.c", |
547 "../gc/pgen.c", | 555 "../gc/pgen.c", |
548 "../gc/plive.c", | 556 "../gc/plive.c", |
549 "../gc/popt.c", | 557 "../gc/popt.c", |
550 "../gc/popt.h", | 558 "../gc/popt.h", |
551 "../8l/enam.c", | |
552 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", | 559 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libgc.a", |
553 }}, | 560 }}, |
554 {"cmd/5l", { | 561 {"cmd/5l", { |
555 "../ld/*", | 562 "../ld/*", |
556 "enam.c", | |
557 }}, | 563 }}, |
558 {"cmd/6l", { | 564 {"cmd/6l", { |
559 "../ld/*", | 565 "../ld/*", |
560 "enam.c", | |
561 }}, | 566 }}, |
562 {"cmd/8l", { | 567 {"cmd/8l", { |
563 "../ld/*", | 568 "../ld/*", |
564 "enam.c", | |
565 }}, | 569 }}, |
566 {"cmd/go", { | 570 {"cmd/go", { |
567 "zdefaultcc.go", | 571 "zdefaultcc.go", |
568 }}, | 572 }}, |
569 {"cmd/", { | 573 {"cmd/", { |
| 574 "$GOROOT/pkg/obj/$GOOS_$GOARCH/liblink.a", |
570 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libmach.a", | 575 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libmach.a", |
571 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libbio.a", | 576 "$GOROOT/pkg/obj/$GOOS_$GOARCH/libbio.a", |
572 "$GOROOT/pkg/obj/$GOOS_$GOARCH/lib9.a", | 577 "$GOROOT/pkg/obj/$GOOS_$GOARCH/lib9.a", |
573 }}, | 578 }}, |
574 {"pkg/runtime", { | 579 {"pkg/runtime", { |
575 "zaexperiment.h", // must sort above zasm | 580 "zaexperiment.h", // must sort above zasm |
576 "zasm_$GOOS_$GOARCH.h", | 581 "zasm_$GOOS_$GOARCH.h", |
577 "zsys_$GOOS_$GOARCH.s", | 582 "zsys_$GOOS_$GOARCH.s", |
578 "zgoarch_$GOARCH.go", | 583 "zgoarch_$GOARCH.go", |
579 "zgoos_$GOOS.go", | 584 "zgoos_$GOOS.go", |
(...skipping 10 matching lines...) Expand all Loading... |
590 ".go", | 595 ".go", |
591 ".goc", | 596 ".goc", |
592 }; | 597 }; |
593 | 598 |
594 // gentab records how to generate some trivial files. | 599 // gentab records how to generate some trivial files. |
595 static struct { | 600 static struct { |
596 char *nameprefix; | 601 char *nameprefix; |
597 void (*gen)(char*, char*); | 602 void (*gen)(char*, char*); |
598 } gentab[] = { | 603 } gentab[] = { |
599 {"opnames.h", gcopnames}, | 604 {"opnames.h", gcopnames}, |
600 » {"enam.c", mkenam}, | 605 » {"anames5.c", mkanames}, |
| 606 » {"anames6.c", mkanames}, |
| 607 » {"anames8.c", mkanames}, |
601 {"zasm_", mkzasm}, | 608 {"zasm_", mkzasm}, |
602 {"zdefaultcc.go", mkzdefaultcc}, | 609 {"zdefaultcc.go", mkzdefaultcc}, |
603 {"zsys_", mkzsys}, | 610 {"zsys_", mkzsys}, |
604 {"zgoarch_", mkzgoarch}, | 611 {"zgoarch_", mkzgoarch}, |
605 {"zgoos_", mkzgoos}, | 612 {"zgoos_", mkzgoos}, |
606 {"zruntime_defs_", mkzruntimedefs}, | 613 {"zruntime_defs_", mkzruntimedefs}, |
607 {"zversion.go", mkzversion}, | 614 {"zversion.go", mkzversion}, |
608 {"zaexperiment.h", mkzexperiment}, | 615 {"zaexperiment.h", mkzexperiment}, |
| 616 |
| 617 // not generated anymore, but delete the file if we see it |
| 618 {"enam.c", nil}, |
609 }; | 619 }; |
610 | 620 |
611 // install installs the library, package, or binary associated with dir, | 621 // install installs the library, package, or binary associated with dir, |
612 // which is relative to $GOROOT/src. | 622 // which is relative to $GOROOT/src. |
613 static void | 623 static void |
614 install(char *dir) | 624 install(char *dir) |
615 { | 625 { |
616 char *name, *p, *elem, *prefix, *exe; | 626 char *name, *p, *elem, *prefix, *exe; |
617 » bool islib, ispkg, isgo, stale; | 627 » bool islib, ispkg, isgo, stale, ispackcmd; |
618 Buf b, b1, path; | 628 Buf b, b1, path; |
619 Vec compile, files, link, go, missing, clean, lib, extra; | 629 Vec compile, files, link, go, missing, clean, lib, extra; |
620 Time ttarg, t; | 630 Time ttarg, t; |
621 » int i, j, k, n, doclean, targ, usecpp; | 631 » int i, j, k, n, doclean, targ; |
622 | 632 |
623 if(vflag) { | 633 if(vflag) { |
624 if(!streq(goos, gohostos) || !streq(goarch, gohostarch)) | 634 if(!streq(goos, gohostos) || !streq(goarch, gohostarch)) |
625 errprintf("%s (%s/%s)\n", dir, goos, goarch); | 635 errprintf("%s (%s/%s)\n", dir, goos, goarch); |
626 else | 636 else |
627 errprintf("%s\n", dir); | 637 errprintf("%s\n", dir); |
628 } | 638 } |
629 | 639 |
630 binit(&b); | 640 binit(&b); |
631 binit(&b1); | 641 binit(&b1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 bprintf(&b, "%s", defaultcc); | 673 bprintf(&b, "%s", defaultcc); |
664 splitfields(&gccargs, bstr(&b)); | 674 splitfields(&gccargs, bstr(&b)); |
665 for(i=0; i<nelem(proto_gccargs); i++) | 675 for(i=0; i<nelem(proto_gccargs); i++) |
666 vadd(&gccargs, proto_gccargs[i]); | 676 vadd(&gccargs, proto_gccargs[i]); |
667 if(contains(gccargs.p[0], "clang")) { | 677 if(contains(gccargs.p[0], "clang")) { |
668 // disable ASCII art in clang errors, if possible | 678 // disable ASCII art in clang errors, if possible |
669 vadd(&gccargs, "-fno-caret-diagnostics"); | 679 vadd(&gccargs, "-fno-caret-diagnostics"); |
670 // clang is too smart about unused command-line argument
s | 680 // clang is too smart about unused command-line argument
s |
671 vadd(&gccargs, "-Qunused-arguments"); | 681 vadd(&gccargs, "-Qunused-arguments"); |
672 } | 682 } |
| 683 // disable word wrapping in error messages |
| 684 vadd(&gccargs, "-fmessage-length=0"); |
673 if(streq(gohostos, "darwin")) { | 685 if(streq(gohostos, "darwin")) { |
674 // golang.org/issue/5261 | 686 // golang.org/issue/5261 |
675 vadd(&gccargs, "-mmacosx-version-min=10.6"); | 687 vadd(&gccargs, "-mmacosx-version-min=10.6"); |
676 } | 688 } |
677 } | 689 } |
678 | 690 |
679 islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd
/gc"); | 691 islib = hasprefix(dir, "lib") || streq(dir, "cmd/cc") || streq(dir, "cmd
/gc"); |
680 ispkg = hasprefix(dir, "pkg"); | 692 ispkg = hasprefix(dir, "pkg"); |
681 isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo"); | 693 isgo = ispkg || streq(dir, "cmd/go") || streq(dir, "cmd/cgo"); |
682 | 694 |
683 exe = ""; | 695 exe = ""; |
684 if(streq(gohostos, "windows")) | 696 if(streq(gohostos, "windows")) |
685 exe = ".exe"; | 697 exe = ".exe"; |
686 | 698 |
687 // Start final link command line. | 699 // Start final link command line. |
688 // Note: code below knows that link.p[targ] is the target. | 700 // Note: code below knows that link.p[targ] is the target. |
| 701 ispackcmd = 0; |
689 if(islib) { | 702 if(islib) { |
690 // C library. | 703 // C library. |
691 vadd(&link, "ar"); | 704 vadd(&link, "ar"); |
692 if(streq(gohostos, "plan9")) | 705 if(streq(gohostos, "plan9")) |
693 vadd(&link, "rc"); | 706 vadd(&link, "rc"); |
694 else | 707 else |
695 vadd(&link, "rsc"); | 708 vadd(&link, "rsc"); |
696 prefix = ""; | 709 prefix = ""; |
697 if(!hasprefix(name, "lib")) | 710 if(!hasprefix(name, "lib")) |
698 prefix = "lib"; | 711 prefix = "lib"; |
699 targ = link.len; | 712 targ = link.len; |
700 vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohost
os, gohostarch, prefix, name)); | 713 vadd(&link, bpathf(&b, "%s/pkg/obj/%s_%s/%s%s.a", goroot, gohost
os, gohostarch, prefix, name)); |
701 } else if(ispkg) { | 714 } else if(ispkg) { |
702 // Go library (package). | 715 // Go library (package). |
703 » » vadd(&link, bpathf(&b, "%s/pack", tooldir)); | 716 » » ispackcmd = 1; |
704 » » vadd(&link, "grc"); | 717 » » vadd(&link, "pack"); // program name - unused here, but all the
other cases record one |
705 p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4); | 718 p = bprintf(&b, "%s/pkg/%s_%s/%s", goroot, goos, goarch, dir+4); |
706 *xstrrchr(p, '/') = '\0'; | 719 *xstrrchr(p, '/') = '\0'; |
707 xmkdirall(p); | 720 xmkdirall(p); |
708 targ = link.len; | 721 targ = link.len; |
709 vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch
, dir+4)); | 722 vadd(&link, bpathf(&b, "%s/pkg/%s_%s/%s.a", goroot, goos, goarch
, dir+4)); |
710 } else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) { | 723 } else if(streq(dir, "cmd/go") || streq(dir, "cmd/cgo")) { |
711 // Go command. | 724 // Go command. |
712 vadd(&link, bpathf(&b, "%s/%sl", tooldir, gochar)); | 725 vadd(&link, bpathf(&b, "%s/%sl", tooldir, gochar)); |
713 vadd(&link, "-o"); | 726 vadd(&link, "-o"); |
714 elem = name; | 727 elem = name; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 for(i=0; i<nelem(deptab); i++) { | 774 for(i=0; i<nelem(deptab); i++) { |
762 if(hasprefix(dir, deptab[i].prefix)) { | 775 if(hasprefix(dir, deptab[i].prefix)) { |
763 for(j=0; (p=deptab[i].dep[j])!=nil; j++) { | 776 for(j=0; (p=deptab[i].dep[j])!=nil; j++) { |
764 breset(&b1); | 777 breset(&b1); |
765 bwritestr(&b1, p); | 778 bwritestr(&b1, p); |
766 bsubst(&b1, "$GOROOT", goroot); | 779 bsubst(&b1, "$GOROOT", goroot); |
767 bsubst(&b1, "$GOOS", goos); | 780 bsubst(&b1, "$GOOS", goos); |
768 bsubst(&b1, "$GOARCH", goarch); | 781 bsubst(&b1, "$GOARCH", goarch); |
769 p = bstr(&b1); | 782 p = bstr(&b1); |
770 if(hassuffix(p, ".a")) { | 783 if(hassuffix(p, ".a")) { |
771 if(streq(gohostos, "plan9") && hassuffix
(p, "libbio.a")) | |
772 continue; | |
773 vadd(&lib, bpathf(&b, "%s", p)); | 784 vadd(&lib, bpathf(&b, "%s", p)); |
774 continue; | 785 continue; |
775 } | 786 } |
776 if(hassuffix(p, "/*")) { | 787 if(hassuffix(p, "/*")) { |
777 bpathf(&b, "%s/%s", bstr(&path), p); | 788 bpathf(&b, "%s/%s", bstr(&path), p); |
778 b.len -= 2; | 789 b.len -= 2; |
779 xreaddir(&extra, bstr(&b)); | 790 xreaddir(&extra, bstr(&b)); |
780 bprintf(&b, "%s", p); | 791 bprintf(&b, "%s", p); |
781 b.len -= 2; | 792 b.len -= 2; |
782 for(k=0; k<extra.len; k++) | 793 for(k=0; k<extra.len; k++) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0); | 874 bpathf(&b1, "%s/os_%s.h", bstr(&path), goos), 0); |
864 copy(bpathf(&b, "%s/signals_GOOS.h", workdir), | 875 copy(bpathf(&b, "%s/signals_GOOS.h", workdir), |
865 bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0); | 876 bpathf(&b1, "%s/signals_%s.h", bstr(&path), goos), 0); |
866 } | 877 } |
867 | 878 |
868 // Generate any missing files; regenerate existing ones. | 879 // Generate any missing files; regenerate existing ones. |
869 for(i=0; i<files.len; i++) { | 880 for(i=0; i<files.len; i++) { |
870 p = files.p[i]; | 881 p = files.p[i]; |
871 elem = lastelem(p); | 882 elem = lastelem(p); |
872 for(j=0; j<nelem(gentab); j++) { | 883 for(j=0; j<nelem(gentab); j++) { |
| 884 if(gentab[j].gen == nil) |
| 885 continue; |
873 if(hasprefix(elem, gentab[j].nameprefix)) { | 886 if(hasprefix(elem, gentab[j].nameprefix)) { |
874 if(vflag > 1) | 887 if(vflag > 1) |
875 errprintf("generate %s\n", p); | 888 errprintf("generate %s\n", p); |
876 gentab[j].gen(bstr(&path), p); | 889 gentab[j].gen(bstr(&path), p); |
877 // Do not add generated file to clean list. | 890 // Do not add generated file to clean list. |
878 // In pkg/runtime, we want to be able to | 891 // In pkg/runtime, we want to be able to |
879 // build the package with the go tool, | 892 // build the package with the go tool, |
880 // and it assumes these generated files already | 893 // and it assumes these generated files already |
881 // exist (it does not know how to build them). | 894 // exist (it does not know how to build them). |
882 // The 'clean' command can remove | 895 // The 'clean' command can remove |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 vuniq(&files); | 927 vuniq(&files); |
915 } | 928 } |
916 | 929 |
917 if((!streq(goos, gohostos) || !streq(goarch, gohostarch)) && isgo) { | 930 if((!streq(goos, gohostos) || !streq(goarch, gohostarch)) && isgo) { |
918 // We've generated the right files; the go command can do the bu
ild. | 931 // We've generated the right files; the go command can do the bu
ild. |
919 if(vflag > 1) | 932 if(vflag > 1) |
920 errprintf("skip build for cross-compile %s\n", dir); | 933 errprintf("skip build for cross-compile %s\n", dir); |
921 goto nobuild; | 934 goto nobuild; |
922 } | 935 } |
923 | 936 |
924 // The files generated by GNU Bison use macros that aren't | |
925 // supported by the Plan 9 compilers so we have to use the | |
926 // external preprocessor when compiling. | |
927 usecpp = 0; | |
928 if(streq(gohostos, "plan9")) { | |
929 for(i=0; i<files.len; i++) { | |
930 p = files.p[i]; | |
931 if(hassuffix(p, "y.tab.c") || hassuffix(p, "y.tab.h")){ | |
932 usecpp = 1; | |
933 break; | |
934 } | |
935 } | |
936 } | |
937 | |
938 // Compile the files. | 937 // Compile the files. |
939 for(i=0; i<files.len; i++) { | 938 for(i=0; i<files.len; i++) { |
940 if(!hassuffix(files.p[i], ".c") && !hassuffix(files.p[i], ".s")) | 939 if(!hassuffix(files.p[i], ".c") && !hassuffix(files.p[i], ".s")) |
941 continue; | 940 continue; |
942 name = lastelem(files.p[i]); | 941 name = lastelem(files.p[i]); |
943 | 942 |
944 vreset(&compile); | 943 vreset(&compile); |
945 if(!isgo) { | 944 if(!isgo) { |
946 // C library or tool. | 945 // C library or tool. |
947 if(streq(gohostos, "plan9")) { | 946 if(streq(gohostos, "plan9")) { |
948 vadd(&compile, bprintf(&b, "%sc", gohostchar)); | 947 vadd(&compile, bprintf(&b, "%sc", gohostchar)); |
949 » » » » vadd(&compile, "-FTVw"); | 948 » » » » vadd(&compile, "-FTVwp"); |
950 » » » » if(usecpp) | 949 » » » » vadd(&compile, "-DPLAN9"); |
951 » » » » » vadd(&compile, "-Bp+"); | 950 » » » » vadd(&compile, "-D__STDC__=1"); |
| 951 » » » » vadd(&compile, "-D__SIZE_TYPE__=ulong"); // for
GNU Bison |
952 vadd(&compile, bpathf(&b, "-I%s/include/plan9",
goroot)); | 952 vadd(&compile, bpathf(&b, "-I%s/include/plan9",
goroot)); |
953 vadd(&compile, bpathf(&b, "-I%s/include/plan9/%s
", goroot, gohostarch)); | 953 vadd(&compile, bpathf(&b, "-I%s/include/plan9/%s
", goroot, gohostarch)); |
954 // Work around Plan 9 C compiler's handling of #
include with .. path. | |
955 vadd(&compile, bpathf(&b, "-I%s/src/cmd/ld", gor
oot)); | |
956 } else { | 954 } else { |
957 vcopy(&compile, gccargs.p, gccargs.len); | 955 vcopy(&compile, gccargs.p, gccargs.len); |
958 vadd(&compile, "-c"); | 956 vadd(&compile, "-c"); |
959 if(streq(gohostarch, "amd64")) | 957 if(streq(gohostarch, "amd64")) |
960 vadd(&compile, "-m64"); | 958 vadd(&compile, "-m64"); |
961 else if(streq(gohostarch, "386")) | 959 else if(streq(gohostarch, "386")) |
962 vadd(&compile, "-m32"); | 960 vadd(&compile, "-m32"); |
963 if(streq(dir, "lib9")) | 961 if(streq(dir, "lib9")) |
964 vadd(&compile, "-DPLAN9PORT"); | 962 vadd(&compile, "-DPLAN9PORT"); |
965 ········ | 963 ········ |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 vadd(&clean, bstr(&b)); | 1044 vadd(&clean, bstr(&b)); |
1047 } | 1045 } |
1048 bgwait(); | 1046 bgwait(); |
1049 | 1047 |
1050 if(isgo) { | 1048 if(isgo) { |
1051 // The last loop was compiling individual files. | 1049 // The last loop was compiling individual files. |
1052 // Hand the Go files to the compiler en masse. | 1050 // Hand the Go files to the compiler en masse. |
1053 vreset(&compile); | 1051 vreset(&compile); |
1054 vadd(&compile, bpathf(&b, "%s/%sg", tooldir, gochar)); | 1052 vadd(&compile, bpathf(&b, "%s/%sg", tooldir, gochar)); |
1055 | 1053 |
1056 » » bpathf(&b, "%s/_go_.%s", workdir, gochar); | 1054 » » bpathf(&b, "%s/_go_.a", workdir); |
| 1055 » » vadd(&compile, "-pack"); |
1057 vadd(&compile, "-o"); | 1056 vadd(&compile, "-o"); |
1058 vadd(&compile, bstr(&b)); | 1057 vadd(&compile, bstr(&b)); |
1059 vadd(&clean, bstr(&b)); | 1058 vadd(&clean, bstr(&b)); |
1060 » » vadd(&link, bstr(&b)); | 1059 » » if(!ispackcmd) |
| 1060 » » » vadd(&link, bstr(&b)); |
1061 | 1061 |
1062 vadd(&compile, "-p"); | 1062 vadd(&compile, "-p"); |
1063 if(hasprefix(dir, "pkg/")) | 1063 if(hasprefix(dir, "pkg/")) |
1064 vadd(&compile, dir+4); | 1064 vadd(&compile, dir+4); |
1065 else | 1065 else |
1066 vadd(&compile, "main"); | 1066 vadd(&compile, "main"); |
1067 | 1067 |
1068 if(streq(dir, "pkg/runtime")) | 1068 if(streq(dir, "pkg/runtime")) |
1069 vadd(&compile, "-+"); | 1069 vadd(&compile, "-+"); |
1070 | 1070 |
1071 vcopy(&compile, go.p, go.len); | 1071 vcopy(&compile, go.p, go.len); |
1072 | 1072 |
1073 runv(nil, bstr(&path), CheckExit, &compile); | 1073 runv(nil, bstr(&path), CheckExit, &compile); |
| 1074 |
| 1075 if(ispackcmd) { |
| 1076 xremove(link.p[targ]); |
| 1077 dopack(link.p[targ], bstr(&b), &link.p[targ+1], link.len
- (targ+1)); |
| 1078 goto nobuild; |
| 1079 } |
1074 } | 1080 } |
1075 | 1081 |
1076 if(!islib && !isgo) { | 1082 if(!islib && !isgo) { |
1077 // C binaries need the libraries explicitly, and -lm. | 1083 // C binaries need the libraries explicitly, and -lm. |
1078 vcopy(&link, lib.p, lib.len); | 1084 vcopy(&link, lib.p, lib.len); |
1079 if(!streq(gohostos, "plan9")) | 1085 if(!streq(gohostos, "plan9")) |
1080 vadd(&link, "-lm"); | 1086 vadd(&link, "-lm"); |
1081 } | 1087 } |
1082 | 1088 |
1083 // Remove target before writing it. | 1089 // Remove target before writing it. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1148 // The main exception is libmach which has been modified | 1154 // The main exception is libmach which has been modified |
1149 // in various places to support Go object files. | 1155 // in various places to support Go object files. |
1150 if(streq(gohostos, "plan9")) { | 1156 if(streq(gohostos, "plan9")) { |
1151 if(streq(dir, "lib9")) { | 1157 if(streq(dir, "lib9")) { |
1152 name = lastelem(file); | 1158 name = lastelem(file); |
1153 if(streq(name, "goos.c") || streq(name, "flag.c")) | 1159 if(streq(name, "goos.c") || streq(name, "flag.c")) |
1154 return 1; | 1160 return 1; |
1155 if(!contains(name, "plan9")) | 1161 if(!contains(name, "plan9")) |
1156 return 0; | 1162 return 0; |
1157 } | 1163 } |
1158 if(streq(dir, "libbio")) | |
1159 return 0; | |
1160 } | 1164 } |
1161 ········ | 1165 ········ |
1162 // Check file name for GOOS or GOARCH. | 1166 // Check file name for GOOS or GOARCH. |
1163 name = lastelem(file); | 1167 name = lastelem(file); |
1164 for(i=0; i<nelem(okgoos); i++) | 1168 for(i=0; i<nelem(okgoos); i++) |
1165 if(contains(name, okgoos[i]) && !streq(okgoos[i], goos)) | 1169 if(contains(name, okgoos[i]) && !streq(okgoos[i], goos)) |
1166 return 0; | 1170 return 0; |
1167 for(i=0; i<nelem(okgoarch); i++) | 1171 for(i=0; i<nelem(okgoarch); i++) |
1168 if(contains(name, okgoarch[i]) && !streq(okgoarch[i], goarch)) | 1172 if(contains(name, okgoarch[i]) && !streq(okgoarch[i], goarch)) |
1169 return 0; | 1173 return 0; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 | 1240 |
1237 if(vflag > 1) | 1241 if(vflag > 1) |
1238 errprintf("cp %s %s\n", src, dst); | 1242 errprintf("cp %s %s\n", src, dst); |
1239 | 1243 |
1240 binit(&b); | 1244 binit(&b); |
1241 readfile(&b, src); | 1245 readfile(&b, src); |
1242 writefile(&b, dst, exec); | 1246 writefile(&b, dst, exec); |
1243 bfree(&b); | 1247 bfree(&b); |
1244 } | 1248 } |
1245 | 1249 |
| 1250 // dopack copies the package src to dst, |
| 1251 // appending the files listed in extra. |
| 1252 // The archive format is the traditional Unix ar format. |
| 1253 static void |
| 1254 dopack(char *dst, char *src, char **extra, int nextra) |
| 1255 { |
| 1256 int i; |
| 1257 char c, *p, *q; |
| 1258 Buf b, bdst; |
| 1259 ········ |
| 1260 binit(&b); |
| 1261 binit(&bdst); |
| 1262 |
| 1263 readfile(&bdst, src); |
| 1264 for(i=0; i<nextra; i++) { |
| 1265 readfile(&b, extra[i]); |
| 1266 // find last path element for archive member name |
| 1267 p = xstrrchr(extra[i], '/'); |
| 1268 if(p) |
| 1269 p++; |
| 1270 q = xstrrchr(extra[i], '\\'); |
| 1271 if(q) { |
| 1272 q++; |
| 1273 if(p == nil || q > p) |
| 1274 p = q; |
| 1275 } |
| 1276 if(p == nil) |
| 1277 p = extra[i]; |
| 1278 bwritef(&bdst, "%-16.16s%-12d%-6d%-6d%-8o%-10d`\n", p, 0, 0, 0,
0644, b.len); |
| 1279 bwriteb(&bdst, &b); |
| 1280 if(b.len&1) { |
| 1281 c = 0; |
| 1282 bwrite(&bdst, &c, 1); |
| 1283 } |
| 1284 } |
| 1285 |
| 1286 writefile(&bdst, dst, 0); |
| 1287 |
| 1288 bfree(&b); |
| 1289 bfree(&bdst); |
| 1290 } |
| 1291 |
1246 // buildorder records the order of builds for the 'go bootstrap' command. | 1292 // buildorder records the order of builds for the 'go bootstrap' command. |
1247 static char *buildorder[] = { | 1293 static char *buildorder[] = { |
1248 "lib9", | 1294 "lib9", |
1249 "libbio", | 1295 "libbio", |
1250 "libmach", | 1296 "libmach", |
| 1297 "liblink", |
1251 | 1298 |
1252 "misc/pprof", | 1299 "misc/pprof", |
1253 | 1300 |
1254 "cmd/addr2line", | 1301 "cmd/addr2line", |
1255 "cmd/nm", | |
1256 "cmd/objdump", | 1302 "cmd/objdump", |
1257 "cmd/pack", | 1303 "cmd/pack", |
1258 "cmd/prof", | 1304 "cmd/prof", |
1259 | 1305 |
1260 "cmd/cc", // must be before c | 1306 "cmd/cc", // must be before c |
1261 "cmd/gc", // must be before g | 1307 "cmd/gc", // must be before g |
1262 "cmd/%sl", // must be before a, c, g | 1308 "cmd/%sl", // must be before a, c, g |
1263 "cmd/%sa", | 1309 "cmd/%sa", |
1264 "cmd/%sc", | 1310 "cmd/%sc", |
1265 "cmd/%sg", | 1311 "cmd/%sg", |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 "cmd/6c", | 1370 "cmd/6c", |
1325 "cmd/6g", | 1371 "cmd/6g", |
1326 "cmd/6l", | 1372 "cmd/6l", |
1327 "cmd/8a", | 1373 "cmd/8a", |
1328 "cmd/8c", | 1374 "cmd/8c", |
1329 "cmd/8g", | 1375 "cmd/8g", |
1330 "cmd/8l", | 1376 "cmd/8l", |
1331 "cmd/addr2line", | 1377 "cmd/addr2line", |
1332 "cmd/cc", | 1378 "cmd/cc", |
1333 "cmd/gc", | 1379 "cmd/gc", |
1334 » "cmd/go", | 1380 » "cmd/go",» |
1335 » "cmd/nm", | |
1336 "cmd/objdump", | 1381 "cmd/objdump", |
1337 "cmd/pack", | 1382 "cmd/pack", |
1338 "cmd/prof", | 1383 "cmd/prof", |
1339 "lib9", | 1384 "lib9", |
1340 "libbio", | 1385 "libbio", |
1341 "libmach", | 1386 "libmach", |
| 1387 "liblink", |
1342 "pkg/bufio", | 1388 "pkg/bufio", |
1343 "pkg/bytes", | 1389 "pkg/bytes", |
1344 "pkg/container/heap", | 1390 "pkg/container/heap", |
1345 "pkg/encoding", | 1391 "pkg/encoding", |
1346 "pkg/encoding/base64", | 1392 "pkg/encoding/base64", |
1347 "pkg/encoding/json", | 1393 "pkg/encoding/json", |
1348 "pkg/errors", | 1394 "pkg/errors", |
1349 "pkg/flag", | 1395 "pkg/flag", |
1350 "pkg/fmt", | 1396 "pkg/fmt", |
1351 "pkg/go/ast", | 1397 "pkg/go/ast", |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 break; | 1788 break; |
1743 default: | 1789 default: |
1744 usage(); | 1790 usage(); |
1745 }ARGEND | 1791 }ARGEND |
1746 | 1792 |
1747 if(argc > 0) | 1793 if(argc > 0) |
1748 usage(); | 1794 usage(); |
1749 | 1795 |
1750 xprintf("%s\n", goversion); | 1796 xprintf("%s\n", goversion); |
1751 } | 1797 } |
LEFT | RIGHT |