Skip to content

Commit

Permalink
Merge pull request #21 from pallene-lang/pt-run-2-pt-lua
Browse files Browse the repository at this point in the history
Migrate pt-run to a complete Lua frontend
  • Loading branch information
singul4ri7y authored Aug 14, 2024
2 parents 3884483 + 40231d6 commit a241fd3
Show file tree
Hide file tree
Showing 19 changed files with 1,067 additions and 398 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
*.a
*.so

pt-run
pt-lua
4 changes: 3 additions & 1 deletion AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ Pallene Tracer Authors
----------------------

Here we thank the many people who have contributed code to this project.
This list was last updated in 2024-07-07, using `compute-authors.lua`.
This list was last updated in 2024-08-13, using `compute-authors.lua`.

SD Asif Hossein

Hugo Musso Gualandi
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ BINDIR = $(PREFIX)/bin
INCDIR = $(PREFIX)/include

# Where to find Lua libraries
LUA_PREFIX = /usr/local
LUA_PREFIX = /usr
LUA_BINDIR = $(LUA_PREFIX)/bin
LUA_INCDIR = $(LUA_PREFIX)/include
LUA_LIBDIR = $(LUA_PREFIX)/lib
Expand All @@ -20,14 +20,15 @@ INSTALL_EXEC= $(INSTALL) -m 0755
INSTALL_DATA= $(INSTALL) -m 0644

# C compilation flags
CFLAGS = -DPT_DEBUG -O2 -std=c99 -pedantic -Wall -Wextra -Wformat-security
CFLAGS = -DPT_DEBUG -g -std=c99 -pedantic -Wall -Wextra -Wformat-security
# Explicitly mention which Lua headers to capture
CPPFLAGS = -I$(LUA_INCDIR) -I.
LIBFLAG = -fPIC -shared

# The -Wl,-E tells the linker to not throw away unused Lua API symbols.
# We need them for Lua modules that are dynamically linked via require
PTRUN_LDFLAGS = -L$(LUA_LIBDIR) -Wl,-E
PTRUN_LDLIBS = -llua -lm
PTLUA_LDFLAGS = -L$(LUA_LIBDIR) -Wl,-E
PTLUA_LDLIBS = -llua -lm

# ===================
# Compilation targets
Expand All @@ -36,7 +37,7 @@ PTRUN_LDLIBS = -llua -lm
.PHONY: library examples tests all install uninstall clean

library: \
pt-run
pt-lua

examples: library \
examples/fibonacci/fibonacci.so
Expand All @@ -52,22 +53,22 @@ tests: library \

all: library examples tests

install:
$(INSTALL_EXEC) pt-run $(BINDIR)
install: library
$(INSTALL_EXEC) pt-lua $(BINDIR)
$(INSTALL_DATA) ptracer.h $(INCDIR)

uninstall:
rm -rf $(INCDIR)/ptracer.h
rm -rf $(BINDIR)/pt-run

clean:
rm -rf pt-run examples/*/*.so spec/tracebacks/*/*.so
rm -rf pt-lua examples/*/*.so spec/tracebacks/*/*.so

%.so: %.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(LIBFLAG) $< -o $@

pt-run: pt-run.c ptracer.h
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(PTRUN_LDFLAGS) $< -o $@ $(PTRUN_LDLIBS)
pt-lua: pt-lua.c ptracer.h
$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(PTLUA_LDFLAGS) $< -o $@ $(PTLUA_LDLIBS)

examples/fibonacci/fibonacci.so: examples/fibonacci/fibonacci.c ptracer.h
spec/tracebacks/anon_lua/module.so: spec/tracebacks/anon_lua/module.c ptracer.h
Expand Down
Loading

0 comments on commit a241fd3

Please sign in to comment.