dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.23k stars 1.57k forks source link

"Couldn't find constructor 'Native'." #51999

Closed selfisekai closed 1 year ago

selfisekai commented 1 year ago

I'm trying to build 3.0.0-425.0.dev and I'm failing with this:

ninja: job failed: python3 ../build/gn_run_binary.py compiled_action ../tools/sdks/dart-sdk/bin/dart -Dsdk_hash=0000000000 --packages=../.dart_tool/package_config.json --dfe=../tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot ../pkg/compiler/lib/src/dart2js.dart /home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/pkg/dev_compiler/web/stack_trace_mapper.dart -m --invoker=gn_build -o/home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/out/dev_compiler/build/web/dart_stack_trace_mapper.js --no-source-maps --platform-binaries=/home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/out
Command failed: /home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/tools/sdks/dart-sdk/bin/dart -Dsdk_hash=0000000000 --packages=../.dart_tool/package_config.json --dfe=../tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot ../pkg/compiler/lib/src/dart2js.dart /home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/pkg/dev_compiler/web/stack_trace_mapper.dart -m --invoker=gn_build -o/home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/out/dev_compiler/build/web/dart_stack_trace_mapper.js --no-source-maps --platform-binaries=/home/lauren/aports/testing/dart3/src/dart-sdk-3.0.0_alpha425/out
output: ../pkg/mmap/lib/src/mmap_impl.dart:18:2: Error: Couldn't find constructor 'Native'.
@Native<Int32 Function(Pointer<Utf8>, Int32)>(symbol: "open")
 ^^^^^^
../pkg/mmap/lib/src/mmap_impl.dart:22:2: Error: Couldn't find constructor 'Native'.
@Native<Int32 Function(Int32)>(symbol: "close")
 ^^^^^^
../pkg/mmap/lib/src/mmap_impl.dart:35:2: Error: Couldn't find constructor 'Native'.
@Native<IntPtr Function(Pointer<Uint8> address, IntPtr len)>(symbol: "munmap")
 ^^^^^^
../pkg/mmap/lib/src/mmap_impl.dart:44:2: Error: Couldn't find constructor 'Native'.
@Native<Int32 Function(Pointer<Uint8>, IntPtr, Int32)>(symbol: "mprotect")
 ^^^^^^

ninja: subcommand failed
>>> ERROR: dart3: build failed

update: also failing with 3.0.0-290.3.beta

used bootstrap: Dart SDK version: 2.19.6 (stable) (2023-03-31T21:27+00:00) on "linux_x64"

mraleph commented 1 year ago

Looks like you have not run gclient sync (or skipped the hooks). According to DEPS checked in sdk is set to version:3.0.0-369.0.dev: https://github.com/dart-lang/sdk/blob/db047857bad7d324bbd54952cab3d84340993d50/DEPS#L46-L49

In general you should currently only expect to build SDK cleanly if your setup matches what DEPS points to.

selfisekai commented 1 year ago

I'm guessing by this response that the version constraints required for build are not documented then?

I replace the downloaded sdk (to the version I specified) because these builds don't work on musl

mraleph commented 1 year ago

I'm guessing by this response that the version constraints required for build are not documented then?

Not sure what you mean by this. The constraint is quite clearly specified in DEPS: it specifies which version of SDK we need for bootstrapping. The best we currently promise is that if you fetch sources and dependencies exactly as specified in DEPS then SDK should build cleanly. We don't test any other combinations ourselves - so if you want to try building with older or newer versions of dependencies this might not work. The same actually applies to toolchains. We test with our prebuilts and specific GCC version on Linux - but nothing else.