Gnnng/Pascal

Error in Make/Build!

Opened this issue · 5 comments

$ make

g++ -c `/usr/local/opt/llvm35/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o parser.o parser.cpp 
/bin/sh: 1: /usr/local/opt/llvm35/bin/llvm-config-3.5: not found
In file included from pascal.y:7:0:
ast.h:4:27: fatal error: llvm/IR/Value.h: No such file or directory
 #include "llvm/IR/Value.h"
                           ^
compilation terminated.
makefile:27: recipe for target 'parser.o' failed
make: *** [parser.o] Error 1

How fix?

this Bug Fix with Changes :

src/ast.h :

#include "llvm/IR/instruction.h"

to

#include "llvm/IR/Instruction.h"

src/makefile :

LLVM_CONFIG = /usr/local/opt/llvm35/bin/llvm-config-3.5

to

LLVM_CONFIG = /usr/bin/llvm-config-3.5
Gnnng commented

It's mainly the path issue. The error says llvm-config-3.5: not found, so you probably want to install llvm tools first. If you already did, next step is updating the paths in Makefile, such as the variable LLC in top-level Makefile and LLVM_CONFIG in src's Makefile. Hope this can help.

Gnnng commented

okay, seems we are fixing it at the same time.

Bug at Final of Make.

$ make

g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o parser.o parser.cpp 
In file included from pascal.y:8:0:
utils.h:30:0: warning: "NDEBUG" redefined
 #define NDEBUG
 
<command-line>:0:0: note: this is the location of the previous definition
parser.cpp: In function ‘int yyparse()’:
parser.cpp:2309:35: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
       yyerror (YY_("syntax error"));
                                   ^
parser.cpp:2453:35: warning: ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]
   yyerror (YY_("memory exhausted"));
                                   ^
At global scope:
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o tokenizer.o tokenizer.cpp 
In file included from pascal.l:8:0:
utils.h:30:0: warning: "NDEBUG" redefined
 #define NDEBUG
 
<command-line>:0:0: note: this is the location of the previous definition
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o ast.o ast.cpp 
In file included from ast.cpp:15:0:
utils.h:30:0: warning: "NDEBUG" redefined
 #define NDEBUG
 
<command-line>:0:0: note: this is the location of the previous definition
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o utils.o utils.cpp 
In file included from utils.cpp:1:0:
utils.h:30:0: warning: "NDEBUG" redefined
 #define NDEBUG
 
<command-line>:0:0: note: this is the location of the previous definition
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o main.o main.cpp 
In file included from ccalc.h:26:0,
                 from main.cpp:7:
utils.h:30:0: warning: "NDEBUG" redefined
 #define NDEBUG
 
<command-line>:0:0: note: this is the location of the previous definition
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o CodeGenContext.o CodeGenContext.cpp 
g++ -c `/usr/bin/llvm-config-3.5 --cppflags` -std=c++11 -Wno-return-type -Wno-c++11-compat-deprecated-writable-strings -Wno-deprecated-register -Wno-switch  -g -o ccalc.o ccalc.cpp 
In file included from ccalc.h:26:0,
                 from ccalc.cpp:14:
utils.h:30:0: warning: "NDEBUG" redefined
 #define NDEBUG
 
<command-line>:0:0: note: this is the location of the previous definition
cc1plus: warning: unrecognized command line option ‘-Wno-deprecated-register’
cc1plus: warning: unrecognized command line option ‘-Wno-c++11-compat-deprecated-writable-strings’
g++ -o pascal parser.o tokenizer.o ast.o utils.o main.o CodeGenContext.o ccalc.o `/usr/bin/llvm-config-3.5 --libs --system-libs` `/usr/bin/llvm-config-3.5 --ldflags`
/usr/bin/ld: cannot find -ledit
collect2: error: ld returned 1 exit status
makefile:33: recipe for target 'pascal' failed
make: *** [pascal] Error 1

$ make

$ make
g++ -o pascal parser.o tokenizer.o ast.o utils.o main.o CodeGenContext.o ccalc.o `/usr/bin/llvm-config-3.5 --libs --system-libs` `/usr/bin/llvm-config-3.5 --ldflags`
/usr/bin/ld: cannot find -ledit
collect2: error: ld returned 1 exit status
makefile:33: recipe for target 'pascal' failed
make: *** [pascal] Error 1

$ sudo apt install libedit*

...
...

$ make

g++ -o pascal parser.o tokenizer.o ast.o utils.o main.o CodeGenContext.o ccalc.o `/usr/bin/llvm-config-3.5 --libs --system-libs` `/usr/bin/llvm-config-3.5 --ldflags`
CodeGenContext.o: In function `CodeGenContext::generateCode(ast::Program&)':
/home/guest/Gits/Pascal/src/CodeGenContext.cpp:51: undefined reference to `llvm::createPrintModulePass(llvm::raw_ostream&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
makefile:33: recipe for target 'pascal' failed
make: *** [pascal] Error 1