<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Clang 3.6.0 (branches/release_36 227193) segfaults in X86ELFObjectWriter.cpp while compiling Linux kernel real mode asm"
   href="http://llvm.org/bugs/show_bug.cgi?id=22349">22349</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang 3.6.0 (branches/release_36 227193) segfaults in X86ELFObjectWriter.cpp while compiling Linux kernel real mode asm
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: X86
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>marco.cilloni@studio.unibo.it
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13741" name="attach_13741" title="preprocessed source (from llvmlinux kernel sources)">attachment 13741</a> <a href="attachment.cgi?id=13741&action=edit" title="preprocessed source (from llvmlinux kernel sources)">[details]</a></span>
preprocessed source (from llvmlinux kernel sources)

I was trying to build LLVMLinux from the llvmlinux git repo with clang trunk
227188 first, and it segfaulted while assembling
arch/x86/realmode/rm/trampoline_64.S (perhaps it's where the kernel initializes
long mode?).
So I tried with clang 3.6 from branch_36 (branches/release_36 227193) and it
still crashed in the very same point on the very same file. Preprocessed .S
files from the two versions are identical (diff'ed them).

clang 3.5.1 built the kernel just fine, with no issues.  

The stack trace is:

  CC      arch/x86/platform/efi/efi.o
  LD      arch/x86/mm/mmiotrace.o
  LD      arch/x86/mm/built-in.o
  CC      arch/x86/realmode/init.o
  CC      arch/x86/platform/efi/efi_64.o
  CC      arch/x86/kernel/pci-dma.o
  CC      arch/x86/kernel/quirks.o
  AS      arch/x86/realmode/rm/header.o
  AS      arch/x86/realmode/rm/trampoline_64.o
invalid fixup kind!
UNREACHABLE executed at
../lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp:160!
#0 0x148d682 llvm::sys::PrintStackTrace(_IO_FILE*)
(/mnt/data/llvm36/bin/clang-3.6+0x148d682)
#1 0x148ecab SignalHandler(int) (/mnt/data/llvm36/bin/clang-3.6+0x148ecab)
#2 0x7f948904d210 __restore_rt (/usr/lib/libpthread.so.0+0x10210)
#3 0x7f948828da97 __GI_raise (/usr/lib/libc.so.6+0x33a97)
#4 0x7f948828ee6a __GI_abort (/usr/lib/libc.so.6+0x34e6a)
#5 0x1459b95 llvm::llvm_unreachable_internal(char const*, char const*, unsigned
int) (/mnt/data/llvm36/bin/clang-3.6+0x1459b95)
#6 0xdb5394 (anonymous
namespace)::X86ELFObjectWriter::GetRelocType(llvm::MCValue const&,
llvm::MCFixup const&, bool) const (/mnt/data/llvm36/bin/clang-3.6+0xdb5394)
#7 0x12be355 (anonymous
namespace)::ELFObjectWriter::RecordRelocation(llvm::MCAssembler const&,
llvm::MCAsmLayout const&, llvm::MCFragment const*, llvm::MCFixup const&,
llvm::MCValue, bool&, unsigned long&)
(/mnt/data/llvm36/bin/clang-3.6+0x12be355)
#8 0x12d59a5 llvm::MCAssembler::Finish()
(/mnt/data/llvm36/bin/clang-3.6+0x12d59a5)
#9 0x130f7cc (anonymous namespace)::AsmParser::Run(bool, bool)
(/mnt/data/llvm36/bin/clang-3.6+0x130f7cc)
#10 0x6d9c47 cc1as_main(llvm::ArrayRef<char const*>, char const*, void*)
(/mnt/data/llvm36/bin/clang-3.6+0x6d9c47)
#11 0x6d5362 main (/mnt/data/llvm36/bin/clang-3.6+0x6d5362)
#12 0x7f948827a040 __libc_start_main (/usr/lib/libc.so.6+0x20040)
#13 0x6d245e _start (/mnt/data/llvm36/bin/clang-3.6+0x6d245e)
Stack dump:
0.      Program arguments: /mnt/data/llvm36/bin/clang-3.6 -cc1as -triple
i386-unknown-linux-code16 -filetype obj -main-file-name trampoline_64.S
-target-cpu i386 -target-feature -mmx -target-feature -sse -g
-fdebug-compilation-dir /home/marco/llvmlinux -dwarf-debug-producer clang
version 3.6.0 (branches/release_36 227193) -o
arch/x86/realmode/rm/trampoline_64.o /tmp/trampoline_64-0ebf88.s 
1.      Program arguments: -triple i386-unknown-linux-code16 -filetype obj
-main-file-name trampoline_64.S -target-cpu i386 -target-feature -mmx
-target-feature -sse -g -fdebug-compilation-dir /home/marco/llvmlinux
-dwarf-debug-producer clang version 3.6.0 (branches/release_36 227193) -o
arch/x86/realmode/rm/trampoline_64.o /tmp/trampoline_64-0ebf88.s 
  CC      mm/compaction.o
