<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - Driver does not honour "-mthumb" for pre-processed assembler and assembler jobs."
   href="https://bugs.llvm.org/show_bug.cgi?id=38559">38559</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Driver does not honour "-mthumb" for pre-processed assembler and assembler jobs.
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>All
          </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>iains-llvm@btconnect.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=20710" name="attach_20710" title="Recognise -mthumb for assembler tasks.">attachment 20710</a> <a href="attachment.cgi?id=20710&action=edit" title="Recognise -mthumb for assembler tasks.">[details]</a></span>
Recognise -mthumb for assembler tasks.

Ran into this trying to build newlib.

case 1;

we invoke with
 ./bin/clang -target arm-none-linux-gnu -mcpu=cortex-a7 -mfpu=neon-vfpv4
-mfloat-abi=hard -mthumb /src/test-arm/thumb-mode.S -c

The driver constructs two jobs (1) to pre-process the ".S" file and (2) to
assemble the resulting ".s" file.

the ivocation for the first job is correct ; the "triple" is updated to
"thumbv7".
./bin/clang -cc1 -triple thumbv7-none-linux-gnu -E -save-temps=cwd 

the invocation for the second is not : the triple is not updated :

./bin/clang -cc1as -triple armv7-none-linux-gnu

case 2:

./bin/clang -target arm-none-linux-gnu -mcpu=cortex-a7 -mfpu=neon-vfpv4
-mfloat-abi=hard -mthumb thumb-mode.s -c -save-temps

the 'triple' is again not updated to include the thumb component - the cc1as
mode does not recognise -mthumb (but only -Wa/Xassembler -mthumb).

output in both cases:
/src/test-arm/thumb-mode.S:16:2: error: instruction requires: thumb
 cbnz r0, .Ltail


===

proposed fix (attached) - recognise the -mthumb flag for assembler tasks this
is consistent with other tools.


alternate fix ; the driver could intercept the thumb flag and push back the
Xassembler -mthumb option.  This seems more complex.

===

However, since the current behaviour seems deliberate (there is a driver test
case matching it) - so it's not clear what the intent should be (e.g. does we
expect the user to enter "-mthumb -Wa,-mthumb" ?)

===

test-case

$ more /src/test-arm/thumb-mode.S
#define synd            r0

        .syntax unified
        .arch   armv7-a
        .fpu    neon

        .text
        .thumb_func

        .global foo
        .type foo,%function
        .cfi_startproc

foo:

        cbnz synd, .Ltail
        nop
        nop
        nop
.Ltail:
        nop

        bx      lr

        .cfi_endproc
        .size   foo, . - foo</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>