Skip to content

fix: raster shader build fail#3950

Open
Crypto-Darth wants to merge 1 commit intoGraphiteEditor:masterfrom
Crypto-Darth:fix/buildfix
Open

fix: raster shader build fail#3950
Crypto-Darth wants to merge 1 commit intoGraphiteEditor:masterfrom
Crypto-Darth:fix/buildfix

Conversation

@Crypto-Darth
Copy link

Resolves #3939

Cargo run was causing failure near the step where raster-nodes-shaders where it is generating dylib for the wrong target (wasm32-unknown-unknown)

Solution I implemented was to unset the CARGO_BUILD_TARGET before cargo_gpu installation and then setting it right after for the rest of the build process.

AI Usage - To help find and understand the root cause of the actual error message generated on cargo run and suggestions for the solution which was implemented.

Thanks to @ghchinoy for his findings which was also same as when i tried debugging it and for his proposed solution as mentioned on #3939

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical build failure in the raster shader compilation process. By carefully managing the CARGO_BUILD_TARGET environment variable, it ensures that the cargo_gpu installation step correctly builds for the intended target, preventing the generation of an incorrect dylib and allowing the project to compile successfully.

Highlights

  • Build Fix for Raster Shaders: Resolved a build failure where raster-nodes-shaders was generating a dylib for the incorrect wasm32-unknown-unknown target during cargo run.
  • Environment Variable Management: Implemented a solution to temporarily unset the CARGO_BUILD_TARGET environment variable before cargo_gpu installation and then restore it afterward to ensure correct target compilation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively resolves the raster shader build fail by correctly managing the CARGO_BUILD_TARGET environment variable during the cargo_gpu installation process. By temporarily unsetting and then restoring this variable, the build system avoids targeting wasm32-unknown-unknown for dylib generation, which was causing the failure. The approach of saving and restoring the environment variable is sound for ensuring the rest of the build process functions as expected.

Comment on lines +32 to +34
unsafe {
// Unset `CARGO_BUILD_TARGET` to prevent `rustc_codegen_spirv` from picking it up and trying to build for the wrong target.
std::env::remove_var("CARGO_BUILD_TARGET");
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The unsafe blocks for std::env::remove_var (lines 32-34) and std::env::set_var (lines 50-52) are used to manipulate environment variables. While unsafe is required on Windows for these operations due to potential thread-safety concerns, it's good practice to provide a clear // SAFETY: comment explaining why it's safe in this context, similar to the one on lines 21-23. This ensures that the justification for using unsafe is explicit and consistent throughout the file.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

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.

cargo run fails on WebAssembly target due to CARGO_BUILD_TARGET leaking into rustc_codegen_spirv build

1 participant