Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The cross compilation instrcutions are confusing #265

Closed
Heath123 opened this issue Apr 8, 2023 · 35 comments
Closed

The cross compilation instrcutions are confusing #265

Heath123 opened this issue Apr 8, 2023 · 35 comments

Comments

@Heath123
Copy link

Heath123 commented Apr 8, 2023

Configuring rustc_codegen_gcc

  • Set TARGET_TRIPLE="m68k-unknown-linux-gnu" in config.sh.
  • Since rustc doesn't support this architecture yet, set it back to TARGET_TRIPLE="mips-unknown-linux-gnu" (or another target having the same attributes). Alternatively, create a target specification file (note that the arch specified in this file must be supported by the rust compiler).
  • Set linker='-Clinker=m68k-linux-gcc'.
  • Set the path to the cross-compiling libgccjit in gcc_path.
  • Comment the line: context.add_command_line_option("-masm=intel"); in src/base.rs.
  • (might not be necessary) Disable the compilation of libstd.so (and possibly libcore.so?).

I want to compile this for SuperH but I'm confused by these instructions. It says to change a setting in config.sh but then immediately change it to something else without running anything in between??? How is that different from just setting it to the second thing directly? Is there a step missing somewhere? Also when it says "having the same attributes" what does it mean? Which attributes?

@bjorn3
Copy link
Member

bjorn3 commented Apr 8, 2023

Also when it says "having the same attributes" what does it mean? Which attributes?

The target configuration like what atomic sizes are supported, the pointer width, type alignments, ... Basically if a target doesn't have a target specification in rustc, you either have to write a target specification json file for it (or patch rustc to add a builtin target spec), or you have to pick a target rustc does support which is as close to the target you actually want to compile for as possible as any divergence can break the abi or cause compilation errors due to eg declaring features supported that aren't actually supported. If the C abi for your target doesn't match any of the existing architectures supported by rustc, you will have to modify rustc one way or another as rustc hard codes the abi calculation code. It doesn't allow specifying it in the target specification.

@Heath123
Copy link
Author

Heath123 commented Apr 8, 2023

Thanks, do you know how I should find out what to use for SuperH?

Also I still don't know the answer to the thing about changing a setting and putting it back immediately

@antoyo
Copy link
Contributor

antoyo commented Apr 8, 2023

Also I still don't know the answer to the thing about changing a setting and putting it back immediately

The first set is here and the second is a bit below.
It's not exactly necessary to do that, but that allows to keep the conditional that sets the proper linker.

@Heath123
Copy link
Author

Heath123 commented Jun 23, 2023

Thanks, now I'm getting

$ LIBRARY_PATH=$(cat gcc_path) LD_LIBRARY_PATH=$(cat gcc_path) ./build.sh --release
   Compiling libc v0.2.112
error: linking with `cc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/heath/.nvm/versions/node/v16.19.1/bin:/home/heath/.pyenv/shims:/home/heath/.path2:/home/heath/.bun/bin:/home/heath/.wasmer/bin:/home/heath/.wasienv/bin:/home/heath/.cabal/bin:/home/heath/.ghcup/bin:/home/heath/.local/bin:/home/heath/z88dk/bin:/home/heath/.cargo/bin:/home/heath/.path2:/home/heath/.bun/bin:/home/heath/.wasmer/bin:/home/heath/.wasienv/bin:/home/heath/.cabal/bin:/home/heath/.ghcup/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/home/heath/.wasmer/globals/wapm_packages/.bin:/var/lib/snapd/snap/bin:/home/heath/.wasmer/globals/wapm_packages/.bin" VSLANG="1033" "cc" "-m64" "/tmp/rustcQ1Td8y/symbols.o" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/build/libc-a6a73888b6a6d97c/build_script_build-a6a73888b6a6d97c.build_script_build.a8d39c753409c5b2-cgu.0.rcgu.o" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/build/libc-a6a73888b6a6d97c/build_script_build-a6a73888b6a6d97c.build_script_build.a8d39c753409c5b2-cgu.1.rcgu.o" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/build/libc-a6a73888b6a6d97c/build_script_build-a6a73888b6a6d97c.build_script_build.a8d39c753409c5b2-cgu.2.rcgu.o" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/build/libc-a6a73888b6a6d97c/build_script_build-a6a73888b6a6d97c.build_script_build.a8d39c753409c5b2-cgu.3.rcgu.o" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/build/libc-a6a73888b6a6d97c/build_script_build-a6a73888b6a6d97c.1kyl27c9bwy4th2a.rcgu.o" "-Wl,--as-needed" "-L" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/deps" "-L" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-Wl,-Bstatic" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd-75b9617f92376d41.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libpanic_unwind-9c9c1db573a7335d.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libobject-943c5a031ea59756.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libmemchr-52b0294e28e85f0c.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libaddr2line-b7fbc62efa77abb9.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libgimli-102731a77dbccbc8.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_demangle-1c48511ebb1a200e.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libstd_detect-c6b390a5b2a049a2.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libhashbrown-0a8aa27d5bf1bc44.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_alloc-d75813e4f4f6bafa.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libminiz_oxide-0804a6feb3ed38ea.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libadler-6772c722dc231412.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libunwind-c941e8f182e10925.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcfg_if-c7fab2ff20d1f2cd.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liblibc-ae318380f963b832.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/liballoc-7c042ecce9932705.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/librustc_std_workspace_core-c8fdd0d8f03b0225.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcore-91facdcc9286d01d.rlib" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib/libcompiler_builtins-86f479762cd41464.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/build/libc-a6a73888b6a6d97c/build_script_build-a6a73888b6a6d97c" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs"
  = note: /usr/bin/ld: unrecognised emulation mode: shelf
          Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe elf64bpf
          collect2: error: ld returned 1 exit status

So it's trying to use the wrong linker, how do I change that?

Edit: Never mind, I was using the wrong GCC path

$ find .. -name libgccjit.so
../gccbuild/build-gcc/gcc/libgccjit.so
../gcc-cross/lib/libgccjit.so

I was using the first one instead of the second

@Heath123
Copy link
Author

Heath123 commented Jun 23, 2023

I'm getting another error (sorry):

$ LIBRARY_PATH=/home/heath/sh-rustc/gcc-cross/lib/ LD_LIBRARY_PATH=/home/heath/sh-rustc/gcc-cross/lib/ ./build.sh --release
    Finished release [optimized] target(s) in 0.03s
[BUILD] sysroot
error: failed to run `rustc` to learn about target-specific information

Caused by:
  process didn't exit successfully: `/home/heath/.rustup/toolchains/nightly-2023-06-19-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -Clinker=sh3eb-elf-gcc -Csymbol-mangling-version=v0 -Cdebuginfo=2 -Clto=off -Zcodegen-backend=/home/heath/sh-rustc/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so --sysroot /home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot -Z force-unstable-if-unmarked --target mips-unknown-linux-gnu --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 1)
  --- stderr
  error: couldn't load codegen backend "/home/heath/sh-rustc/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so": /home/heath/sh-rustc/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so: undefined symbol: gcc_jit_function_add_attribute


real    0m0.193s
user    0m0.091s
sys     0m0.069s

It looks like that symbol isn't in the shared library, did I build it wrong? I did
../gcc/./configure --target=sh3eb-elf --prefix=/home/heath/sh-rustc/gcc-cross --disable-nls --enable-languages=c,jit,c++ --without-headers --enable-host-shared --disable-multilib

@antoyo
Copy link
Contributor

antoyo commented Jun 23, 2023

Your command looks good. You can also add --disable-bootstrap for a faster build.

Are you sure you're using the latest commit in my gcc fork?
This gcc_jit_function_add_attribute function was added in this commit.

@Heath123
Copy link
Author

Your command looks good. You can also add --disable-bootstrap for a faster build.

Are you sure you're using the latest commit in my gcc fork? This gcc_jit_function_add_attribute function was added in this commit.

I downloaded the GCC source from the GNU website as a tarball and applies the patches in the patches repo. I'll try building it from that repo instead

@antoyo
Copy link
Contributor

antoyo commented Jun 23, 2023

Ah right. I forgot to update the patches repo recently, so there are a few patches missing. Sorry.

@Heath123
Copy link
Author

Heath123 commented Jun 23, 2023

I hope I'm not being too annoying but when I try to build your fork I get this error:

In file included from /home/heath/sh-rustc/gccbuild/build-gcc/../gcc/./gcc/coretypes.h:478,
                 from /home/heath/sh-rustc/gccbuild/build-gcc/../gcc/./gcc/jit/jit-recording.cc:23:
/home/heath/sh-rustc/gccbuild/build-gcc/../gcc/./gcc/jit/jit-recording.cc: In member function ‘virtual size_t gcc::jit::recording::memento_of_get_type::get_size()’:
/home/heath/sh-rustc/gccbuild/build-gcc/../gcc/./gcc/jit/jit-recording.cc:2476:34: error: ‘BFmode’ was not declared in this scope; did you mean ‘BImode’?
 2476 |       return GET_MODE_UNIT_SIZE (BFmode);
      |                                  ^~~~~~
/home/heath/sh-rustc/gccbuild/build-gcc/../gcc/./gcc/machmode.h:730:53: note: in definition of macro ‘GET_MODE_UNIT_SIZE’
  730 | #define GET_MODE_UNIT_SIZE(MODE) mode_to_unit_size (MODE)
      |                                                 

It seems like this might be to do with SuperH not supporting the bfloat16 format?

@antoyo
Copy link
Contributor

antoyo commented Jun 23, 2023

Yeah, maybe try commenting this case and see if this works?

@Heath123
Copy link
Author

Heath123 commented Jun 23, 2023

I did a slightly different patch to set the size to 16 bits, then I got this:

  running: "mips-linux-gnu-gcc" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-fno-builtin" "-fvisibility=hidden" "-ffreestanding" "-DVISIBILITY_HIDDEN" "-o" "/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/target/mips-unknown-linux-gnu/debug/build/compiler_builtins-76f164bc1bb16142/out/9655f4812c85c2b4-absvdi2.o" "-c" "/home/heath/sh-rustc/llvm/compiler-rt/lib/builtins/absvdi2.c"

  --- stderr


  error occurred: Failed to find tool. Is `mips-linux-gnu-gcc` installed?

So I symlinked mips-linux-gnu-gcc to sh3eb-elf-gcc, but now I get this really long error

$ LIBRARY_PATH=/home/heath/sh-rustc/gcc-cross/lib/ LD_LIBRARY_PATH=/home/heath/sh-rustc/gcc-cross/lib/ ./build.sh --release
    Finished release [optimized] target(s) in 0.03s
[BUILD] sysroot
    Updating crates.io index
   Compiling compiler_builtins v0.1.93
   Compiling core v0.0.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/core)
   Compiling libc v0.2.146
   Compiling memchr v2.5.0
   Compiling unwind v0.0.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/unwind)
   Compiling std v0.0.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/std)
   Compiling rustc-std-workspace-core v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <var_decl 0x7fe9702ee000 ptrReturnValue1
    type <pointer_type 0x7fe970250000
        type <record_type 0x7fe97024a7e0 struct BLK
            size <integer_cst 0x7fe970226c90 constant 0>
            unit-size <integer_cst 0x7fe970226c30 constant 0>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe97024a7e0
            pointer_to_this <pointer_type 0x7fe970250000>>
        unsigned SI
        size <integer_cst 0x7fe970226c00 constant 32>
        unit-size <integer_cst 0x7fe970226c18 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe970250000>
    visited unsigned SI (null):0:0 size <integer_cst 0x7fe970226c00 32> unit-size <integer_cst 0x7fe970226c18 4>
    align:32 warn_if_not_align:0 context <function_decl 0x7fe970254900 _RNvMNtNtCsf115zUkEl8g_4core3ptr9const_ptrPAjj4_4addrB6_> chain <var_decl 0x7fe9702e0f30 stack_var_1>>
requested type (size: 64):
 <integer_type 0x7fe97022c000 long long int DI
    size <integer_cst 0x7fe970226c60 type <integer_type 0x7fe97021ddc8 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe970226c78 type <integer_type 0x7fe97021dd20 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe97022c000 precision:64 min <integer_cst 0x7fe970226f00 -9223372036854775808> max <integer_cst 0x7fe970226f18 9223372036854775807>
    pointer_to_this <pointer_type 0x7fe97023d3f0>>
as: unrecognized option '-big'
libgccjit.so: error: error invoking gcc driver
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <var_decl 0x7fe97038a3f0 ptrReturnValue1661
    type <pointer_type 0x7fe970315348
        type <record_type 0x7fe9703152a0 struct BLK
            size <integer_cst 0x7fe9702f3d68 constant 0>
            unit-size <integer_cst 0x7fe9702f3d08 constant 0>
            align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe9703152a0
            pointer_to_this <pointer_type 0x7fe970315348>>
        unsigned SI
        size <integer_cst 0x7fe9702f3cd8 constant 32>
        unit-size <integer_cst 0x7fe9702f3cf0 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe970315348
        pointer_to_this <pointer_type 0x7fe97038bc78>>
    visited unsigned SI (null):0:0 size <integer_cst 0x7fe9702f3cd8 32> unit-size <integer_cst 0x7fe9702f3cf0 4>
    align:32 warn_if_not_align:0 context <function_decl 0x7fe97031c900 _RNvMNtNtCsf115zUkEl8g_4core3ptr9const_ptrPh4addrB6_> chain <var_decl 0x7fe97038a360 stack_var_1>>
requested type (size: 64):
 <integer_type 0x7fe9702f9150 long long int DI
    size <integer_cst 0x7fe9702f3d38 type <integer_type 0x7fe9702edb28 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe9702f3d50 type <integer_type 0x7fe9702eda80 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe9702f9150 precision:64 min <integer_cst 0x7fe9702f3fd8 -9223372036854775808> max <integer_cst 0x7fe9702fa000 9223372036854775807>
    pointer_to_this <pointer_type 0x7fe9703065e8>>
error: failed to build archive: failed to open object file: No such file or directory (os error 2)

