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

inf2cat.exe Exited with Code -2 and Warnings Treated as Errors Despite Configuration #3944

Open
dynamic-i opened this issue Oct 21, 2024 · 13 comments
Assignees
Labels
bug Something isn't working P2 triaged Discussed in a triage meeting
Milestone

Comments

@dynamic-i
Copy link

Describe the bug

I'm experiencing a build error while attempting to compile the eBPF for Windows project using Visual Studio 2022. The errors persist despite disabling the warnings-as-errors setting in the project properties and using the /p:TreatWarningsAsErrors=false flag in the msbuild command.

OS information

Operating System: Windows 11
Visual Studio Version: Visual Studio 2022 (17.11.2)
Windows SDK Version: 10.0.22621.755
Windows Driver Kit Version: 10.0.22621.382
CMake Version: 3.30

Steps taken to reproduce bug

  1. Clone the ebpf-for-windows repository with submodules.

    git clone --recurse-submodules https://github.com/microsoft/ebpf-for-windows.git

  2. Run the initialization script:

    .\scripts\initialize_ebpf_repo.ps1

  3. Open Developer Command Prompt for VS 2022.

  4. Run the following build command:
    msbuild /m /p:Configuration=Debug /p:Platform=x64 /p:TreatWarningsAsErrors=false ebpf-for-windows.sln

Expected behavior

The build process should complete successfully without errors. After disabling "Treat Warnings as Errors" in Visual Studio project settings and adding the /p:TreatWarningsAsErrors=false flag in the msbuild command, no warnings should be treated as errors during the build.

Actual outcome

The build process fails despite setting the flags to not treat warnings as errors. The errors encountered are related to inf2cat.exe exiting with code -2 and warnings still being treated as errors in elf_types.hpp. Here are the specific errors:

C:\Program Files (x86)\Windows Kits\10\build\10.0.22621.0\WindowsDriver.common.targets(1362,5): error MSB6006: “inf2cat.exe”已退出,代码为 -2。 [c:\Users\17204\ebpf-for-windows\netebpfext\sys\netebpfext.vcxproj]
c:\Users\17204\ebpf-for-windows\external\ebpf-verifier\external\bpf_conformance\external\elfio\elfio\elf_types.hpp(1,1): error C2220: 以下警告被视为错误 [c:\Users\17204\ebpf-for-windows\tools\bpf2c\bpf2c.vcxproj]

Additional details

image and I have re-run the msbuild command as you requested and generated the BuildOutput.log.I'm attaching the log file for your review. Thank you for your assistanceBuildOutput.log

@dynamic-i dynamic-i added the bug Something isn't working label Oct 21, 2024
@shankarseal shankarseal added the triaged Discussed in a triage meeting label Oct 21, 2024
@shankarseal shankarseal added the P2 label Oct 21, 2024
@shankarseal shankarseal added this to the 2410 milestone Oct 21, 2024
@Alan-Jowett
Copy link
Member

Can you please repro this with the "/bl" option? This will give a detailed output exactly what is happening.

@Alan-Jowett
Copy link
Member

@dynamic-i
Copy link
Author

Can you please repro this with the "/bl" option? This will give a detailed output exactly what is happening.

Hello, I encountered an issue uploading the .binlog file directly, so I have compressed it and attached it as a .zip file. Please let me know if this works, or if you need an alternative method to access the log. Thank youmsbuild.zip

@dynamic-i
Copy link
Author

Hi @Alan-Jowett , just checking in to see if you had a chance to review the compressed .zip file with the .binlog. Please let me know if you need any additional details to help with troubleshooting. Thanks!

@Alan-Jowett
Copy link
Member

I will take a look today. My apologies for the delay.

@Alan-Jowett
Copy link
Member

Here are the errors that show up in the binlog:
Image

I am going to see if I can get Bing or Google to translate this for me as unfortunately I don't speak this language.

@dynamic-i
Copy link
Author

Here are the errors that show up in the binlog: Image

I am going to see if I can get Bing or Google to translate this for me as unfortunately I don't speak this language.

"Here is the translation of the errors you mentioned:

In bpf2c.vcxproj:

Error: 'The following warning is treated as an error' (appears twice).
In ebpf-for-windows.wixproj:

Error: 'MSBuild returned false in the task, but no error was logged.'
I hope this helps! Let me know if there's anything else I can provide."

@Alan-Jowett
Copy link
Member

After clicking through the first error message it points to:
C:\Users\17204\ebpf-for-windows\external\ebpf-verifier\external\bpf_conformance\external\elfio\elfio\elf_types.hpp(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 [C:\Users\17204\ebpf-for-windows\tools\bpf2c\bpf2c.vcxproj]

and:
C:\Users\17204\ebpf-for-windows\external\ebpf-verifier\external\bpf_conformance\external\elfio\elfio\elf_types.hpp(1,1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 [C:\Users\17204\ebpf-for-windows\tools\bpf2c\bpf2c.vcxproj]

Which says that the file contains ANSI characters that can't be represented in the current code page (I think).

@Alan-Jowett
Copy link
Member

Can you try switching these files from ANSI to UTF-8 and seeing if that fixes it?

@Alan-Jowett
Copy link
Member

Actually, it seems like this might fix it:

diff --git a/.gitattributes b/.gitattributes
index fd2f383b..80a082e9 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -16,3 +16,6 @@

 # Mark generated corpus files as binary.
 **/corpus/**        -text
+
+*.c* text encoding=utf-8
+*.h* text encoding=utf-8
\ No newline at end of file

To try this out:

  1. Make this change in your fork and push to your fork on github.
  2. Clone the repro fresh.

At this point all the files should have the UTF-8 byte order marker (aka BOM) and be UTF-8 encoded.

@Alan-Jowett
Copy link
Member

If this fixes it, let me know and we can spin up a PR with this change.

@dynamic-i
Copy link
Author

If this fixes it, let me know and we can spin up a PR with this change.

Thank you so much for all the time and effort you put into helping me troubleshoot this issue. With your guidance, I was finally able to complete the build successfully. The process finished with 10 warnings but no errors, and everything seems to be functioning as expected now. I really appreciate your support!

@Alan-Jowett
Copy link
Member

Will be fixed by serge1/ELFIO#144

@Alan-Jowett Alan-Jowett modified the milestones: 2410, 2411 Oct 30, 2024
@shankarseal shankarseal modified the milestones: 2411, 2501 Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 triaged Discussed in a triage meeting
Projects
None yet
Development

No branches or pull requests

3 participants