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

fix(embedded): Don't append hash to bin names #12269

Merged
merged 1 commit into from
Jun 14, 2023
Merged

Conversation

epage
Copy link
Contributor

@epage epage commented Jun 14, 2023

What does this PR try to resolve?

More immediately, this is to unblock rust-lang/rust#112601

The hash existed for sharing a target directory. That code isn't
implemented yet and a per-user build cache might remove the need for it,
so let's remove it for now and more carefully weigh adding it back in.

In general, this is also the more appropriate way for a feature that would be first class.

How should we test and review this PR?

This originally built on #12268 but now stands alone as the other PR has windows issues to work out

Additional information

@rustbot
Copy link
Collaborator

rustbot commented Jun 14, 2023

r? @weihanglo

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added A-cli Area: Command-line interface, option parsing, etc. A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-manifest Area: Cargo.toml issues A-workspaces Area: workspaces Command-package Command-run S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 14, 2023
Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

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

Make sense. I was going to suggest using crate::util::hex::short_hash against manifest string, but just realize the bin name will be uplifted to target/debug. That means if someone edit-and-runs the script many times, a lot of executables will mess up target/debug directory.

Background: the hash existed for sharing a target directory.  That code isn't
implemented yet and a per-user build cache might remove the need for it,
so let's remove it for now and more carefully weigh adding it back in.

Immediate: This reduces the chance of hitting file length issues on Windows.

Generally: This is a bit hacky and for an official solution, we should
probably try to find a better way.  This could become more important as
single-file packages are allowed in workspaces.
@epage epage force-pushed the bin branch 2 times, most recently from 744028a to 56b2812 Compare June 14, 2023 17:51
@weihanglo
Copy link
Member

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented Jun 14, 2023

📌 Commit 56b2812 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 14, 2023
@bors
Copy link
Contributor

bors commented Jun 14, 2023

⌛ Testing commit 56b2812 with merge 0c14026...

@bors
Copy link
Contributor

bors commented Jun 14, 2023

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 0c14026 to master...

@bors bors merged commit 0c14026 into rust-lang:master Jun 14, 2023
@epage epage deleted the bin branch June 14, 2023 19:41
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2023
Update cargo