error: could not compile `rustc-std-workspace-core` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe946014220
    type <pointer_type 0x7fe9460157e0
        type <record_type 0x7fe946015738 struct packed BLK
            size <integer_cst 0x7fe9703bb7b0 constant 312>
            unit-size <integer_cst 0x7fe946016210 constant 39>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946015690 fields <field_decl 0x7fe9703dd980 field0_TODO>
            pointer_to_this <pointer_type 0x7fe9460157e0>>
        unsigned SI
        size <integer_cst 0x7fe970390828 constant 32>
        unit-size <integer_cst 0x7fe970390840 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946015888>
    readonly constant visited
    arg:0 <var_decl 0x7fe97038a900 global.0 type <record_type 0x7fe946015738 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe9703bb7b0 312> unit-size <integer_cst 0x7fe946016210 39>
        user align:64 warn_if_not_align:0 initial <constructor 0x7fe946016ba0>>>
requested type (size: 64):
 <integer_type 0x7fe97038cf18 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe970390888 type <integer_type 0x7fe97038c690 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe9703908a0 type <integer_type 0x7fe97038c5e8 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe97038cf18 precision:64 min <integer_cst 0x7fe970390b70 0> max <integer_cst 0x7fe97038f200 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe9703a5498>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe94606ddc0
    type <pointer_type 0x7fe9460752a0
        type <record_type 0x7fe9460751f8 struct packed BLK
            size <integer_cst 0x7fe94606fd20 constant 400>
            unit-size <integer_cst 0x7fe94606ffd8 constant 50>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946075150 fields <field_decl 0x7fe9460654c0 field0_TODO>
            pointer_to_this <pointer_type 0x7fe9460752a0>>
        unsigned SI
        size <integer_cst 0x7fe94601ad08 constant 32>
        unit-size <integer_cst 0x7fe94601ad20 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946075348>
    readonly constant visited
    arg:0 <var_decl 0x7fe9460716c0 global.0 type <record_type 0x7fe9460751f8 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe94606fd20 400> unit-size <integer_cst 0x7fe94606ffd8 50>
        user align:64 warn_if_not_align:0 initial <constructor 0x7fe946076bd0>>>
requested type (size: 64):
 <integer_type 0x7fe94601f150 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe94601ad68 type <integer_type 0x7fe946015a80 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe94601ad80 type <integer_type 0x7fe9460159d8 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe94601f150 precision:64 min <integer_cst 0x7fe946020060 0> max <integer_cst 0x7fe946014920 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe94602ec78>>
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)40 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: param2 (type: __uint32_t) b: (unsigned long long)1 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL ltype
libgccjit.so: error: gcc_jit_context_new_array_access: NULL ptr
gcc_jit_lvalue_as_rvalue: NULL lvalue
libgccjit.so: error: gcc_jit_context_new_cast: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: NULL argument 3 to function "memcpy": param arg2 (type: size_t)
libgccjit.so: error: gcc_jit_block_add_eval: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: param2 (type: __uint32_t) b: (unsigned long long)1 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL ltype
libgccjit.so: error: gcc_jit_context_new_array_access: NULL ptr
gcc_jit_lvalue_as_rvalue: NULL lvalue
libgccjit.so: error: gcc_jit_context_new_cast: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: NULL argument 3 to function "memcpy": param arg2 (type: size_t)
libgccjit.so: error: gcc_jit_block_add_eval: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: param2 (type: __uint32_t) b: (unsigned long long)1 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL ltype
libgccjit.so: error: gcc_jit_context_new_array_access: NULL ptr
gcc_jit_lvalue_as_rvalue: NULL lvalue
libgccjit.so: error: gcc_jit_context_new_cast: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: NULL argument 3 to function "memcpy": param arg2 (type: size_t)
libgccjit.so: error: gcc_jit_block_add_eval: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: param2 (type: __uint32_t) b: (unsigned long long)2 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL ltype
libgccjit.so: error: gcc_jit_context_new_array_access: NULL ptr
gcc_jit_lvalue_as_rvalue: NULL lvalue
libgccjit.so: error: gcc_jit_context_new_cast: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: NULL argument 3 to function "memcpy": param arg2 (type: size_t)
libgccjit.so: error: gcc_jit_block_add_eval: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: (unsigned long long)1 (type: unsigned long long) b: param2 (type: __uint32_t)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL rtype
gcc_jit_compatible_types: NULL ltype
libgccjit.so: error: gcc_jit_context_new_array_access: NULL ptr
gcc_jit_lvalue_as_rvalue: NULL lvalue
libgccjit.so: error: gcc_jit_context_new_cast: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: NULL argument 3 to function "memset": param arg2 (type: size_t)
libgccjit.so: error: gcc_jit_block_add_eval: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)275 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)1465 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe94610a600
    type <pointer_type 0x7fe94610c540
        type <record_type 0x7fe94610c498 struct packed BLK
            size <integer_cst 0x7fe9460d68a0 constant 408>
            unit-size <integer_cst 0x7fe94610d1e0 constant 51>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe94610c3f0 fields <field_decl 0x7fe9460fe720 field0_TODO>
            pointer_to_this <pointer_type 0x7fe94610c540>>
        unsigned SI
        size <integer_cst 0x7fe94607bd38 constant 32>
        unit-size <integer_cst 0x7fe94607bd50 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe94610c5e8>
    readonly constant visited
    arg:0 <var_decl 0x7fe9461063f0 global.0 type <record_type 0x7fe94610c498 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe9460d68a0 408> unit-size <integer_cst 0x7fe94610d1e0 51>
        user align:64 warn_if_not_align:0 initial <constructor 0x7fe94610ddb0>>>
