Page MenuHomePhabricator

[compiler-rt] Fix library suffixes on windows
ClosedPublic

Authored by fjricci on Aug 30 2016, 11:13 AM.

Details

Summary

Make sure that windows libraries contain the suffixes expected by clang.
This is expecially important when compiling the windows builtins with
clang, as cmake will use .a as the suffix by default.

Diff Detail

Repository
rL LLVM

Event Timeline

fjricci updated this revision to Diff 69731.Aug 30 2016, 11:13 AM
fjricci retitled this revision from to [compiler-rt] Fix library suffixes on windows.
fjricci updated this object.
fjricci added reviewers: beanz, compnerd.
fjricci added a subscriber: llvm-commits.
beanz edited edge metadata.Aug 30 2016, 1:01 PM

I question if this is correct. When targeting Windows CMAKE_STATIC_LIBRARY_SUFFIX should be ".lib" by default, unless you're targeting MinGW or Cygwin, in which case it is ".a".

Is this not what you're experiencing?

The problem comes when we use clang and not MSVC, and the gcc driver in clang is used, which adds the .a suffix instead of the .lib suffix by default.

(cmake:Modules/Platform/Windows-Clang.cmake)

if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC"
    OR "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
  include(Platform/Windows-MSVC)
  macro(__windows_compiler_clang lang)
    __windows_compiler_msvc(${lang})
  endmacro()
else()
  include(Platform/Windows-GNU)
  macro(__windows_compiler_clang lang)
    __windows_compiler_gnu(${lang})
  endmacro()
endif()

I'll update the patch to check for CMAKE_SYSTEM_NAME=Windows instead of WIN32 to avoid breaking MinGW and Cygwin.

fjricci updated this revision to Diff 69754.Aug 30 2016, 2:11 PM
fjricci edited edge metadata.

Make sure suffixes aren't changed on MinGW or Cygwin

fjricci updated this revision to Diff 69902.Aug 31 2016, 2:22 PM

Also make sure correct prefixes are used, and fix mingw/cygwin checks

fjricci updated this revision to Diff 69906.Aug 31 2016, 2:34 PM

Make sure to also set prefix for import libraries

compnerd accepted this revision.Sep 7 2016, 12:00 PM
compnerd edited edge metadata.
This revision is now accepted and ready to land.Sep 7 2016, 12:00 PM

I sent a message to the cmake developer list to ask about using the correct suffixes by default when using the GNU driver in clang to target MSVCRT. For now, I'll go ahead and merge this patch, and hope that we can remove it if cmake adds proper support in the future.

This revision was automatically updated to reflect the committed changes.