Skip to content

Conversation

@bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Apr 7, 2022

This is using the new fancy ittapi high-level crate that we've worked on, @abrown @jlb6740 and myself, and it upgrades to the latest version.

Could someone please test it locally and confirm it works for them? On my machine I get a weird failure that I also hit on main, not sure what's going on:

Assertion failed: tool:1328: g_instr_global.is_libpthread_so_loaded == 0 : g_instr_global.is_libpthread_so_loaded == 1
. Please contact the technical support. vtune: Error: Assertion failed: tool:1328: g_instr_global.is_libpthread_so_loaded == 0 : g_instr_global.is_libpthread_so_loaded == 1
. Please contact the technical support. 

@bnjbvr
Copy link
Member Author

bnjbvr commented Apr 7, 2022

Ah, seems compilation of the ittapi crate on windows is broken. Any ideas @abrown @jlb6740?

@abrown
Copy link
Member

abrown commented Apr 7, 2022

I looked into this but don't know yet how to resolve it: the compilation failure is due to strnlen_s not being available in MinGW by default (it is, after all, a non-standard function). There are some thoughts out there that adding --enable-secure-api will include the headers with this function, but before I add that to ittapi-sys's build.rs, I wanted to be able to reproduce the issue.

Locally I was unable to reproduce: after installing MSYS2 and compiling the ittapi crates with cargo build --target x86_64-pc-windows-gnu, everything seemed to build as normal. When I run cargo test --target x86_64-pc-windows-gnu, I get a different error: linker x86)64-w64-mingw32-gcc not found.

I then attempted to reproduce on ittapi's CI: using a similar setup to the Wasmtime workflow, I added x86_64-pc-windows-gnu as a target in the matrix. With the windows-latest OS, however, the crates built and tests ran. With the windows-2019 OS, then I observe a completely different failure related to libclang.dll being inaccessible.

Any suggestions?

@abrown
Copy link
Member

abrown commented Apr 13, 2022

@bnjbvr: since we can't really replicate this, we could just disable the ittapi dependency for MinGW builds?

@bnjbvr
Copy link
Member Author

bnjbvr commented Apr 13, 2022

@abrown Need to check but I think that we do use this target to cross-compile internally. If so at least I might find people who could poke at this, maybe...

@bnjbvr
Copy link
Member Author

bnjbvr commented Apr 13, 2022

Seems we don't use it, so yeah we could disable ittapi on mingw then, and if someone wants to support that, they would need to contribute a patch. Does it sound acceptable?

@abrown
Copy link
Member

abrown commented Apr 13, 2022

Does it sound acceptable?

It sounds acceptable to me, though others feel free to comment. I'm not sure how much energy to put into MinGW since I don't use it much (ever!) and I wonder sometimes if it has been obsoleted by WSL.

@alexcrichton
Copy link
Member

Personally I find managing platform-specific exceptions and such to APIs not easy to maintain over time. To that end I would prefer to see this solved. It looks to me like MinGW doesn't provide the strnlen_s function which is the source of this error. The only reason we're seeing this now is probably because something in the ittapi crate is calling a function we didn't call before in the C library and the C function requires strnlen_s or something like that.

Locally I was unable to reproduce: after installing MSYS2 and compiling the ittapi crates with cargo build --target x86_64-pc-windows-gnu, everything seemed to build as normal

That's because when you build an rlib it doesn't actually link anything, so this doesn't verify that symbols are actually present on the system.

When I run cargo test --target x86_64-pc-windows-gnu, I get a different error: linker x86)64-w64-mingw32-gcc not found.

If the ) there isn't a typo then that's a misconfigured compiler somewhere. Otherwise this may mean you're not running the command in an MSYS2 shell or something like that. Basically if the linker isn't being invoked you won't be able to reproduce this issue.

With the windows-latest OS, however, the crates built and tests ran

