Skip to content
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

Windows executables: only load imported DLLs from System32 #85227

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ add_subdirectory(minipal)

if(CLR_CMAKE_TARGET_WIN32)
add_subdirectory(gc/sample)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

#-------------------------------------
Expand Down
11 changes: 1 addition & 10 deletions src/coreclr/build-runtime.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -414,16 +414,7 @@ if %__BuildNative% EQU 1 (
goto ExitWithCode
)

if %__EnforcePgo% EQU 1 (
set PgoCheckCmd="!PYTHON!" "!__ProjectDir!\scripts\pgocheck.py" "!__BinDir!\coreclr.dll" "!__BinDir!\clrjit.dll"
echo !PgoCheckCmd!
!PgoCheckCmd!
if not !errorlevel! == 0 (
set __exitCode=!errorlevel!
echo !__ErrMsgPrefix!!__MsgPrefix!Error: Error running pgocheck.py on coreclr and clrjit.
goto ExitWithCode
)
)
@REM DO NOT COMMIT: skip PGO check

:SkipNativeBuild
REM } Scope environment changes end
Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ function(add_pgo TargetName)
message("Cannot use PGO optimization built with Ninja from MSBuild. Re-run build with Ninja to apply PGO information")
else(NOT EXISTS ${ProfilePath})
if(CLR_CMAKE_HOST_WIN32)
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /LTCG /USEPROFILE:PGD=\"${ProfilePath}\"")
set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /USEPROFILE:PGD=\"${ProfilePath}\"")
add_compile_definitions(WITH_NATIVE_PGO)
# DO NOT COMMIT: temporarily disable PGO, since the build fails with: "LINK : fatal error LNK1268: inconsistent option 'DEPENDENTLOADFLAG:0x800' specified with /USEPROFILE but not with /GENPROFILE"
# set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELEASE " /LTCG /USEPROFILE:PGD=\"${ProfilePath}\"")
# set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /USEPROFILE:PGD=\"${ProfilePath}\"")
# add_compile_definitions(WITH_NATIVE_PGO)
else(CLR_CMAKE_HOST_WIN32)
if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6))
Expand Down
5 changes: 4 additions & 1 deletion src/native/corehost/apphost/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ include(../../exe.cmake)

add_definitions(-DFEATURE_APPHOST=1)

# Disable manifest generation into the file .exe on Windows
if(CLR_CMAKE_TARGET_WIN32)
# Disable manifest generation into the file .exe on Windows
set_property(TARGET ${PROJECT_NAME} PROPERTY
LINK_FLAGS "/MANIFEST:NO"
)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

# Specify non-default Windows libs to be used for Arm/Arm64 builds
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/apphost/static/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ if(CLR_CMAKE_TARGET_WIN32)

# Delay load libraries required for WinRT as that is not supported on all platforms
add_linker_flag("/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll")

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

if(CLR_CMAKE_TARGET_WIN32)
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/comhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ if (CLR_CMAKE_TARGET_WIN32)
list(APPEND WINLIBS Ole32.lib OleAut32.lib)
endif()

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")

target_link_libraries(comhost PRIVATE ${WINLIBS})
endif()

Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/dotnet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
dotnet.manifest
dotnet.rc)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

list(APPEND SOURCES
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/fxr/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ include(../files.cmake)
if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
hostfxr.def)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
else(CLR_CMAKE_TARGET_WIN32)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hostfxr_unixexports.src)
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/hostfxr.exports)
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/hostpolicy/standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ include(../files.cmake)
if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
hostpolicy.def)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
else(CLR_CMAKE_TARGET_WIN32)
set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hostpolicy_unixexports.src)
set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/hostpolicy.exports)
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/ijwhost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ set(SOURCES
if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
Exports.def)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

set (ASM_HELPERS_SOURCES
Expand Down
3 changes: 3 additions & 0 deletions src/native/corehost/nethost/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ set(SOURCES
if(CLR_CMAKE_TARGET_WIN32)
list(APPEND SOURCES
Exports.def)

# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

include(../lib.cmake)
Expand Down
5 changes: 5 additions & 0 deletions src/native/libs/System.IO.Compression.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ set(NATIVECOMPRESSION_SOURCES
pal_zlib.c
)

if(CLR_CMAKE_TARGET_WIN32)
# Load all imported DLLs from the System32 directory.
add_linker_flag("/DEPENDENTLOADFLAG:0x800")
endif()

if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI)

if (CLR_CMAKE_USE_SYSTEM_BROTLI)
Expand Down