mirror of
https://github.com/encounter/winedll.git
synced 2026-07-11 06:18:49 -07:00
Working universal msvcrt build
This commit is contained in:
@@ -1,2 +1,6 @@
|
||||
build/
|
||||
*.lib
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.pyd
|
||||
|
||||
+14
-2
@@ -6,6 +6,18 @@ set(CMAKE_C_STANDARD 11)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
add_subdirectory(libs/musl)
|
||||
add_subdirectory(imports/kernel32)
|
||||
# Find Python for build scripts
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter)
|
||||
|
||||
# Define paths to build tools
|
||||
set(MERGE_SPECS_TOOL ${CMAKE_SOURCE_DIR}/tools/merge_specs.py)
|
||||
set(GENERATE_DEF_TOOL ${CMAKE_SOURCE_DIR}/tools/generate_def.py)
|
||||
set(GENERATE_STUBS_TOOL ${CMAKE_SOURCE_DIR}/tools/generate_stubs.py)
|
||||
set(SPEC_PARSER_LIB ${CMAKE_SOURCE_DIR}/tools/spec_parser.py)
|
||||
|
||||
add_subdirectory(dlls/advapi32)
|
||||
add_subdirectory(dlls/kernel32)
|
||||
add_subdirectory(dlls/kernelbase)
|
||||
add_subdirectory(dlls/msvcrt)
|
||||
add_subdirectory(dlls/user32)
|
||||
add_subdirectory(libs/musl)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "base",
|
||||
"hidden": true,
|
||||
"generator": "Ninja",
|
||||
"cacheVariables": {
|
||||
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
|
||||
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/i686-windows-clang.cmake"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
"displayName": "Debug",
|
||||
"inherits": ["base"],
|
||||
"binaryDir": "${sourceDir}/build/debug",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"displayName": "Release",
|
||||
"inherits": ["base"],
|
||||
"binaryDir": "${sourceDir}/build/release",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
}
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "debug",
|
||||
"displayName": "Build (Debug)",
|
||||
"configurePreset": "debug",
|
||||
"configuration": "Debug"
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"displayName": "Build (Release)",
|
||||
"configurePreset": "release",
|
||||
"configuration": "Release"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -24,3 +24,5 @@ set(CMAKE_CXX_FLAGS_INIT "-nostdinc")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-nostdlib")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nostdlib")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_INIT "-nostdlib")
|
||||
|
||||
set(CMAKE_C_STANDARD_LIBRARIES "")
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(ADVAPI32_SPEC ${CMAKE_CURRENT_SOURCE_DIR}/advapi32.spec)
|
||||
set(ADVAPI32_DEF ${CMAKE_CURRENT_BINARY_DIR}/advapi32.def)
|
||||
set(ADVAPI32_LIB ${CMAKE_CURRENT_BINARY_DIR}/advapi32.lib)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${ADVAPI32_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--imports-only
|
||||
${ADVAPI32_SPEC}
|
||||
${ADVAPI32_DEF}
|
||||
DEPENDS
|
||||
${ADVAPI32_SPEC}
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating advapi32.def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${ADVAPI32_LIB}
|
||||
COMMAND llvm-dlltool -m i386 -k -d ${ADVAPI32_DEF} -l ${ADVAPI32_LIB}
|
||||
DEPENDS ${ADVAPI32_DEF}
|
||||
COMMENT "Generating advapi32 import library"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(advapi32_import ALL DEPENDS ${ADVAPI32_LIB})
|
||||
|
||||
add_library(advapi32_import_lib STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(advapi32_import_lib PROPERTIES
|
||||
IMPORTED_LOCATION ${ADVAPI32_LIB}
|
||||
)
|
||||
|
||||
add_dependencies(advapi32_import_lib advapi32_import)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
# set(KERNEL32_SPEC ${PROJECT_SOURCE_DIR}/../wine/dlls/kernel32/kernel32.spec)
|
||||
set(KERNEL32_SPEC ${CMAKE_CURRENT_SOURCE_DIR}/kernel32.spec)
|
||||
set(KERNEL32_DEF ${CMAKE_CURRENT_BINARY_DIR}/kernel32.def)
|
||||
set(KERNEL32_LIB ${CMAKE_CURRENT_BINARY_DIR}/kernel32.lib)
|
||||
|
||||
# add_custom_command(
|
||||
# OUTPUT ${KERNEL32_DEF}
|
||||
# COMMAND winebuild --target=i386-windows --def -E ${KERNEL32_SPEC} -o ${KERNEL32_DEF}
|
||||
# DEPENDS ${KERNEL32_SPEC}
|
||||
# COMMENT "Generating kernel32.def from Wine spec"
|
||||
# VERBATIM
|
||||
# )
|
||||
add_custom_command(
|
||||
OUTPUT ${KERNEL32_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--imports-only
|
||||
${KERNEL32_SPEC}
|
||||
${KERNEL32_DEF}
|
||||
DEPENDS
|
||||
${KERNEL32_SPEC}
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating kernel32.def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${KERNEL32_LIB}
|
||||
COMMAND llvm-dlltool -m i386 -d ${KERNEL32_DEF} -l ${KERNEL32_LIB}
|
||||
COMMAND llvm-dlltool -m i386 -k -d ${KERNEL32_DEF} -l ${KERNEL32_LIB}
|
||||
DEPENDS ${KERNEL32_DEF}
|
||||
COMMENT "Generating kernel32 import library"
|
||||
VERBATIM
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(KERNELBASE_SPEC ${CMAKE_CURRENT_SOURCE_DIR}/kernelbase.spec)
|
||||
set(KERNELBASE_DEF ${CMAKE_CURRENT_BINARY_DIR}/kernelbase.def)
|
||||
set(KERNELBASE_LIB ${CMAKE_CURRENT_BINARY_DIR}/kernelbase.lib)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${KERNELBASE_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--imports-only
|
||||
${KERNELBASE_SPEC}
|
||||
${KERNELBASE_DEF}
|
||||
DEPENDS
|
||||
${KERNELBASE_SPEC}
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating kernelbase.def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${KERNELBASE_LIB}
|
||||
COMMAND llvm-dlltool -m i386 -k -d ${KERNELBASE_DEF} -l ${KERNELBASE_LIB}
|
||||
DEPENDS ${KERNELBASE_DEF}
|
||||
COMMENT "Generating kernelbase import library"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(kernelbase_import ALL DEPENDS ${KERNELBASE_LIB})
|
||||
|
||||
add_library(kernelbase_import_lib STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(kernelbase_import_lib PROPERTIES
|
||||
IMPORTED_LOCATION ${KERNELBASE_LIB}
|
||||
)
|
||||
|
||||
add_dependencies(kernelbase_import_lib kernelbase_import)
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,82 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
file(GLOB MSVCR_SPEC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../msvcr*/msvcr*.spec)
|
||||
set(UCRTBASE_SOURCE_SPEC ${CMAKE_CURRENT_SOURCE_DIR}/../ucrtbase/ucrtbase.spec)
|
||||
|
||||
# Generated files in build directory
|
||||
set(MSVCRT_MERGED_SPEC ${CMAKE_CURRENT_BINARY_DIR}/msvcrt.spec)
|
||||
set(MSVCRT_GENERATED_STUBS ${CMAKE_CURRENT_BINARY_DIR}/generated_stubs.c)
|
||||
set(MSVCRT_DEF ${CMAKE_CURRENT_BINARY_DIR}/msvcrt.def)
|
||||
|
||||
# Merge spec files
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT_MERGED_SPEC}
|
||||
COMMAND ${Python3_EXECUTABLE} ${MERGE_SPECS_TOOL}
|
||||
${MSVCR_SPEC_FILES}
|
||||
${UCRTBASE_SOURCE_SPEC}
|
||||
${MSVCRT_MERGED_SPEC}
|
||||
DEPENDS
|
||||
${MSVCR_SPEC_FILES}
|
||||
${UCRTBASE_SOURCE_SPEC}
|
||||
${MERGE_SPECS_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Merging spec files"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Generate stub implementations from merged spec
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT_GENERATED_STUBS}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_STUBS_TOOL}
|
||||
--arch i386
|
||||
${MSVCRT_MERGED_SPEC}
|
||||
${MSVCRT_GENERATED_STUBS}
|
||||
DEPENDS
|
||||
${MSVCRT_MERGED_SPEC}
|
||||
${GENERATE_STUBS_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating stubs"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Generate .def file from merged spec
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--no-stdcall-suffix
|
||||
${MSVCRT_MERGED_SPEC}
|
||||
${MSVCRT_DEF}
|
||||
DEPENDS
|
||||
${MSVCRT_MERGED_SPEC}
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating msvcrt.def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_library(msvcrt SHARED
|
||||
concurrency.c
|
||||
console.c
|
||||
cpp.c
|
||||
# crt_gccmain.c
|
||||
# crt_main.c
|
||||
# crt_winmain.c
|
||||
# crt_wmain.c
|
||||
# crt_wwinmain.c
|
||||
ctype.c
|
||||
data.c
|
||||
dir.c
|
||||
environ.c
|
||||
errno.c
|
||||
except.c
|
||||
except_i386.c
|
||||
exception_ptr.c
|
||||
exit.c
|
||||
file.c
|
||||
handler4.c
|
||||
heap.c
|
||||
iob.c
|
||||
# iob.c
|
||||
locale.c
|
||||
lock.c
|
||||
main.c
|
||||
@@ -18,7 +84,8 @@ add_library(msvcrt SHARED
|
||||
mathf.c
|
||||
mbcs.c
|
||||
misc.c
|
||||
onexit.c
|
||||
# onexit.c
|
||||
printf.c
|
||||
process.c
|
||||
scanf.c
|
||||
sincos.c
|
||||
@@ -28,6 +95,11 @@ add_library(msvcrt SHARED
|
||||
undname.c
|
||||
wcs.c
|
||||
stubs.c
|
||||
${MSVCRT_GENERATED_STUBS}
|
||||
# ../winecrt0/crt_dllmain.c
|
||||
../winecrt0/setjmp.c
|
||||
../winecrt0/exception.c
|
||||
${MSVCRT_DEF}
|
||||
)
|
||||
|
||||
set(CMAKE_SHARED_LIBRARY_PREFIX "")
|
||||
@@ -36,7 +108,6 @@ set_target_properties(msvcrt PROPERTIES OUTPUT_NAME msvcrt)
|
||||
target_compile_definitions(msvcrt
|
||||
PRIVATE
|
||||
_CRTIMP=
|
||||
_MSVCR_VER=90
|
||||
_NTSYSTEM_ # stub ntdll calls
|
||||
__WINE_PE_BUILD
|
||||
)
|
||||
@@ -52,6 +123,11 @@ target_compile_options(msvcrt
|
||||
-Wno-ignored-qualifiers
|
||||
)
|
||||
|
||||
target_link_options(msvcrt
|
||||
PRIVATE
|
||||
-Wl,--enable-stdcall-fixup
|
||||
)
|
||||
|
||||
target_include_directories(msvcrt
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/dlls/msvcrt
|
||||
@@ -63,7 +139,10 @@ target_include_directories(msvcrt
|
||||
target_link_libraries(msvcrt
|
||||
PRIVATE
|
||||
musl
|
||||
advapi32_import_lib
|
||||
kernel32_import_lib
|
||||
kernelbase_import_lib
|
||||
user32_import_lib
|
||||
)
|
||||
|
||||
execute_process(
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
EXTRADEFS = -D_CRTIMP=
|
||||
MODULE = msvcrt.dll
|
||||
IMPORTLIB = msvcrt
|
||||
IMPORTS = $(MUSL_PE_LIBS) ntdll
|
||||
DELAYIMPORTS = advapi32 user32
|
||||
|
||||
SOURCES = \
|
||||
concurrency.c \
|
||||
console.c \
|
||||
cpp.c \
|
||||
crt_gccmain.c \
|
||||
crt_main.c \
|
||||
crt_winmain.c \
|
||||
crt_wmain.c \
|
||||
crt_wwinmain.c \
|
||||
ctype.c \
|
||||
data.c \
|
||||
dir.c \
|
||||
environ.c \
|
||||
errno.c \
|
||||
except.c \
|
||||
except_arm.c \
|
||||
except_arm64.c \
|
||||
except_arm64ec.c \
|
||||
except_i386.c \
|
||||
except_x86_64.c \
|
||||
exception_ptr.c \
|
||||
exit.c \
|
||||
file.c \
|
||||
handler4.c \
|
||||
heap.c \
|
||||
iob.c \
|
||||
locale.c \
|
||||
lock.c \
|
||||
main.c \
|
||||
math.c \
|
||||
mathf.c \
|
||||
mbcs.c \
|
||||
misc.c \
|
||||
onexit.c \
|
||||
process.c \
|
||||
rsrc.rc \
|
||||
scanf.c \
|
||||
sincos.c \
|
||||
string.c \
|
||||
thread.c \
|
||||
time.c \
|
||||
undname.c \
|
||||
wcs.c
|
||||
@@ -957,7 +957,7 @@ void __thiscall ExternalContextBase_Unblock(ExternalContextBase *this)
|
||||
|
||||
/* TODO: throw context_unblock_unbalanced if this->blocked goes below -1 */
|
||||
if (!InterlockedDecrement(&this->blocked))
|
||||
RtlWakeAddressSingle(&this->blocked);
|
||||
WakeByAddressSingle(&this->blocked);
|
||||
}
|
||||
|
||||
DEFINE_THISCALL_WRAPPER(ExternalContextBase_IsSynchronouslyBlocked, 4)
|
||||
@@ -977,7 +977,7 @@ void __thiscall ExternalContextBase_Block(ExternalContextBase *this)
|
||||
blocked = InterlockedIncrement(&this->blocked);
|
||||
while (blocked >= 1)
|
||||
{
|
||||
RtlWaitOnAddress(&this->blocked, &blocked, sizeof(LONG), NULL);
|
||||
WaitOnAddress(&this->blocked, &blocked, sizeof(LONG), INFINITE);
|
||||
blocked = this->blocked;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user