Skip to content

Targeting a specific MIPS arch: internal compiler error on building compiler_builtins stemming from ABI troubles. #546

@gabfca

Description

@gabfca

target.json in question:

{
  "arch": "mips64r5",
  "data-layout": "e-m:m-p:64:32-i8:8:32-i16:16:32-i64:64-n32-S64",
  "dynamic-linking": false,
  "executables": true,
  "linker": "mipsel-none-elf-ld",
  "linker-flavor": "ld",
  "llvm-target": "mipsel-none-elf",
  "llvm-args": "-mxgot",
  "max-atomic-width": 32,
  "features": "+soft_float",
  "os": "none",
  "panic-strategy": "abort",
  "position-independent-executables": false,
  "relro-level": "full",
  "target-c-int-width": "32",
  "target-endian": "little",
  "target-pointer-width": "64",
  "vendor": "unknown"
}

which, after some wrangling, can build core, but not compiler_builtins:


error: internal compiler error: src/context.rs:605:21: `fn_abi_of_instance(conv::__floatunsisf, [])` failed: AdjustForForeignAbi(Unsupported { arch: "mips64r5", abi: C { unwind: false } })
   --> /home/gabca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.109/src/macros.rs:491:9
    |
491 |           pub extern $abi fn $name( $($argname: $ty),* ) $(-> $ret)? {
    |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
   ::: /home/gabca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.109/src/float/conv.rs:74:1
    |
74  | / intrinsics! {
75  | |     #[arm_aeabi_alias = __aeabi_ui2f]
76  | |     pub extern "C" fn __floatunsisf(i: u32) -> f32 {
77  | |         f32::from_bits(int_to_float::u32_to_f32_bits(i))
...   |
103 | |     }
104 | | }
    | |_- in this macro invocation
    |
    = note: this error: internal compiler error originates in the macro `intrinsics` (in Nightly builds, run with -Z macro-backtrace for more info)

thread 'rustc' panicked at src/context.rs:605:21:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_errors::DiagCtxtHandle::span_bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_context_opt
   6: rustc_middle::util::bug::span_bug_fmt
   7: <rustc_codegen_gcc::context::CodegenCx as rustc_middle::ty::layout::FnAbiOfHelpers>::handle_fn_abi_err
   8: rustc_middle::ty::layout::FnAbiOf::fn_abi_of_instance::{{closure}}
   9: rustc_middle::ty::layout::FnAbiOf::fn_abi_of_instance
  10: rustc_codegen_gcc::mono_item::<impl rustc_codegen_ssa::traits::declare::PreDefineMethods for rustc_codegen_gcc::context::CodegenCx>::predefine_fn
  11: rustc_codegen_gcc::base::compile_codegen_unit::module_codegen
  12: rustc_codegen_gcc::base::compile_codegen_unit
  13: rustc_codegen_ssa::base::codegen_crate
  14: <rustc_codegen_gcc::GccCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  15: <rustc_interface::queries::Queries>::codegen_and_build_linker
  16: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: using internal features is not supported and expected to cause internal compiler errors when used incorrectly

note: please attach the file at `/home/gabca/.cargo/registry/src/index.crates.io-6f17d22bba15001f/compiler_builtins-0.1.109/rustc-ice-2024-07-28T15_04_39-617670.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -Z force-unstable-if-unmarked -Z codegen-backend=/home/gabca/rustc_codegen_gcc/target/release/librustc_codegen_gcc.so

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
end of query stack
warning: `compiler_builtins` (lib) generated 1 warning
error: could not compile `compiler_builtins` (lib); 1 warning emitted
warning: build failed, waiting for other jobs to finish...
error: internal compiler error: src/context.rs:605:21: `fn_abi_of_instance(CString::from_raw::strlen, [])` failed: AdjustForForeignAbi(Unsupported { arch: "mips64r5", abi: C { unwind: false } })
   --> /home/gabca/.rustup/toolchains/nightly-2024-07-02-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/ffi/c_str.rs:409:17
    |
409 |                 fn strlen(s: *const c_char) -> usize;
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

thread 'rustc' panicked at src/context.rs:605:21:
Box<dyn Any>
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
   2: rustc_errors::DiagCtxtHandle::span_bug
   3: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
   4: rustc_middle::ty::context::tls::with_opt::{{closure}}
   5: rustc_middle::ty::context::tls::with_context_opt
   6: rustc_middle::util::bug::span_bug_fmt
   7: <rustc_codegen_gcc::context::CodegenCx as rustc_middle::ty::layout::FnAbiOfHelpers>::handle_fn_abi_err
   8: <rustc_codegen_gcc::builder::Builder as rustc_middle::ty::layout::FnAbiOfHelpers>::handle_fn_abi_err
   9: rustc_middle::ty::layout::FnAbiOf::fn_abi_of_instance::{{closure}}
  10: rustc_codegen_ssa::mir::block::<impl rustc_codegen_ssa::mir::FunctionCx<Bx>>::codegen_terminator
  11: rustc_codegen_ssa::mir::codegen_mir
  12: rustc_codegen_ssa::base::codegen_instance
  13: <rustc_middle::mir::mono::MonoItem as rustc_codegen_ssa::mono_item::MonoItemExt>::define
  14: rustc_codegen_gcc::base::compile_codegen_unit::module_codegen
  15: rustc_codegen_gcc::base::compile_codegen_unit
  16: rustc_codegen_ssa::base::codegen_crate
  17: <rustc_codegen_gcc::GccCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  18: <rustc_interface::queries::Queries>::codegen_and_build_linker
  19: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}

https://gcc.gnu.org/onlinedocs/gcc/MIPS-Options.html documents a from-abi value that could fix this hopefully. No idea how to go about getting rustc_codegen_gcc to emit that though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions