Unable to build cross-compiler for SH4-elf target
Hello, when trying to build gcc-rs as a cross-compiler for the SH4-elf target (linux -> SH4), the makefile eventually fails with the error sh4-elf-ar: command not found.
The steps to get to this point:
- As described by the readme, create a build dir and run
../gccrs/configure --prefix=$HOME/gccrs-install --disable-bootstrap --enable-multilib --enable-languages=rust --host=sh4-elf - This produces the following log: config.log
- Run
make - This produces the following output: make_output.txt
Everything is run in WSL Ubuntu 20.04.4 LTS.
Building a normal compiler for the same target as the machine (standard x86) used to build the compiler works perfectly with the same setup (omitting the --host=sh4-elf).
Please feel free to let me know if any additional information is needed.
I get this issue when trying to compile gcc (not gccrs) from source as well. Have you followed a specific tutorial or instructions when trying to cross-compile for SH4? I haven't looked into it, but since the same issue happens when giving your configure line to mainstream gcc, I assume there might be an issue with the --host option you're passing. I don't think this issue directly concerns gccrs, but I'm happy to help more if you need :)
I changed out the build command for a slightly different one ../gccrs/configure --prefix=$HOME/gccrs-install --disable-bootstrap --enable-multilib --enable-languages=rust --host=sh4-elf --without-headers --disable-nls. This command should work with a normal gcc build, but it fails with gccrs with a different error this time: /usr/bin/ld: ../libiberty/libiberty.a: error adding symbols: archive has no index; run ranlib to add one. There might also be something broken with my setup. I'll experiment more.
There was an issue with my binutils setup. After fixing it, I can definitely confirm that building the normal GCC works with the command ../gccrs/configure --target=sh4-elf --prefix="$PREFIX" --disable-nls --enable-languages=rust --without-headers (using make all-gcc). However, gccrs now has a different error, actually related to the compilation this time:
libtool: compile: /mnt/c/Users/xxx/xxx/CrossDevelopment/rust/gccrs-build2/./gcc/xgcc -B/mnt/c/Users/xxx/xxx/CrossDevelopment/rust/gccrs-build2/./gcc/ -B/mnt/c/Users/xxx/xxx/CrossDevelopment/rust/gccrs-cross/sh4-elf/bin/ -B/mnt/c/Users/xxx/xxx/CrossDevelopment/rust/gccrs-cross/sh4-elf/lib/ -isystem /mnt/c/Users/xxx/xxx/CrossDevelopment/rust/gccrs-cross/sh4-elf/include -isystem /mnt/c/Users/xxx/xxx/CrossDevelopment/rust/gccrs-cross/sh4-elf/sys-include -DHAVE_CONFIG_H -I. -I../../../gccrs/libssp -Wall -g -O2 -MT ssp.lo -MD -MP -MF .deps/ssp.Tpo -c ../../../gccrs/libssp/ssp.c -o ssp.o
../../../gccrs/libssp/ssp.c: In function '__guard_setup':
../../../gccrs/libssp/ssp.c:93:12: warning: implicit declaration of function 'open' [-Wimplicit-function-declaration]
93 | int fd = open ("/dev/urandom", O_RDONLY);
| ^~~~
../../../gccrs/libssp/ssp.c:93:34: error: 'O_RDONLY' undeclared (first use in this function)
93 | int fd = open ("/dev/urandom", O_RDONLY);
| ^~~~~~~~
../../../gccrs/libssp/ssp.c:93:34: note: each undeclared identifier is reported only once for each function it appears in
../../../gccrs/libssp/ssp.c:96:7: error: unknown type name 'ssize_t'
96 | ssize_t size = read (fd, &__stack_chk_guard,
| ^~~~~~~
../../../gccrs/libssp/ssp.c:96:22: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration]
96 | ssize_t size = read (fd, &__stack_chk_guard,
| ^~~~
../../../gccrs/libssp/ssp.c:98:7: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
98 | close (fd);
| ^~~~~
../../../gccrs/libssp/ssp.c: At top level:
../../../gccrs/libssp/ssp.c:113:25: error: unknown type name 'size_t'
113 | fail (const char *msg1, size_t msg1len, const char *msg3)
| ^~~~~~
../../../gccrs/libssp/ssp.c:36:1: note: 'size_t' is defined in header '<stddef.h>'; did you forget to '#include <stddef.h>'?
35 | #include "config.h"
+++ |+#include <stddef.h>
36 | #ifdef HAVE_ALLOCA_H
The same error occurs when adding --enable-multilib to the configure command
@Friedrich-S did you manage to fix that error? Sorry I forgot about it a bit. It's extremely weird, especially since this code is not specific to gccrs and is common to all frontends
No worries, I lost track of this ticket and forgot to close it. Yes, it worked out in the end, and I simply messed up a step in the setup process.