<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 - clang -O2 BPF netd.o failed to boot on some Android devices"
   href="https://bugs.llvm.org/show_bug.cgi?id=52390">52390</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang -O2 BPF netd.o failed to boot on some Android devices
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>LLVM Codegen
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chh@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=25418" name="attach_25418" title="zip of netd.i.c, netd.old.s, netd.new.s">attachment 25418</a> <a href="attachment.cgi?id=25418&action=edit" title="zip of netd.i.c, netd.old.s, netd.new.s">[details]</a></span>
zip of netd.i.c, netd.old.s, netd.new.s

When upgrading Android's prebuilt clang/llvm compiler tools,
we found boot failures on some but not all ARM devices.
We tried to revert one change <a href="https://reviews.llvm.org/D107281">https://reviews.llvm.org/D107281</a>
and then passed booting on all failing devices.

We found that D107281 changed -O2 output of Android's
system/netd/bpf_progs/netd.c. By replacing that .o file
with one compiled by older compiler, or with only -O1,
Android can boot again on the failing devices.

Without knowing the exact impact of D107281 on BPF and specific
ARM devices, we are looking for reverting this change at least
for the Android platform and/or BPF target.
Could someone take a look of the attached output files and suggest a fix?

(1) netd.i.c    (preprocessed file from AOSP)
(2) netd.old.s  (compiled by older clang without D107281)
(3) netd.new.s  (compiled by clang with D107281, fail to boot)

The files are generated from AOSP source tree:

prebuilts/clang/host/linux-x86/clang-r433403b/bin/clang \
--target=bpf -nostdlibinc -no-canonical-prefixes \
-O2 -isystem bionic/libc/include \
-isystem bionic/libc/kernel/uapi \
-isystem bionic/libc/kernel/uapi/asm-arm64 \
-isystem bionic/libc/kernel/android/uapi \
-I system/core/libcutils/include \
-I system/bpf/progs/include \
-I system/netd/bpf_progs \
-I system/netd/libnetdbpf/include \
-I system/netd/libnetdutils/include \
system/netd/bpf_progs/netd.c \
-E -o /tmp/netd.i.c

# use clang without D107281, or with AOSP prebuilt clang
prebuilts/clang/host/linux-x86/clang-r433403b/bin/clang \
--target=bpf -nostdlibinc -no-canonical-prefixes -O2 \
/tmp/netd.i.c -S -o /tmp/netd.old.s

# use the latest clang or a version after D107281:
clang --target=bpf -nostdlibinc -no-canonical-prefixes -O2 \
/tmp/netd.i.c -S -o /tmp/netd.new.s</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>