11 commits in 49b6d9e179a91cf7645142541c9563443f64bf2b..0c14026aa84ee2ec4c67460c0a18abc8519ca6b2
2023-06-09 17:21:19 +0000 to 2023-06-14 18:43:05 +0000
- fix(embedded): Don't append hash to bin names (rust-lang/cargo#12269)
- Fix version requirement example in Dependency Resolution, SemVer compatibility section (rust-lang/cargo#12267)
- Update triagebot links. (rust-lang/cargo#12265)
- Show a better error when container tests fail. (rust-lang/cargo#12264)
- chore: update dependencies (rust-lang/cargo#12261)
- refactor(embedded) (rust-lang/cargo#12262)
- docs: clarify the use of `default` branch instead of `main` by default (rust-lang/cargo#12251)
- docs: update changelog for 1.71 backport and 1.72 (rust-lang/cargo#12256)
- feat: Initial support for single-file packages (rust-lang/cargo#12245)
- test(z-flags): Verify `-Z` flags list is sorted (rust-lang/cargo#12224)
- refactor: registry data kinds cleanup (rust-lang/cargo#12248)

---

This commit also update LICENSE exceptions, as Cargo introduced a newer version of `dunce` and `blake3` as dependencies.

r? `@ghost`
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Jun 16, 2023
Update cargo

11 commits in 49b6d9e179a91cf7645142541c9563443f64bf2b..0c14026aa84ee2ec4c67460c0a18abc8519ca6b2
2023-06-09 17:21:19 +0000 to 2023-06-14 18:43:05 +0000
- fix(embedded): Don't append hash to bin names (rust-lang/cargo#12269)
- Fix version requirement example in Dependency Resolution, SemVer compatibility section (rust-lang/cargo#12267)
- Update triagebot links. (rust-lang/cargo#12265)
- Show a better error when container tests fail. (rust-lang/cargo#12264)
- chore: update dependencies (rust-lang/cargo#12261)
- refactor(embedded) (rust-lang/cargo#12262)
- docs: clarify the use of `default` branch instead of `main` by default (rust-lang/cargo#12251)
- docs: update changelog for 1.71 backport and 1.72 (rust-lang/cargo#12256)
- feat: Initial support for single-file packages (rust-lang/cargo#12245)
- test(z-flags): Verify `-Z` flags list is sorted (rust-lang/cargo#12224)
- refactor: registry data kinds cleanup (rust-lang/cargo#12248)

---

This commit also update LICENSE exceptions, as Cargo introduced a newer version of `dunce` and `blake3` as dependencies.

r? `@ghost`
epage added a commit to epage/cargo that referenced this pull request Jun 17, 2023
This was originally split out because before rust-lang#12269, it was needed
elsewhere.
@ehuss ehuss added this to the 1.72.0 milestone Jun 22, 2023
@guest271314
Copy link

Is there official documentation for how this works, and what the bare required folders and files are from Rust nightly release?

@epage
Copy link
Contributor Author

epage commented Aug 6, 2024

The documentation is at https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#script

Unsure what you mean by files and folders.

@guest271314
Copy link

guest271314 commented Aug 7, 2024

Unsure what you mean by files and folders.

It's basically impossible to download the entire Rust toolchain on a temporary file system running a live Linux session.

So I fetched the Nightly archive, immediately got rid of the 600+ MB documentation folder, and everything else except rustc and rust-std-x86_64-unknown-linux-gnu folders.

I'll re-fetch the nightly archive and extract cargo folder.
Eventually I got this to run, using -L to I guess link to rustlib/x86_64-unknown-linux-gnu/lib

#!/bin/sh
//bin/bash -ec '[ "$0" -nt "${0%.*}" ] && /home/user/bin/rustc/bin/rustc -L /home/user/bin/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$0" -o "${0%.*}"; "${0%.*}" "$@"' "$0" "$@"; exit $?

use std::env;
// https://stackoverflow.com/a/75981598
fn main() {
  let args: Vec<String> = env::args().collect();
  if args.len() > 1 {
      println!("Hello {}!", &args[1]);
  } else {
      println!("Hello world!");
  }
}

What I'm really working on doing is using Rust .rs file as a Native Messaging host script.

I converted a working C version to Rust using https://c2rust.com/.

Now I have to figure out how to link to libc in the resulting file https://gist.github.com/rust-play/92af6fefec0ea8bcc76a5b18be40005e

//https://stackoverflow.com/q/41322300
//https://c2rust.com/
//https://github.com/rust-lang/rust/issues/1772
#![allow(dead_code, mutable_transmutes, non_camel_case_types, non_snake_case, non_upper_case_globals, unused_assignments, unused_mut)]
#![register_tool(c2rust)]
#![feature(register_tool)]
extern "C" {
    static mut stdin: *mut _IO_FILE;
    static mut stdout: *mut _IO_FILE;
    fn fflush(__stream: *mut FILE) -> libc::c_int;
// ...

Just to see what would happen if I was trying to compile the C to Rust code

./rust.sh "test"
error[E0433]: failed to resolve: use of undeclared crate or module `libc`
  --> ./rust.sh:10:39

// ...

118 |         free(message as *mut libc::c_void);
    |                              ^^^^ use of undeclared crate or module `libc`

error: aborting due to 58 previous errors

For more information about this error, try `rustc --explain E0433`.

This is my second time trying to use Rust to build something. My first time using Rust as a script. Thanks.

@epage
Copy link
Contributor Author

epage commented Aug 7, 2024

@guest271314 a long-merged PR for an unrelated part of a feature that it doesn't look like you are using from your examples is likely not the best place for us to be having this conversation. For user support, https://users.rust-lang.org/ tends to be a good place to go.

@guest271314
Copy link

@epage Thanks.

I was replying to

Unsure what you mean by files and folders.

And included my use case for context.

Have a great day.

@guest271314
Copy link

a long-merged PR for an unrelated part of a feature that it doesn't look like you are using from your examples

The links in my research led me here.

@guest271314
Copy link

@epage Is there anything special I need to do to avoid "no such command: +nightly"?

 cargo/bin/cargo +nightly -Zscript ~/bin/script.rs
error: no such command: `+nightly`

	Cargo does not handle `+toolchain` directives.
	Did you mean to invoke `cargo` through `rustup` instead?

@weihanglo
Copy link
Member

@guest271314 If you are not using cargo via rustup, you don't need to pass the +nightly argument.

Anyhow, this PR was closed a year ago. If you have feedback for -Zscript feature, please consider opening a new issue instead of leaving a comment here.

@guest271314
Copy link

@weihanglo #14363

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: Command-line interface, option parsing, etc. A-infrastructure Area: infrastructure around the cargo repo, ci, releases, etc. A-manifest Area: Cargo.toml issues A-workspaces Area: workspaces Command-package Command-run S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants