<html>
    <head>
      <base href="https://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 --- - After r249655, -save-temps causes -cc1as mode to crash"
   href="https://llvm.org/bugs/show_bug.cgi?id=26999">26999</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>After r249655, -save-temps causes -cc1as mode to crash
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>dimitry@andric.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>In r249655, there was an overhaul of the -g flag handling in the driver.  This
seems to have caused a problem when you use -g in combination with -save-temps:

$ echo "int main(void) { return 0; }" > test.c
$ clang -g -save-temps -c test.c
Unknown version
UNREACHABLE executed at /share/dim/src/llvm/trunk/lib/MC/MCDwarf.cpp:1257!
clang-3.9: error: unable to execute command: Abort trap (core dumped)
clang-3.9: error: clang integrated assembler command failed due to signal (use
-v to see invocation)
clang version 3.9.0 (trunk 263389)
Target: i386-unknown-freebsd11.0
Thread model: posix
InstalledDir: /share/dim/llvm/263389-trunk-freebsd11-i386-ninja-rel-1/bin

Running the same command with -v shows that the cc1as stage is run as follows:

clag -cc1as -triple i386-unknown-freebsd11.0 -filetype obj -main-file-name
test.c -target-cpu i486 -mrelocation-model static -mrelax-all -o test.o test.s

Because no -g option is passed, cc1as_main.cpp sets the DwarfVersion to 0, and
this causes an assertion failure in MCDwarf.cpp's getCIEVersion() function:

  1245  static unsigned getCIEVersion(bool IsEH, unsigned DwarfVersion) {
  1246    if (IsEH)
  1247      return 1;
  1248    switch (DwarfVersion) {
  1249    case 2:
  1250      return 1;
  1251    case 3:
  1252      return 3;
  1253    case 4:
  1254    case 5:
  1255      return 4;
  1256    }
  1257    llvm_unreachable("Unknown version");
  1258  }

This function was called by FrameEmitterImpl::EmitCIE(), because the .s file
generated by the previous .c -> .s stage contains debugging directives.

Either the -cc1as stage should get a -dwarfversion flag passed by the previous
stage, or it should not set the DwarfVersion to 0 by default.  (But if not
zero, then the DwarfVersion is really dependent on the platform and target...)</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>