• Stephan Bergmann's avatar
    Support loplugin in clang-cl · 39e7a72b
    Stephan Bergmann yazdı
    This works at least with a recent Clang trunk (towards Clang 6.0).
    
    In order for the plugin.dll to find the LLVM/Clang symbols, it needs to be
    loaded into clang.exe not clang-cl.exe, so set CC/CXX to 'clang.exe
    --driver-mode=cl ...'.
    
    Buidling the plugin requires some linker flags that must go at the very end of
    the COMPILER_PLUGINS_CXX command line, after a /link switch, so introduce
    another COMPILER_PLUGINS_CXX_LINKFLAGS variable for that.  Also, clang.lib is
    not installed as part of LLVM's 'cmake --build ... --target install' step, so
    is not available under CLANGDIR and needs to be taken from the build tree
    instead, so introduce another CLANGLIBDIR variable for that.  autogen.input
    settings that work for me on Windows 8.1 with Microsoft Visual Studio 14.0 are:
    
    > CLANGDIR=C:/llvm/inst
    > CLANGLIBDIR=C:/llvm/build/lib
    > COMPILER_PLUGINS_CXX=C:/PROGRA~2/MICROS~3.0/VC/bin/amd64/cl.exe /IC:\PROGRA~2\MICROS~3.0\VC\INCLUDE /IC:\PROGRA~2\MICROS~3.0\VC\ATLMFC\INCLUDE /IC:\PROGRA~2\WI3CF2~1\10\include\100102~1.0\ucrt /IC:\PROGRA~2\WI3CF2~1\NETFXSDK\46D346~1.1\include\um /IC:\PROGRA~2\WI3CF2~1\8.1\include\shared /IC:\PROGRA~2\WI3CF2~1\8.1\include\um /IC:\PROGRA~2\WI3CF2~1\8.1\include\winrt
    > COMPILER_PLUGINS_CXX_LINKFLAGS=/LIBPATH:C:/PROGRA~2/MICROS~3.0/VC/LIB/amd64 /LIBPATH:C:/PROGRA~2/MICROS~3.0/VC/ATLMFC/LIB/amd64 /LIBPATH:C:/PROGRA~2/WI3CF2~1/10/lib/100102~1.0/ucrt/x64 /LIBPATH:C:/PROGRA~2/WI3CF2~1/NETFXSDK/46D346~1.1/lib/um/x64 /LIBPATH:C:/PROGRA~2/WI3CF2~1/8.1/lib/winv6.3/um/x64
    
    (The last two are "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/
    amd64/cl.exe" and translations of %INCLUDE% and %LIB% as set in the "VS2015 x64
    Native Tools Command Prompt" shell.
    AC_CHECK_HEADER(clang/AST/RecursiveASTVisitor.h, ...) in configure.ac wouldn't
    like CXX to start with INCLUDE=... LIB=... environment variable settings, so it
    wouldn't work to instead pass %INCLUDE% and %LIB% to cl.exe that way.  See
    <https://wiki.documentfoundation.org/Development/clang-cl> for general
    information about building with clang-cl on Windows.)
    
    There's still some room for improvement marked "TODO".  (And some of the unused*
    plugins, which are not run by default anyway, use Unix-style functionality, so
    have been disabled for now.)
    
    Change-Id: I6c28bdeb801af39ce2bae03111f455e2338d66c9
    Reviewed-on: https://gerrit.libreoffice.org/42931Tested-by: 's avatarJenkins <ci@libreoffice.org>
    Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
    39e7a72b
unusedmethodsremove.cxx 4.59 KB