Re: Cross-compiling with Autoconf

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

 



On 11/2/15, Dustin Laurence <dllaurence@xxxxxxxxxxxxxx> 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.

Cheers,
  Nick

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf



[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux