lsegal/my_toy_compiler — pull request #7 by mpiroc (2012-09-07 03:28:02+00:00)
Title: Fix build with g++

Makefile was using the following recipe for parser:

g++ -o $@ $(LDFLAGS) $(OBJS) $(LIBS)

`LDFLAGS` contains linker flags such as `-ldl` and `-lpthread`. But g++ requires that linker flags come after the object files that require functions from the linked libraries. Because `LDFLAGS` came before `OBJS` and `LIBS`, g++ fails with linker errors (at least on my Ubuntu 12.04 box).

The fix is simple: Move `LDFLAGS` to the end:

g++ -o $@ $(OBJS) $(LIBS) $(LDFLAGS)

This patch does that.