[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cross-compiling with Autoconf

From: Nick Bowler
Subject: Re: Cross-compiling with Autoconf
Date: Mon, 2 Nov 2015 17:28:24 -0500

On 11/2/15, Dustin Laurence <address@hidden> wrote:
> Situation: I need to cross-compile an autoconfiscated library
>         LONG_ARCH = strongarm
>         ./configure \
>         --build=`./build-aux/config.guess` \
>         --host $(LONG_ARCH)-codesafe-elf \
>         CC="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-gcc" \
>         AR="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-ar" \
>         RANLIB="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-ranlib" \
>         AS="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-as" \
>         LD="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-ld" \
>         NM="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-nm" \
>         STRIP="/opt/nfast/gcc/bin/$(LONG_ARCH)-codesafe-elf-strip

I strongly recommend against hardcoding all these program locations.
If you put /opt/nfast/gcc/bin in your PATH, configure should pick them
all up automatically based on the --host option.

> First problem--configure dies, reporting that "C compiler cannot create
> executables."  I suspect this is related to the Second Problem.

Basically this means that autoconf tried to run the compiler and it failed.
If you open up config.log, you should be able to find the exact compiler
command line(s) which were attempted and failed.

> Second Problem: I don't know The Right Way to pass in the architecture
> flags to autoconf (-march, text segment address, etc.).  I tried
> overriding CFLAGS with the values I use for my own code, but that didn't
> work.  Plus, I suspect that I shouldn't simply set CFLAGS anyway, since the
> library build system presumably has some important opinions about that.

According to the GNU coding standards, CFLAGS is *supposed* to be
reserved for the user (i.e., you) to set, and passed unadulterated
to *every* invocation of $CC.  Package authors sometimes botch it up,
either by modifying CFLAGS in some way, or by failing to pass $CFLAGS
to every invocation.  Either may cause serious build problems if you
need specific flags just to make the compiler work at all (very common
with embedded targets).

So I suggest putting such flags in CC instead, which feels more
natural anyway (leaving CFLAGS for non-critical things like fine-
tuning optimizations or whatnot).  Almost every package handles
$CC properly.  But ...

> I tried appending them to the value of CC, but that failed as well.  I
> imagine I'm missing some basic autoconf knowledge here.

... this should have worked.  For example, something like:

  ./configure --build=x86_64-pc-linux-gnu \
              --host=strongarm-codesafe-elf \
              CC='strongarm-codesafe-elf-gcc -mflag=whatever ...'

should behave acceptably.  If it is not you will need to open up the
config.log file to see what's happening.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]