Skip to content

Commit

Permalink
Windows compile with /MT and link using Hybrid CRT (Xilinx#8551)
Browse files Browse the repository at this point in the history
This changes how XRT links on windows and it switches the external
dependency folder to c:/Xilinx/XRT/ext.new with corresponding build
changes to Boost.
  • Loading branch information
stsoe authored Oct 21, 2024
1 parent 950bfe5 commit 24264b2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 14 deletions.
4 changes: 2 additions & 2 deletions build/build-win22.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ CORE=`grep -c ^processor /proc/cpuinfo`

CMAKE="/mnt/c/Program Files/CMake/bin/cmake.exe"
XRT=/mnt/c/Xilinx/xrt
BOOST=$XRT/ext
KHRONOS=$XRT/ext
BOOST=$XRT/ext.new
KHRONOS=$XRT/ext.new

BOOST=$(sed -e 's|/mnt/\([A-Za-z]\)/\(.*\)|\1:/\2|' -e 's|/|\\|g' <<< $BOOST)
KHRONOS=$(sed -e 's|/mnt/\([A-Za-z]\)/\(.*\)|\1:/\2|' -e 's|/|\\|g' <<< $KHRONOS)
Expand Down
2 changes: 1 addition & 1 deletion build/build22.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set BUILDDIR=%SCRIPTDIR%

set DEBUG=1
set RELEASE=1
set EXT_DIR=C:/Xilinx/XRT/ext
set EXT_DIR=C:/Xilinx/XRT/ext.new
set CREATE_PACKAGE=0
set CMAKEFLAGS=
set NOCMAKE=0
Expand Down
28 changes: 17 additions & 11 deletions src/CMake/nativeWin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,24 @@ add_compile_definitions("BOOST_BIND_GLOBAL_PLACEHOLDERS")
add_compile_definitions("_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING")

if (MSVC)
add_compile_options(
/Zc:__cplusplus
/Zi # generate pdb files even in release mode
/sdl # enable security checks
/Qspectre # compile with the Spectre mitigations switch
/ZH:SHA_256 # enable secure source code hashing
/guard:cf # enable compiler control guard feature (CFG) to prevent attackers from redirecting execution to unsafe locations
# Static linking with the CRT
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

add_compile_options(
/MT$<$<CONFIG:Debug>:d> # static linking with the CRT
/Zc:__cplusplus
/Zi # generate pdb files even in release mode
/sdl # enable security checks
/Qspectre # compile with the Spectre mitigations switch
/ZH:SHA_256 # enable secure source code hashing
/guard:cf # enable compiler control guard feature (CFG) to prevent attackers from redirecting execution to unsafe locations
)
add_link_options(
/DEBUG # instruct linker to create debugging info
/guard:cf # enable linker control guard feature (CFG) to prevent attackers from redirecting execution to unsafe locations
/CETCOMPAT # enable Control-flow Enforcement Technology (CET) Shadow Stack mitigation
add_link_options(
/NODEFAULTLIB:libucrt$<$<CONFIG:Debug>:d>.lib # Hybrid CRT
/DEFAULTLIB:ucrt$<$<CONFIG:Debug>:d>.lib # Hybrid CRT
/DEBUG # instruct linker to create debugging info
/guard:cf # enable linker control guard feature (CFG) to prevent attackers from redirecting execution to unsafe locations
/CETCOMPAT # enable Control-flow Enforcement Technology (CET) Shadow Stack mitigation
)
endif()

Expand Down

0 comments on commit 24264b2

Please sign in to comment.