requested type (size: 64):
 <integer_type 0x7fe946075dc8 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe94607bd98 type <integer_type 0x7fe946075540 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe94607bdb0 type <integer_type 0x7fe946075498 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946075dc8 precision:64 min <integer_cst 0x7fe946081090 0> max <integer_cst 0x7fe9460794c0 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe946093498>>
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 2 of function "__builtin_usub_overflow": assignment to param arg1 (type: unsigned int) from (unsigned long long)55 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 2 of function "__builtin_usub_overflow": assignment to param arg1 (type: unsigned int) from (unsigned long long)43 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)39 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)40 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)40 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)10 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: param1 (type: __uint32_t) b: (unsigned long long)1 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_type_get_pointer: NULL type
libgccjit.so: error: gcc_jit_context_new_bitcast: NULL type
gcc_jit_rvalue_dereference: NULL rvalue
gcc_jit_lvalue_as_rvalue: NULL lvalue
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_type_unqualified: NULL type
gcc_jit_type_get_aligned: NULL type
gcc_jit_type_get_pointer: NULL type
libgccjit.so: error: gcc_jit_context_new_bitcast: NULL rvalue
gcc_jit_rvalue_dereference: NULL rvalue
libgccjit.so: error: gcc_jit_block_add_assignment: NULL lvalue
libgccjit.so: error: gcc_jit_context_new_binary_op: mismatching types for binary op: a: param1 (type: __uint32_t) b: (unsigned long long)4 (type: unsigned long long)
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_type_get_pointer: NULL type
libgccjit.so: error: gcc_jit_context_new_bitcast: NULL type
gcc_jit_rvalue_dereference: NULL rvalue
gcc_jit_lvalue_as_rvalue: NULL lvalue
gcc_jit_rvalue_get_type: NULL rvalue
gcc_jit_type_unqualified: NULL type
gcc_jit_type_get_aligned: NULL type
gcc_jit_type_get_pointer: NULL type
libgccjit.so: error: gcc_jit_context_new_bitcast: NULL rvalue
gcc_jit_rvalue_dereference: NULL rvalue
libgccjit.so: error: gcc_jit_block_add_assignment: NULL lvalue
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe945e5c520
    type <pointer_type 0x7fe945e5d2a0
        type <record_type 0x7fe945e5d1f8 struct no-force-blk packed BLK
            size <integer_cst 0x7fe946110f18 constant 32>
            unit-size <integer_cst 0x7fe946110f30 constant 4>
            user align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe945e5d150 fields <field_decl 0x7fe94616f8e8 field0_TODO>
            pointer_to_this <pointer_type 0x7fe945e5d2a0>>
        unsigned SI size <integer_cst 0x7fe946110f18 32> unit-size <integer_cst 0x7fe946110f30 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe945e5d348>
    readonly constant visited
    arg:0 <var_decl 0x7fe945e59900 global.0 type <record_type 0x7fe945e5d1f8 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe946110f18 32> unit-size <integer_cst 0x7fe946110f30 4>
        user align:256 warn_if_not_align:0 initial <constructor 0x7fe945e5b6d8>>>
requested type (size: 64):
 <integer_type 0x7fe94610c0a8 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe946110f78 type <integer_type 0x7fe94610c7e0 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe946110f90 type <integer_type 0x7fe94610c738 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe94610c0a8 precision:64 min <integer_cst 0x7fe946113270 0> max <integer_cst 0x7fe94610ad00 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe946126690>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe945faa400
    type <pointer_type 0x7fe945fa92a0
        type <record_type 0x7fe945fa9150 struct packed BLK
            size <integer_cst 0x7fe945ea87f8 constant 400>
            unit-size <integer_cst 0x7fe945fab3a8 constant 50>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe945fa90a8 fields <field_decl 0x7fe945f9ada8 field0_TODO>
            pointer_to_this <pointer_type 0x7fe945fa92a0>>
        unsigned SI
        size <integer_cst 0x7fe945e62840 constant 32>
        unit-size <integer_cst 0x7fe945e62858 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe945fa9bd0>
    readonly constant visited
    arg:0 <var_decl 0x7fe945fa87e0 global.0 type <record_type 0x7fe945fa9150 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe945ea87f8 400> unit-size <integer_cst 0x7fe945fab3a8 50>
        align:8 warn_if_not_align:0 initial <constructor 0x7fe945fabf18>>>
requested type (size: 64):
 <integer_type 0x7fe945e5ddc8 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe945e628a0 type <integer_type 0x7fe945e5d540 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe945e628b8 type <integer_type 0x7fe945e5d498 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe945e5ddc8 precision:64 min <integer_cst 0x7fe945e62b88 0> max <integer_cst 0x7fe945e5cc20 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe945e6fe70>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe9460146a0
    type <pointer_type 0x7fe946024150
        type <record_type 0x7fe9460240a8 struct packed BLK
            size <integer_cst 0x7fe970272738 constant 408>
            unit-size <integer_cst 0x7fe9702727c8 constant 51>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946024000 fields <field_decl 0x7fe946065e40 field0_TODO>
            pointer_to_this <pointer_type 0x7fe946024150>>
        unsigned SI
        size <integer_cst 0x7fe97020d330 constant 32>
        unit-size <integer_cst 0x7fe97020d348 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe9460242a0>
    readonly constant visited
    arg:0 <var_decl 0x7fe97020a630 global.0 type <record_type 0x7fe9460240a8 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe970272738 408> unit-size <integer_cst 0x7fe9702727c8 51>
        user align:64 warn_if_not_align:0 initial <constructor 0x7fe9702e74e0>>>
requested type (size: 64):
 <integer_type 0x7fe97020ebd0 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe97020d3c0 type <integer_type 0x7fe97020e2a0 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe97020d3d8 type <integer_type 0x7fe97020e1f8 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe97020ebd0 precision:64 min <integer_cst 0x7fe97020d888 0> max <integer_cst 0x7fe9702037a0 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe9702337e0>>
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)315 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)5 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)727 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: gcc_jit_context_new_call: mismatching types for argument 1 of function "__builtin_usub_overflow": assignment to param arg0 (type: unsigned int) from (unsigned long long)875 (type: unsigned long long)
libgccjit.so: error: gcc_jit_block_add_assignment: NULL rvalue
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7fe945f80720
    type <pointer_type 0x7fe9461a7540
        type <record_type 0x7fe9461a7498 struct packed BLK
            size <integer_cst 0x7fe970350d98 constant 336>
            unit-size <integer_cst 0x7fe970390600 constant 42>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe9461a73f0 fields <field_decl 0x7fe946171c78 field0_TODO>
            pointer_to_this <pointer_type 0x7fe9461a7540>>
        unsigned SI
        size <integer_cst 0x7fe9702f3660 constant 32>
        unit-size <integer_cst 0x7fe9702f3678 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe9461a75e8>
    readonly constant visited
    arg:0 <var_decl 0x7fe94616abd0 global.0 type <record_type 0x7fe9461a7498 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7fe970350d98 336> unit-size <integer_cst 0x7fe970390600 42>
        align:8 warn_if_not_align:0 initial <constructor 0x7fe9703a3330>>>
requested type (size: 64):
 <integer_type 0x7fe946024d20 long long unsigned int public unsigned DI
    size <integer_cst 0x7fe9702f36c0 type <integer_type 0x7fe946024498 bitsizetype> constant 64>
    unit-size <integer_cst 0x7fe9702f36d8 type <integer_type 0x7fe9460243f0 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7fe946024d20 precision:64 min <integer_cst 0x7fe9702f39a8 0> max <integer_cst 0x7fe946014e40 18446744073709551615>
    pointer_to_this <pointer_type 0x7fe946073888>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7f2bd83056a0
    type <pointer_type 0x7f2bd83097e0
        type <record_type 0x7f2bd8309738 struct packed BLK
            size <integer_cst 0x7f2bd822f0c0 constant 736>
            unit-size <integer_cst 0x7f2bd83080f0 constant 92>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd8309690 fields <field_decl 0x7f2bd8277ed8 field0_TODO>
            pointer_to_this <pointer_type 0x7f2bd83097e0>>
        unsigned SI
        size <integer_cst 0x7f2bd8226c00 constant 32>
        unit-size <integer_cst 0x7f2bd8226c18 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd8309888>
    readonly constant visited
    arg:0 <var_decl 0x7f2bd820ad80 global.0 type <record_type 0x7f2bd8309738 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7f2bd822f0c0 736> unit-size <integer_cst 0x7f2bd83080f0 92>
        user align:64 warn_if_not_align:0 initial <constructor 0x7f2bd830b4c8>>>
