frama-cacsl

Error compiling E-ACSL FRAMA-C


I am new to Frama-C framework and I am trying to do some contract testing with C programs. I intend to use E-ACSL plugin for this, and I tried a test program to see how it works, but I get some compilation errors. Here is my code:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
int x = 0;
  /*@ assert x == 1;*/
  /*@ assert x == 0;*/
  return 0;
}

Then, here is the Frama-C annotated code:

/* Generated by Frama-C */
#include "stdio.h"
#include "stdlib.h"
struct __e_acsl_mpz_struct {
   int _mp_alloc ;
   int _mp_size ;
   unsigned long *_mp_d ;
};
typedef struct __e_acsl_mpz_struct __e_acsl_mpz_struct;
typedef __e_acsl_mpz_struct ( __attribute__((__FC_BUILTIN__)) __e_acsl_mpz_t)[1];
/*@ ghost extern int __e_acsl_init; */

/*@ ghost extern int __e_acsl_internal_heap; */

extern size_t __e_acsl_heap_allocation_size;

/*@
predicate diffSize{L1, L2}(ℤ i) =
  \at(__e_acsl_heap_allocation_size,L1) -
  \at(__e_acsl_heap_allocation_size,L2) ≡ i;

*/
int main(void)
{
  int __retres;
  int x = 0;
  /*@ assert x ≡ 1; */ ;
  /*@ assert x ≡ 0; */ ;
  __retres = 0;
  return __retres;
}

Finally, I try to compile it with and the flags the manual indicates (page 13) but I get the following errors (and warnings):

$ gcc monitored_second.c -o monitored_second -leacsl -leacsl-gmp -leacsl -jemalloc -lpthread -lm

monitored_second.c:10:1: warning: ‘__FC_BUILTIN__’ attribute directive ignored [-Wattributes]
 typedef __e_acsl_mpz_struct ( __attribute__((__FC_BUILTIN__)) __e_acsl_mpz_t)[1];

monitored_second.c:18:55: warning: ‘__FC_BUILTIN__’ attribute directive ignored [-Wattributes]
                                                   int line);
                                                   ^
monitored_second.c:25:60: warning: ‘__FC_BUILTIN__’ attribute directive ignored [-Wattributes]
                                                        size_t ptr_size);
                                                        ^
/usr/bin/ld: cannot find -leacsl
/usr/bin/ld: cannot find -leacsl-jemalloc
collect2: error: ld returned 1 exit status

I've also removed the "-rtl-bittree" label because it returns another error.

Frama-C version is the latest: Sulfur-20171101 Got any idea of what is happening?

Thanks!


Solution

  • Normally, you should have a script called e-acsl-gcc.sh installed in the same directory as frama-c binary, that can take care of calling gcc with appropriate options. Its basic usage is documented in section 2.2 of the manual, and man e-acsl-gcc.sh gives more details on the options that can be used. In short, you should be able to type

    e-acsl-gcc.sh -c \
      --oexec-eacsl=first_monitored \
      --oexec=first \
      --ocode=first_monitored.i \
      first.i
    

    to obtain

    Edit Looking at the linking command used by the script, I'd say that the command line proposed earlier in the manual is out of date (in particular, it refers to eacsl-jemalloc whereas e-acsl-gcc.sh seems to prefer eacsl-dlmalloc), which could probably be reported as a bug at https://bts.frama-c.com