Yann Droneaud
2013-02-03 11:56:57 UTC
Hi,
When cross-compile, one have to use --host= and --build to enable
cross-compilation mode of ./configure.
The argument of --host is going to be used to recognize the "host
target" and as the prefix of the cross-compilation tools.
Let's say my toochain, vendor provided, is named "ARMv8-linux-gnu"
(just an exemple):
ARMv8-linux-gnu-as
ARMv8-linux-gnu-ar
ARMv8-linux-gnu-cpp
ARMv8-linux-gnu-gcc
ARMv8-linux-gnu-ld
...
Let's try to cross-compile a program with this example toolchain:
- With current autoconf and config.sub, using the name of the toolchain:
$ ./configure --host="ARMv8-linux-gnu" --build='x86_64-linux'
[unrelated output removed]
checking whether build environment is sane... yes
checking for ARMv8-linux-gnu-strip... ARMv8-linux-gnu-strip
checking build system type... x86_64-pc-linux-gnu
checking host system type... Invalid configuration
`ARMv8-linux-gnu': machine `ARMv8' not recognized
configure: error: /bin/sh ./config.sub ARMv8-linux-gnu failed
Architecture is not recognized. ./configure stop with error.
- With current autoconf and config.sub, using the canonical name of the
host system:
$ ./configure --host="armv8-linux-gnu" --build='x86_64-linux'
[unrelated output removed]
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for armv8-linux-gnu-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking build system type... x86_64-pc-linux-gnu
checking host system type... armv8-unknown-linux-gnu
checking for armv8-linux-gnu-gcc... no
checking for gcc... gcc
checking for armv8-linux-gnu-dumpbin... no
checking for armv8-linux-gnu-link... no
checking how to convert x86_64-pc-linux-gnu file names to
armv8-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain
format... func_convert_file_noop
checking for armv8-linux-gnu-objdump... no
checking for objdump... objdump
checking for armv8-linux-gnu-dlltool... no
checking for dlltool... no
checking for armv8-linux-gnu-ar... no
checking for ar... ar
checking for armv8-linux-gnu-strip... strip
checking for armv8-linux-gnu-ranlib... no
checking for ranlib... ranlib
checking for armv8-linux-gnu-gcc... gcc
./configure succeeded, but as one can see, it's not going to use the
correct toolchain (how can it ?).
- Following discussion on config-***@gnu.org
http://lists.gnu.org/archive/html/config-patches/2013-02/msg00002.html
let's try with the following patches on config.sub:
http://lists.gnu.org/archive/html/config-patches/2013-02/msg00000.html
http://lists.gnu.org/archive/html/config-patches/2013-02/msg00001.html
Yann Droneaud (2):
config.sub: use $name instead of $1
config.sub: be more liberal on input case: accept upper case name
$ ./configure --host="ARMv8-linux-gnu" --build='x86_64-linux'
[unrelated output removed]
checking whether build environment is sane... yes
checking for ARMv8-linux-gnu-strip... ARMv8-linux-gnu-strip
checking build system type... x86_64-pc-linux-gnu
checking host system type... armv8-unknown-linux-gnu
checking for ARMv8-linux-gnu-gcc... ARMv8-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/ydroneaud/foo':
configure: error: C compiler cannot create executables
See `config.log' for more details
It's working better: now the archicture is recognized, and the correct
toolchain is also used.
It's important to note, that, regardless the case, the host system type
as recognized by config.sub is not the exactly matching the toolchain
prefix, so there's no 1:1 relation on the host system type and the
toolchain name.
Allowing uppercase in --host might improve the compatibility of the GNU
build system against any toolchain or mixed environnement.
Regards.
When cross-compile, one have to use --host= and --build to enable
cross-compilation mode of ./configure.
The argument of --host is going to be used to recognize the "host
target" and as the prefix of the cross-compilation tools.
Let's say my toochain, vendor provided, is named "ARMv8-linux-gnu"
(just an exemple):
ARMv8-linux-gnu-as
ARMv8-linux-gnu-ar
ARMv8-linux-gnu-cpp
ARMv8-linux-gnu-gcc
ARMv8-linux-gnu-ld
...
Let's try to cross-compile a program with this example toolchain:
- With current autoconf and config.sub, using the name of the toolchain:
$ ./configure --host="ARMv8-linux-gnu" --build='x86_64-linux'
[unrelated output removed]
checking whether build environment is sane... yes
checking for ARMv8-linux-gnu-strip... ARMv8-linux-gnu-strip
checking build system type... x86_64-pc-linux-gnu
checking host system type... Invalid configuration
`ARMv8-linux-gnu': machine `ARMv8' not recognized
configure: error: /bin/sh ./config.sub ARMv8-linux-gnu failed
Architecture is not recognized. ./configure stop with error.
- With current autoconf and config.sub, using the canonical name of the
host system:
$ ./configure --host="armv8-linux-gnu" --build='x86_64-linux'
[unrelated output removed]
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for armv8-linux-gnu-strip... no
checking for strip... strip
configure: WARNING: using cross tools not prefixed with host triplet
checking build system type... x86_64-pc-linux-gnu
checking host system type... armv8-unknown-linux-gnu
checking for armv8-linux-gnu-gcc... no
checking for gcc... gcc
checking for armv8-linux-gnu-dumpbin... no
checking for armv8-linux-gnu-link... no
checking how to convert x86_64-pc-linux-gnu file names to
armv8-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain
format... func_convert_file_noop
checking for armv8-linux-gnu-objdump... no
checking for objdump... objdump
checking for armv8-linux-gnu-dlltool... no
checking for dlltool... no
checking for armv8-linux-gnu-ar... no
checking for ar... ar
checking for armv8-linux-gnu-strip... strip
checking for armv8-linux-gnu-ranlib... no
checking for ranlib... ranlib
checking for armv8-linux-gnu-gcc... gcc
./configure succeeded, but as one can see, it's not going to use the
correct toolchain (how can it ?).
- Following discussion on config-***@gnu.org
http://lists.gnu.org/archive/html/config-patches/2013-02/msg00002.html
let's try with the following patches on config.sub:
http://lists.gnu.org/archive/html/config-patches/2013-02/msg00000.html
http://lists.gnu.org/archive/html/config-patches/2013-02/msg00001.html
Yann Droneaud (2):
config.sub: use $name instead of $1
config.sub: be more liberal on input case: accept upper case name
$ ./configure --host="ARMv8-linux-gnu" --build='x86_64-linux'
[unrelated output removed]
checking whether build environment is sane... yes
checking for ARMv8-linux-gnu-strip... ARMv8-linux-gnu-strip
checking build system type... x86_64-pc-linux-gnu
checking host system type... armv8-unknown-linux-gnu
checking for ARMv8-linux-gnu-gcc... ARMv8-linux-gnu-gcc
checking whether the C compiler works... no
configure: error: in `/home/ydroneaud/foo':
configure: error: C compiler cannot create executables
See `config.log' for more details
It's working better: now the archicture is recognized, and the correct
toolchain is also used.
It's important to note, that, regardless the case, the host system type
as recognized by config.sub is not the exactly matching the toolchain
prefix, so there's no 1:1 relation on the host system type and the
toolchain name.
Allowing uppercase in --host might improve the compatibility of the GNU
build system against any toolchain or mixed environnement.
Regards.
--
Yann Droneaud
OPTEYA
Yann Droneaud
OPTEYA