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

fix and simplify build #85

Closed
wants to merge 6 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
17 changes: 1 addition & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ add_compile_options (-fno-strict-aliasing)

include (StaticCRT)

# Avoid Posix threads. Posix threads is required for support of certain C++11
# multi-threading features, but it introduces a new DLL dependency and we don't
# use those features.
# https://github.com/jrfonseca/drmingw/issues/82#issuecomment-1360081041
execute_process (
COMMAND "${CMAKE_COMMAND}" -E echo "#include <thread>\n#ifdef _GLIBCXX_HAS_GTHREADS\n#error _GLIBCXX_HAS_GTHREADS\n#endif"
COMMAND "${CMAKE_CXX_COMPILER}" -x c++ -E -
RESULT_VARIABLE STATUS_CXX11_THREADS
OUTPUT_QUIET
ERROR_QUIET
)
if (NOT STATUS_CXX11_THREADS EQUAL 0)
message (SEND_ERROR "Win32 threads required.")
endif ()

# Enable stack protection
# XXX: Broken on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86832
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0" OR
Expand Down Expand Up @@ -177,4 +162,4 @@ set (CPACK_GENERATOR "7Z")

set (CPACK_STRIP_FILES ON)

include(CPack)
include(CPack)
21 changes: 21 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"version": 3,
"configurePresets": [
{
"name": "gcc64",
"generator": "Ninja",
"binaryDir": "build-gcc64",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "gcc32",
"generator": "Ninja",
"binaryDir": "build-gcc32",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
4 changes: 0 additions & 4 deletions ci/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ Exec { cmake "-S." "-B$buildDir" -G $generator "-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_
#
# Build
#
if ($target -eq "mingw32") {
# XXX: Temporary hack to avoid "No rule to make target lib*.dll.a"
Exec { cmake --build $buildDir --use-stderr --target libmgwhelp_implib --target libexchndl_implib }
}
Exec { cmake --build $buildDir --use-stderr --target all }

Exec { python tests\check_dynamic_linkage.py --objdump=objdump --validate $buildDir\bin\*.dll $buildDir\bin\*.exe }
Expand Down
3 changes: 1 addition & 2 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ force_debug ()
add_executable (sample
sample.cpp
)
add_dependencies (sample exchndl_implib)
target_link_libraries (sample PRIVATE exchndl_implib)
target_link_libraries (sample PRIVATE exchndl)

install (FILES sample.cpp DESTINATION sample)
install (FILES sample.mak DESTINATION sample RENAME Makefile)
6 changes: 2 additions & 4 deletions src/addr2line/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ add_executable (addr2line
addr2line.cpp
)

add_dependencies (addr2line mgwhelp_implib)

target_link_libraries (addr2line
target_link_libraries (addr2line PRIVATE
common
mgwhelp_implib
mgwhelp
)

install (TARGETS addr2line RUNTIME DESTINATION bin)
6 changes: 2 additions & 4 deletions src/catchsegv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ include_directories (

set_property (TARGET catchsegv APPEND_STRING PROPERTY LINK_FLAGS " -municode")

add_dependencies (catchsegv mgwhelp_implib)

target_link_libraries (catchsegv
target_link_libraries (catchsegv PRIVATE
common
getoptW
mgwhelp_implib
mgwhelp
winmm
)

Expand Down
6 changes: 2 additions & 4 deletions src/drmingw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ target_compile_definitions (drmingw PRIVATE
VERSION="${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}"
)

add_dependencies (drmingw mgwhelp_implib)

target_link_libraries (drmingw
target_link_libraries (drmingw PRIVATE
common
mgwhelp_implib
mgwhelp
)

install (TARGETS drmingw RUNTIME DESTINATION bin)
20 changes: 2 additions & 18 deletions src/exchndl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_C_COMPILER_ID STREQUAL GNU)
# Build import library separately, to deal with MinGW issues

add_library (exchndl MODULE exchndl32exp.def)

set (EXCHNDL_IMPLIB ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libexchndl.dll.a)
add_custom_command (
OUTPUT ${EXCHNDL_IMPLIB}
COMMAND ${CMAKE_DLLTOOL} --output-lib ${EXCHNDL_IMPLIB} --dllname exchndl.dll --kill-at --input-def ${CMAKE_CURRENT_SOURCE_DIR}/exchndl32imp.def
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/exchndl32imp.def
)
add_custom_target (libexchndl_implib DEPENDS exchndl ${EXCHNDL_IMPLIB})
add_library (exchndl_implib INTERFACE IMPORTED GLOBAL)
target_link_libraries (exchndl_implib INTERFACE ${EXCHNDL_IMPLIB})
install (FILES ${EXCHNDL_IMPLIB} DESTINATION lib)
add_library (exchndl SHARED exchndl32.def)
else ()
add_library (exchndl SHARED exchndl64.def)
add_library (exchndl_implib ALIAS exchndl)
endif ()

target_sources (exchndl PRIVATE
exchndl.cpp
version.rc
)

add_dependencies (exchndl mgwhelp_implib)

target_link_libraries (exchndl PRIVATE
common
mgwhelp_implib
mgwhelp
)

set_target_properties (exchndl PROPERTIES
Expand Down
6 changes: 6 additions & 0 deletions src/exchndl/exchndl32.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
LIBRARY exchndl.dll

EXPORTS
ExcHndlInit@0 == ExcHndlInit
ExcHndlSetLogFileNameA@4 == ExcHndlSetLogFileNameA
ExcHndlSetLogFileNameW@4 == ExcHndlSetLogFileNameW
6 changes: 0 additions & 6 deletions src/exchndl/exchndl32exp.def

This file was deleted.

6 changes: 0 additions & 6 deletions src/exchndl/exchndl32imp.def

This file was deleted.

16 changes: 1 addition & 15 deletions src/mgwhelp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,7 @@
if (CMAKE_SIZEOF_VOID_P EQUAL 4 AND CMAKE_C_COMPILER_ID STREQUAL GNU)
# Build import library separately, to deal with MinGW issues

add_library (mgwhelp MODULE mgwhelp32exp.def)

set (MGWHELP_IMPLIB ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/libmgwhelp.dll.a)
add_custom_command (
OUTPUT ${MGWHELP_IMPLIB}
COMMAND ${CMAKE_DLLTOOL} --output-lib ${MGWHELP_IMPLIB} --dllname mgwhelp.dll --kill-at --input-def ${CMAKE_CURRENT_SOURCE_DIR}/mgwhelp32imp.def
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/mgwhelp32imp.def
)
add_custom_target (libmgwhelp_implib DEPENDS mgwhelp ${MGWHELP_IMPLIB})
add_library (mgwhelp_implib INTERFACE IMPORTED GLOBAL)
target_link_libraries (mgwhelp_implib INTERFACE ${MGWHELP_IMPLIB})
install (FILES ${MGWHELP_IMPLIB} DESTINATION lib)
add_library (mgwhelp SHARED mgwhelp32.def)
else ()
add_library (mgwhelp SHARED mgwhelp64.def)
add_library (mgwhelp_implib ALIAS mgwhelp)
endif ()

target_sources (mgwhelp PRIVATE
Expand Down
108 changes: 108 additions & 0 deletions src/mgwhelp/mgwhelp32.def
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
EXPORTS
SymInitialize@12 = MgwSymInitialize@12 == SymInitialize
SymInitializeW@12 = MgwSymInitializeW@12 == SymInitializeW
SymCleanup@4 = MgwSymCleanup@4 == SymCleanup
SymSetOptions@4 = MgwSymSetOptions@4 == SymSetOptions
SymFromAddr@20 = MgwSymFromAddr@20 == SymFromAddr
SymFromAddrW@20 = MgwSymFromAddrW@20 == SymFromAddrW
SymGetLineFromAddr64@20 = MgwSymGetLineFromAddr64@20 == SymGetLineFromAddr64
SymGetLineFromAddrW64@20 = MgwSymGetLineFromAddrW64@20 == SymGetLineFromAddrW64
SymLoadModuleEx@36 = MgwSymLoadModuleEx@36 == SymLoadModuleEx
SymLoadModuleExW@36 = MgwSymLoadModuleExW@36 == SymLoadModuleExW
UnDecorateSymbolName@16 = MgwUnDecorateSymbolName@16 == UnDecorateSymbolName

EnumDirTree@24 == EnumDirTree
EnumDirTreeW@24 == EnumDirTreeW
EnumerateLoadedModules@12 == EnumerateLoadedModules
EnumerateLoadedModules64@12 == EnumerateLoadedModules64
EnumerateLoadedModulesW64@12 == EnumerateLoadedModulesW64
ExtensionApiVersion@0 == ExtensionApiVersion
FindDebugInfoFile@12 == FindDebugInfoFile
FindDebugInfoFileEx@20 == FindDebugInfoFileEx
FindExecutableImage@12 == FindExecutableImage
FindExecutableImageEx@20 == FindExecutableImageEx
FindExecutableImageExW@20 == FindExecutableImageExW
GetTimestampForLoadedLibrary@4 == GetTimestampForLoadedLibrary
ImageDirectoryEntryToData@16 == ImageDirectoryEntryToData
ImageDirectoryEntryToDataEx@20 == ImageDirectoryEntryToDataEx
ImageNtHeader@4 == ImageNtHeader
ImageRvaToSection@12 == ImageRvaToSection
ImageRvaToVa@16 == ImageRvaToVa
ImagehlpApiVersion@0 == ImagehlpApiVersion
ImagehlpApiVersionEx@4 == ImagehlpApiVersionEx
MakeSureDirectoryPathExists@4 == MakeSureDirectoryPathExists
MapDebugInformation@16 == MapDebugInformation
MiniDumpReadDumpStream@20 == MiniDumpReadDumpStream
MiniDumpWriteDump@28 == MiniDumpWriteDump
SearchTreeForFile@12 == SearchTreeForFile
SearchTreeForFileW@12 == SearchTreeForFileW
StackWalk@36 == StackWalk
StackWalk64@36 == StackWalk64
SymAddSymbol@32 == SymAddSymbol
SymAddSymbolW@32 == SymAddSymbolW
SymEnumLines@28 == SymEnumLines
SymEnumSourceFiles@24 == SymEnumSourceFiles
SymEnumSymbols@24 == SymEnumSymbols
SymEnumSymbolsW@24 == SymEnumSymbolsW
SymEnumTypes@20 == SymEnumTypes
SymEnumTypesW@20 == SymEnumTypesW
SymEnumerateModules@12 == SymEnumerateModules
SymEnumerateModules64@12 == SymEnumerateModules64
SymEnumerateModulesW64@12 == SymEnumerateModulesW64
SymEnumerateSymbols@16 == SymEnumerateSymbols
SymEnumerateSymbols64@20 == SymEnumerateSymbols64
SymFindFileInPath@40 == SymFindFileInPath
SymFindFileInPathW@40 == SymFindFileInPathW
SymFromName@12 == SymFromName
SymFunctionTableAccess@8 == SymFunctionTableAccess
SymFunctionTableAccess64@12 == SymFunctionTableAccess64
SymGetLineFromAddr@16 == SymGetLineFromAddr
SymGetLineNext@8 == SymGetLineNext
SymGetLineNext64@8 == SymGetLineNext64
SymGetLinePrev@8 == SymGetLinePrev
SymGetLinePrev64@8 == SymGetLinePrev64
SymGetModuleBase@8 == SymGetModuleBase
SymGetModuleBase64@12 == SymGetModuleBase64
SymGetModuleInfo@12 == SymGetModuleInfo
SymGetModuleInfo64@16 == SymGetModuleInfo64
SymGetModuleInfoW@12 == SymGetModuleInfoW
SymGetModuleInfoW64@16 == SymGetModuleInfoW64
SymGetOptions@0 == SymGetOptions
SymGetSearchPath@12 == SymGetSearchPath
SymGetSearchPathW@12 == SymGetSearchPathW
SymGetSourceFileToken@24 == SymGetSourceFileToken
SymGetSourceFileTokenW@24 == SymGetSourceFileTokenW
SymGetSymFromAddr@16 == SymGetSymFromAddr
SymGetSymFromAddr64@20 == SymGetSymFromAddr64
SymGetSymFromName@12 == SymGetSymFromName
SymGetSymFromName64@12 == SymGetSymFromName64
SymGetSymNext@8 == SymGetSymNext
SymGetSymNext64@8 == SymGetSymNext64
SymGetSymPrev@8 == SymGetSymPrev
SymGetSymPrev64@8 == SymGetSymPrev64
SymGetTypeFromName@20 == SymGetTypeFromName
SymGetTypeInfo@24 == SymGetTypeInfo
SymLoadModule@24 == SymLoadModule
SymLoadModule64@28 == SymLoadModule64
SymMatchFileName@16 == SymMatchFileName
SymMatchFileNameW@16 == SymMatchFileNameW
SymMatchString@12 == SymMatchString
SymRefreshModuleList@4 == SymRefreshModuleList
SymRegisterCallback@12 == SymRegisterCallback
SymRegisterCallback64@16 == SymRegisterCallback64
SymRegisterCallbackW64@16 == SymRegisterCallbackW64
SymRegisterFunctionEntryCallback@12 == SymRegisterFunctionEntryCallback
SymRegisterFunctionEntryCallback64@16 == SymRegisterFunctionEntryCallback64
SymSearch@44 == SymSearch
SymSearchW@44 == SymSearchW
SymSetContext@12 == SymSetContext
SymSetParentWindow@4 == SymSetParentWindow
SymSetScopeFromAddr@12 == SymSetScopeFromAddr
SymSetSearchPath@8 == SymSetSearchPath
SymSetSearchPathW@8 == SymSetSearchPathW
SymUnDName@12 == SymUnDName
SymUnDName64@12 == SymUnDName64
SymUnloadModule@8 == SymUnloadModule
SymUnloadModule64@12 == SymUnloadModule64
UnmapDebugInformation@4 == UnmapDebugInformation
WinDbgExtensionDllInit@12 == WinDbgExtensionDllInit
Loading
Loading