[Top][All Lists]

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

Cross-compiling with Autoconf

From: Dustin Laurence
Subject: Cross-compiling with Autoconf
Date: Mon, 02 Nov 2015 11:39:12 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

Situation: I need to cross-compile an autoconfiscated library
(libsecp256k1: for a couple of
embedded systems (one ARM-based, one PPC-based).  What I believe to be
the Right Thing is to teach autoconf to use the vendor cross-compilers,
vendor C libraries, firmware API libraries, etc., hopefully without
having to fork and hack the library build system (...I hope), so I
simply cross-compile the library and then link to it like I would
anything else.  The vendor cross-compilers are just (rather old) GCC
versions built for the target architecture, so it seems that this should
be a reasonably sane thing to do.

I have the flags needed to correctly cross-compile our code for the
target architectures, obviously, so I think I have all the tools in hand
and just need to learn how to put them together.  I found the
Vaughan-Elliston-Tromey-Taylor book online as well as random internet
sources of questionable provenance, but they usually don't go further
than mentioning the build and host flags and don't discuss custom
toolchains, custom C libraries, etc.  I came up with the following first
cut for the ARM build (snipped out of the makefile):

        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" \

So, hopefully, I've figured out how to set build and host (the host
argument is obviously the prefix the vendor used when building the
toolchain) and point autoconf at the correct toolchain.

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

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.  I guess I simply want to add my architecture flags to the
library's choices, not override.  I tried appending them to the value of
CC, but that failed as well.  I imagine I'm missing some basic autoconf
knowledge here.

What basic piece of knowledge am I missing here?


reply via email to

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