rust-lang / rustc_codegen_gcc

libgccjit AOT codegen for rustc
Apache License 2.0
905 stars 60 forks source link

`cannot find default-jit.o: No such file or directory` when building cross-compiler #407

Closed darcagn closed 7 months ago

darcagn commented 7 months ago

Hi all, I'm a Sega Dreamcast developer attempting to deliver Rust support to the platform (Dreamcast uses the SuperH SH4). I've already had some success creating a Rust demo on the Dreamcast using gccrs, but I would really like to get rustc_codegen_gcc working since it's much further along, as I understand it. I'm also a maintainer of the toolchain for our platform so if I can get this working, I'll create a configuration that I can help test over time.

I've tried to build @antoyo's GCC fork both with our own toolchain building scripts and also with crosstool-ng, but I receive the error ld: cannot find default-jit.o: No such file or directory

I don't receive this error building libgccjit with standard GCC versions.

I can open gcc/jit/default-jit.cc and see that the only code it contains is: struct gcc_targetjitm targetjitm = TARGETJITM_INITIALIZER;

So as a workaround, I can open gcc/config.gcc and remove default-jit.o from the following section:

if [ "$target_has_targetjitm" = "no" ]; then
  jit_target_objs="$jit_target_objs default-jit.o"
fi

so it no longer complains about the missing default-jit.o, and then find gcc/jit/jit-target.cc and add the following code:

#include "jit-target-def.h"
struct gcc_targetjitm targetjitm = TARGETJITM_INITIALIZER;

and then it successfully compiles and functions (though I haven't managed to get Rust itself compiled with the resulting compiler yet, but I'll attempt to troubleshoot that next).

darcagn commented 7 months ago

I figured out by checking @YakoYakoYokuYoku's AVR issue #406 that the proper fix here is to add the following:

default-jit.o: config/default-jit.cc
    $(COMPILE) $<
    $(POSTCOMPILE)

to gcc/Makefile.in. As he plans on upstreaming that change, I'll close this issue as a duplicate and continue on in my quest. Thanks.

YakoYakoYokuYoku commented 7 months ago

I've sent this to fix your issue, thanks for reporting anyways.