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

statically link gc_pal on windows #77468

Merged
merged 2 commits into from
Oct 26, 2022
Merged
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: 1 addition & 2 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ set_property(TARGET coreclr APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})

if (CLR_CMAKE_HOST_UNIX)
set(LIB_UNWINDER unwinder_wks)
set(GC_PAL gc_unix)
endif (CLR_CMAKE_HOST_UNIX)

# IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is
Expand All @@ -109,7 +108,7 @@ set(CORECLR_LIBRARIES
System.Globalization.Native-Static
interop
coreclrminipal
${GC_PAL}
gc_pal
)

if(CLR_CMAKE_TARGET_WIN32)
Expand Down
10 changes: 4 additions & 6 deletions src/coreclr/gc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ set(GC_SOURCES
if(CLR_CMAKE_HOST_UNIX)
add_subdirectory(unix)
include(unix/configure.cmake)
set (GC_SOURCES
${GC_SOURCES})
else()
add_subdirectory(windows)
set (GC_SOURCES
${GC_SOURCES}
windows/gcenv.windows.cpp
windows/Native.rc)
endif(CLR_CMAKE_HOST_UNIX)

Expand Down Expand Up @@ -98,9 +96,9 @@ if(CLR_CMAKE_HOST_WIN32)
${STATIC_MT_VCRT_LIB}
kernel32.lib
advapi32.lib)
else()
set (GC_LINK_LIBRARIES gc_unix)
endif(CLR_CMAKE_HOST_WIN32)
endif(CLR_CMAKE_HOST_WIN32)

set (GC_LINK_LIBRARIES ${GC_LINK_LIBRARIES} gc_pal)

list(APPEND GC_SOURCES ${GC_HEADERS})

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/unix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ set(GC_PAL_SOURCES
events.cpp
cgroup.cpp)

add_library(gc_unix STATIC ${GC_PAL_SOURCES} ${VERSION_FILE_PATH})
add_library(gc_pal STATIC ${GC_PAL_SOURCES} ${VERSION_FILE_PATH})
9 changes: 9 additions & 0 deletions src/coreclr/gc/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("../env")
include_directories("..")

set(GC_PAL_SOURCES
gcenv.windows.cpp
)

add_library(gc_pal STATIC ${GC_PAL_SOURCES})
12 changes: 6 additions & 6 deletions src/coreclr/gc/windows/gcenv.windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <memory>
#include "windows.h"
#include "psapi.h"
#include "env/gcenv.structs.h"
#include "env/gcenv.base.h"
#include "env/gcenv.os.h"
#include "env/gcenv.ee.h"
#include "env/gcenv.windows.inl"
#include "env/volatile.h"
#include "gcenv.structs.h"
#include "gcenv.base.h"
#include "gcenv.os.h"
#include "gcenv.ee.h"
#include "gcenv.windows.inl"
#include "volatile.h"
#include "gcconfig.h"

GCSystemInfo g_SystemInfo;
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_gcAllowVeryLargeObjects, W("gcAllowVeryLargeOb
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCStress, W("GCStress"), 0, "Trigger GCs at regular intervals")
CONFIG_DWORD_INFO(INTERNAL_GcStressOnDirectCalls, W("GcStressOnDirectCalls"), 0, "Whether to trigger a GC on direct calls")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_HeapVerify, W("HeapVerify"), 0, "When set verifies the integrity of the managed heap on entry and exit of each GC")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_GCNumaAware, W("GCNumaAware"), 1, "Specifies if to enable GC NUMA aware")
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_GCCpuGroup, W("GCCpuGroup"), 0, "Specifies if to enable GC to support CPU groups")
RETAIL_CONFIG_STRING_INFO(EXTERNAL_GCName, W("GCName"), "")
/**
Expand Down
25 changes: 0 additions & 25 deletions src/coreclr/inc/utilcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -950,31 +950,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
//
LPVOID ClrVirtualAllocAligned(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect, SIZE_T alignment);

class NumaNodeInfo
{
private:
static BOOL m_enableGCNumaAware;
static uint16_t m_nNodes;
static BOOL InitNumaNodeInfoAPI();

public:
static BOOL CanEnableGCNumaAware();
static void InitNumaNodeInfo();

#if !defined(FEATURE_NATIVEAOT)
public: // functions

static LPVOID VirtualAllocExNuma(HANDLE hProc, LPVOID lpAddr, SIZE_T size,
DWORD allocType, DWORD prot, DWORD node);
#ifdef HOST_WINDOWS
static BOOL GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no);
static bool GetNumaInfo(PUSHORT total_nodes, DWORD* max_procs_per_node);
#else // HOST_WINDOWS
static BOOL GetNumaProcessorNodeEx(USHORT proc_no, PUSHORT node_no);
#endif // HOST_WINDOWS
#endif
};

#ifdef HOST_WINDOWS

struct CPU_Group_Info
Expand Down
28 changes: 0 additions & 28 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3914,34 +3914,6 @@ PALAPI
GetSystemInfo(
OUT LPSYSTEM_INFO lpSystemInfo);

//
// NUMA related APIs
//

PALIMPORT
BOOL
PALAPI
GetNumaHighestNodeNumber(
OUT PULONG HighestNodeNumber
);

PALIMPORT
BOOL
PALAPI
PAL_GetNumaProcessorNode(WORD procNo, WORD* node);

PALIMPORT
LPVOID
PALAPI
VirtualAllocExNuma(
IN HANDLE hProcess,
IN OPTIONAL LPVOID lpAddress,
IN SIZE_T dwSize,
IN DWORD flAllocationType,
IN DWORD flProtect,
IN DWORD nndPreferred
);

PALIMPORT
BOOL
PALAPI
Expand Down
88 changes: 0 additions & 88 deletions src/coreclr/utilcode/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -514,94 +514,6 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr,
}

#ifdef HOST_WINDOWS

//******************************************************************************
// NumaNodeInfo
//******************************************************************************
#if !defined(FEATURE_NATIVEAOT)

/*static*/ LPVOID NumaNodeInfo::VirtualAllocExNuma(HANDLE hProc, LPVOID lpAddr, SIZE_T dwSize,
DWORD allocType, DWORD prot, DWORD node)
{
return ::VirtualAllocExNuma(hProc, lpAddr, dwSize, allocType, prot, node);
}

