<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 by default creates ELFv1 binaries for powerpc64-unknown-freebsd target"
   href="https://bugs.llvm.org/show_bug.cgi?id=51585">51585</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clang by default creates ELFv1 binaries for powerpc64-unknown-freebsd target
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>pkubaj@anongoth.pl
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When passed --target=powerpc64-unknown-freebsd, clang creates ELFv1 binaries,
even on a ELFv2 system. ELFv2 binaries are created only when the version is
appended, like --target=powerpc64-unknown-freebsd13.0.

Since ELFv1 is generally considered legacy on FreeBSD and on life support, it's
fine to just default to ELFv2. Clang never worked properly on FreeBSD on ELFv1
anyway.

The following patch fixes this issue.

--- clang/lib/Driver/ToolChains/Clang.cpp.orig  2021-08-11 19:51:00.122735000
+0200
+++ clang/lib/Driver/ToolChains/Clang.cpp       2021-08-11 19:51:24.346107000
+0200
@@ -1921,8 +1921,7 @@
   if (T.isOSBinFormatELF()) {
     switch (getToolChain().getArch()) {
     case llvm::Triple::ppc64: {
-      if ((T.isOSFreeBSD() && T.getOSMajorVersion() >= 13) ||
-          T.isOSOpenBSD() || T.isMusl())
+      if (T.isOSFreeBSD() || T.isOSOpenBSD() || T.isMusl())
         ABIName = "elfv2";
       else
         ABIName = "elfv1";</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>