Skip to content

Commit

Permalink
Fix build with FEATURE_STANDALONE_GC disabled (#111682)
Browse files Browse the repository at this point in the history
* Fix build with FEATURE_STANDALONE_GC disabled

Currently, the build fails, because the gc_pal is built only when
standalone GC is enabled, but it is used for the built-in GC as
well.

This change fixes it.

* PR feedback
  • Loading branch information
janvorli authored Jan 22, 2025
1 parent 41e2b8c commit 1f93ea7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 45 deletions.
5 changes: 1 addition & 4 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ endif(CLR_CMAKE_HOST_WIN32)
#----------------------------------
include(clrdefinitions.cmake)

if(FEATURE_STANDALONE_GC)
add_definitions(-DFEATURE_STANDALONE_GC)
add_subdirectory(gc)
endif(FEATURE_STANDALONE_GC)
add_subdirectory(gc)

if (CLR_CMAKE_HOST_UNIX)
include_directories("pal/inc")
Expand Down
82 changes: 41 additions & 41 deletions src/coreclr/gc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Local GC meta-issue: https://github.com/dotnet/runtime/issues/8061

# https://github.com/dotnet/runtime/issues/8059
remove_definitions(-DSTRESS_HEAP)

# https://github.com/dotnet/runtime/issues/8062
remove_definitions(-DWRITE_BARRIER_CHECK)
if(FEATURE_STANDALONE_GC)
add_definitions(-DFEATURE_STANDALONE_GC)
remove_definitions(-DSTRESS_HEAP)
remove_definitions(-DWRITE_BARRIER_CHECK)
endif(FEATURE_STANDALONE_GC)

set(GC_SOURCES
gceventstatus.cpp
Expand Down Expand Up @@ -100,37 +98,39 @@ list(APPEND GC_SOURCES ${GC_HEADERS})

convert_to_absolute_path(GC_SOURCES ${GC_SOURCES})

# clrgcexp is build with standalone+regions
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
add_library_clr(clrgcexp SHARED ${GC_SOURCES})
add_dependencies(clrgcexp eventing_headers)
target_link_libraries(clrgcexp PRIVATE ${GC_LINK_LIBRARIES})
target_compile_definitions(clrgcexp PRIVATE -DUSE_REGIONS)
install_clr(TARGETS clrgcexp DESTINATIONS . COMPONENT runtime)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)

# clrgc is build with standalone+segments
add_library_clr(clrgc SHARED ${GC_SOURCES})
add_dependencies(clrgc eventing_headers)
target_link_libraries(clrgc PRIVATE ${GC_LINK_LIBRARIES})
install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime)

add_definitions(-DBUILD_AS_STANDALONE)
add_definitions(-DFEATURE_CONSERVATIVE_GC)

add_definitions(-DFX_VER_INTERNALNAME_STR=clrgc.dll)
add_definitions(-DVERIFY_HEAP)
if(CLR_CMAKE_HOST_APPLE)
# The implementation of GCToOSInterface on Apple platforms makes use of non-POSIX
# pthreads APIs, which by default are not included in the pthreads header
# unless we define this macro.
add_definitions(-D_DARWIN_C_SOURCE)
endif(CLR_CMAKE_HOST_APPLE)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/env)

install_clr(TARGETS clrgc DESTINATIONS . sharedFramework COMPONENT runtime)
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
install_clr(TARGETS clrgcexp DESTINATIONS . sharedFramework COMPONENT runtime)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
if(FEATURE_STANDALONE_GC)
# clrgcexp is build with standalone+regions
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
add_library_clr(clrgcexp SHARED ${GC_SOURCES})
add_dependencies(clrgcexp eventing_headers)
target_link_libraries(clrgcexp PRIVATE ${GC_LINK_LIBRARIES})
target_compile_definitions(clrgcexp PRIVATE -DUSE_REGIONS)
install_clr(TARGETS clrgcexp DESTINATIONS . COMPONENT runtime)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)

# clrgc is build with standalone+segments
add_library_clr(clrgc SHARED ${GC_SOURCES})
add_dependencies(clrgc eventing_headers)
target_link_libraries(clrgc PRIVATE ${GC_LINK_LIBRARIES})
install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime)

add_definitions(-DBUILD_AS_STANDALONE)
add_definitions(-DFEATURE_CONSERVATIVE_GC)

add_definitions(-DFX_VER_INTERNALNAME_STR=clrgc.dll)
add_definitions(-DVERIFY_HEAP)
if(CLR_CMAKE_HOST_APPLE)
# The implementation of GCToOSInterface on Apple platforms makes use of non-POSIX
# pthreads APIs, which by default are not included in the pthreads header
# unless we define this macro.
add_definitions(-D_DARWIN_C_SOURCE)
endif(CLR_CMAKE_HOST_APPLE)

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/env)

install_clr(TARGETS clrgc DESTINATIONS . sharedFramework COMPONENT runtime)
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
install_clr(TARGETS clrgcexp DESTINATIONS . sharedFramework COMPONENT runtime)
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
endif(FEATURE_STANDALONE_GC)

0 comments on commit 1f93ea7

Please sign in to comment.