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

no prelude rust example mysteriously fails #143

Closed
steveklabnik opened this issue Apr 11, 2023 · 2 comments
Closed

no prelude rust example mysteriously fails #143

steveklabnik opened this issue Apr 11, 2023 · 2 comments

Comments

@steveklabnik
Copy link
Contributor

steveklabnik commented Apr 11, 2023

If I am in the "no prelude" example directory, building the Rust project works just fine.

buck2\examples\no_prelude〉buck2 build //rust:main
Build ID: 08d04cf1-ec8f-4450-87ec-b5674348fdce
Jobs completed: 3. Time elapsed: 0.0s.
BUILD SUCCEEDED

If I copy that entire subdirectory into a new project:

buck-rust-hello〉git status
On branch main
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   .buckconfig
        new file:   .buckroot
        deleted:    .gitmodules
        modified:   BUCK
        new file:   README.md
        new file:   cpp/hello_world/BUCK
        new file:   cpp/hello_world/func.cpp
        new file:   cpp/hello_world/func.hpp
        new file:   cpp/hello_world/main.cpp
        new file:   cpp/library/BUCK
        new file:   cpp/library/library.cpp
        new file:   cpp/library/library.hpp
        new file:   cpp/rules.bzl
        new file:   go/BUCK
        new file:   go/go_binary.bzl
        new file:   go/main.go
        new file:   go/rules.bzl
        deleted:    prelude
        new file:   prelude.bzl
        new file:   prelude/prelude.bzl
        new file:   rust/BUCK
        new file:   rust/main.rs
        new file:   rust/rules.bzl
        modified:   toolchains/BUCK
        new file:   toolchains/cpp_toolchain.bzl
        new file:   toolchains/export_file.bzl
        new file:   toolchains/go_toolchain.bzl
        new file:   toolchains/rust_toolchain.bzl
        new file:   toolchains/symlink.bat

I get a failure:

buck2\examples\no_prelude〉buck2 build //rust:main
File changed: root//cpp/hello_world
File changed: root//cpp/library
File changed: root//.git/index.lock
70 additional file change events
Action failed: root//rust:main (compile)
Required outputs are missing: Action failed to produce outputs: `buck-out/v2/gen/root/6dd044292ff31ae1/rust/__main__/main`
Reproduce locally: `rustc "--crate-type=bin" "rust\\main.rs" -o "buck-out\\v2\\gen\\root\\6dd044292ff31ae1\\rust\\__main__\\main"`
stdout:
stderr:
Build ID: 0efa591f-0382-4df5-b9a5-bd623bf4a3b5
Jobs completed: 3. Time elapsed: 0.7s. Cache hits: 0%. Commands: 1 (cached: 0, remote: 0, local: 1)
BUILD FAILED
Failed to build 'root//rust:main (<unspecified>)'

Now, why this is failing is very interesting: it's looking for a binary named main, but rustc will be producing one called main.exe. What's extra confusing to me, after scouring all of these rules for the past few hours, is that:

main.exe is being produced by the compiler in the new repo:

buck-rust-hello〉ls buck-out\\v2\\gen\\root\\6dd044292ff31ae1\\rust\\__main__\\
╭───┬──────────────────────────────────────────────────────────────┬──────┬─────────┬──────────────╮
│ # │                             name                             │ type │  size   │   modified   │
├───┼──────────────────────────────────────────────────────────────┼──────┼─────────┼──────────────┤
│ 0 │ buck-out\v2\gen\root\6dd044292ff31ae1\rust\__main__\main.exe │ file │ 5.0 MiB │ a minute ago │
│ 1 │ buck-out\v2\gen\root\6dd044292ff31ae1\rust\__main__\main.pdb │ file │ 1.2 MiB │ 2 hours ago  │
╰───┴──────────────────────────────────────────────────────────────┴──────┴─────────┴──────────────╯

but it is producing main with no extension in the demo sub-repo:

buck2\examples\no_prelude〉ls buck-out\v2\gen\root\6dd044292ff31ae1\rust\__main__\╭───┬──────────────────────────────────────────────────────────────┬──────┬───────────┬─────────────╮
│ # │                             name                             │ type │   size    │  modified   │
├───┼──────────────────────────────────────────────────────────────┼──────┼───────────┼─────────────┤
│ 0 │ buck-out\v2\gen\root\6dd044292ff31ae1\rust\__main__\main     │ file │ 159.5 KiB │ 2 hours ago │
│ 1 │ buck-out\v2\gen\root\6dd044292ff31ae1\rust\__main__\main.pdb │ file │   1.2 MiB │ 2 hours ago │
╰───┴──────────────────────────────────────────────────────────────┴──────┴───────────┴─────────────╯

Does this behavior make sense? Is there some other bit of ambient configuration that I'm missing?

@ndmitchell
Copy link
Contributor

I wouldn't think too hard about the no_prelude rules. The don't use the Prelude rust rules, so they aren't really complete enough to be expected to work.

@steveklabnik
Copy link
Contributor Author

Yeah, I was just trying to get something going on my local machine, and given that this example does build for me in-tree, was hoping it would be a bit simpler to get started with before trying to figure out what's up with the prelude :)

Given that's a longer-term solution anyways, seems good! I'll not chase down this thread. Thanks :)

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

2 participants