Issue #2 open

Failing to build on Mac OS X

Anonymous created an issue

I installed opam through Homebrew and installed CIL and ocamlgraph though opam. After cloning the repository I created a build directory and ran cmake successfully.

$ mkdir build
$ cd build
$ cmake ..
-- The C compiler identification is Clang 4.2.0
-- The CXX compiler identification is Clang 4.2.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - not found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Found OCAML: 4.00.1
isntall prefix = /usr/local/lib/ciltut/
PPARGS =
-- Found unix: [distributed with Ocaml]
-- Found str: [distributed with Ocaml]
-- Found ocamlgraph: 1.8.3
-- Found cil: 1.7.2
-- Configuring done
-- Generating done
-- Build files have been written to: ~/cil-template/build

But make install fails:

$ make install
Scanning dependencies of target ciltutcc.exe.opt
[  1%] Building OCaml implementation tututil
[  2%] Building OCaml implementation ciltutoptions
[  3%] Building OCaml implementation tut0
[  4%] Building OCaml implementation tut1
[  5%] Building OCaml implementation tut10
[  6%] Building OCaml implementation tut11
[  7%] Building OCaml implementation tut12
[  8%] Building OCaml implementation tut13
[  9%] Building OCaml implementation tut8
[ 10%] Building OCaml implementation tut14
[ 11%] Building OCaml implementation tut15
[ 12%] Building OCaml implementation tut2
[ 13%] Building OCaml implementation tut3
[ 14%] Building OCaml implementation tut4
[ 15%] Building OCaml implementation tut5
[ 16%] Building OCaml implementation tut6
[ 17%] Building OCaml implementation tut7
[ 18%] Building OCaml implementation tut9
[ 19%] Building OCaml implementation main
[ 19%] Building OCaml executable ciltutcc.exe_opt
clang: error: no such file or directory: '~/.opam/system/lib/cil/cil.a'
File "caml_startup", line 1:
Error: Error during linking
make[2]: *** [CMakeFiles/ocaml.ciltutcc.exe.dir/ciltutcc.exe_opt] Error 2
make[1]: *** [CMakeFiles/ciltutcc.exe.opt.dir/all] Error 2
make: *** [all] Error 2

I get the same error if I use gcc instead on llvm's clang.

Comments (10)

  1. Zachary Anderson repo owner

    Could you tell me which version of CIL you have installed? There are install bugs with CIL 1.7.1 and 1.7.2 that are fixed at the head of the CIL git repo, so you might give that a try if you are using one of those versions.

  2. Pietro Monteiro

    I was using CIL 1.7.2. Using the git repo worked but now I'm getting this error:

    $ ciltutcc --save-temps -o test1 test1.c
    Can't locate CilConfig.pm in @INC (@INC contains: /usr/local/lib/ciltut/bin/../cil/lib
    /usr/local/lib/ciltut/bin/../cil/bin /usr/local/lib/ciltut/bin/../lib /usr/local/lib/ciltut/bin/../..
    /Library/Perl/5.12/darwin-thread-multi-2level /Library/Perl/5.12
    /Network/Library/Perl/5.12/darwin-thread-multi-2level /Network/Library/Perl/5.12
    /Library/Perl/Updates/5.12.4 /System/Library/Perl/5.12/darwin-thread-multi-2level
    /System/Library/Perl/5.12 /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
    /System/Library/Perl/Extras/5.12 .) at /usr/local/bin/ciltutcc line 14.
    BEGIN failed--compilation aborted at /usr/local/bin/ciltutcc line 14.
    

    If I add the Cilly opam directories to PERL5LIB i get this error:

    $ PERL5LIB=~/.opam/system/lib/perl5:~/.opam/system/lib/perl5/App:~/.opam/system/lib/perl5/App/Cilly ciltutcc --save-temps -o test1 test1.c
    Can't locate object method "new" via package "Cilly" (perhaps you forgot to load "Cilly"?) at /usr/local/lib/ciltut/bin/../lib/Ciltut.pm line 51.
    

    The only Cilly.pm file CIL installs is ~/.opam/system/lib/perl5/App/Cilly.pm and it defines a package named App::Cilly. If I edit /usr/local/lib/ciltut/lib/Ciltut.pm and change occurrences of Cilly to App::Cilly test1 fails with this error:

    test1.c[24:0-0] : syntax error
    Parsing errorFatal error: exception Frontc.ParseError("Parse error")
    (Program not linked with -g, cannot print stack backtrace)
    

    But tut1 succeeds:

    $ PERL5LIB=~/.opam/system/lib/perl5:~/.opam/system/lib/perl5/App:~/.opam/system/lib/perl5/App/Cilly ciltutcc --save-temps --enable-tut1 tut1.c
    tut1.c:9: Deleted assignment: #line 9 "tut1.c"
    deleted = 0;
    $ ./a.out
    r = 37
    
  3. Zachary Anderson repo owner

    Hi Pietro,

    Thanks for the additional information. Since you were able to build ciltutcc and tut1.c, it sounds like you're in good shape now w.r.t. the tutorial. Unfortunately, the problems with the Perl paths and package names sound like upstream CIL problems. Just to double check, though, did you 'sudo make install' CIL? If so, I'd report your problems on the CIL bug tracker at sourceforge.

    Cheers, Zach

  4. Gabriel Kerneis

    So, several issues here:

    • when you install through opam, you have to specify PERL5LIB as Pietro noticed;

    • CIL now indeed provides App::Cilly instead of Cilly. It didn't occur to me that I should mention it in the changelog because I didn't think anybody would use this module outside of CIL. Zach, you should fix Ciltut.pm to "use App::Cilly", sorry.

    • I have no idea why this would make test1 fail (it seems an unrelated parse error).

  5. Gabriel Kerneis

    Looks like I cannot attach a patch when the issue has been closed. Here it is:

    diff -r 8b517ea24d40 bin/ciltutcc
    --- a/bin/ciltutcc  Fri Jun 28 19:23:18 2013 -0700
    +++ b/bin/ciltutcc  Wed Jul 24 23:08:07 2013 +0100
    @@ -11,7 +11,7 @@
     use lib "$FindBin::RealBin/../cil/bin";
     use lib "$FindBin::RealBin/../cil/lib";
    
    -use CilConfig;
    +use App::Cilly::CilConfig;
     use Ciltut;
    
     $::ciltuthome = "$FindBin::RealBin/..";
    diff -r 8b517ea24d40 lib/Ciltut.pm
    --- a/lib/Ciltut.pm Fri Jun 28 19:23:18 2013 -0700
    +++ b/lib/Ciltut.pm Wed Jul 24 23:08:07 2013 +0100
    @@ -7,12 +7,12 @@
     $::version_minor = 0;
     $::version_sub = 0;
    
    -use Cilly;
    +use App::Cilly;
    
     # NOTE: If perl chokes, complaining about 'our', or
     # "Array found where operator expected", it's because
     # you need perl version 5.6.0 or later.
    -our @ISA = qw(Cilly);
    +our @ISA = qw(App::Cilly);
    
     sub new {
         my ($proto, @args) = @_;
    @@ -48,7 +48,7 @@
         # Save choice in global vars for printHelp (can be called from Cilly::new)
         $Ciltut::compiler = "$bin/ciltutcc" . ($use_debug ? ".exe" : ".exe_opt");
    
    -    my $self = Ciltut->Cilly::new(@args);
    +    my $self = Ciltut->App::Cilly::new(@args);
    
         # New variables for Ciltut
         $self->{COMPILER} = $Ciltut::compiler;
    
  6. Gabriel Kerneis

    And for test1.c, this is not a CIL bug but just a C file that does not compile, even with gcc:

    cil-template/test$ gcc -I ../ciltut-include/ test1.c
    test1.c: In function make:
    test1.c:23:33: error: TRACKCONDS undeclared (first use in this function)
    test1.c:23:33: note: each undeclared identifier is reported only once for each function it appears in
    test1.c:24:9: error: expected ; before if
    
  7. Zachary Anderson repo owner

    Thanks for letting me know about this. I've checked in your patch, and it works for me. Please let me know if you find any more problems.

    Re test1.c: A relic from the past, I've removed it now, and fixed the README.

    Re Cilly.pm: Inheriting from the Cilly class is an nice way to customize the front-end script, so I'll definitely be interested in hearing about any breaking changes there =)

  8. Log in to comment