idris-lang / Idris-dev

A Dependently Typed Functional Programming Language
http://idris-lang.org
Other
3.43k stars 644 forks source link

opts="--interface" in .ipkg file results in packages not searched for C header file #3163

Open colin-adams opened 8 years ago

colin-adams commented 8 years ago

I am trying to generates an exports C header file so as to get external symbols into a shared object (.so file). To do this, it seems necessary to add:

opts = "--interface" 

to the .ipkg file.

But with this change, the C compiler complains:

/tmp/idris8444.c:2:17: fatal error: lws.h: No such file or directory
compilation terminated.

The lws.h file is part of one of the installed packages specified in the pgks = clause of the .ipkg file. It is invoked by:

%include C "lws.h"

from various modules in that package, which are imported by the package I am trying to compile.

So it would seem that --interface is partially turning off the effects of the pkgs = clause. That is, the packages are still searched for Idris imports, but not for C includes.

colin-adams commented 8 years ago

A workaround seems to be to add the -I flag back in: e.g:

opts = "--interface '--cg-opt -I /home/colin/dev/.cabal-sandbox/share/x86_64-linux-ghc-7.8.4/idris-0.11.1/libwebsockets'"

colin-adams commented 8 years ago

Actually, this just turns off generation of the exports header file. So the real workaround is to try first --interface, and then try again without :-(

colin-adams commented 8 years ago

That's not a sufficient workaround, as I also need to specify -o filename to get an object file without a main. So this is a serious problem.

colin-adams commented 8 years ago

So a workaround is to abandon the package system completely, and code everything in the makefile. This ivolves add the -I flag to point to the installed header file :-(