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

Add rust targets #900

Merged
merged 2 commits into from
Apr 15, 2024
Merged

Conversation

ulrikstrid
Copy link
Contributor

Adds targets as a list of strings of additional targets, as an example you can now easily add wasm32-unknown-unknown to build for wasm.

@ulrikstrid
Copy link
Contributor Author

Usage example together with Godot https://github.com/ulrikstrid/dodge-the-creeps-nix-rust

(rustPackages.combine
(
(map (c: config.languages.rust.toolchain.${c}) cfg.components) ++
(map (t: rustPackages.targets.${t}.latest.rust-std) cfg.targets)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Would you always want the nightly channel here? Should this use the channel specified in the config instead?
  2. Is the standard library the only component you would ever want to include for a given target?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. You are correct, we probably want whatever is supplied by the user.
  2. I'm still new to rust, but as I understand it std is what you compile against and the other things in the toolchain should run on your own computer and should therefore be your arch.

Please correct me if I'm wrong.

@domenkozar
Copy link
Member

We'd want to not commit examples/rust/devenv.lock

@ulrikstrid
Copy link
Contributor Author

ulrikstrid commented Feb 9, 2024

We'd want to not commit examples/rust/devenv.lock

The whole second commit can and probably should be dropped

@domenkozar
Copy link
Member

Would be great to have tests for #866

@domenkozar
Copy link
Member

@ulrikstrid do you plan to finish this one?

@ulrikstrid
Copy link
Contributor Author

@domenkozar I have some time right now so I'll try to get it in shape today

@@ -4,3 +4,5 @@ inputs:
inputs:
nixpkgs:
follows: nixpkgs
devenv:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be removed, you can use devenv-run-tests and it will automatically do the overriding

@@ -14,7 +16,9 @@
# clippy.enable = true;
#};

packages = lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk; [
packages = [
pkgs.wasm-pack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include that only of wasm32- target is set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually moving the example to rust-wasm-cross currently

@@ -13,4 +13,5 @@ fi
echo "$PATH" | grep -- "$CARGO_INSTALL_ROOT/bin"

cd app
cargo run
# cargo run
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to uncomment?

@domenkozar
Copy link
Member

clippy...................................................................Failed
- hook id: clippy
- exit code: 101

error: no matching package named `clap` found
location searched: registry `crates-io`
required by package `devenv v1.0.4 (/run/github-runner/cachix-x[86](https://github.com/cachix/devenv/actions/runs/8688299006/job/23826470738#step:6:87)_64-linux/devenv/devenv/devenv)`

@domenkozar domenkozar merged commit 02196df into cachix:main Apr 15, 2024
233 of 255 checks passed
@ulrikstrid ulrikstrid deleted the ulrikstrid--add-rust-targets branch April 15, 2024 14:08
@sandydoo
Copy link
Member

Interesting, my macOS machine refuses to build the wasm example unless frameworks is removed from RUSTFLAGS.

Error log
thread 'rustc' panicked at compiler/rustc_codegen_ssa/src/back/linker.rs:1241:9:
frameworks not supported
stack backtrace:
   0:        0x105bece74 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hd504cdf75dd790a5
   1:        0x105c2ff1c - core::fmt::write::h5707604b140ad434
   2:        0x105be30d8 - std::io::Write::write_fmt::h4786975223352ad5
   3:        0x105becccc - std::sys_common::backtrace::print::hbbeb9ed95a7b80ec
   4:        0x105bef264 - std::panicking::default_hook::{{closure}}::h9824320c6941fbee
   5:        0x105beef54 - std::panicking::default_hook::h9842bf3cae562040
   6:        0x10f2d4a80 - <alloc[b0dc11c95d7216a5]::boxed::Box<rustc_driver_impl[3cc9bf65ca00f6ee]::install_ice_hook::{closure#0}> as core[153a4a09f3d31382]::ops::function::Fn<(&dyn for<'a, 'b> core[153a4a09f3d31382]::ops::function::Fn<(&'a core[153a4a09f3d31382]::panic::panic_info::PanicInfo<'b>,), Output = ()> + core[153a4a09f3d31382]::marker::Sync + core[153a4a09f3d31382]::marker::Send, &core[153a4a09f3d31382]::panic::panic_info::PanicInfo)>>::call
   7:        0x105befc74 - std::panicking::rust_panic_with_hook::h83d90448f6646b96
   8:        0x105bef63c - std::panicking::begin_panic_handler::{{closure}}::hf0c46de292f71ea2
   9:        0x105bed304 - std::sys_common::backtrace::__rust_end_short_backtrace::h19b73a882a1ec51f
  10:        0x105bef3d4 - _rust_begin_unwind
  11:        0x105c4bce0 - core::panicking::panic_fmt::h5317ec8667b1cbec
  12:        0x10f163098 - <rustc_codegen_ssa[4d9577c8027bdfcc]::back::linker::WasmLd as rustc_codegen_ssa[4d9577c8027bdfcc]::back::linker::Linker>::framework_path
  13:        0x10f0b28dc - rustc_codegen_ssa[4d9577c8027bdfcc]::back::link::linker_with_args
  14:        0x10f0ac7c8 - rustc_codegen_ssa[4d9577c8027bdfcc]::back::link::link_natively
  15:        0x10f0a7b18 - rustc_codegen_ssa[4d9577c8027bdfcc]::back::link::link_binary
  16:        0x10ef8f4d4 - <rustc_codegen_llvm[b33fa16c10489259]::LlvmCodegenBackend as rustc_codegen_ssa[4d9577c8027bdfcc]::traits::backend::CodegenBackend>::link
  17:        0x10fa40e94 - <rustc_interface[7886f7beac8da793]::queries::Linker>::link
  18:        0x10f2d76e4 - rustc_span[5f336a5c6a7d3b2b]::set_source_map::<core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>, rustc_interface[7886f7beac8da793]::interface::run_compiler<core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>, rustc_driver_impl[3cc9bf65ca00f6ee]::run_compiler::{closure#0}>::{closure#0}::{closure#0}>
  19:        0x10f313bac - <scoped_tls[e07671f0187c90a4]::ScopedKey<rustc_span[5f336a5c6a7d3b2b]::SessionGlobals>>::set::<rustc_interface[7886f7beac8da793]::util::run_in_thread_with_globals<rustc_interface[7886f7beac8da793]::util::run_in_thread_pool_with_globals<rustc_interface[7886f7beac8da793]::interface::run_compiler<core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>, rustc_driver_impl[3cc9bf65ca00f6ee]::run_compiler::{closure#0}>::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#0}::{closure#0}::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>
  20:        0x10f2dff14 - std[b70c874603df6a6]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[7886f7beac8da793]::util::run_in_thread_with_globals<rustc_interface[7886f7beac8da793]::util::run_in_thread_pool_with_globals<rustc_interface[7886f7beac8da793]::interface::run_compiler<core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>, rustc_driver_impl[3cc9bf65ca00f6ee]::run_compiler::{closure#0}>::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>
  21:        0x10f31b7b8 - <<std[b70c874603df6a6]::thread::Builder>::spawn_unchecked_<rustc_interface[7886f7beac8da793]::util::run_in_thread_with_globals<rustc_interface[7886f7beac8da793]::util::run_in_thread_pool_with_globals<rustc_interface[7886f7beac8da793]::interface::run_compiler<core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>, rustc_driver_impl[3cc9bf65ca00f6ee]::run_compiler::{closure#0}>::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[153a4a09f3d31382]::result::Result<(), rustc_span[5f336a5c6a7d3b2b]::ErrorGuaranteed>>::{closure#2} as core[153a4a09f3d31382]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  22:        0x105bf86fc - std::sys::pal::unix::thread::Thread::new::thread_start::h56bc2156fc274a0f
  23:        0x192cd2f94 - __pthread_joiner_wake

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

@domenkozar
Copy link
Member

Looks like rust-lang/rust#122333

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

Successfully merging this pull request may close these issues.

3 participants