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

Build ICD Loader using Clang on Windows #177

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

MathiasMagnus
Copy link
Contributor

This work was born out of grievance of reproducing non-MSVC specific warnings, errors and linker failures on the OpenCL-Layers project on Windows without having to fire up containers or building-installing under WSL. (At a larger scale, using Clang-derivates on Windows such as ComputeCpp often blow up the console with warnings if the device compiler sees the OpenCL headers.)

Beside touching up the source code to fix warnings, two major things were implemented in CI:

  • Extend Windows CI coverage to using clang-cl.exe, the MSVC-like CLI of Clang.
    • This was done while porting CI definition to PowerShell and doing better error checking
    • Improving error checking uncovered a lot of shortcomings of the previous CI definition (lots of errors went unnoticed)
  • Simplify Linux CI definition and accelerate it by using the same build image as the SDK does

Note: Overall I'm fairly unsatisfied how much code getting this range of CI coverage takes. (Linux/Mac/Win, GCC/Clang/MSVC, C99/11/17, with/without lang exts, Debug/Release) CI is doing the very same thing, but with 2-3 lines of difference for every test matrix elem. I'll be thinking about how to achieve the same coverage with a unified script and much less duplication of code. I would like the scripts to be much simpler.

@@ -270,7 +270,7 @@ void *khrIcdOsLibraryLoad(const char *libraryName)
}
if (!hTemp)
{
KHR_ICD_TRACE("Failed to load driver. Windows error code is %d.\n", GetLastError());
KHR_ICD_TRACE("Failed to load driver. Windows error code is %lu.\n", GetLastError());
Copy link
Contributor

@Kerilk Kerilk May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use %"PRIuDW" here instead of %lu.

Suggested change
KHR_ICD_TRACE("Failed to load driver. Windows error code is %lu.\n", GetLastError());
KHR_ICD_TRACE("Failed to load driver. Windows error code is %"PRIuDW".\n", GetLastError());

Comment on lines -139 to -143
cmake-latest:
runs-on: ${{ matrix.OS }}
strategy:
matrix:
OS : [ubuntu-20.04]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu 20.04 is not tested anymore after those changes. Is this intended?

Comment on lines +285 to +297
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( push )
#pragma warning( disable : 4152 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#endif
return GetProcAddress( (HMODULE)library, functionName);
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
Copy link
Contributor

@Kerilk Kerilk May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try using:

Suggested change
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( push )
#pragma warning( disable : 4152 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#endif
return GetProcAddress( (HMODULE)library, functionName);
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
return (void *)(intptr_t)GetProcAddress( (HMODULE)library, functionName);

here. It would be consistent with what we do at other place in the code. You may require an additional include.

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.

2 participants