Kai Ruottu kirjoitti 10.11.2017 klo 11:21:
RAVI DEWANGAN kirjoitti 10.11.2017 klo 4:56:
Hi GNU Team,
Could you please guide me regarding cross compilation.
I am trying to cross compile the toolchain for FreeBSD11(target) using
Ubuntu16.04(host).
The issue is
/home/rdewangan/freebsd/gcc-7.2.0/build/./gcc/xgcc
-B/home/rdewangan/freebsd/gcc-7.2.0/build/./gcc/
-B/opt/freebsd_toolchain/x86_64-pc-freebsd11/bin/
-B/opt/freebsd_toolchain/x86_64-pc-freebsd11/lib/ -isystem
/opt/freebsd_toolchain/x86_64-pc-freebsd11/include -isystem
/opt/freebsd_toolchain/x86_64-pc-freebsd11/sys-include -g -O2 -O2 -g
-O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing
-Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -isystem ./include -fpic -pthread -g
-DIN_LIBGCC2
-fbuilding-libgcc -fno-stack-protector -Dinhibit_libc -fpic -pthread
-I.
-I. -I../.././gcc -I../../../libgcc -I../../../libgcc/.
-I../../../libgcc/../gcc -I../../../libgcc/../include -DHAVE_CC_TLS -o
_muldi3.o -MT _muldi3.o -MD -MP -MF _muldi3.dep -DL_muldi3 -c
../../../libgcc/libgcc2.c -fvisibility=hidden -DHIDE_EXPORTS
In file included from ../../../libgcc/../gcc/tsystem.h:44:0,
from ../../../libgcc/libgcc2.c:27:
/home/rdewangan/freebsd/gcc-7.2.0/build/gcc/include/stddef.h:56:10:
fatal
error: sys/_types.h: No such file or directory
#include <sys/_types.h>
^~~~~~~~~~~~~~
compilation terminated.
Makefile:491: recipe for target '_muldi3.o' failed
For a "working compiler" one needs also the target C library. Prebuilt
and pretested
in your case when your FreeBSD system is already made. There isn't
much difference
between a native and a cross compiler in this issue, both require the
target C library
during the GCC build when the extra libraries : libgcc, libstdc++,
libssp etc will be built.
A cross compiler needs also the binutils made for the "host-to-target"
use but a native
build usually already has also them prebuilt, sometimes as non-GNU
"native ones".
Furthermore the target C library must be put into a separate $SYSROOT
on the host.
Not in it's "native" place (usually '/lib*', '/usr/include' and
'/usr/lib*' like in Linux) but
in a sysroot like '/opt/freebsd_toolchain/sysroot' in your case, the
native FreeBSD
sysroot '/' being replaced with this.
Just for a fun I tried a gcc-7.2.0 based crosscompiler for FreeBSD
11.1/amd64. First built
binutils-2.24.51 for it, then unpacked the 'base.txz' and 'lib32.txz'
into my chosen sysroot.
Then configured the GCC sources and used 'make'. A problem was seen in
the libstdc++
build :
libtool: compile: /home/src-old/gcc-7.2.0/build/./gcc/xgcc
-shared-libgcc -B/home/src-old/gcc-7.2.0/build/./gcc -nostdinc++
-L/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/src
-L/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/src/.libs
-L/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/libsupc++/.libs
-B/opt/cross/x86_64-freebsd11.1/bin/
-B/opt/cross/x86_64-freebsd11.1/lib/ -isystem
/opt/cross/x86_64-freebsd11.1/include -isystem
/opt/cross/x86_64-freebsd11.1/sys-include
-I/home/src-old/gcc-7.2.0/libstdc++-v3/../libgcc
-I/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/include/x86_64-freebsd11.1
-I/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/include
-I/home/src-old/gcc-7.2.0/libstdc++-v3/libsupc++ -D_GLIBCXX_SHARED
-fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual -Wabi
-fdiagnostics-show-location=once -ffunction-sections -fdata-sections
-frandom-seed=new_opa.lo -g -O2 -std=gnu++1z -c
../../../../libstdc++-v3/libsupc++/new_opa.cc -fPIC -DPIC
-D_GLIBCXX_SHARED -o new_opa.o
../../../../libstdc++-v3/libsupc++/new_opa.cc: In function 'void*
aligned_alloc(std::size_t, std::size_t)':
../../../../libstdc++-v3/libsupc++/new_opa.cc:62:1: error: 'void*
aligned_alloc(std::size_t, std::size_t)' was declared 'extern' and later
'static' [-fpermissive]
aligned_alloc (std::size_t al, std::size_t sz)
^~~~~~~~~~~~~
In file included from
/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/include/cstdlib:75:0,
from
/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/include/stdlib.h:36,
from ../../../../libstdc++-v3/libsupc++/new_opa.cc:27:
/home/src-old/gcc-7.2.0/build/gcc/include-fixed/stdlib.h:178:8: note:
previous declaration of 'void* aligned_alloc(size_t, size_t)'
void * aligned_alloc(size_t, size_t) __malloc_like __alloc_align(1)
^~~~~~~~~~~~~
make[4]: *** [new_opa.lo] Virhe 1
make[4]: Poistutaan hakemistosta
"/home/src-old/gcc-7.2.0/build/x86_64-freebsd11.1/libstdc++-v3/libsupc++"
make[3]: *** [all-recursive] Virhe 1
Seemingly the same problem was with the x86_64-freebsd10.1 target which
I tried first after updating the
earlier gcc-4.9.2 to gcc-4.9.3 with it. No problems in that build. Will
check the FreeBSD 11.1 with gcc-4.9.3
too...
Probably this problem with gcc-7.2.0 is easy to fix but now Ravi knows
what to expect :)