requested type (size: 64):
 <integer_type 0x7f2bd822c0a8 long long unsigned int public unsigned DI
    size <integer_cst 0x7f2bd8226c60 type <integer_type 0x7f2bd821ddc8 bitsizetype> constant 64>
    unit-size <integer_cst 0x7f2bd8226c78 type <integer_type 0x7f2bd821dd20 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd822c0a8 precision:64 min <integer_cst 0x7f2bd8226f48 0> max <integer_cst 0x7f2bd8203c40 18446744073709551615>
    pointer_to_this <pointer_type 0x7f2bd823db28>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7f2bd83728c0
    type <pointer_type 0x7f2bd8378d20
        type <record_type 0x7f2bd8378c78 struct packed BLK
            size <integer_cst 0x7f2bd8351300 constant 848>
            unit-size <integer_cst 0x7f2bd8375a20 constant 106>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd8378bd0 fields <field_decl 0x7f2bd83794c0 field0_TODO>
            pointer_to_this <pointer_type 0x7f2bd8378d20>>
        unsigned SI
        size <integer_cst 0x7f2bd8311630 constant 32>
        unit-size <integer_cst 0x7f2bd8311648 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd8378dc8>
    readonly constant visited
    arg:0 <var_decl 0x7f2bd8371b40 global.0 type <record_type 0x7f2bd8378c78 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7f2bd8351300 848> unit-size <integer_cst 0x7f2bd8375a20 106>
        user align:64 warn_if_not_align:0 initial <constructor 0x7f2bd837b180>>>
requested type (size: 64):
 <integer_type 0x7f2bd83093f0 long long unsigned int public unsigned DI
    size <integer_cst 0x7f2bd8311690 type <integer_type 0x7f2bd8309a80 bitsizetype> constant 64>
    unit-size <integer_cst 0x7f2bd83116a8 type <integer_type 0x7f2bd83099d8 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd83093f0 precision:64 min <integer_cst 0x7f2bd8311978 0> max <integer_cst 0x7f2bd8305da0 18446744073709551615>
    pointer_to_this <pointer_type 0x7f2bd8325690>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7f2bd83ff420
    type <pointer_type 0x7f2bd1bff498
        type <record_type 0x7f2bd1bff3f0 struct packed BLK
            size <integer_cst 0x7f2bd83ef3f0 constant 256>
            unit-size <integer_cst 0x7f2bd83fd570 constant 32>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1bff348 fields <field_decl 0x7f2bd83aba18 field0_TODO>
            pointer_to_this <pointer_type 0x7f2bd1bff498>>
        unsigned SI
        size <integer_cst 0x7f2bd837f2e8 constant 32>
        unit-size <integer_cst 0x7f2bd837f300 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1bff540>
    readonly constant visited
    arg:0 <var_decl 0x7f2bd83f9870 global.0 type <record_type 0x7f2bd1bff3f0 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7f2bd83ef3f0 256> unit-size <integer_cst 0x7f2bd83fd570 32>
        user align:64 warn_if_not_align:0 initial <constructor 0x7f2bd83fdd98>>>
requested type (size: 64):
 <integer_type 0x7f2bd8383348 long long unsigned int public unsigned DI
    size <integer_cst 0x7f2bd837f348 type <integer_type 0x7f2bd83782a0 bitsizetype> constant 64>
    unit-size <integer_cst 0x7f2bd837f360 type <integer_type 0x7f2bd8378f18 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd8383348 precision:64 min <integer_cst 0x7f2bd837f630 0> max <integer_cst 0x7f2bd8372fc0 18446744073709551615>
    pointer_to_this <pointer_type 0x7f2bd83930a8>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7f2bd1c28b00
    type <pointer_type 0x7f2bd1c33d20
        type <record_type 0x7f2bd1c33c78 struct packed BLK
            size <integer_cst 0x7f2bd1c245b8 constant 736>
            unit-size <integer_cst 0x7f2bd1c249f0 constant 92>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1c33bd0 fields <field_decl 0x7f2bd1c35260 field0_TODO>
            pointer_to_this <pointer_type 0x7f2bd1c33d20>>
        unsigned SI
        size <integer_cst 0x7f2bd1c02f00 constant 32>
        unit-size <integer_cst 0x7f2bd1c02f18 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1c33dc8>
    readonly constant visited
    arg:0 <var_decl 0x7f2bd83f9b40 global.0 type <record_type 0x7f2bd1c33c78 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7f2bd1c245b8 736> unit-size <integer_cst 0x7f2bd1c249f0 92>
        user align:64 warn_if_not_align:0 initial <constructor 0x7f2bd1c36dc8>>>
requested type (size: 64):
 <integer_type 0x7f2bd1bff5e8 long long unsigned int public unsigned DI
    size <integer_cst 0x7f2bd1c02f60 type <integer_type 0x7f2bd1bff738 bitsizetype> constant 64>
    unit-size <integer_cst 0x7f2bd1c02f78 type <integer_type 0x7f2bd1bff690 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1bff5e8 precision:64 min <integer_cst 0x7f2bd1c04258 0> max <integer_cst 0x7f2bd83ffb20 18446744073709551615>
    pointer_to_this <pointer_type 0x7f2bd1c18930>>
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7f2bd1cb3240
    type <pointer_type 0x7f2bd1cb6000
        type <record_type 0x7f2bd1cb2f18 struct packed BLK
            size <integer_cst 0x7f2bd1ca3618 constant 736>
            unit-size <integer_cst 0x7f2bd1caedb0 constant 92>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1cb2e70 fields <field_decl 0x7f2bd1c4db48 field0_TODO>
            pointer_to_this <pointer_type 0x7f2bd1cb6000>>
        unsigned SI
        size <integer_cst 0x7f2bd1c3af30 constant 32>
        unit-size <integer_cst 0x7f2bd1c3af48 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1cb60a8>
    readonly constant visited
    arg:0 <var_decl 0x7f2bd1caaea0 global.0 type <record_type 0x7f2bd1cb2f18 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7f2bd1ca3618 736> unit-size <integer_cst 0x7f2bd1caedb0 92>
        user align:64 warn_if_not_align:0 initial <constructor 0x7f2bd1cb5150>>>
requested type (size: 64):
 <integer_type 0x7f2bd1c40348 long long unsigned int public unsigned DI
    size <integer_cst 0x7f2bd1c3af90 type <integer_type 0x7f2bd1c332a0 bitsizetype> constant 64>
    unit-size <integer_cst 0x7f2bd1c3afa8 type <integer_type 0x7f2bd1c33f18 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2bd1c40348 precision:64 min <integer_cst 0x7f2bd1c3d288 0> max <integer_cst 0x7f2bd1c39200 18446744073709551615>
    pointer_to_this <pointer_type 0x7f2bd1c4e0a8>>
error: could not compile `compiler_builtins` (lib) due to previous error
libgccjit.so: error: bitcast with types of different sizes
input expression (size: 32):
 <addr_expr 0x7f2a7792cca0
    type <pointer_type 0x7f2a779360a8
        type <record_type 0x7f2a77936000 struct packed BLK
            size <integer_cst 0x7f2a7785fe70 constant 880>
            unit-size <integer_cst 0x7f2a7785fee8 constant 110>
            user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2a77932c78 fields <field_decl 0x7f2a77935000 field0_TODO>
            pointer_to_this <pointer_type 0x7f2a779360a8>>
        unsigned SI
        size <integer_cst 0x7f2a77826c00 constant 32>
        unit-size <integer_cst 0x7f2a77826c18 constant 4>
        align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2a77936150>
    readonly constant visited
    arg:0 <var_decl 0x7f2a7792b900 global.0 type <record_type 0x7f2a77936000 struct>
        readonly addressable static visited BLK (null):0:0 size <integer_cst 0x7f2a7785fe70 880> unit-size <integer_cst 0x7f2a7785fee8 110>
        user align:64 warn_if_not_align:0 initial <constructor 0x7f2a77934af8>>>
requested type (size: 64):
 <integer_type 0x7f2a7782c0a8 long long unsigned int public unsigned DI
    size <integer_cst 0x7f2a77826c60 type <integer_type 0x7f2a7781ddc8 bitsizetype> constant 64>
    unit-size <integer_cst 0x7f2a77826c78 type <integer_type 0x7f2a7781dd20 sizetype> constant 8>
    align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f2a7782c0a8 precision:64 min <integer_cst 0x7f2a77826f48 0> max <integer_cst 0x7f2a77803c40 18446744073709551615>
    pointer_to_this <pointer_type 0x7f2a7783db28>>
error: could not compile `core` (lib) due to previous error
error: could not compile `libc` (lib) due to previous error

real    0m8.264s
user    0m6.971s
sys     0m0.961s

It looks like something to do with it being 32-bit? It seems to be trying to use a 32-bit pointer as a 64-bit integer

@antoyo
Copy link
Contributor

antoyo commented Jun 23, 2023

Yeah, indeed, it looks like it wants to cast a 32-bit pointer to a 64-bit integer. I'll attempt to fix this issue soon.

@Heath123
Copy link
Author

I think the issue is here:

let isize_type = context.new_c_type(CType::LongLong);
let usize_type = context.new_c_type(CType::ULongLong);

@Heath123
Copy link
Author

How do I disable compilation of std so that I can compile things without #![no_std] for now?

@Heath123
Copy link
Author

It also seems to be trying to use https://github.com/rust-lang/compiler-builtins, can it just use libgcc?

@bjorn3
Copy link
Member

bjorn3 commented Jun 24, 2023

How do I disable compilation of std so that I can compile things without #![no_std] for now?

Without #![no_std] rustc will always attempt to load libstd and fail if it isn't available. You can disable compilation of libstd by removing/commenting out

alloc = { path = "./sysroot_src/library/alloc" }
std = { path = "./sysroot_src/library/std", features = ["panic_unwind", "backtrace"] }
test = { path = "./sysroot_src/library/test" }
proc_macro = { path = "./sysroot_src/library/proc_macro" }

It also seems to be trying to use https://github.com/rust-lang/compiler-builtins, can it just use libgcc?

I guess you could try. compiler-builtins contains some missing from llvm's compiler-rt. It may or may not be the case that this also applies to libgcc. In any case libgcc or compiler-rt are still used as fallback for intrinsics missing from compiler-builtins.

@Heath123
Copy link
Author

Heath123 commented Jun 24, 2023

Oops, I meant with, not without