I don't think that the CI is configured correctly which is why this seems to work. In the logs I see:

     Running tests\bindgen-up-to-date.rs (target\debug\deps\bindgen_up_to_date-ae57c289f5ef2e2d.exe)

but if you're cross compiling the path to the binary should be target\x86_64-pc-windows-gnu\debug\deps\.... You added this to the CI configuration:

    - run: echo CARGO_BUILD_TARGET=${{ matrix.target }} >> $GITHUB_ENV
      if: matrix.target != ''

but I don't think that works because the shell you're using is windows cmd or powershell (I dunno which) and probably doesn't use $foo for environment variables. This I believe means you're not actually configuring Cargo for cross-compilation.

@bnjbvr
Copy link
Member Author

bnjbvr commented Apr 13, 2022

Very good call, @alexcrichton! Managed to reproduce the compilation error on ittapi now: intel/ittapi#61

abrown added a commit to intel/ittapi that referenced this pull request May 13, 2022
In bytecodealliance/wasmtime#4003 we discovered that the `ittapi` C code uses the uncommon `strnlen_s` function. On older versions of MinGW (GitHub runners currently come with v8.1.0 pre-installed), this function was not available. Since v8.1.0, other versions have been published; this change re-installs MinGW with a recent version which includes `strnlen_s`. This commit has no code changes, just CI configuration to prove that the crate builds with the right MinGW version.

As a result of this, we opened actions/runner-images#5530 to upgrade MinGW on all Windows GitHub runners. That upgrade may take some time so in the meantime the workaround is to use a new-ish version of MinGW. Note that this build issue is likely rare: it only really applies if someone builds the `ittapi` crate with `--target x86_64-pc-windows-gnu` AND with an old version of MinGW installed.

Co-authored-by: Andrew Brown <[email protected]>
@abrown
Copy link
Member

abrown commented Jun 13, 2022

This should be merge-able once GitHub's virtual environment for Windows is updated with the latest version of MinGW: actions/runner-images#5729.

@abrown
Copy link
Member

abrown commented Jun 23, 2022

I believe that the updated version of MinGW (which includes the missing strnlen_s definition) has been rolled out to the machines that run the windows-latest CI jobs. Over in intel/ittapi#63 I was able to build ittapi without issues on windows-latest. I'm re-running CI here to check if we can actually merge this now.

@alexcrichton
Copy link
Member

I believe the issue here is that we're pinned to windows-2019 (see #3864 for info on that) so we're not getting updates. I'd reiterate though that there's no requirement to get this working on all platforms. Disabling this on mingw is fine.

@bnjbvr
Copy link
Member Author

bnjbvr commented Jul 18, 2022

Just added a commit that disables this on windows + mingw, and it seems to compile fine. Unfortunately there's an unrelated MacOS build error (Github says the CI run has been cancelled), and I can't request a retry, so could anyone with the right authorization bits please do that?

@alexcrichton alexcrichton merged commit f0337c9 into bytecodealliance:main Jul 18, 2022
@bnjbvr bnjbvr deleted the upgrade-ittapi branch July 18, 2022 15:15
LRenzo0801 pushed a commit to LRenzo0801/ittapi that referenced this pull request May 31, 2025
In bytecodealliance/wasmtime#4003 we discovered that the `ittapi` C code uses the uncommon `strnlen_s` function. On older versions of MinGW (GitHub runners currently come with v8.1.0 pre-installed), this function was not available. Since v8.1.0, other versions have been published; this change re-installs MinGW with a recent version which includes `strnlen_s`. This commit has no code changes, just CI configuration to prove that the crate builds with the right MinGW version.

As a result of this, we opened actions/runner-images#5530 to upgrade MinGW on all Windows GitHub runners. That upgrade may take some time so in the meantime the workaround is to use a new-ish version of MinGW. Note that this build issue is likely rare: it only really applies if someone builds the `ittapi` crate with `--target x86_64-pc-windows-gnu` AND with an old version of MinGW installed.

Co-authored-by: Andrew Brown <[email protected]>
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.

3 participants