Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72402

win32-clang-msvc: -ltcg is not working

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.12.1, 5.12.2
    • 5.12.0
    • Build System
    • None
    • Clang 7.0.0, VS2017 15.9.3, Win 10 17763.168
    • Windows
    • b34143f8a19040a457d399a22f0bde53ac327ff1 (qt/qtbase/5.12)

    Description

      To enable LTCG, clang-cl.exe need "-flto" instead of "-GL". But if you enabled LTO, the lib tool will have to change from "lib.exe" to "llvm-lib.exe" and the link tool also need to change from "link.exe" to "lld-link.exe"(or "ld.lld.exe"/"ld64.lld.exe"/"lld.exe", they are the same), because msvc linker will see these lib files as corrupted files.

      Add the following lines to qtbase\mkspecs\win32-clang-msvc\qmake.conf will solve this problem:

      QMAKE_LINK = lld-link
      QMAKE_LIB = llvm-lib /NOLOGO
      QMAKE_CFLAGS_LTCG = -flto
      QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
      QMAKE_LFLAGS_LTCG =
      

      Leave QMAKE_LFLAGS_LTCG empty because "lld-link.exe" does not recognize "-flto" or "-GL".

      And one more thing, there's a flood of warning messages when I'm compiling qtbase:

       clang-cl.exe: warning: argument unused during compilation: '-Gm-' [-Wunused-command-line-argument]
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-72402
          # Subject Branch Project Status CR V

          Activity

            People

              buddenha Oswald Buddenhagen
              wangwenx190 赵 宇航
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes