Skip to content

Commit 95a93fe

Browse files
author
Stephen Gutekanst
committed
support Zig cross-compilation
Signed-off-by: Stephen Gutekanst <[email protected]>
1 parent 245fd12 commit 95a93fe

File tree

28 files changed

+420
-136
lines changed

28 files changed

+420
-136
lines changed

CMakeLists.txt

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,21 +107,27 @@ endif()
107107
option(DXC_DISABLE_ALLOCATOR_OVERRIDES "Disable usage of allocator overrides" OFF)
108108
mark_as_advanced(DXC_DISABLE_ALLOCATOR_OVERRIDES)
109109

110-
# adjust link option to enable debugging from kernel mode; not compatible with incremental linking
111-
if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND WIN32 AND NOT CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64EC")
112-
add_link_options(/DEBUGTYPE:CV,FIXUP,PDATA /INCREMENTAL:NO)
113-
endif()
114-
115-
# enable control flow guard
116-
if(WIN32)
117-
add_compile_options(/guard:cf)
118-
add_link_options(/guard:cf)
119-
endif(WIN32)
120-
121-
# Enable CET Shadow Stack
122-
if(WIN32 AND NOT (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*"))
123-
add_link_options(/CETCOMPAT)
124-
endif()
110+
#------------------
111+
# Mach change start
112+
#------------------
113+
# # adjust link option to enable debugging from kernel mode; not compatible with incremental linking
114+
# if(NOT CMAKE_VERSION VERSION_LESS "3.13" AND WIN32 AND NOT CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64EC")
115+
# add_link_options(/DEBUGTYPE:CV,FIXUP,PDATA /INCREMENTAL:NO)
116+
# endif()
117+
118+
# # enable control flow guard
119+
# if(WIN32)
120+
# add_compile_options(/guard:cf)
121+
# add_link_options(/guard:cf)
122+
# endif(WIN32)
123+
124+
# # Enable CET Shadow Stack
125+
# if(WIN32 AND NOT (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM.*"))
126+
# add_link_options(/CETCOMPAT)
127+
# endif()
128+
#------------------
129+
# Mach change end
130+
#------------------
125131

126132
# HLSL Change Ends
127133

@@ -804,9 +810,16 @@ endif()
804810

805811
include(CoverageReport)
806812

807-
# HLSL Change begin - Set default distribution value.
808-
set(LLVM_DISTRIBUTION_COMPONENTS "dxc;dxcompiler;dxc-headers" CACHE STRING "")
809-
# HLSL Change end - Set default distribution value.
813+
#------------------
814+
# Mach change start
815+
#------------------
816+
# # HLSL Change begin - Set default distribution value.
817+
# set(LLVM_DISTRIBUTION_COMPONENTS "dxc;dxcompiler;dxc-headers" CACHE STRING "")
818+
# # HLSL Change end - Set default distribution value.
819+
set(LLVM_DISTRIBUTION_COMPONENTS "dxcompiler;dxc-headers" CACHE STRING "")
820+
#------------------
821+
# Mach change end
822+
#------------------
810823

811824
# This must be at the end of the LLVM root CMakeLists file because it must run
812825
# after all targets are created.

cmake/modules/AddLLVM.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ function(llvm_update_compile_flags name)
1616
endif()
1717
else()
1818
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
19-
list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
19+
#------------------
20+
# Mach change start
21+
#------------------
22+
# list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
23+
#------------------
24+
# Mach change end
25+
#------------------
2026
elseif(MSVC)
2127
list(APPEND LLVM_COMPILE_DEFINITIONS _HAS_EXCEPTIONS=0)
2228
list(APPEND LLVM_COMPILE_FLAGS "/EHs-c-")

external/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,13 @@ if (${ENABLE_SPIRV_CODEGEN})
8181
# Avoid exception handling warning from MSVC.
8282
# This add_compile_options() will only affect the current directory and its subdirectories.
8383
if (WIN32)
84-
add_compile_options(/EHs)
84+
#------------------
85+
# Mach change start
86+
#------------------
87+
# add_compile_options(/EHs)
88+
#------------------
89+
# Mach change end
90+
#------------------
8591
else(WIN32)
8692
# Disable all warnings in subproject RE2
8793
add_compile_options(-w)

include/dxc/Tracing/CMakeLists.txt

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,53 @@
44

55
# Create the header in a temporary file and only update when necessary,
66
# to avoid invalidating targets that depend on it.
7+
#------------------
8+
# Mach change start
9+
#------------------
10+
# add_custom_command(
11+
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
12+
# COMMAND mc -r ${CMAKE_CURRENT_BINARY_DIR} -h ${CMAKE_CURRENT_BINARY_DIR} -p DxcEtw_ -um -z tmpdxcetw ${CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man
13+
# DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man
14+
# COMMENT "Building instrumentation manifest ..."
15+
# )
716
add_custom_command(
817
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
9-
COMMAND mc -r ${CMAKE_CURRENT_BINARY_DIR} -h ${CMAKE_CURRENT_BINARY_DIR} -p DxcEtw_ -um -z tmpdxcetw ${CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man
18+
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
1019
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dxcetw.man
1120
COMMENT "Building instrumentation manifest ..."
1221
)
22+
#------------------
23+
# Mach change end
24+
#------------------
25+
#------------------
26+
# Mach change start
27+
#------------------
28+
# add_custom_command(
29+
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h
30+
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
31+
# ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
32+
# ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h
33+
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
34+
# ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.rc
35+
# ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.rc
36+
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
37+
# ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetwTEMP.bin
38+
# ${CMAKE_CURRENT_BINARY_DIR}/dxcetwTEMP.bin
39+
# COMMAND ${CMAKE_COMMAND} -E copy_if_different
40+
# ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw_MSG00001.bin
41+
# ${CMAKE_CURRENT_BINARY_DIR}/MSG00001.bin
42+
# DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
43+
# COMMENT "Updating instrumentation manifest ..."
44+
# )
1345
add_custom_command(
1446
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h
15-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
16-
${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
17-
${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h
18-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
19-
${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.rc
20-
${CMAKE_CURRENT_BINARY_DIR}/dxcetw.rc
21-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
22-
${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetwTEMP.bin
23-
${CMAKE_CURRENT_BINARY_DIR}/dxcetwTEMP.bin
24-
COMMAND ${CMAKE_COMMAND} -E copy_if_different
25-
${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw_MSG00001.bin
26-
${CMAKE_CURRENT_BINARY_DIR}/MSG00001.bin
47+
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h
2748
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/tmpdxcetw.h
2849
COMMENT "Updating instrumentation manifest ..."
2950
)
51+
#------------------
52+
# Mach change end
53+
#------------------
3054

3155
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dxcetw.h PROPERTIES GENERATED 1)
3256
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/dxcetw.rc PROPERTIES GENERATED 1)

include/llvm/Support/Host.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
#include <endian.h>
2121
#else
2222
#if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
23-
#include <machine/endian.h>
23+
//#------------------
24+
//# Mach change start
25+
//#------------------
26+
// #include <machine/endian.h>
27+
//#------------------
28+
//# Mach change end
29+
//#------------------
2430
#endif
2531
#endif
2632

lib/CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ add_subdirectory(DXIL) # HLSL Change
2727
add_subdirectory(DxilContainer) # HLSL Change
2828
add_subdirectory(DxilPdbInfo) # HLSL Change
2929
add_subdirectory(DxilPIXPasses) # HLSL Change
30-
add_subdirectory(DxilDia) # HLSL Change
30+
#------------------
31+
# Mach change start
32+
#------------------
33+
# add_subdirectory(DxilDia) # HLSL Change
34+
#------------------
35+
# Mach change end
36+
#------------------
3137
add_subdirectory(DxilRootSignature) # HLSL Change
3238
add_subdirectory(DxcBindingTable) # HLSL Change
3339
add_subdirectory(DxrFallback) # HLSL Change

lib/DxilDia/DxilDiaDataSource.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ getMemBufferFromStream(IStream *pStream, std::vector<char> &DataContainer,
5959

6060
STATSTG statstg;
6161
IFT(pStream->Stat(&statstg, STATFLAG_NONAME));
62-
size_t size = statstg.cbSize.LowPart;
62+
//#------------------
63+
//# Mach change start
64+
//#------------------
65+
// size_t size = statstg.cbSize.LowPart;
66+
size_t size = statstg.cbSize.u.LowPart;
67+
//#------------------
68+
//# Mach change end
69+
//#------------------
6370

6471
DataContainer.resize(size);
6572
ULONG read;

lib/HLSL/DxilContainerReflection.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,13 @@ void CShaderReflectionConstantBuffer::Initialize(
14781478
}
14791479

14801480
static unsigned CalcResTypeSize(DxilModule &M, DxilResource &R) {
1481-
UNREFERENCED_PARAMETER(M);
1481+
//#------------------
1482+
//# Mach change start
1483+
//#------------------
1484+
// UNREFERENCED_PARAMETER(M);
1485+
//#------------------
1486+
//# Mach change end
1487+
//#------------------
14821488
Type *Ty = R.GetHLSLType()->getPointerElementType();
14831489
if (R.IsStructuredBuffer()) {
14841490
Ty = dxilutil::StripArrayTypes(Ty);

lib/Support/CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,14 @@ add_llvm_library(LLVMSupport
145145
)
146146

147147
set_property(TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS "${system_libs}")
148-
if(WIN32)
149-
set_property(TARGET LLVMSupport PROPERTY COMPILE_FLAGS /EHsc )
150-
endif(WIN32)
148+
#------------------
149+
# Mach change start
150+
#------------------
151+
# if(WIN32)
152+
# set_property(TARGET LLVMSupport PROPERTY COMPILE_FLAGS /EHsc )
153+
# endif(WIN32)
154+
#------------------
155+
# Mach change end
156+
#------------------
151157

152158
target_link_libraries(LLVMSupport PUBLIC LLVMMSSupport) # HLSL Change

lib/Support/MSFileSystemBasic.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,16 @@ static HRESULT CopyStatStg(const STATSTG *statStg,
7070
lpFindFileData->ftCreationTime = statStg->ctime;
7171
lpFindFileData->ftLastAccessTime = statStg->atime;
7272
lpFindFileData->ftLastWriteTime = statStg->mtime;
73-
lpFindFileData->nFileSizeLow = statStg->cbSize.LowPart;
74-
lpFindFileData->nFileSizeHigh = statStg->cbSize.HighPart;
73+
//#------------------
74+
//# Mach change start
75+
//#------------------
76+
// lpFindFileData->nFileSizeLow = statStg->cbSize.LowPart;
77+
// lpFindFileData->nFileSizeHigh = statStg->cbSize.HighPart;
78+
lpFindFileData->nFileSizeLow = statStg->cbSize.u.LowPart;
79+
lpFindFileData->nFileSizeHigh = statStg->cbSize.u.HighPart;
80+
//#------------------
81+
//# Mach change end
82+
//#------------------
7583
if (statStg->pwcsName != nullptr) {
7684
IFC(StringCchCopyW(lpFindFileData->cFileName,
7785
_countof(lpFindFileData->cFileName), statStg->pwcsName));
@@ -842,8 +850,16 @@ long MSFileSystemForIface::lseek(int fd, long offset, int origin) throw() {
842850
}
843851

844852
GetHandleStream(GetHandleForFD(fd), &stream);
845-
li.HighPart = 0;
846-
li.LowPart = offset;
853+
//#------------------
854+
//# Mach change start
855+
//#------------------
856+
// li.HighPart = 0;
857+
// li.LowPart = offset;
858+
li.u.HighPart = 0;
859+
li.u.LowPart = offset;
860+
//#------------------
861+
//# Mach change end
862+
//#------------------
847863
IFC(stream->Seek(li, origin, &uli));
848864

849865
Cleanup:
@@ -852,12 +868,26 @@ long MSFileSystemForIface::lseek(int fd, long offset, int origin) throw() {
852868
return -1;
853869
}
854870

855-
if (uli.HighPart > 0) {
871+
//#------------------
872+
//# Mach change start
873+
//#------------------
874+
// if (uli.HighPart > 0) {
875+
if (uli.u.HighPart > 0) {
876+
//#------------------
877+
//# Mach change end
878+
//#------------------
856879
errno = EOVERFLOW;
857880
return -1;
858881
}
859882

860-
return uli.LowPart;
883+
//#------------------
884+
//# Mach change start
885+
//#------------------
886+
// return uli.LowPart;
887+
return uli.u.LowPart;
888+
//#------------------
889+
//# Mach change end
890+
//#------------------
861891
}
862892

863893
int MSFileSystemForIface::setmode(int fd, int mode) throw() { return 0; }

0 commit comments

Comments
 (0)