Ok, got it to work with some fun hours of configuring+compiling binutils and gcc. With even an iota of luck, it will work on OS X too.

On 04/01/16 11:14, Miroslav Dobsicek wrote:
However, then, running
CC=x86_64-netbsd-gcc ./build-rr.sh hw
fails. The first problem is a reported missing header errno.h (and later
others) when dependencies for libc / GCDAProfiling.c are being created.
The toolchain does not seem play very well with the
'--sysroot=/..../dest' option and then appending the default header file
suffix '/usr/include' to it. To get experimentally over this problem I
have added option -I=/usr/include and then this particular problem was
gone (ie headers from ..../dest/usr/include were used).

You need to configure both binutils and gcc with --with-sysroot.

nb. at some point the gcc build complains about x86_64-linux-gnu/sys-root/usr/include missing. I just created that directory manually and re-ran "make all-gcc".

Next crash comes when one of the headers depends on compiler default
macros/defines __INT64_TYPE__ and alike. I have dumped all the defines
from the toolchain and this one (and similar) is not there. Bad ...
A check at https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html
tells that these macros are occasionally not defined when GCC does not
support stdint.h on a given system. However, config.log from building
the toolchain claims that stdint.h is fine.

Yes, apparently netbsd-stdint.h is not part of the upstream gcc distribution for whatever weird and sucky reason. One could start patching the downloaded gcc, but it's probably easier to just build the compiler for the linux-gnu target.

So, the configure for binutils becomes:
./configure --prefix=$PREFIX --target=x86_64-linux-gnu --disable-nls --with-sysroot

and for gcc:
./configure --prefix=$PREFIX --target=x86_64-linux-gnu --with-sysroot --disable-nls --enable-languages=c --without-headers --enable-long-long

You'll also run into another problem with "include-fixed". I just renamed lib/gcc/x86_64-linux-gnu/5.1.0/include-fixed to include-broken. Obviously that's a bit of a hack.

I guess it would be best to turn the whole "build me a compiler" thingie into a script hosted under repo.rumpkernel.org, for the benefit on OS X and other handicapped systems (e.g. packaged compiler is too old). I'll do that some day in the near future (though I'd not be terribly disappointed in case someone beats me to it).

Anyway, for now, try to repeat my results and, if so, enjoy.

Reply via email to