OpenTimer / Parser-Verilog

A Standalone Structural Verilog Parser
MIT License
79 stars 33 forks source link

Compile Issues #1

Closed mgwoo closed 5 years ago

mgwoo commented 5 years ago

Thanks for really great work! I've found two compile issues regarding with this Verilog parser.

1) Flex 2.5.37 is compile-able, but flex 2.6.4 generated compile error. Below command,

    $ flex -o ./verilog_lexer.yy.cc parser-verilog/verilog_lexer.l 

the verilog_lexer.yy.cc from Flex 2.5.37 is working for me, but the verilog_lexer.yy.cc from Flex 2.6.4 generated compile error.

I've attached compiled verilog_lexer_yy.cc file just in case. ( Compile environment: Centos 7 / GCC 8.2.0 ) verilog_lexer.zip

2) The below command was working in my environments.

    $ g++ -std=c++17 -I./ -Iparser-verilog/ verilog_parser.tab.cc verilog_lexer.yy.cc example/sample_parser.cpp -o sample_parser -lstdc++fs
clin99 commented 5 years ago

Hi @mgwoo , thanks for reporting this issue!
I just build the flex-2.6.4 retrieved from flex repo and use this flex to compile the verilog_lexer.l :

$ flex -o ./verilog_lexer.yy.cc parser-verilog/verilog_lexer.l

I didn't get any compilation error. Here is the generated verilog_lexer.yy.cc file https://github.com/OpenTimer/Parser-Verilog/files/2738877/verilog_lexer.yy.cc.zip

This file is the same as your lexer file by flex-2.6.4. The following command also works using the generated lexer file:

 $ g++ -std=c++17 -I./ -Iparser-verilog/ verilog_parser.tab.cc verilog_lexer.yy.cc example/sample_parser.cpp -o sample_parser -lstdc++fs

I try both gcc-7.4 & 8.1 and both work.

Could you please provide the compilation error messages so I can dig into this further?

Thanks!

mgwoo commented 5 years ago

Thanks for the quick response. I've attached the log file of this.

compile_error.log (If you could use $ cat compile_error.log in the Linux, you may see the colored logs)

Could you check this?

clin99 commented 5 years ago

Hi @mgwoo , I have checked the log file and I think the problem is caused by the out-of-sync Flex package. This stackoverflow post reports a compilation error message similar to your log file. To verify this, I suggest you build the latest Flex package from source code. Please follow below steps to build the Flex binary:

First download the source code flex-2.6.4.tar.gz from the official repo and then

$ tar zxvf flex-2.6.4.tar.gz
$ cd flex-2.6.4
$ ./autogen.sh
$ mkdir build
$ ./configure --prefix=absolute_path_to_the_build_folder
$ make 
$ make install

Above steps will only install the Flex binary inside flex-2.6.4 folder and no root permission required. If you didn't see any error in those steps, you can find the Flex binary inside the flex-2.6.4/build/bin folder. Then you can use the Flex binary to compile the lexer file

flex-2.6.4/build/bin/flex -o ./verilog_lexer.yy.cc parser-verilog/verilog_lexer.l 

If you get the same compilation error, please let me know.

Note: you can clear the built Flex package by removing the flex-2.6.4 folder.

Thanks!

mgwoo commented 5 years ago

Thank you for pointing out this problem...! I added one additional -I/path/to/the/FlexLexer-2.6.4.h/folder command in g++ and it worked. Sorry for confusing. I'll close this issue.