/*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(PPROCESSOR_NUMBER proc_no, PUSHORT node_no)
{
return ::GetNumaProcessorNodeEx(proc_no, node_no);
}
/*static*/ bool NumaNodeInfo::GetNumaInfo(PUSHORT total_nodes, DWORD* max_procs_per_node)
{
if (m_enableGCNumaAware)
{
DWORD currentProcsOnNode = 0;
for (uint16_t i = 0; i < m_nNodes; i++)
{
GROUP_AFFINITY processorMask;
if (GetNumaNodeProcessorMaskEx(i, &processorMask))
{
DWORD procsOnNode = 0;
uintptr_t mask = (uintptr_t)processorMask.Mask;
while (mask)
{
procsOnNode++;
mask &= mask - 1;
}

currentProcsOnNode = max(currentProcsOnNode, procsOnNode);
}
}

*max_procs_per_node = currentProcsOnNode;
*total_nodes = m_nNodes;
return true;
}

return false;
}
#else // HOST_WINDOWS
/*static*/ BOOL NumaNodeInfo::GetNumaProcessorNodeEx(USHORT proc_no, PUSHORT node_no)
{
return PAL_GetNumaProcessorNode(proc_no, node_no);
jkotas marked this conversation as resolved.
Show resolved Hide resolved
}
#endif // HOST_WINDOWS
#endif

#ifdef HOST_WINDOWS
/*static*/ BOOL NumaNodeInfo::m_enableGCNumaAware = FALSE;
/*static*/ uint16_t NumaNodeInfo::m_nNodes = 0;
/*static*/ BOOL NumaNodeInfo::InitNumaNodeInfoAPI()
{
#if !defined(FEATURE_NATIVEAOT)
//check for numa support if multiple heaps are used
ULONG highest = 0;

if (CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_GCNumaAware) == 0)
mangod9 marked this conversation as resolved.
Show resolved Hide resolved
return FALSE;

// fail to get the highest numa node number
if (!::GetNumaHighestNodeNumber(&highest) || (highest == 0))
return FALSE;

m_nNodes = (USHORT)(highest + 1);

return TRUE;
#else
return FALSE;
#endif
}

/*static*/ BOOL NumaNodeInfo::CanEnableGCNumaAware()
{
return m_enableGCNumaAware;
}

/*static*/ void NumaNodeInfo::InitNumaNodeInfo()
{
m_enableGCNumaAware = InitNumaNodeInfoAPI();
}


//******************************************************************************
// CPUGroupInfo
//******************************************************************************
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -503,13 +503,6 @@ if (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)
)
endif (CLR_CMAKE_TARGET_ARCH_AMD64 AND CLR_CMAKE_TARGET_WIN32)

if (CLR_CMAKE_TARGET_WIN32)
set ( GC_SOURCES_WKS
${GC_SOURCES_WKS}
gcenv.os.cpp
)
endif (CLR_CMAKE_TARGET_WIN32)

set(GC_HEADERS_WKS
${GC_HEADERS_DAC_AND_WKS_COMMON}
../gc/gceventstatus.h
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/vm/ceemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,6 @@ void EEStartupHelper()
#ifdef HOST_WINDOWS
InitializeCrashDump();


// Initialize Numa and CPU group information
// Need to do this as early as possible. Used by creating object handle
// table inside Ref_Initialization() before GC is initialized.
NumaNodeInfo::InitNumaNodeInfo();
#endif // HOST_WINDOWS
#ifndef TARGET_UNIX
CPUGroupInfo::EnsureInitialized();
Expand Down
Loading