GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — wasm_js rustlfags on top workspace by youknowone · Pull Request #6116 · RustPython/RustPython

Conversation

@youknowone

@youknowone youknowone commented Aug 31, 2025 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved reliability of WebAssembly builds by ensuring a browser-compatible random backend is selected for wasm32 targets, reducing initialization errors in non-WASI WASM environments.
  • Chores

    • Consolidated WASM build configuration at the workspace level for consistent behavior across platforms.
    • Added a workspace-level WASM feature and updated package feature mappings to streamline cross-package builds and reduce duplication.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@coderabbitai

coderabbitai Bot commented Aug 31, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a top-level wasm32 target rustflag, introduces a new wasm_js feature in common/Cargo.toml, removes the duplicate wasm target rustflags from wasm/lib/.cargo/config.toml, and updates the vm crate's wasmbind feature to depend on rustpython-common/wasm_js.

Changes

Cohort / File(s) Change summary
Top-level Cargo config
/.cargo/config.toml
Adds [target.wasm32-unknown-unknown] with rustflags = ["--cfg=getrandom_backend=\"wasm_js\""].
Common crate features
/common/Cargo.toml
Adds feature wasm_js = ["getrandom/wasm_js"] under [features].
WASM library local config cleanup
/wasm/lib/.cargo/config.toml
Removes the local [target.wasm32-unknown-unknown] rustflags entry; keeps [build] target = "wasm32-unknown-unknown".
VM crate feature update
/vm/Cargo.toml
Updates wasmbind feature to include rustpython-common/wasm_js in its feature list (replacing direct getrandom/wasm_js).

Sequence Diagram(s)

(omitted — changes are configuration-only and do not alter runtime control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble flags beneath the moon,
A tiny hop, a compile tune.
Features stitched and flags set free,
getrandom wanders, safe and merry.
From burrow to the browser sea—hooray for me! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title refers to moving wasm_js rustflags to the top-level workspace, which matches the PR objective and the changeset, but it contains a spelling error ("rustlfags") and awkward phrasing that reduce clarity.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 51acf58 and 2e36ff8.

📒 Files selected for processing (2)
  • common/Cargo.toml (1 hunks)
  • vm/Cargo.toml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • vm/Cargo.toml
  • common/Cargo.toml

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
  • X
  • Mastodon
  • Reddit
  • LinkedIn

Comment @coderabbitai help to get the list of available commands and usage tips.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coderabbitai[bot]
coderabbitai Bot reviewed Aug 31, 2025
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.cargo/config.toml (1)

7-8: Workspace-level wasm_js cfg looks good; minor quoting/style nit and scope check

Moving the cfg to the top-level target is the right direction. Two nits:

  • Use single-quoted TOML to avoid inner escapes.
  • Confirm this broad workspace-level cfg is intended for all crates when building for wasm32-unknown-unknown (it will apply to all members and their deps for that target).

Apply within this hunk:

-[target.wasm32-unknown-unknown]
-rustflags = ["--cfg=getrandom_backend=\"wasm_js\""]
+[target.wasm32-unknown-unknown]
+rustflags = ['--cfg=getrandom_backend="wasm_js"']
common/Cargo.toml (1)

39-41: Double-check getrandom feature name; likely unnecessary/incorrect here

Please verify that getrandom provides a feature literally named "wasm_js". If not, this will fail or be a no-op; the backend selection is already driven by the cfg you added via rustflags. If the cfg is sufficient (it usually is), drop the feature and possibly the whole target-specific dep block to avoid confusion/duplication with the global getrandom dep on Line 22.

Option A — keep the block but remove the feature:

 [target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
-getrandom = { workspace = true, features = ["wasm_js"] }
+getrandom = { workspace = true }

Option B — remove the redundant block entirely (global dep already exists):

-[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
-getrandom = { workspace = true, features = ["wasm_js"] }

Also, if the workspace isn’t on Cargo feature resolver = "2", consider enabling it at the workspace root to prevent unintended feature unification across targets.

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 7509387 and fdf5f3e.

📒 Files selected for processing (3)
  • .cargo/config.toml (1 hunks)
  • common/Cargo.toml (1 hunks)
  • wasm/lib/.cargo/config.toml (0 hunks)
💤 Files with no reviewable changes (1)
  • wasm/lib/.cargo/config.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run tests under miri
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
coolreader18
coolreader18 approved these changes Sep 1, 2025
View reviewed changes
@coolreader18

coolreader18 commented Sep 1, 2025

Copy link
Copy Markdown
Member

Ah, actually - that test failure is why the config is the way it is. Putting it in the top level means js gets selected even when we're not compiling wasm for browser.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

youknowone
youknowone commented Sep 2, 2025
View reviewed changes
Comment thread common/Cargo.toml Outdated
Comment on lines +39 to +41
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
getrandom = { workspace = true, features = ["wasm_js"] }

@youknowone youknowone Sep 2, 2025

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Suggested change
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies]
getrandom = { workspace = true, features = ["wasm_js"] }

This is wrong.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@coolreader18 coolreader18 Sep 4, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Hmm, true. I guess that should be enabled by a js feature flag that common exposes.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
youknowone added 2 commits September 14, 2025 17:07
@youknowone
getrandom/wasm_js for rustpython-common
2e14ba8
@youknowone
wasm_js rustflags on top workspace
5cbb152
@youknowone
youknowone force-pushed the rustflag branch from fdf5f3e to 51acf58 Compare September 14, 2025 08:07
coderabbitai[bot]
coderabbitai Bot reviewed Sep 14, 2025
View reviewed changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fdf5f3e and 51acf58.

📒 Files selected for processing (4)
  • .cargo/config.toml (1 hunks)
  • common/Cargo.toml (1 hunks)
  • vm/Cargo.toml (1 hunks)
  • wasm/lib/.cargo/config.toml (0 hunks)
💤 Files with no reviewable changes (1)
  • wasm/lib/.cargo/config.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .cargo/config.toml
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-11T05:06:59.971Z
Learnt from: CR
PR: RustPython/RustPython#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-09-11T05:06:59.971Z
Learning: Applies to {vm,stdlib}/**/*.rs : Use RustPython macros (`pyclass`, `pymodule`, `pyfunction`, etc.) when implementing Python functionality in Rust

Applied to files:

  • vm/Cargo.toml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run rust tests (windows-2025)
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (windows-2025)
  • GitHub Check: Run snippets and cpython tests (macos-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Ensure compilation on various targets

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread common/Cargo.toml Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread vm/Cargo.toml Outdated
parser = ["ast"]
serde = ["dep:serde"]
wasmbind = ["chrono/wasmbind", "getrandom/wasm_js", "wasm-bindgen"]
wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "getrandom/wasm_js", "wasm-bindgen"]

@coderabbitai coderabbitai Bot Sep 14, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid double-enabling getrandom’s JS backend; rely on common’s feature only.

wasmbind currently enables both rustpython-common/wasm_js and getrandom/wasm_js. Due to feature unification this is redundant and risks confusion about the single source of truth. Drop the direct getrandom/wasm_js from vm and let common own it.

Apply:

-wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "getrandom/wasm_js", "wasm-bindgen"]
+wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "getrandom/wasm_js", "wasm-bindgen"]
wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"]
🤖 Prompt for AI Agents
In vm/Cargo.toml around line 27, the wasmbind feature list currently includes
both "rustpython-common/wasm_js" and "getrandom/wasm_js"; remove
"getrandom/wasm_js" from the vm crate's wasmbind feature so the getrandom JS
backend is provided only via rustpython-common's wasm_js feature, leaving
wasmbind = ["rustpython-common/wasm_js", "chrono/wasmbind", "wasm-bindgen"]
(ensure no other references to getrandom/wasm_js remain in this feature).

💡 Verification agent

🧩 Analysis chain

Do not enable browser/wasm bindings by default; this likely caused the test failures.

default = ["compiler", "wasmbind", "stdio"] means native builds also activate wasmbind, which (transitively) opts into the JS randomness backend. Make wasmbind opt‑in only.

Apply:

-default = ["compiler", "wasmbind", "stdio"]
+default = ["compiler", "stdio"]

Quick checks:


🏁 Script executed:

#!/bin/bash
# 1) Confirm default features no longer include wasmbind
rg -nP '^\s*default\s*=\s*\[.*wasmbind' -g 'vm/Cargo.toml'

# 2) Ensure no other crate pulls wasmbind by default
rg -nP '\bfeatures\b.*wasmbind' -C2 -g '!**/target/**'

# 3) Inspect .cargo/config.* to ensure any `--cfg getrandom_backend="wasm_js"` is target-scoped to wasm32 only
rg -nP --hidden -C2 'getrandom_backend\s*=\s*"wasm_js"|--cfg\s+getrandom_backend' -g '.cargo/**'

Length of output: 209


Remove wasmbind from default features in vm/Cargo.toml

vm/Cargo.toml:13 currently enables wasmbind in default features, which pulls in the JS getrandom backend for native builds — make wasmbind opt‑in.

Apply:

-default = ["compiler", "wasmbind", "stdio"]
+default = ["compiler", "stdio"]

Also ensure any .cargo/config.* or --cfg getrandom_backend="wasm_js" entries are target‑scoped to wasm32 and that no other crate exposes wasmbind in its default features.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In vm/Cargo.toml around line 27, remove "wasmbind" from the default features
list so the getrandom wasm_js backend is not pulled into native builds; instead
add a separate optional feature (e.g., wasmbind) that includes the wasmbind deps
and mark those dependencies as optional under that feature so wasm support is
opt‑in. Also audit any .cargo/config.* files and Cargo command args and make
sure any --cfg getrandom_backend="wasm_js" or equivalent settings are restricted
to the wasm32 target (or moved into target."cfg(target_arch = \"wasm32\")"
sections), and verify no other crate in the workspace exposes wasmbind in its
default-features so the change actually prevents native pulls.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@youknowone
rustpython-common/wasm_js
2e36ff8
@youknowone
youknowone force-pushed the rustflag branch from 51acf58 to 2e36ff8 Compare September 14, 2025 08:22
@youknowone

youknowone commented Sep 14, 2025

Copy link
Copy Markdown
Member Author

@coolreader18 better?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

coolreader18
coolreader18 approved these changes Sep 16, 2025
View reviewed changes
@youknowone
youknowone merged commit aa0eb4b into RustPython:main Sep 17, 2025
@youknowone
youknowone deleted the rustflag branch September 17, 2025 00:11
This was referenced Nov 16, 2025
Fix wasm32-unknown-unknown target build #6278
Merged
Test wasm32 without js #6283
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@coderabbitai coderabbitai[bot] coderabbitai[bot] left review comments
@coolreader18 coolreader18 coolreader18 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@youknowone @coolreader18
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.