Skip to content

[windows] [build-hook] Logging is incomplete/inaccurate when running with CBuilder #61980

@poirierlouis

Description

@poirierlouis

Information

  • Dart 3.10.0 (stable) (Thu Nov 6 05:24:55 2025 -0800) on "windows_x64"
  • on windows / "Windows 11 Famille" 10.0 (Build 26200)

I'm trying to make a custom package using Dart FFI related features.

Dependencies

  • hooks: ^1.0.0
  • code_assets: ^1.0.0
  • native_toolchain_c: ^0.17.3

Description:
I've defined a custom wrapper to create a dynamic library on top of Intel XED. I'm only trying on Windows x64 for now. Outside of Dart/Build Hook workflow, I built a xed.lib.

I copy the static library (xed.lib) inside my hook runner. In the example below, I purposely forgot to give the path to include headers for xed (while my code does #include <xed/xed-interface.h>).

Actual behavior
I execute dart run and get logs in stderr.txt and in the console about cl.exe (from MSVC) failing with a ProcessException. But there is nothing related to cl.exe logs output that could help me understand what went wrong.

Expected behavior
It should correctly output the entire stdout/stderr of the process being run (cl.exe).

If I run the cl.exe command myself (generated by CBuilder), it will show an error about the header of xed not present (missing -I declaration for xed/xed-interface.h).

hook/build.dart

void main(List<String> args) async {
  await build(args, (input, output) async {
    final packageName = input.packageName;

    // ... copy `xed.lib` in `<output-dir>/vendors` ...

    final builder = CBuilder.library(
      name: packageName,
      assetName: "src/$packageName.dart",
      sources: ["src/main.cpp"],
      includes: [
        "src",
        // "src/vendors/xed/kits/latest/include", // absent on purpose
      ],
      linkModePreference: LinkModePreference.dynamic,
      libraries: ["xed"],
      libraryDirectories: ["vendors"],
    );

    await builder.run(input: input, output: output);
  });
}

Additional notes
The following may not be directly related (in case you wonder about building xed.lib outside of Dart Build Hook feature):
I first intended to directly clone Intel XED repositories (xed + mbuild), and build it as a shared library to import symbols directly (with build.dart).
Without Build Hook workflow, I can build the shared library without issues (MSVC + Python3).
With Build Hook, it failed when using Process.run to execute python mfile.py --shared (which is the build system used for Intel XED). Whether I was using runInShell, using python as the executable (absolute path), or running a shell (which would then execute the python command) it was always failing. Perhaps it works on other platforms (not Windows).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-ffitriagedIssue has been triaged by sub team

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions