pepper-project / pequin

A system for verifying outsourced computations, and applying SNARKs. Simplified release of the main Pepper codebase.
Other
122 stars 46 forks source link

No indication of where C compile errors occur #47

Open Eliott opened 5 years ago

Eliott commented 5 years ago

I have written code in C that I'm porting to Pequin and my code is generating compile errors when running pepper_compile_and_setup_V.sh, but these errors don't indicate where in my code they occurred.

For example, one error I was getting was an, Unexpected "int", with no other information, i.e., what line it occurred on. After updating frontend/gensrc/ccomp/parser/CScanner.java to output progress, I was able to locate and fix my error.

I am now getting the error, I don't know how to coerce BLOCK_SIZE [] args: null pointer: null to a constant. This error is being thrown from frontend/src/ccomp/parser_hw/CCompiler.java:2240, but I don't know how to update this to make it output the related line-number--it's past the scanning stage at this point, so it seems I only have the variable k to work with, but it's just an empty interface.

How can I get line-numbers, or some other indication, of where the compile errors are occurring within my code?

Also, is there any documentation on parser_hw's errors? What does I don't know how to coerce X to a constant mean?

Thank you.

maxhowald commented 5 years ago

About the specific error you mentioned, it just means X isn't a C constant expresison that can be evaluated at compile time. If you're able to post a sample of the code that generated the error, I may be able to give more detailed help.

In general though, Pepper's compiler errors are not very descriptive or user-friendly, unfortunately. If you have found simple ways to improve them (e.g. by adding line numbers in some cases), we're always happy to accept pull requests!

One tip / workaround: you can try compiling your program with gcc, e.g. "gcc -ansi -c example.c" to get more descriptive error messages, especially about basic syntax errors. Of course, Pepper isn't guaranteed to compile everything that gcc can, but this is still a good first thing to check.