Skip to content
This repository has been archived by the owner on Dec 14, 2023. It is now read-only.

Added a garbage collector to the llgo runtime #108

Closed
wants to merge 6 commits into from

Conversation

antongulenko
Copy link
Contributor

This implements issue #106.
I found a way to avoid cloning the entire GC source tree into the llgo repo, so I'll just go ahead and open this pull request.
The Böhm garbage collector is added to the llgo runtime in the following way:

  • llgo-dist has an additional step that clones the repositories for the collector into llgo/pkg/runtime/gc
  • There is the file llgo/pkg/runtime/gc.c that includes the entire collector code. Since the file is in this folder, it will be compiled into the runtime.bc file by llgo-dist.
  • To make it compile, I had to add a pseudo-generic rule to llgo-build - if C-files are compiled, it recursively looks for folders called 'include' and adds them to the header lookup path of the compiler. This is the most portable way to compile the collector directly into the runtime.
  • I added the switch -gc (bool) to llgo-build, that switches the gc on/off for every invocation of llgo-build. This works by defining symbols called llgo_malloc and llgo_free at link-time using --defsym.

Check it out! Here you can find a program to test this:
https://github.com/antongulenko/test-gc

Cheers,
Anton

@axw
Copy link
Member

axw commented Mar 27, 2014

We're finally moving to libgo, courtesy of pcc. I'll close this now - thanks for spending the time on this anyway.

@axw axw closed this Mar 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants