diff --git a/LLVM/cplusplus/Makefile b/LLVM/cplusplus/Makefile index 5234e25bba4071e2512279a927a43e221fba71f9..6fb1122d664f11a5b6a98bfcb9eb20289abd62e7 100644 --- a/LLVM/cplusplus/Makefile +++ b/LLVM/cplusplus/Makefile @@ -17,29 +17,38 @@ CC := clang++ # clang++ -g -O3 toy.cpp `llvm-config --cxxflags --ldflags --system-libs --libs core` -o toy # based on that, and some experimentation, we got, for LLVM 3.6... # CFLAGS=-std=c++11 `llvm-config --cxxflags --ldflags --system-libs --libs all` -rdynamic -O3 -# Now, for llvm >= 3.7.1, further experience has brought us to.... -# At one time, we piped the output of llvm-config to sed s/no-maybe/no/ . -# Hopefully this is no longer necessary... ? +# Later, for a while, we piped the output of llvm-config to sed s/no-maybe/no/ # (sed was used to hide an incompatibility between llvm-config and clang) +# Hopefully this seems to no longer be necessary. +# So, the current solution is... LLVM_FLAGS := `llvm-config --cxxflags --ldflags --system-libs --libs all ` CFLAGS := $(LLVM_FLAGS) -rdynamic -O3 -## More preliminaries -# See https://www.gnu.org/software/make/manual/html_node/Special-Targets.html +### Gnu Make Preliminaries -- See also +# https://www.gnu.org/software/make/manual/html_node/Special-Targets.html + # In this makefile, we want to keep going even if we find errors -.IGNORE : +# Update: Let's only ignore errors in the tests, not in the build. +.IGNORE : $(TESTS) # Further, we do not want multiple things built at once, even if make called with -j2 .NOTPARALLEL : -# Tell make that the following "targets" are "phony" -# Cf. https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets -.PHONY : all tests clean testclean +# We define the list of tests how, so that we can declare them "phony". +# WARNING: test9 is included, but seems to be broken... ?!? +TESTS := testModuleMaker testFibonacci test2 test3 test4 test5 test6 test7 test8 test9 + +# "A phony target is one that is not really the name of a file; +# rather it is just a name for a recipe to be executed +# when you make an explicit request". +# Quote from (see also) +# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html#Phony-Targets +.PHONY : all tests clean testclean $(TESTS) -## Now, the targets -- the things that will get made! +#### Now, the targets -- the things that will get made! all: $(PROGS) @@ -52,12 +61,13 @@ clean: testclean testclean: rm -fv *~ *.output test8.o test9 +tests: $(TESTS) + testModuleMaker: ModuleMaker echo && echo "Testing ModuleMaker (expect 5)...\n" @./ModuleMaker >ModuleMaker.bc @lli ModuleMaker.bc || echo $$? -# WARNING: testFibonacci broken (with LLVM and clang 3.7.1) testFibonacci: fibonacci echo && echo "\n===================> Testing fibonacci (expect 46368)...\n" -./fibonacci @@ -97,7 +107,3 @@ test9: toy9 tests/test9.kal -./toy9 <tests/test9.kal |& clang -x ir - -o test9 -./test9 -# WARNING: test9 removed since broken (with LLVM and clang <= 3.9) -# NOTE: fibonacci added BACK to tests since it's working again! -tests: testModuleMaker testFibonacci test2 test3 test4 test5 test6 test7 test8 - diff --git a/LLVM/cplusplus/tests/test9.kal b/LLVM/cplusplus/tests/test9.kal index 6d8714d5eb4d4edc839299b48b26672b7d6ae4de..122c1a004218313bef179071414660f04ef78623 100644 --- a/LLVM/cplusplus/tests/test9.kal +++ b/LLVM/cplusplus/tests/test9.kal @@ -4,4 +4,4 @@ def fib(x) else fib(x-1)+fib(x-2); -fib(10) +fib(2) diff --git a/LLVM/cplusplus/toy9.cpp b/LLVM/cplusplus/toy9.cpp index ea134cd4ee44160f2cca937d617ef9453f2fc606..e75a21a5550a962585961ddcb21eb2cc07473d33 100644 --- a/LLVM/cplusplus/toy9.cpp +++ b/LLVM/cplusplus/toy9.cpp @@ -802,7 +802,7 @@ static std::unique_ptr<FunctionAST> ParseTopLevelExpr() { SourceLocation FnLoc = CurLoc; if (auto E = ParseExpression()) { // Make an anonymous proto. - auto Proto = std::make_unique<PrototypeAST>(FnLoc, "__anon_expr", + auto Proto = std::make_unique<PrototypeAST>(FnLoc, "main", // "__anon_expr", std::vector<std::string>()); return std::make_unique<FunctionAST>(std::move(Proto), std::move(E)); }