diff options
author | Matthew Sotoudeh <matthew@masot.net> | 2024-04-20 17:16:33 -0700 |
---|---|---|
committer | Matthew Sotoudeh <matthew@masot.net> | 2024-04-20 17:16:33 -0700 |
commit | 378b80c38369159fe2171df80151f609c84a3863 (patch) | |
tree | 40f78721cdf0bb5e6c06a0058efa57d293e7f52b | |
parent | ee0ea049f6bae5d1ffc137e17b1858cb1e154b13 (diff) |
allow compiling a C version from the gamma version
-rw-r--r-- | gamma_version/main.c | 4 | ||||
-rw-r--r-- | self_hosting/Makefile.gamma_to_c | 2 | ||||
-rwxr-xr-x | self_hosting/bootstrap.sh | 9 |
3 files changed, 15 insertions, 0 deletions
diff --git a/gamma_version/main.c b/gamma_version/main.c index 780c80f..72e5aef 100644 --- a/gamma_version/main.c +++ b/gamma_version/main.c @@ -38,6 +38,10 @@ char *TMPDIR; int GAMMA_TO_C; int main(int argc, char **argv) { + if (argc <= 1) { + fprintf(stderr, "Usage: ./gc [cc] [cc args]\n"); + return 1; + } // ======= Make a working copy of argv ======= ARGV = calloc(argc, sizeof(argv[0])); memcpy(ARGV, argv+1, argc * sizeof(argv[0])); diff --git a/self_hosting/Makefile.gamma_to_c b/self_hosting/Makefile.gamma_to_c new file mode 100644 index 0000000..dd4eba9 --- /dev/null +++ b/self_hosting/Makefile.gamma_to_c @@ -0,0 +1,2 @@ +gc: *.c + cc -O3 *.c -o gc diff --git a/self_hosting/bootstrap.sh b/self_hosting/bootstrap.sh index 4f73b61..6aa966f 100755 --- a/self_hosting/bootstrap.sh +++ b/self_hosting/bootstrap.sh @@ -19,4 +19,13 @@ cp -r $GAMMA_VERSION self_hosted_version rm -rf self_hosted_version/build GC=$(pwd)/$GAMMA_VERSION/build/gc make -C self_hosted_version +echo "------------- Using the Gamma version to create a bootstrap dir -------------" +GC="$(pwd)/self_hosted_version/build/gc" CFLAGS="--gamma-to-c" make -B -C self_hosted_version +rm -rf gamma_to_c_version +mv self_hosted_version/c.out gamma_to_c_version +cp Makefile.gamma_to_c gamma_to_c_version/Makefile + +echo "------------- Building the gamma_to_c version with GCC -------------" +make -C gamma_to_c_version + echo "------------- Done! See self_hosted_version/build/gc -------------" |