Commenting that out gives me this:

   Compiling libc v0.2.112
   Compiling smallvec v1.8.0
   Compiling gccjit_sys v0.0.1 (https://github.com/antoyo/gccjit.rs#d6e52626)
   Compiling gccjit v1.0.0 (https://github.com/antoyo/gccjit.rs#d6e52626)
   Compiling rustc_codegen_gcc v0.1.0 (/home/heath/sh-rustc/rustc_codegen_gcc)
    Finished dev [optimized + debuginfo] target(s) in 25.13s
rm: cannot remove 'target/out': No such file or directory
[BUILD] sysroot
    Updating crates.io index
warning: Patch `rustc-std-workspace-alloc v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-alloc)` was not used in the crate graph.
Patch `rustc-std-workspace-core v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)` was not used in the crate graph.
Patch `rustc-std-workspace-std v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-std)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
   Compiling compiler_builtins v0.1.93
   Compiling core v0.0.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/core)
error[E0463]: can't find crate for `core`
  |
  = note: the `mips-unknown-linux-gnu` target may not be installed
  = help: consider downloading the target with `rustup target add mips-unknown-linux-gnu`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:99:9
   |
99 |         cfg!(target_feature = "b")
   |         ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:97:15
   |
97 |     } else if cfg!(any(target_arch = "riscv32", target_arch = "riscv64")) {
   |               ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:96:9
   |
96 |         cfg!(target_feature = "vis3")
   |         ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:94:15
   |
94 |     } else if cfg!(any(target_arch = "sparc", target_arch = "sparc64")) {
   |               ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:92:13
   |
92 |             cfg!(target_feature = "v5te")
   |             ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:87:13
   |
87 |             cfg!(target_feature = "v6t2")
   |             ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:83:12
   |
83 |         if cfg!(target_feature = "thumb-mode") {
   |            ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find macro `cfg` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:82:8
   |
82 |     if cfg!(target_arch = "arm") {
   |        ^^^
   |
   = note: `cfg` is in scope, but it is an attribute: `#[cfg]`

error: cannot find attribute `derive` in this scope
 --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/float/cmp.rs:6:3
  |
6 | #[derive(Clone, Copy)]
  |   ^^^^^^

error[E0405]: cannot find trait `Copy` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/float/mod.rs:18:5
   |
18 |     Copy
   |     ^^^^ not found in this scope

error[E0405]: cannot find trait `PartialEq` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/float/mod.rs:20:7
   |
20 |     + PartialEq
   |       ^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `PartialOrd` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/float/mod.rs:21:7
   |
21 |     + PartialOrd
   |       ^^^^^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:128:12
    |
128 |     if let Some(quo) = duo.checked_div(div) {
    |            ^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:129:16
    |
129 |         if let Some(rem) = duo.checked_rem(div) {
    |                ^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:220:12
    |
220 |     if let Some(quo) = duo.checked_div(div) {
    |            ^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/specialized_div_rem/mod.rs:221:16
    |
221 |         if let Some(rem) = duo.checked_rem(div) {
    |                ^^^^ not found in this scope

error[E0412]: cannot find type `Option` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/udiv.rs:24:57
   |
24 |     pub extern "C" fn __udivmodsi4(n: u32, d: u32, rem: Option<&mut u32>) -> u32 {
   |                                                         ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/udiv.rs:26:16
   |
26 |         if let Some(rem) = rem {
   |                ^^^^ not found in this scope

error[E0412]: cannot find type `Option` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/udiv.rs:49:57
   |
49 |     pub extern "C" fn __udivmoddi4(n: u64, d: u64, rem: Option<&mut u64>) -> u64 {
   |                                                         ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/udiv.rs:51:16
   |
51 |         if let Some(rem) = rem {
   |                ^^^^ not found in this scope

error[E0412]: cannot find type `Option` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/udiv.rs:89:59
   |
89 |     pub extern "C" fn __udivmodti4(n: u128, d: u128, rem: Option<&mut u128>) -> u128 {
   |                                                           ^^^^^^ not found in this scope

error[E0531]: cannot find tuple struct or tuple variant `Some` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/udiv.rs:92:20
   |
92 |             if let Some(rem) = rem {
   |                    ^^^^ not found in this scope

error[E0405]: cannot find trait `Copy` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/mod.rs:17:5
   |
17 |     Copy
   |     ^^^^ not found in this scope

error[E0405]: cannot find trait `PartialEq` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/mod.rs:19:7
   |
19 |     + PartialEq
   |       ^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `PartialOrd` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/mod.rs:20:7
   |
20 |     + PartialOrd
   |       ^^^^^^^^^^ not found in this scope

error[E0405]: cannot find trait `Copy` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/mod.rs:361:30
    |
361 | pub(crate) trait CastInto<T: Copy>: Copy {
    |                              ^^^^ not found in this scope

error[E0405]: cannot find trait `Copy` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/mod.rs:361:37
    |
361 | pub(crate) trait CastInto<T: Copy>: Copy {
    |                                     ^^^^ not found in this scope

error[E0405]: cannot find trait `Copy` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/mem/mod.rs:72:39
   |
72 | fn memcpy_element_unordered_atomic<T: Copy>(dest: *mut T, src: *const T, bytes: usize) {
   |                                       ^^^^ not found in this scope

error[E0405]: cannot find trait `Copy` in this scope
  --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/mem/mod.rs:85:40
   |
85 | fn memmove_element_unordered_atomic<T: Copy>(dest: *mut T, src: *const T, bytes: usize) {
   |                                        ^^^^ not found in this scope

error[E0405]: cannot find trait `Copy` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/mem/mod.rs:110:8
    |
110 |     T: Copy + From<u8> + Shl<u32, Output = T> + BitOr<T, Output = T>,
    |        ^^^^ not found in this scope

error[E0405]: cannot find trait `From` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/mem/mod.rs:110:15
    |
110 |     T: Copy + From<u8> + Shl<u32, Output = T> + BitOr<T, Output = T>,
    |               ^^^^ not found in this scope

error[E0425]: cannot find function, tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/sdiv.rs:29:58
    |
29  |                   let t = $unsigned_fn(a as $uX, b as $uX, Some(&mut r)) as $iX;
    |                                                            ^^^^ not found in this scope
...
117 | / sdivmod!(
118 | |     __udivmodsi4,
119 | |     __divmodsi4,
120 | |     u32,
121 | |     i32,
122 | |     maybe_use_optimized_c_shim
123 | | );
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `sdivmod` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function, tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/sdiv.rs:29:58
    |
29  |                   let t = $unsigned_fn(a as $uX, b as $uX, Some(&mut r)) as $iX;
    |                                                            ^^^^ not found in this scope
...
150 | / sdivmod!(
151 | |     __udivmoddi4,
152 | |     __divmoddi4,
153 | |     u64,
154 | |     i64,
155 | |     maybe_use_optimized_c_shim
156 | | );
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `sdivmod` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0425]: cannot find function, tuple struct or tuple variant `Some` in this scope
   --> /home/heath/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.93/src/int/sdiv.rs:29:58
    |
29  |                   let t = $unsigned_fn(a as $uX, b as $uX, Some(&mut r)) as $iX;
    |                                                            ^^^^ not found in this scope
...
161 | / sdivmod!(
162 | |     __udivmodti4,
163 | |     __divmodti4,
164 | |     u128,
165 | |     i128,
166 | |     maybe_use_optimized_c_shim
167 | | );
    | |_- in this macro invocation
    |
    = note: this error originates in the macro `sdivmod` (in Nightly builds, run with -Z macro-backtrace for more info)

Some errors have detailed explanations: E0405, E0412, E0425, E0463, E0531.
For more information about an error, try `rustc --explain E0405`.
error: could not compile `compiler_builtins` (lib) due to 35 previous errors
warning: build failed, waiting for other jobs to finish...

real    0m18.501s
user    0m19.053s
sys     0m1.245s

Commenting out the compiler builtins line too gives me this:

/home/heath/sh-rustc/gcc-cross/lib/
    Blocking waiting for file lock on build directory
    Finished dev [optimized + debuginfo] target(s) in 1m 02s
[BUILD] sysroot
warning: Patch `rustc-std-workspace-alloc v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-alloc)` was not used in the crate graph.
Patch `rustc-std-workspace-core v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)` was not used in the crate graph.
Patch `rustc-std-workspace-std v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-std)` was not used in the crate graph.
Check that the patched package version and available features are compatible
with the dependency requirements. If the patch has a different version from
what is locked in the Cargo.lock file, run `cargo update` to use the new
version. This may also occur with an optional dependency that is not enabled.
error: package `sysroot v0.0.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot)` does not have a dependency named `compiler_builtins`

real    0m0.209s
user    0m0.121s
sys     0m0.071s

Also commenting the patch lines:

    Blocking waiting for file lock on build directory
    Finished dev [optimized + debuginfo] target(s) in 28.97s
[BUILD] sysroot
error: package `sysroot v0.0.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot)` does not have a dependency named `compiler_builtins`

real    0m0.124s
user    0m0.077s
sys     0m0.038s

@bjorn3
Copy link
Member

bjorn3 commented Jun 24, 2023

Patch `rustc-std-workspace-core v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)` was not used in the crate graph.

Is the core issue here. This patch is necessary for many crates in the standard library to compile, including compiler-builtins. Could you got back to the state where only alloc, std, proc_macro and test are commented out, build again and then post the contents of build_sysroot/Cargo.lock?

@Heath123
Copy link
Author

Patch `rustc-std-workspace-core v1.99.0 (/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot_src/library/rustc-std-workspace-core)` was not used in the crate graph.

Is the core issue here. This patch is necessary for many crates in the standard library to compile, including compiler-builtins. Could you got back to the state where only alloc, std, proc_macro and test are commented out, build again and then post the contents of build_sysroot/Cargo.lock?

I see this:

# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3

[[package]]
name = "compiler_builtins"
version = "0.1.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76630810d973ecea3dbf611e1b7aecfb1012751ef1ff8de3998f89014a166781"

[[package]]
name = "core"
version = "0.0.0"

[[package]]
name = "sysroot"
version = "0.0.0"
dependencies = [
 "compiler_builtins",
 "core",
]

[[patch.unused]]
name = "rustc-std-workspace-alloc"
version = "1.99.0"

[[patch.unused]]
name = "rustc-std-workspace-core"
version = "1.99.0"

[[patch.unused]]
name = "rustc-std-workspace-std"
version = "1.99.0"

@bjorn3
Copy link
Member

bjorn3 commented Jun 24, 2023

I think I know the issue. Normally liballoc enables the rustc-dep-of-std feature of compiler-builtins, but since liballoc isn't used, you need to explicitly enable it. You could replace the compiler-builtins dependency with compiler_builtins = { version = "0.1.40", features = ['rustc-dep-of-std'] } which is what liballoc uses.

@Heath123
Copy link
Author

That fixes that issue, thank you! I can compile Rust for SuperH now, at least for simple programs without std, but I had to patch some things etc. Maybe I can make some PRs for improving the documentation that I found confusing

@antoyo
Copy link
Contributor

antoyo commented Jun 25, 2023

Sorry I was not there to follow this discussion.
Is there more help you would need?

I'll still make a fix for the 32-bit pointer casts.

@Heath123
Copy link
Author

Heath123 commented Jun 25, 2023

Another issue I'm having when building with Cargo is this:

error: linking with `sh3eb-elf-gcc` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot/lib/rustlib/x86_64-unknown-linux-gnu/bin:/home/heath/.pyenv/shims:/home/heath/.path2:/home/heath/.bun/bin:/home/heath/.wasmer/bin:/home/heath/.wasienv/bin:/home/heath/.cabal/bin:/home/heath/.ghcup/bin:/home/heath/.local/bin:/home/heath/z88dk/bin:/home/heath/.cargo/bin:/home/heath/.path2:/home/heath/.bun/bin:/home/heath/.wasmer/bin:/home/heath/.wasienv/bin:/home/heath/.cabal/bin:/home/heath/.ghcup/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/home/heath/.wasmer/globals/wapm_packages/.bin:/var/lib/snapd/snap/bin:/home/heath/.wasmer/globals/wapm_packages/.bin" VSLANG="1033" "sh3eb-elf-gcc" "/tmp/rustcGsK74s/symbols.o" "/home/heath/rust-host/rust/target/sh3eb-elf/debug/deps/rust-b8cc55e227ea1890.rust.7899f377fd2916b4-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/home/heath/rust-host/rust/target/sh3eb-elf/debug/deps" "-L" "/home/heath/rust-host/rust/target/debug/deps" "-L" "/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot/lib/rustlib/sh3eb-elf/lib" "-Wl,-Bdynamic" "-lgint-cg" "-lc" "-lgint-cg" "-lc" "-lgint-cg" "-lc" "-lgcc" "-m4a-nofpu" "-mb" "-ffreestanding" "-nostdlib" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/home/heath/sh-rustc/rustc_codegen_gcc/build_sysroot/sysroot/lib/rustlib/sh3eb-elf/lib" "-o" "/home/heath/rust-host/rust/target/sh3eb-elf/debug/deps/rust-b8cc55e227ea1890" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "-Tfxcg50_fastload.ld" "-fno-pie"
  = note: /home/heath/.local/share/fxsdk/sysroot/lib/gcc/sh3eb-elf/11.1.0/../../../../sh3eb-elf/bin/ld: unknown architecture of input file `/tmp/rustcGsK74s/symbols.o' is incompatible with sh4 output
          collect2: error: ld returned 1 exit status
          

warning: `rust` (bin "rust") generated 1 warning

It looks like this causes the issue:
https://github.com/rust-lang/rust/blob/db3c3942ea846c541dd6c34c80fe8470b8a228b1/compiler/rustc_codegen_ssa/src/back/link.rs#L1826-L1847
So it's creating an object file that's not SuperH which causes a linker error?

@bjorn3
Copy link
Member

bjorn3 commented Jun 25, 2023

Yeah, unless you used a custom target specification with the correct architecture, rustc will produce a couple of object files with the wrong architecture outside of the control of the codegen backend.

@Heath123
Copy link
Author

But the architecture isn't supported by LLVM so it won't recognise it

@bjorn3
Copy link
Member

bjorn3 commented Jun 25, 2023

That shouldn't matter. When rustc_codegen_gcc is used as codegen backend, LLVM isn't used anywhere and I believe all places in rustc where an object file is created without asking the codegen backend have a fallback for unknown architectures (except for dylibs, but you aren't creating a dylib anyway, right?)

@Heath123
Copy link
Author

Heath123 commented Jun 25, 2023

It still tries to use it for the ABI

error: internal compiler error: src/context.rs:505:21: `fn_abi_of_instance(main, [])` failed: AdjustForForeignAbi(Unsupported { arch: "sh4", abi: C { unwind: false } })
  --> src/main.rs:24:1
   |
24 | pub extern "C" fn main() -> i32 {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/2d0aa57684e10f7b3d3fe740ee18d431181583ad/compiler/rustc_errors/src/lib.rs:994:33

You said earlier

rustc hard codes the abi calculation code. It doesn't allow specifying it in the target specification.

so would I have to modify rustc?

@bjorn3
Copy link
Member

bjorn3 commented Jun 25, 2023

Right, didn't think of the ABI calculations. Yeah, for those you need to modify rustc itself. It doesn't support defining ABI calculations in target spec json files.

@Heath123
Copy link
Author

For now I made a wrapper script around the linker that rewrites the architecture field in the ELF header to set it to SuperH, which I think is safe as there's no actual code in it? It's not really a good solution but it lets me test it for now

@bjorn3
Copy link
Member

bjorn3 commented Jun 26, 2023

That should work.

which I think is safe as there's no actual code in it?

Indeed. All object files produced directly by rustc contain symbol references and data in an architecture independent format only.

@Heath123
Copy link
Author

I put a Dockerfile that builds this for SuperH here if anyone wants to use it as a rough guide either for SuperH or any other architecture:
https://github.com/Heath123/rust-casio-docker/blob/main/Dockerfile
I still need to improve some things in it like making Cargo work (I only got this working outside of Docker so far) and using fixed commits so it's more reproducible and won't break on its own

@antoyo
Copy link
Contributor

antoyo commented Jun 27, 2023

What could I change in rustc_codegen_gcc to help make anything simpler?

@Heath123
Copy link
Author

Heath123 commented Jun 27, 2023

I think the best way would be to upstream some of the patches I'm having to apply, which I'll try to make PRs for, and if there's anything where I'm not sure how to do it in a clean way I can ask for help with that, and then the documentation probably needs some improvement which I'll also try to PR

Thanks for all the help so far, I would have struggled to work some of this out on my own

@jonathanbcarlson
Copy link

jonathanbcarlson commented Aug 24, 2023

@Heath123 thank you for all the patches you made in rust-casio-docker. I modified an older version of rust-casio-docker to successfully compile for the arc-elf32 target. Modifications made to rust-casio-docker:

You can test the compiled Rust code using QEMU. Follow kolerov's synopsys repository on how to build QEMU for ARC.

Note that ./test.sh in rustc_codegen_gcc still fails.

  • The first issue you'll experience is an arc_legitimize_tls_address issue.
  • So remove the thread-local storage (TLS) related tests in example/mini_core.rs.
  • The second issue is that arc-elf32-ld can't find libc. I haven't figured out a solution to that yet.

I initially attempted to use LLVM since ARC is an experimental target but ran into issues documented in the Rust users forum.

@antoyo
Copy link
Contributor

antoyo commented Oct 25, 2023

I updated the instructions and it should hopefully be much simpler now.
We even have CI running tests cross-compiling to m68k.

Please reopen if you need more improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants