Skip to content

Make dxcompiler target build with ClangCL 19.1.1 #7351

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

YasInvolved
Copy link

@YasInvolved YasInvolved commented Apr 15, 2025

Fixed clang 19.1.1 (Visual Studio) build. There were issues with function type casts after invoking ::GetProcAddress to get a function pointer (FARPROC -> desired type).

Copy link
Contributor

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff ea3d8466d807fccbee1a3dc16d4b15bafd12d4fe 155a31a1b711e2106a5930f9663b7cf03878a1c8 -- include/dxc/Support/dxcapi.use.h include/llvm/CodeGen/SchedulerRegistry.h lib/IR/Core.cpp lib/MSSupport/MSFileSystemImpl.cpp
View the diff from clang-format here.
diff --git a/include/dxc/Support/dxcapi.use.h b/include/dxc/Support/dxcapi.use.h
index 747a7ca2..dee10503 100644
--- a/include/dxc/Support/dxcapi.use.h
+++ b/include/dxc/Support/dxcapi.use.h
@@ -34,7 +34,8 @@ protected:
     m_dll = LoadLibraryA(dllName);
     if (m_dll == nullptr)
       return HRESULT_FROM_WIN32(GetLastError());
-    m_createFn = reinterpret_cast<DxcCreateInstanceProc>(reinterpret_cast<void *>(GetProcAddress(m_dll, fnName)));
+    m_createFn = reinterpret_cast<DxcCreateInstanceProc>(
+        reinterpret_cast<void *>(GetProcAddress(m_dll, fnName)));
 
     if (m_createFn == nullptr) {
       HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
@@ -64,7 +65,8 @@ protected:
       fnName2[s] = '2';
       fnName2[s + 1] = '\0';
 #ifdef _WIN32
-      m_createFn2 = reinterpret_cast<DxcCreateInstance2Proc>(reinterpret_cast<void *>(GetProcAddress(m_dll, fnName2)));
+      m_createFn2 = reinterpret_cast<DxcCreateInstance2Proc>(
+          reinterpret_cast<void *>(GetProcAddress(m_dll, fnName2)));
 #else
       m_createFn2 = (DxcCreateInstance2Proc)::dlsym(m_dll, fnName2);
 #endif
diff --git a/include/llvm/CodeGen/SchedulerRegistry.h b/include/llvm/CodeGen/SchedulerRegistry.h
index 04d24412..5e26252d 100644
--- a/include/llvm/CodeGen/SchedulerRegistry.h
+++ b/include/llvm/CodeGen/SchedulerRegistry.h
@@ -40,8 +40,11 @@ public:
   static MachinePassRegistry Registry;
 
   RegisterScheduler(const char *N, const char *D, FunctionPassCtor C)
-      : MachinePassRegistryNode(N, D, reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)))
-  { Registry.Add(this); }
+      : MachinePassRegistryNode(
+            N, D,
+            reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C))) {
+    Registry.Add(this);
+  }
   ~RegisterScheduler() { Registry.Remove(this); }
 
 
@@ -54,10 +57,12 @@ public:
     return (RegisterScheduler *)Registry.getList();
   }
   static FunctionPassCtor getDefault() {
-    return reinterpret_cast<FunctionPassCtor>(reinterpret_cast<void *>(Registry.getDefault()));
+    return reinterpret_cast<FunctionPassCtor>(
+        reinterpret_cast<void *>(Registry.getDefault()));
   }
   static void setDefault(FunctionPassCtor C) {
-    Registry.setDefault(reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)));
+    Registry.setDefault(
+        reinterpret_cast<MachinePassCtor>(reinterpret_cast<void *>(C)));
   }
   static void setListener(MachinePassRegistryListener *L) {
     Registry.setListener(L);
diff --git a/lib/MSSupport/MSFileSystemImpl.cpp b/lib/MSSupport/MSFileSystemImpl.cpp
index ca734f7b..e75019be 100644
--- a/lib/MSSupport/MSFileSystemImpl.cpp
+++ b/lib/MSSupport/MSFileSystemImpl.cpp
@@ -323,8 +323,7 @@ typedef BOOLEAN(WINAPI *PtrCreateSymbolicLinkW)(
 
 PtrCreateSymbolicLinkW create_symbolic_link_api =
     PtrCreateSymbolicLinkW(reinterpret_cast<void *>(::GetProcAddress(
-        ::GetModuleHandleW(L"Kernel32.dll"),
-                                            "CreateSymbolicLinkW")));
+        ::GetModuleHandleW(L"Kernel32.dll"), "CreateSymbolicLinkW")));
 } // namespace
 #endif
 
  • Check this box to apply formatting changes to this branch.

@YasInvolved
Copy link
Author

@microsoft-github-policy-service agree [company="Devsh Graphics Programming Sp. z O.O."]

@YasInvolved
Copy link
Author

YasInvolved commented Apr 15, 2025

@microsoft-github-policy-service agree company="Devsh Graphics Programming Sp. z O.O."

@github-project-automation github-project-automation bot moved this from New to Done in HLSL Roadmap Apr 17, 2025
@YasInvolved YasInvolved reopened this Apr 17, 2025
@devshgraphicsprogramming

Fixed clang 19.1.1 (Visual Studio) build. There were issues with function type casts after invoking ::GetProcAddress to get a function pointer (FARPROC -> desired type).

this is so that DXC can compile on Clang without -fpermissive

@AnastaZIuk
Copy link

AnastaZIuk commented Apr 17, 2025

and logs with what it fixed

lib\MSSupport\MSFileSystemImpl.cpp(325,5): error : cast from 'FARPROC' (aka 'long long (*)()') to 'PtrCreateSymbolicLinkW' (aka 'unsigned char (*)(const wchar_t *, const wchar_t *, unsigned long)') converts to incompatible function type [-Werror,-Wcast-function-type-mismatch]

@YasInvolved YasInvolved changed the title Make dxcompiler target build with Clang 19.1.1 Make dxcompiler target build with ClangCL 19.1.1 Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants