Skip to content

Commit

Permalink
[Build] add kernel_link_options for windows
Browse files Browse the repository at this point in the history
Add msvc version of kernel_link_options.

For pytorch#4661
  • Loading branch information
python3kgae committed Aug 23, 2024
1 parent 11e8ed3 commit e6a65b4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions build/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,21 @@ function(macos_kernel_link_options target_name)
)
endfunction()

# Same as kernel_link_options but it's for MSVC linker
function(msvc_kernel_link_options target_name)
target_link_options(
${target_name} INTERFACE
"SHELL:LINKER:/WHOLEARCHIVE:$<TARGET_FILE:${target_name}>"
)
endfunction()

# Ensure that the load-time constructor functions run. By default, the linker
# would remove them since there are no other references to them.
function(target_link_options_shared_lib target_name)
if(APPLE)
macos_kernel_link_options(${target_name})
elseif(MSVC)
msvc_kernel_link_options(${target_name})
else()
kernel_link_options(${target_name})
endif()
Expand Down

0 comments on commit e6a65b4

Please sign in to comment.