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

Version 3.0.4 can't be compiled with dart2js server mode #251

Closed
simolus3 opened this issue Aug 14, 2024 · 12 comments
Closed

Version 3.0.4 can't be compiled with dart2js server mode #251

simolus3 opened this issue Aug 14, 2024 · 12 comments
Assignees
Labels
package:crypto type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@simolus3
Copy link

This is a regression in version 3.0.4, compiling this package works fine with 3.0.3:

../../../../.pub-cache/hosted/pub.dev/crypto-3.0.4/lib/src/sha512_fastsinks.dart:197:3:
Error: The integer literal 0x428a2f98d728ae22 can't be represented exactly in JavaScript.
  0x428a2f98d728ae22,
  ^^^^^^^^^^^^^^^^^^

There are many more such errors in that file.

@devoncarew
Copy link
Member

Is this a regression? related to dart-archive/crypto#165? cc @kevmoo

@kevmoo
Copy link
Member

kevmoo commented Aug 14, 2024

Ah shoot. Hrm...

@kevmoo
Copy link
Member

kevmoo commented Aug 14, 2024

@simolus3 – which version of Flutter/Dart are you using?

@simolus3
Copy link
Author

Dart SDK version: 3.5.0 (stable) (Tue Jul 30 02:17:59 2024 -0700) on "linux_x64"

@kevmoo
Copy link
Member

kevmoo commented Aug 14, 2024

SO WEIRD! Can you try running the crypto tests locally @simolus3 ?

dart test -p chrome,vm --compiler dart2wasm,dart2js -j 1

@simolus3
Copy link
Author

Oh wait I think I know what's happening haha, I'm running dart2js in server mode because my only test that is affected by this is @TestOn('node'). That doesn't have dart:html, normal dart2js does.
I suppose this will make it pretty hard to detect JS being targeted in conditional imports?

@simolus3 simolus3 changed the title Version 3.0.4 can't be compiled to JavaScript Version 3.0.4 can't be compiled with dart2js server mode Aug 14, 2024
@kevmoo
Copy link
Member

kevmoo commented Aug 14, 2024

@simolus3 – ah! We can fix that I think.

@kevmoo
Copy link
Member

kevmoo commented Aug 14, 2024

@sigmundch is looking into this now!

@kevmoo kevmoo added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Aug 14, 2024
@sigmundch
Copy link
Member

@kevmoo - ideally both dart.library.js and dart.library.js_util should be false in a conditional imports in dart2wasm, but it's not today (cc @srujzs @mkustermann).

I recall there were recent changes around what libraries are exposed by the wasm backend, and found a recent change it to make dart.library.ffi false. According to https://dart-review.googlesource.com/c/sdk/+/370880, this should be the case starting from 3.4.4 in the stable channel.

Given that this is already available, I'd suggest to use that for now:

import 'fast.dart'
  if (dart.library.ffi) 'fast.dart' // force wasm to go down this path.
  if (dart.library.js) 'slow.dart';

And later revisit to make it more precise. Ideally, we should allow conditional imports that directly describe the platform (e.g. dart.tool.dart2wasm), rather than the libraries available to that platform (see dart-lang/sdk#54785).

@sigmundch
Copy link
Member

My bad, the example above is incorrect - the change to dart.library.ffi precisely makes this harder: it made dart2wasm harder to distinguish from dart2js, not the other way around. It gives us a secondary way to distinguish VM from wasm, but not a way to divide between JS and Wasm backends.

@sigmundch
Copy link
Member

For now, I'd suggest revert the original change until we land something. We have dart-lang/sdk#55266 to track the underlying issue.

@kevmoo
Copy link
Member

kevmoo commented Aug 15, 2024

Fixed in dart-archive/crypto@eede7d6

@kevmoo kevmoo closed this as completed Aug 15, 2024
@mosuem mosuem transferred this issue from dart-archive/crypto Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:crypto type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants