Knowledge (XXG)

Self-hosting (compilers)

Source 📝

25: 292:
This technique is usually only practicable when an interpreter already exists for the very same language that is to be compiled; though possible, it is extremely uncommon to humanly compile a compiler with itself. The concept borrows directly from and is an example of the broader notion of running a
184:
Before a system can become self-hosted, another system is needed to develop it until it reaches a stage where self-hosting is possible. When developing for a new computer or operating system, a system to run the development software is needed, but development software used to write and build the
204:
on one platform to be compiled for a different machine or operating system, making it possible to create an operating system for a machine for which a self-hosting compiler does not yet exist. Once written, software can be deployed to the target system using means such as an
235:
Since self-hosted compilers suffer from the same bootstrap problems as operating systems, a compiler for a new programming language needs to be written in an existing language. So the developer may use something like assembly language,
252:
to build the first version of the compiler. Once the language is mature enough, development of the compiler can shift to the compiler's native language, allowing the compiler to build itself.
221:
device. This is similar to the method used to write software for gaming consoles or for handheld devices like cellular phones or tablets, which do not host their own development tools.
181:
An operating system is self-hosted when the toolchain to build the operating system runs on that same operating system. For example, Windows can be built on a computer running Windows.
328:, an editor, an assembler, and a few utilities were completed, the Unix operating system was self-hosting – programs could be written and tested on the PDP-7 itself. 342:) in TMG on a piece of paper and "decided to give his piece of paper to his piece of paper", doing the computation himself, thus compiling a TMG compiler into 224:
Once the system is mature enough to compile its own code, the cross-development dependency ends. At this point, an operating system is said to be self-hosted.
42: 797: 790: 89: 569: 108: 61: 261: 232:
Software development using compiler or interpreters can also be self hosted when the compiler is capable of compiling itself.
68: 992: 574: 539: 509: 469: 445: 46: 987: 652: 622: 609: 589: 554: 519: 504: 499: 489: 245: 647: 544: 524: 494: 474: 294: 75: 687: 642: 632: 559: 549: 484: 380:, where a core version of the language is initially implemented using another high-level language, assembler, or even 278:
The compiler as it exists on the standard compiler tape is a machine language program that was obtained by having the
162: 274:. Once they had improved the compiler to the point where it could compile its own source code, it was self-hosting. 747: 709: 584: 397: 249: 57: 35: 534: 377: 267: 186: 158: 479: 422: 237: 166: 271: 270:
by Hart and Levin at MIT in 1962. They wrote a Lisp compiler in Lisp, testing it inside an existing Lisp
376:
have self-hosted implementations: compilers that are both in and for the same language. An approach is
910: 768: 946: 373: 122: 926: 82: 732: 325: 190: 384:; the resulting compiler is then used to start building successive expanded versions of itself. 361:(a popular editor), making possible the self contained, maintained and sustained development of 695: 343: 339: 154: 874: 737: 699: 449: 170: 138: 130: 930: 703: 453: 406: 331: 298: 825: 742: 722: 677: 439: 354: 335: 197: 981: 594: 362: 317: 851: 464: 431: 381: 309: 279: 214: 200:(or cross assembler when working with assembly language). A cross compiler allows 662: 613: 598: 563: 366: 210: 201: 146: 24: 727: 682: 898:
The flat assembler is self-hosting and the complete source code is included.
863: 657: 134: 157:
and larger systems. Other programs that are typically self-hosting include
886: 150: 142: 830: 579: 459: 266:
The first self-hosting compiler (excluding assemblers) was written for
636: 529: 967: 427: 241: 666: 604: 435: 412: 402: 358: 321: 282:
definition of the compiler work on itself through the interpreter.
206: 392:
The following programming languages have self-hosting compilers:
626: 514: 417: 313: 218: 141:
that produces new versions of that same program—for example, a
672: 350: 18: 942: 346:, which he typed up and assembled on Ken Thompson's PDP-7. 293:
program on itself as input, used also in various proofs in
826:"VCF East 2019 -- Brian Kernighan interviews Ken Thompson" 923: 185:
operating system is also necessary. This is called a
49:. Unsourced material may be challenged and removed. 316:in 1968 by writing and compiling programs on the 16:Software that can produce new versions of itself 388:List of languages having self-hosting compilers 276: 324:for testing. After the initial Unix kernel, a 8: 819: 817: 911:"Haskell Communities and Activities Report" 109:Learn how and when to remove this message 784: 782: 759: 357:(the GNU Compiler Collection) and GNU 864:BASICO compiler bootstrapping example 7: 244:, or even a scripting language like 47:adding citations to reliable sources 852:"The Development of the C Language" 769:"What is a self-hosting compiler?" 196:A solution to this problem is the 14: 262:History of compiler construction 217:(such as a USB thumb drive), or 189:problem or, more generically, a 23: 949:from the original on 2017-06-04 34:needs additional citations for 320:and carrying them over to the 1: 791:"AI Memo 39-The new compiler" 297:, such as the proof that the 58:"Self-hosting" compilers 295:theoretical computer science 1009: 748:Indirect self-modification 259: 353:system relies largely on 171:revision control software 167:command-line interpreters 145:that can compile its own 789:Hart, Tim; Levin, Mike. 312:started development on 943:"Implement TCL in TCL" 290: 993:Self-hosting software 924:https://www.pyret.org 374:programming languages 988:Computer programming 123:computer programming 43:improve this article 850:Dennis M. Ritchie. 733:Futamura projection 349:Development of the 326:command interpreter 929:2018-04-10 at the 875:ClojureScript Next 191:chicken or the egg 155:personal computers 153:is commonplace on 773:robertheaton.com/ 696:Visual Basic .NET 340:compiler-compiler 177:Operating systems 119: 118: 111: 93: 1000: 972: 971: 964: 958: 957: 955: 954: 939: 933: 921: 915: 914: 907: 901: 900: 895: 893: 887:"flat assembler" 883: 877: 872: 866: 861: 855: 848: 842: 841: 839: 838: 821: 812: 811: 809: 808: 802: 796:. Archived from 795: 786: 777: 776: 767:Heaton, Robert. 764: 738:Self-interpreter 700:Microsoft Roslyn 450:Microsoft Roslyn 382:machine language 301:is undecidable. 288: 139:operating system 129:is the use of a 114: 107: 103: 100: 94: 92: 51: 27: 19: 1008: 1007: 1003: 1002: 1001: 999: 998: 997: 978: 977: 976: 975: 966: 965: 961: 952: 950: 941: 940: 936: 931:Wayback Machine 922: 918: 909: 908: 904: 891: 889: 885: 884: 880: 873: 869: 862: 858: 849: 845: 836: 834: 824:Thompson, Ken. 823: 822: 815: 806: 804: 800: 793: 788: 787: 780: 766: 765: 761: 756: 719: 714: 407:Burroughs B5000 390: 332:Douglas McIlroy 307: 299:halting problem 289: 286: 264: 258: 230: 211:floppy diskette 179: 149:. Self-hosting 133:as part of the 115: 104: 98: 95: 52: 50: 40: 28: 17: 12: 11: 5: 1006: 1004: 996: 995: 990: 980: 979: 974: 973: 959: 934: 916: 902: 878: 867: 856: 843: 813: 778: 758: 757: 755: 752: 751: 750: 745: 743:Self-reference 740: 735: 730: 725: 723:Cross-compiler 718: 715: 713: 712: 707: 693: 690: 685: 680: 675: 670: 660: 655: 650: 645: 640: 630: 620: 617: 607: 602: 592: 587: 582: 577: 572: 567: 557: 552: 547: 542: 537: 532: 527: 522: 517: 512: 507: 502: 497: 492: 487: 482: 477: 472: 467: 462: 457: 443: 425: 420: 415: 410: 400: 394: 389: 386: 306: 303: 284: 260:Main article: 257: 254: 229: 226: 198:cross compiler 178: 175: 117: 116: 31: 29: 22: 15: 13: 10: 9: 6: 4: 3: 2: 1005: 994: 991: 989: 986: 985: 983: 969: 963: 960: 948: 944: 938: 935: 932: 928: 925: 920: 917: 912: 906: 903: 899: 888: 882: 879: 876: 871: 868: 865: 860: 857: 853: 847: 844: 833: 832: 827: 820: 818: 814: 803:on 2020-12-13 799: 792: 785: 783: 779: 774: 770: 763: 760: 753: 749: 746: 744: 741: 739: 736: 734: 731: 729: 726: 724: 721: 720: 716: 711: 708: 705: 701: 697: 694: 691: 689: 686: 684: 681: 679: 676: 674: 671: 668: 664: 661: 659: 656: 654: 651: 649: 646: 644: 641: 638: 634: 631: 628: 624: 621: 618: 615: 611: 608: 606: 603: 600: 596: 595:Object Pascal 593: 591: 588: 586: 583: 581: 578: 576: 573: 571: 568: 565: 561: 558: 556: 553: 551: 548: 546: 543: 541: 538: 536: 533: 531: 528: 526: 523: 521: 518: 516: 513: 511: 508: 506: 503: 501: 498: 496: 493: 491: 488: 486: 483: 481: 478: 476: 473: 471: 468: 466: 463: 461: 460:ClojureScript 458: 455: 451: 447: 444: 441: 437: 433: 429: 426: 424: 421: 419: 416: 414: 411: 408: 404: 401: 399: 396: 395: 393: 387: 385: 383: 379: 378:bootstrapping 375: 370: 368: 364: 363:free software 360: 356: 352: 347: 345: 341: 337: 333: 329: 327: 323: 319: 315: 311: 304: 302: 300: 296: 283: 281: 275: 273: 269: 263: 255: 253: 251: 247: 243: 239: 233: 227: 225: 222: 220: 216: 212: 208: 203: 199: 194: 192: 188: 187:bootstrapping 182: 176: 174: 172: 168: 164: 160: 156: 152: 148: 144: 140: 136: 132: 128: 124: 113: 110: 102: 91: 88: 84: 81: 77: 74: 70: 67: 63: 60: –  59: 55: 54:Find sources: 48: 44: 38: 37: 32:This article 30: 26: 21: 20: 962: 951:. Retrieved 937: 919: 905: 897: 890:. Retrieved 881: 870: 859: 846: 835:. Retrieved 829: 805:. Retrieved 798:the original 772: 762: 465:CoffeeScript 391: 371: 348: 330: 310:Ken Thompson 308: 291: 280:S-expression 277: 265: 234: 231: 223: 215:flash memory 195: 183: 180: 127:self-hosting 126: 120: 105: 96: 86: 79: 72: 65: 53: 41:Please help 36:verification 33: 663:Standard ML 614:Free Pascal 599:Free Pascal 564:Common Lisp 367:GNU Project 272:Interpreter 202:source code 147:source code 982:Categories 953:2017-09-19 837:2019-10-28 807:2008-05-23 754:References 728:Dogfooding 683:TypeScript 570:LiveScript 432:Visual C++ 287:AI Memo 39 163:assemblers 99:April 2010 69:newspapers 892:7 January 658:Smalltalk 228:Compilers 193:dilemma. 135:toolchain 968:"Virgil" 947:Archived 927:Archived 717:See also 365:for the 344:assembly 305:Examples 285:—  151:software 143:compiler 854:. 1993. 831:YouTube 580:Nemerle 575:Mercury 540:Haskell 470:Crystal 256:History 159:kernels 131:program 83:scholar 692:Virgil 653:Scheme 637:Rakudo 623:Python 610:Pascal 590:Oberon 555:Kotlin 530:Gambas 520:Factor 505:Elixir 500:Eiffel 490:Delphi 334:wrote 318:GE-635 246:Python 85:  78:  71:  64:  56:  801:(PDF) 794:(PDF) 667:MLton 648:Scala 619:Pyret 605:OCaml 545:Idris 525:Forth 495:Dylan 475:Curry 436:clang 413:BASIC 403:ALGOL 372:Many 359:Emacs 322:PDP-7 207:EPROM 90:JSTOR 76:books 894:2022 704:Mono 688:Vala 643:Rust 633:Raku 627:PyPy 560:Lisp 550:Java 515:FASM 485:Dart 454:Mono 442:4.8) 418:BCPL 314:Unix 268:Lisp 219:JTAG 169:and 62:news 710:Zig 678:TMG 673:Tcl 585:Nim 440:gcc 428:C++ 398:Ada 355:GCC 351:GNU 338:(a 336:TMG 250:Lua 248:or 242:C++ 137:or 121:In 45:by 984:: 945:. 896:. 828:. 816:^ 781:^ 771:. 702:, 535:Go 510:F# 452:, 446:C# 438:, 434:, 369:. 213:, 209:, 173:. 165:, 161:, 125:, 970:. 956:. 913:. 840:. 810:. 775:. 706:) 698:( 669:) 665:( 639:) 635:( 629:) 625:( 616:) 612:( 601:) 597:( 566:) 562:( 480:D 456:) 448:( 430:( 423:C 409:) 405:( 240:/ 238:C 112:) 106:( 101:) 97:( 87:· 80:· 73:· 66:· 39:.

Index


verification
improve this article
adding citations to reliable sources
"Self-hosting" compilers
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
computer programming
program
toolchain
operating system
compiler
source code
software
personal computers
kernels
assemblers
command-line interpreters
revision control software
bootstrapping
chicken or the egg
cross compiler
source code
EPROM
floppy diskette
flash memory

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.