1

I am new to Frama-C and wanted to ask how I could add header files when using the E-ACSL wrapper script. Normally, I've been adding header files the following way with WP and RTE:

frama-c -rte main.c -cpp-extra-args="-I src/include -I ..."

However, I am unsure of how I can include these files when using the wrapper script.

e-acsl-gcc.sh --rte=all -c main.c

Without the header files I run into the following error:

[kernel] Parsing main.c (with preprocessing)/main.c:10:10: fatal error: header.h: No such file or directory #include "header.h"

I am using Frama-C 24.0 (Chromium). Any help would be appreciated. Thanks.

Aamir
  • 1,974
  • 1
  • 14
  • 18
sgjl
  • 27
  • 5

1 Answers1

2

If you run e-acsl-gcc.sh -h, you'll get a help message with the script's options:

Options:
  -h         show this help page
  -c         compile instrumented code
  (...)
  -E         pass additional arguments to the Frama-C preprocessor
  -F         pass additional options to the Frama-C command line
  (...)

The two above are relevant for you: -E adds arguments to an implicit -cpp-extra-args used by the script, while -F allows you to add the option itself.

So, you can either run:

e-acsl-gcc.sh -E "-Isrc/include -I..." <other options and source files>

Or:

e-acsl-gcc.sh -F -cpp-extra-args="-Isrc/include,-I..." <other options and source files>

Note that with -F, due to quoting issues (between e-acsl-gcc.sh, Frama-C's command-line, C preprocessor, etc), you may need to replace spaces with commas, as in "-Isrc/include,-I...".

Important: do not add spaces between -I and the directory name. Due to parsing issues, e-acsl-gcc.sh will not parse it correctly if you do. GCC accepts both syntaxes anyway, so I'd recommend getting used to not adding spaces after -I (and -D as well) in general.

Overall, using -E is better here, but -F can be used to pass other options besides -cpp-extra-args.

anol
  • 8,264
  • 3
  • 34
  • 78
  • Thank you for the help. I tried this, which got rid of the error. However, now when I run the wrapper script, nothing is printed or returned (no files are generated). I noticed that this is happening when I add a `-I` to the `-E` option. I'm thinking this might be an issue with how the code is annotated or the installation, but I'm not sure what could cause such an issue. Any help would be appreciated. – sgjl Aug 31 '22 at 17:00
  • I'm unable to reproduce it; with my very simple test file including headers in subdirectories, adding `-E` has no impact on the code generation, I still get messages such as `[kernel] Parsing file.c`, `[e-acsl] beginning translation.`, and `[e-acsl] translation done in project "e-acsl"`. I'm afraid that more details or an [MVCE](https://stackoverflow.com/help/minimal-reproducible-example) might be necessary to better understand it. Maybe this could be done in a separate question, since I think the current question/answer is self-suffficient and possibly useful for others. – anol Aug 31 '22 at 18:05
  • Can you please confirm that you have at least one `[e-acsl]` message emitted when you run it? Otherwise, could you please show the entire `-E` argument you are using? If there are parsing/quoting issues, it's easier to understand with a concrete example. – anol Aug 31 '22 at 18:06
  • I am not getting any messages when I run the script using the `-I` flag. It's as if I am entering nothing to the console. Here is a simplified version of the argument I am using, which has the same issue: ``e-acsl-gcc.sh -c main.c -E "-I src/include"`` . I can create another question if more information is needed. – sgjl Aug 31 '22 at 18:43
  • Sorry, I forgot to add an important detail: do **not** put spaces between `-I` and the directory name. I had them changed in my own test case and incorrectly assumed your version might work. I'll update the answer to include this. – anol Sep 01 '22 at 06:55