<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 - error: unknown argument: '-m32 -DLIBCXX_BUILDING_LIBCXXABI' when building 32-bit libc++ on x86_64/Linux"
   href="https://bugs.llvm.org/show_bug.cgi?id=49294">49294</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>error: unknown argument: '-m32 -DLIBCXX_BUILDING_LIBCXXABI' when building 32-bit libc++ on x86_64/Linux
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

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

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

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I am seeing a bunch of error: unknown argument: '-m32
-DLIBCXX_BUILDING_LIBCXXABI' when building 32-bit libc++ on x86_64/Linux.

Repro steps:

1. Build clang and compiler-rt builtins

$ cd /path/to/llvm-project
$ mkdir ../build && cd ../build
$ cmake ../llvm-project/llvm 
-DLLVM_ENABLE_PROJECTS="llvm;clang;lld;compiler-rt"
$ ninja clang builtins


2. Try to build 32-bit libc++ as standalone library
(We are in llvm-project/../build directory)

$ mkdir libcxx_build && cd libcxx_build
$  cmake -GNinja  ../../llvm-project/libcxx "-DLLVM_USE_LINKER=lld"
-DCMAKE_C_COMPILER=/path/to/build/bin/clang    
-DCMAKE_CXX_COMPILER=/path/to/build/bin/clang++     -DCMAKE_BUILD_TYPE=Release
"-DLIBCXX_USE_COMPILER_RT=ON" "-DLIBCXX_BUILD_32_BITS=ON"
"-DLIBCXX_CXX_ABI=libcxxabi"
"-DLIBCXX_CXX_ABI_INCLUDE_PATHS=../../llvm-project/libcxxabi/include"

I see following messages in the logs that look surprising. Seems like somewhere
"-m32" and "-DLIBCXX_BUILDING_LIBCXXABI" were combined as a single compiler
option which is causing clang to reject the option.

clang-12: error: unknown argument: '-m32 -DLIBCXX_BUILDING_LIBCXXABI'
-- Failed to find compiler-rt library
clang-12: error: unknown argument: '-m32 -DLIBCXX_BUILDING_LIBCXXABI'
-- Failed to find compiler-rt library
clang-12: error: unknown argument: '-m32 -DLIBCXX_BUILDING_LIBCXXABI'
-- Failed to find compiler-rt library

This does not cause any build breakage but I believe there is some incorrect
compiler flag handling somewhere.</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>