microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
2.98k stars 666 forks source link

Conflict with DirectX-Headers #5079

Open valeriydymura opened 1 year ago

valeriydymura commented 1 year ago

Conflict with DirectX-Headers

It's impossible to use DXC with DirectX-Headers on Linux.

Functional impact

I can't compile project on Linux.

Minimal repro steps

  1. Download DXC release(https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.7.2212.1) and DirectX-Headers(https://github.com/microsoft/DirectX-Headers/releases/tag/v1.608.2)
  2. Create CMake project, add DirectX-Headers as subproject and link to DXC
  3. Create simple file:
    
    #include <unknwn.h>
    #include <directx/d3d12shader.h>
    #include <dxc/dxcapi.h>

int main() { return 0; }

4. Try to compile with clang(version 15.0.7)

### Expected result
It should be possible to use DXC with DirectX-Headers

### Actual result
It doesn't compile.

### Further technical details
Log:

In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:361:14: error: typedef redefinition with different types ('BYTE' (aka 'unsigned char') vs 'char') typedef BYTE BOOLEAN; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:38:14: note: previous definition is here typedef char BOOLEAN; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:364:14: error: typedef redefinition with different types ('bool' vs 'uint32_t' (aka 'unsigned int')) typedef bool BOOL; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:23:46: note: previous definition is here typedef uint32_t UINT32, UINT, ULONG, DWORD, BOOL, WINBOOL; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:368:14: error: typedef redefinition with different types ('long' vs 'int32_t' (aka 'int')) typedef long LONG; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:24:29: note: previous definition is here typedef int32_t INT32, INT, LONG; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:370:23: error: typedef redefinition with different types ('unsigned long' vs 'uint32_t' (aka 'unsigned int')) typedef unsigned long ULONG; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:23:32: note: previous definition is here typedef uint32_t UINT32, UINT, ULONG, DWORD, BOOL, WINBOOL; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:371:19: error: typedef redefinition with different types ('long long' vs 'int64_t' (aka 'long')) typedef long long LONGLONG; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:41:17: note: previous definition is here typedef int64_t LONGLONG, PLONGLONG; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:372:19: error: typedef redefinition with different types ('long long' vs 'int64_t' (aka 'long')) typedef long long LONG_PTR; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:42:17: note: previous definition is here typedef int64_t LONG_PTR, PLONG_PTR; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:373:28: error: typedef redefinition with different types ('unsigned long long' vs 'uint64_t' (aka 'unsigned long')) typedef unsigned long long ULONG_PTR; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:47:18: note: previous definition is here typedef uint64_t ULONG_PTR, *PULONG_PTR; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:374:28: error: typedef redefinition with different types ('unsigned long long' vs 'uint64_t' (aka 'unsigned long')) typedef unsigned long long ULONGLONG; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:39:18: note: previous definition is here typedef uint64_t ULONGLONG; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:434:16: error: redefinition of '_GUID' typedef struct _GUID ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:101:16: note: previous definition is here typedef struct _GUID { ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:448:21: error: 'const' qualifier may not be applied to a reference typedef const GUID &REFGUID; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:122:17: note: expanded from macro 'REFGUID'

define REFGUID const GUID &

            ^

In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:448:21: error: typedef redefinition with different types ('const GUID &' (aka 'const _GUID &') vs 'struct _GUID') /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:122:23: note: expanded from macro 'REFGUID'

define REFGUID const GUID &

                  ^

/mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:106:3: note: previous definition is here } GUID; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:448:21: error: expected ';' after top level declarator typedef const GUID &REFGUID; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:122:28: note: expanded from macro 'REFGUID'

define REFGUID const GUID &

                       ^

In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:449:21: error: 'const' qualifier may not be applied to a reference typedef const GUID &REFCLSID; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:124:18: note: expanded from macro 'REFCLSID'

define REFCLSID const IID &

             ^

In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:449:21: error: typedef redefinition with different types ('const GUID &' (aka 'const _GUID &') vs 'GUID' (aka '_GUID')) /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:124:24: note: expanded from macro 'REFCLSID'

define REFCLSID const IID &

                   ^

/mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:118:14: note: previous definition is here typedef GUID IID; ^ In file included from /home/keeper/test/main.cpp:2: In file included from /mnt/project/ThirdParty/dxc/include/dxc/dxcapi.h:37: /mnt/project/ThirdParty/dxc/include/dxc/WinAdapter.h:449:21: error: expected ';' after top level declarator typedef const GUID &REFCLSID; ^ /mnt/project/ThirdParty/d3d12/include/wsl/stubs/basetsd.h:124:28: note: expanded from macro 'REFCLSID'

define REFCLSID const IID &

                       ^

fatal error: too many errors emitted, stopping now [-ferror-limit=] 17 warnings and 20 errors generated. ninja: build stopped: subcommand failed.

LAKostis commented 1 year ago

Stumble on this too. Looks like dxc doesn't use latest version of dx headers but specific commit:

$ git submodule update
Cloning into '/home/lakostis/local/src/git/work/DirectXShaderCompiler/external/DirectX-Headers'...
Cloning into '/home/lakostis/local/src/git/work/DirectXShaderCompiler/external/SPIRV-Headers'...
Cloning into '/home/lakostis/local/src/git/work/DirectXShaderCompiler/external/SPIRV-Tools'...
Cloning into '/home/lakostis/local/src/git/work/DirectXShaderCompiler/external/effcee'...
Cloning into '/home/lakostis/local/src/git/work/DirectXShaderCompiler/external/re2'...
Submodule path 'external/DirectX-Headers': checked out '980971e835876dc0cde415e8f9bc646e64667bf7'
...

And commit 980971e835876dc0cde415e8f9bc646e64667bf7 is linked to version 1.600.10.

LAKostis commented 3 months ago

Hello!

Could you find some time to upgrade DirectX-Headers submodule to more recent version? It's very confusing to figure out this every time during the build that despite the most recent DirectX SDK is needed to make dxc work the headers used in build of dxc are 2years old.