darcs patch: Fix detection of libiconf.

Ian Lynagh igloo at earth.li
Wed Jun 24 13:10:26 EDT 2009

On Wed, Jun 24, 2009 at 06:03:27PM +0200, Matthias Kilian wrote:
> On Wed, Jun 24, 2009 at 04:43:02PM +0200, Matthias Kilian wrote:
> > > $1_$2_CONFIGURE_OPTS += --gcc-options="$$(filter-out -Werror,$$(SRC_CC_OPTS)) $$($1_CC_OPTS) $$($1_$2_CC_OPTS)"
> > > $1_$2_CONFIGURE_OPTS += --ld-options="$$(SRC_LD_OPTS) $$($1_LD_OPTS) $$($1_$2_LD_OPTS)"
> > > 
> > > then does that fix the problem?
> > 
> > The second added line doesn't work as expected.  I explicitely have
> > to set CFLAGS="-I/usr/local/include -L/usr/local/lib".  It seems
> > like cabal only uses --gcc-options when running gcc (and ignoring
> > --ld-options). So for now, the addition of --gcc-options helps me
> > to build ghc-head again.
> Except that now ghc-stage1 fails to link ghc-stage2:
> "inplace/bin/ghc-stage1" -o ghc/stage2/build/tmp/ghc-stage2  -H32m -O     -i -ighc/. -ighc/stage2/build -ighc/stage2/build/autogen -Ighc/stage2/build -Ighc/stage2/build/autogen       -O -fasm -DGHCI -threaded -package ghc-6.11.20090624 -package haskeline -XCPP -XPatternGuards -XForeignFunctionInterface -XUnboxedTuples -XFlexibleInstances -XMagicHash -no-user-package-conf    -odir ghc/stage2/build -hidir ghc/stage2/build -stubdir ghc/stage2/build -hisuf hi -osuf  o -hcsuf hc  ghc/stage2/build/Main.o ghc/stage2/build/GhciMonad.o ghc/stage2/build/GhciTags.o ghc/stage2/build/InteractiveUI.o   
> /usr/bin/ld: cannot find -liconv
> I could probably "fix" it by setting LD_OPTS, but I don't think
> that's a proper fix. I didn't find where compiler/stage2/package-data.mk
> gets its compiler_stage2_LD_OPTS variable set (i tried to set
> $1_$2_LD_OPTS in rules/build-package-data.mk, but it didn't help).
> And it's probably still the wrong place to fix it. The knowledge
> that linking against base needs -L/usr/local/lib (for to find
> libiconv) should be stored in the entry of base in the package.conf.

We don't have that knowledge, though. All we could do is to stick all
the linker flags we are using in there, which might include all sorts of
things that you wouldn't want in the package.conf.

One possibility is we could have some sort of base_linker_flags
variable, that you would manually set to -L/usr/local/lib, and we could
put that in the package.conf.

But what I don't get is: If you need to specify -L/usr/local/lib when
linking a C program against iconv, why should you expect to be able to
link a Haskell program against base without specifying -L/usr/local/lib?

It's probably a bug that the stage2 link step isn't using the flag, if
you've got this far. Where do you have -L/usr/local/lib now? Just in


More information about the Libraries mailing list