From a34a2b1aab981f02d139cf3a1c0aea3fbeded327 Mon Sep 17 00:00:00 2001 From: sforman Date: Mon, 24 Jul 2023 11:29:39 -0700 Subject: [PATCH] Compile on Ubuntu. --- implementations/C/Makefile | 2 +- implementations/C/README.md | 14 ++++++++--- implementations/C/notes | 47 ++++++++++++++++++++++++++++++++++++- 3 files changed, 58 insertions(+), 5 deletions(-) diff --git a/implementations/C/Makefile b/implementations/C/Makefile index e8c5df1..1f26c74 100644 --- a/implementations/C/Makefile +++ b/implementations/C/Makefile @@ -1,6 +1,6 @@ OBJS=joy.o keywords.o definitions.o linenoise.o -LDFLAGS=-L/usr/local/lib -lgc -lgmp +LDFLAGS= -Wl,--no-as-needed -L/usr/local/lib -lgc -lgmp # Hold my hand, in fact, hold both of them, and pat my head too please. CFLAGS = -ansi -Wall -Wextra -Werror -pedantic -Wstrict-overflow -fno-strict-aliasing -pedantic-errors diff --git a/implementations/C/README.md b/implementations/C/README.md index a2d9cda..0f3a1ce 100644 --- a/implementations/C/README.md +++ b/implementations/C/README.md @@ -1,8 +1,7 @@ -Thun in C ---------------- +# Thun in C This is my first attempt to write C in many years, I hope it's not too -embarassing. +embarrassing. I use Gperf to create a static wordlist. This make word lookup very efficient, but there's no way currently to add definitions at runtime. @@ -11,4 +10,13 @@ There's a janky script *convert\_defs.py* that generates *definitions.c*, *definitions.h*, and *KEYWORDS.txt* from the *defs.txt* file. I would like to replace the dependency on Python with, say, Awk or something. +## Dependencies +- python +- gperf +- gmake +- boehm-gc +- gmp + + + sudo apt install gperf diff --git a/implementations/C/notes b/implementations/C/notes index c31683a..7d12f7d 100644 --- a/implementations/C/notes +++ b/implementations/C/notes @@ -32,7 +32,7 @@ VList instead of singly-linked list.) But I want to tackle efficiency by compilation, and write the compiler(s) in Prolog. I think that avoids complexity compared to intricating the guts of the interpreter by hand, and moves the unavoidable complexity into formal statements of logic that -can be evaulated by machine (aka Prolog.) +can be evaluated by machine (aka Prolog.) --------------------------------------- @@ -100,3 +100,48 @@ the comparison functions as definitions: neq [true] [false] [true] cmp le [false] [true] [true] cmp ge [true] [true] [false] cmp + + + + + + + + + + + + + + + + + + + + + + + +---------------------------------- +Argh! That was brutal. + +I hate staring at the thing that SHOULD work and it just fucking doesn't work. + +Why? Because some fuck-wit somewhere decided to fuck up how things have always been done. + +https://stackoverflow.com/questions/12734161/how-to-use-boehm-garbage-collector-in-ubuntu-12-04 + +> To answer my own question: actually, the Boehm GC library still works the same way as it used to in 12.04. The problem is that GCC doesn't! GCC has started to default to --as-needed, and it drops -lgc completely if it is at the beginning of the line. This is a very major change!! + +> Solution is to move -lgc to the end: + +> gcc test.c -lgc + +> Or add: + +> gcc -Wl,--as-needed -lgc test.c + + + +Goddamnit!