From 5351f4480862eb9848871debb4fc170333ac0af5 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Wed, 29 Dec 2010 23:58:17 +0000 Subject: [PATCH] [CMAKE] LD is stupid and doesn't handle stdcall decoration as proper as dlltool does (after we provided a patch). Passing --kill-at, also kills C++ mangled names and exports with stdcall decoration are imposible. In trunk we use dlltool to generate an exp file that we link with LD, but in the cmake branch we pass the def file to LD directly. Luckily we have a tool called spec2def that can handle these things. We now generate 2 different .def files, one for LD, containing the undecorated export name forwarded to the decorated symbol name (FooFunc=FooFunc@12), while the 2nd def file which is passed to dlltool for exportlib generation has full stdcall decorations. --kill-at is now passed to dlltool only. This commit might break msvc, but should be pretty easy to fix. svn path=/branches/cmake-bringup/; revision=50217 --- gcc.cmake | 8 ++++---- toolchain-mingw32.cmake | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gcc.cmake b/gcc.cmake index ddcc90a7837..be9ac337e3a 100644 --- a/gcc.cmake +++ b/gcc.cmake @@ -9,7 +9,7 @@ else() link_directories("${REACTOS_SOURCE_DIR}/importlibs" ${REACTOS_BINARY_DIR}/lib/3rdparty/mingw) set(CMAKE_C_LINK_EXECUTABLE " -o ") set(CMAKE_CXX_LINK_EXECUTABLE " -o ") -set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at -Wl,--disable-auto-import") +set(CMAKE_EXE_LINKER_FLAGS "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--disable-auto-import") # -Wl,-T,${REACTOS_SOURCE_DIR}/global.lds set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--disable-stdcall-fixup") @@ -242,8 +242,8 @@ macro(add_importlib_target _exports_file) add_custom_command( OUTPUT ${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a - COMMAND native-spec2def ${DLLNAME_OPTION} ${DECO_OPTION} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}.def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} - COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a + COMMAND native-spec2def ${DLLNAME_OPTION} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file} + COMMAND ${MINGW_PREFIX}dlltool --def ${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_exports_file}) elseif(${_extension} STREQUAL ".def") @@ -265,7 +265,7 @@ macro(spec2def _dllname _spec_file) get_filename_component(_file ${_spec_file} NAME_WE) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file}.def ${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c - COMMAND native-spec2def -n=${_dllname} ${DECO_OPTION} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} + COMMAND native-spec2def -n=${_dllname} --kill-at -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_file}.def -s=${CMAKE_CURRENT_BINARY_DIR}/${_file}_stubs.c ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_spec_file}) set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_file}.def PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE) diff --git a/toolchain-mingw32.cmake b/toolchain-mingw32.cmake index f89dfb43b66..52f33657498 100644 --- a/toolchain-mingw32.cmake +++ b/toolchain-mingw32.cmake @@ -49,14 +49,14 @@ set(CMAKE_C_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries") set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING "Standard C++ Libraries") if(ARCH MATCHES i386) - set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at -Wl,--disable-auto-import") + set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--disable-auto-import") #-Wl,-T,${REACTOS_SOURCE_DIR}/global.lds elseif(ARCH MATCHES amd64) - set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--kill-at -Wl,--disable-auto-import") + set(CMAKE_SHARED_LINKER_FLAGS_INIT "-nodefaultlibs -nostdlib -Wl,--enable-auto-image-base -Wl,--disable-auto-import") endif() # adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search +# search headers and libraries in the target environment, search # programs in the host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)