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

win32-clang-msvc: -ltcg is not working

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important 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)

      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]
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

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

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes