[llvm-bugs] [Bug 34909] New: ThinLTO on windows produces invalid code.

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 10 17:05:01 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=34909

            Bug ID: 34909
           Summary: ThinLTO on windows produces invalid code.
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: zturner at google.com
                CC: llvm-bugs at lists.llvm.org, llvm at inglorion.net,
                    peter at pcc.me.uk

1. Build an x86 Release version of clang using the standard MSVC compiler and
linker.

> (From an x86 MSVC build environment)
> cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=clang <llvm-source-dir>
> ninja clang

2. Build an x64 Release version of lld using the standard MSVC compiler and
linker.
> (From an x64 MSVC build environment)
> cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS=lld <llvm-source-dir>
> ninja lld

Because clang-cl uses the default target triple based on its bitness, in order
to build and link an x86 binary with clang-cl + lld, the compiler has to be
built x86, and the linker has to be built x64 (or it runs out of memory).  This
is really lame and the compiler should detect the MSVC environment that is
configured, but that isn't the way it works today.

So, continuing...

3. Configure a third build directory that uses the compiler from step 1 and the
linker from step 2, and that uses -DLLVM_ENABLE_LTO=Thin.

> (From an x86 MSVC build environment)
> cmake -G Ninja -DLLVM_ENABLE_LTO=Thin -DCMAKE_C_COMPILER=<path-to-clang-cl.exe-in-step-1> -DCMAKE_CXX_COMPILER=<path-to-clang-cl.exe-in-step-1> -DCMAKE_LINKER=<path-to-lld-link.exe-in-step-2> -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_ENABLE_PROJECTS="clang;lld" ..\..\..\..\llvm-mono\llvm

4. Build your LTO'ed tblgen

> ninja llvm-tblgen

5. Run tblgen.
> bin\llvm-tblgen.exe -gen-attrs -I D:/src/llvm-mono/llvm/include/llvm/IR -I D:/src/llvm-mono/llvm/include D:/src/llvm-mono/llvm/include/llvm/IR/Attributes.td -o include/llvm/IR/Attributes.gen.tmp -d include/llvm/IR/Attributes.gen.d

6. Print the value of ERRORLEVEL
> echo %ERRORLEVEL%
-1073741819

This corresponds to 0xFFFFFFFFC0000005 which is access violation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171011/c2c4c9d7/attachment.html>


More information about the llvm-bugs mailing list