#0 0x148d682 llvm::sys::PrintStackTrace(_IO_FILE*)
(/mnt/data/llvm36/bin/clang-3.6+0x148d682)
#1 0x148ecab SignalHandler(int) (/mnt/data/llvm36/bin/clang-3.6+0x148ecab)
#2 0x7f948904d210 __restore_rt (/usr/lib/libpthread.so.0+0x10210)
#3 0x7f948828da97 __GI_raise (/usr/lib/libc.so.6+0x33a97)
#4 0x7f948828ee6a __GI_abort (/usr/lib/libc.so.6+0x34e6a)
#5 0x1459b95 llvm::llvm_unreachable_internal(char const*, char const*, unsigned
int) (/mnt/data/llvm36/bin/clang-3.6+0x1459b95)
#6 0xdb5394 (anonymous
namespace)::X86ELFObjectWriter::GetRelocType(llvm::MCValue const&,
llvm::MCFixup const&, bool) const (/mnt/data/llvm36/bin/clang-3.6+0xdb5394)
#7 0x12be355 (anonymous
namespace)::ELFObjectWriter::RecordRelocation(llvm::MCAssembler const&,
llvm::MCAsmLayout const&, llvm::MCFragment const*, llvm::MCFixup const&,
llvm::MCValue, bool&, unsigned long&)
(/mnt/data/llvm36/bin/clang-3.6+0x12be355)
#8 0x12d59a5 llvm::MCAssembler::Finish()
(/mnt/data/llvm36/bin/clang-3.6+0x12d59a5)
#9 0x130f7cc (anonymous namespace)::AsmParser::Run(bool, bool)
(/mnt/data/llvm36/bin/clang-3.6+0x130f7cc)
#10 0x6d9c47 cc1as_main(llvm::ArrayRef<char const*>, char const*, void*)
(/mnt/data/llvm36/bin/clang-3.6+0x6d9c47)
#11 0x6d5362 main (/mnt/data/llvm36/bin/clang-3.6+0x6d5362)
#12 0x7f948827a040 __libc_start_main (/usr/lib/libc.so.6+0x20040)
#13 0x6d245e _start (/mnt/data/llvm36/bin/clang-3.6+0x6d245e)
clang-3.6: error: unable to execute command: Aborted (core dumped)
clang-3.6: error: clang integrated assembler command failed due to signal (use
-v to see invocation)
clang version 3.6.0 (branches/release_36 227193)
Target: i386-unknown-linux-code16
Thread model: posix
clang-3.6: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.6: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.6: note: diagnostic msg: /tmp/trampoline_64-c0a49e.S
clang-3.6: note: diagnostic msg: /tmp/trampoline_64-c0a49e.sh
clang-3.6: note: diagnostic msg: 

********************
  AS      arch/x86/platform/efi/efi_stub_64.o
scripts/Makefile.build:307: recipe for target
'arch/x86/realmode/rm/trampoline_64.o' failed
make[3]: *** [arch/x86/realmode/rm/trampoline_64.o] Error 254
arch/x86/realmode/Makefile:18: recipe for target
'arch/x86/realmode/rm/realmode.bin' failed
make[2]: *** [arch/x86/realmode/rm/realmode.bin] Error 2
scripts/Makefile.build:416: recipe for target 'arch/x86/realmode' failed
make[1]: *** [arch/x86/realmode] Error 2
make[1]: *** Waiting for unfinished jobs....

The two run scripts are:

trampoline_64-489e6f.sh:

 "/mnt/data/llvm-trunk/bin/clang-3.7" "-cc1as" "-triple"
"i386-unknown-linux-code16" "-filetype" "obj" "-main-file-name"
"trampoline_64.S" "-target-cpu" "i386" "-target-feature" "-mmx"
"-target-feature" "-sse" "-g" "-dwarf-debug-producer" "clang version 3.7.0
(trunk 227188)" "/tmp/trampoline_64-47e829.s"

trampoline_64-c0a49e.sh:

 "/mnt/data/llvm36/bin/clang-3.6" "-cc1as" "-triple"
"i386-unknown-linux-code16" "-filetype" "obj" "-main-file-name"
"trampoline_64.S" "-target-cpu" "i386" "-target-feature" "-mmx"
"-target-feature" "-sse" "-g" "-dwarf-debug-producer" "clang version 3.6.0
(branches/release_36 227193)" "/tmp/trampoline_64-0ebf88.s"

I've also attached the preprocessed .S file from the 3.6 segfault.

All the versions of Clang and LLVM I've mentioned have been built with Clang
3.5.1 on Arch Linux (x86_64, linux 3.18.2, gibc 2.20, gcc 4.9.2). LLVM/Clang
3.5.1 is also custom built (not the one shipped by the distro).</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>