{"id":13681851,"url":"https://github.com/DQNEO/minigo","last_synced_at":"2025-04-30T06:32:34.109Z","repository":{"id":54458823,"uuid":"151851490","full_name":"DQNEO/minigo","owner":"DQNEO","description":"minigo🐥is a small Go compiler made from scratch. It can compile itself.","archived":false,"fork":false,"pushed_at":"2021-02-16T16:05:25.000Z","size":2551,"stargazers_count":530,"open_issues_count":0,"forks_count":20,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-30T19:46:02.689Z","etag":null,"topics":["assembly","compiler","go","golang","lexer","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DQNEO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-06T15:07:31.000Z","updated_at":"2024-10-28T15:15:02.000Z","dependencies_parsed_at":"2022-08-13T16:20:14.567Z","dependency_job_id":null,"html_url":"https://github.com/DQNEO/minigo","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DQNEO%2Fminigo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DQNEO%2Fminigo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DQNEO%2Fminigo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DQNEO%2Fminigo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DQNEO","download_url":"https://codeload.github.com/DQNEO/minigo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224201755,"owners_count":17272635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","compiler","go","golang","lexer","parser"],"created_at":"2024-08-02T13:01:36.896Z","updated_at":"2024-11-12T01:30:37.101Z","avatar_url":"https://github.com/DQNEO.png","language":"Go","funding_links":[],"categories":["开源类库","Go","Open source library","Repositories"],"sub_categories":["编译器","Translator"],"readme":"# minigo🐥\n\n[![Go](https://github.com/DQNEO/minigo/workflows/Go/badge.svg)](https://github.com/DQNEO/minigo/actions) [![CircleCI](https://circleci.com/gh/DQNEO/minigo.svg?style=svg)](https://circleci.com/gh/DQNEO/minigo)\n\n\nA Go compiler made from scratch.\n\n# Notice\n\nThis repository is no longer maintained actively.\n\nI made another Go compiler `babygo` from scratch again, which is much more simple, sophisticated and understandable.\n\nPlease look at https://github.com/DQNEO/babygo\n\n\n# Description\n\n`minigo🐥` is a small Go compiler made from scratch. It can compile itself.\n\n* Generates a single static  binary executable\n* No dependency on yacc/lex or any external libraries\n* Standard libraries are also made from scratch\n\nIt depends only on GNU Assembler and GNU ld.\n\n`minigo` supports x86-64 Linux only.\n \n# Design\n\nI made this almost without reading the original Go compiler.\n\n`minigo` inherits most of its design from the following:\n\n* 8cc (https://github.com/rui314/8cc)\n* 8cc.go (https://github.com/DQNEO/8cc.go)\n\nThere are several steps in the compilation process.\n\n[go source] -\u003e byte_stream.go -\u003e [byte stream] -\u003e token.go -\u003e [token stream] -\u003e parser.go -\u003e [AST] -\u003e gen.go -\u003e [assembly code]\n\n\n# How to run\n\nYou need Linux, so I would recommend that you use Docker.\n\n```sh\n$ docker run --rm -it -w /mnt -v `pwd`:/mnt dqneo/ubuntu-build-essential:go bash\n```\n\nAfter entering the container, you can build and run it.\n\n```sh\n$ make\n$ ./minigo t/hello/hello.go \u003e hello.s\n$ as -o hello.o hello.s\n$ ld -o hello hello.o\n$ ./hello\nhello world\n```\n\n# How to \"self compile\"\n\n```sh\n$ make\n$ ./minigo --version\nminigo 0.1.0\nCopyright (C) 2019 @DQNEO\n\n$ ./minigo *.go \u003e /tmp/minigo2.s\n$ as -o /tmp/minigo2.o /tmp/minigo2.s\n$ ld -o minigo2 /tmp/minigo2.o\n$ ./minigo2 --version\nminigo 0.1.0\nCopyright (C) 2019 @DQNEO\n\n$ ./minigo2 *.go \u003e /tmp/minigo3.s\n$ as -o /tmp/minigo3.o /tmp/minigo3.s\n$ ld -o minigo3 /tmp/minigo3.o\n$ ./minigo3 --version\nminigo 0.1.0\nCopyright (C) 2019 @DQNEO\n```\n\nYou will see that the contents of 2nd generation compiler and 3rd generation compiler are identical.\n\n```sh\n$ diff /tmp/minigo2.s /tmp/minigo3.s\n```\n\n# Test\n\n```sh\n$ make test\n```\n\n# Debug by gdb\n\nAdd `--cap-add=SYS_PTRACE --security-opt='seccomp=unconfined'` option to `docker run`.\nIt will allow you to use `gdb` in the docker image.\n\n```\ndocker run --cap-add=SYS_PTRACE --security-opt='seccomp=unconfined' -it --rm -w /mnt -v `pwd`:/mnt --tmpfs=/tmp/tmpfs:rw,size=500m,mode=1777 dqneo/ubuntu-build-essential:go bash\n```\n\n## The Assembly language\nWe are currently using GNU assembler in AT\u0026T syntax.\n\nhttps://sourceware.org/binutils/docs/as/i386_002dDependent.html#i386_002dDependent\n\n# AUTHOR\n\n[@DQNEO](https://twitter.com/DQNEO)\n\n# LICENSE\n\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDQNEO%2Fminigo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FDQNEO%2Fminigo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FDQNEO%2Fminigo/lists"}