[VCSTARTUP] Separate the library from vcruntime

Previously this was mixed with vcruntime, with some objects being shared. But this is messy. Instead use a separate library and link ucrtbase to this as well. This also matches more closely how native libraries are organized, where vcstartup is merged into the CRT import libraries, while vcruntime is merged into the static CRT libraries.
This commit is contained in:
Timo Kreuzer
2026-02-02 21:46:20 +02:00
parent f473ddad73
commit d0b292cda6
21 changed files with 79 additions and 55 deletions

View File

@@ -36,6 +36,7 @@ target_link_libraries(ucrtbase
msvcrt_shared
crtmath
vcruntime
vcstartup
chkstk
wine
)

View File

@@ -58,6 +58,7 @@ add_subdirectory(ucrt)
add_subdirectory(udmihelp)
add_subdirectory(uuid)
add_subdirectory(vcruntime)
add_subdirectory(vcstartup)
add_subdirectory(wine2ros)
add_subdirectory(wdmguid)

View File

@@ -11,49 +11,12 @@ if(DBG)
add_compile_definitions(_DEBUG) # TODO: define this globally
endif()
# Silence GCC/Clang warnings
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(
-Wno-builtin-declaration-mismatch
-Wno-unused-function
)
endif()
add_compile_definitions(
_CORECRT_BUILD
_CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
_NTSYSTEM_
)
if(${ARCH} STREQUAL "i386")
list(APPEND VCRT_COMMON_ASM_SOURCES
i386/__security_check_cookie.s
i386/_chkesp.s
)
elseif(${ARCH} STREQUAL "amd64")
list(APPEND VCRT_COMMON_ASM_SOURCES
amd64/__security_check_cookie.s
)
endif()
add_asm_files(vcrt_common_asm ${VCRT_COMMON_ASM_SOURCES})
list(APPEND VCRT_COMMON_SOURCES
${vcrt_common_asm}
__report_gsfailure.c
__report_rangecheckfailure.c
__security_init_cookie.c
_fltused.c
initializers.cpp
isa_available.cpp
tlssup.c
)
# Common between vcstartup and vcruntime
add_library(vcrt_common ${VCRT_COMMON_SOURCES})
target_link_libraries(vcrt_common ${PSEH_LIB})
add_dependencies(vcrt_common psdk)
if(${ARCH} STREQUAL "i386")
list(APPEND VCRT_SETJMP_SOURCES
i386/longjmp.c
@@ -94,34 +57,32 @@ add_asm_files(vcrt_setjmp_asm ${VCRT_SETJMP_ASM_SOURCES})
add_library(setjmp ${VCRT_SETJMP_SOURCES} ${vcrt_setjmp_asm})
add_dependencies(setjmp psdk asm)
list(APPEND VCRT_RUNTIME_SOURCES
${vcrt_runtime_asm}
if(${ARCH} STREQUAL "i386")
list(APPEND VCRUNTIME_ASM_SOURCES
i386/_chkesp.s
)
elseif(${ARCH} STREQUAL "amd64")
list(APPEND VCRUNTIME_ASM_SOURCES
)
endif()
add_asm_files(vcruntime_asm ${VCRUNTIME_ASM_SOURCES})
list(APPEND VCRUNTIME_SOURCES
${vcruntime_asm}
__std_terminate.c
__vcrt_init.c
purecall.cpp
)
if(${ARCH} STREQUAL "i386")
list(APPEND VCRT_RUNTIME_SOURCES
list(APPEND VCRUNTIME_SOURCES
i386/_chkesp_failed.c
)
endif()
# Runtime library (linked into ucrtbase)
add_library(vcruntime ${VCRT_RUNTIME_SOURCES} $<TARGET_OBJECTS:vcrt_common> $<TARGET_OBJECTS:setjmp>)
add_library(vcruntime ${VCRUNTIME_SOURCES} $<TARGET_OBJECTS:setjmp>)
target_link_libraries(vcruntime ${PSEH_LIB})
target_include_directories(vcruntime INTERFACE inc)
list(APPEND VCRT_STARTUP_SOURCES
__acrt_initialize_stub.cpp
__scrt_uninitialize_crt.cpp
__vcrt_init_stubs.c
_onexit.c
atexit.c
mainCRTStartup.cpp
wmainCRTStartup.cpp
)
# Startup library (linked into executables, linking to ucrtbase)
add_library(vcstartup ${VCRT_STARTUP_SOURCES} $<TARGET_OBJECTS:vcrt_common>)
target_link_libraries(vcstartup ${PSEH_LIB} libucrtbase libkernel32)

View File

@@ -0,0 +1,61 @@
# Replace the old CRT include directory with the UCRT include directory
get_property(INCLUDE_DIRS DIRECTORY . PROPERTY INCLUDE_DIRECTORIES)
list(REMOVE_ITEM INCLUDE_DIRS "${REACTOS_SOURCE_DIR}/sdk/include/crt")
set_property(DIRECTORY . PROPERTY INCLUDE_DIRECTORIES ${INCLUDE_DIRS})
include_directories(${REACTOS_SOURCE_DIR}/sdk/include/ucrt)
include_directories(inc)
if(DBG)
add_compile_definitions(_DEBUG) # TODO: define this globally
endif()
# Silence GCC/Clang warnings
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR
CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(
-Wno-builtin-declaration-mismatch
-Wno-unused-function
)
endif()
add_compile_definitions(
_CORECRT_BUILD
_CRT_DECLARE_GLOBAL_VARIABLES_DIRECTLY
_NTSYSTEM_
)
if(${ARCH} STREQUAL "i386")
list(APPEND VCSTARTUP_ASM_SOURCES
i386/__security_check_cookie.s
)
elseif(${ARCH} STREQUAL "amd64")
list(APPEND VCSTARTUP_ASM_SOURCES
amd64/__security_check_cookie.s
)
endif()
add_asm_files(vcstartup_asm ${VCSTARTUP_ASM_SOURCES})
list(APPEND VCSTARTUP_SOURCES
${vcstartup_asm}
__acrt_initialize_stub.cpp
__report_gsfailure.c
__report_rangecheckfailure.c
__scrt_uninitialize_crt.cpp
__security_init_cookie.c
__vcrt_init_stubs.c
_fltused.c
_onexit.c
atexit.c
initializers.cpp
isa_available.cpp
mainCRTStartup.cpp
tlssup.c
wmainCRTStartup.cpp
)
# Startup library (linked into executables, linking to ucrtbase)
add_library(vcstartup ${VCSTARTUP_SOURCES})
target_link_libraries(vcstartup ${PSEH_LIB} libkernel32)
target_include_directories(vcstartup PRIVATE $<TARGET_PROPERTY:vcruntime,INTERFACE_INCLUDE_DIRECTORIES>)