<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/56311>56311</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            The 'default build' puts the compiler-rt libraries in the wrong place
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Mark-Dunn-OIL
      </td>
    </tr>
</table>

<pre>
    The document [https://libcxx.llvm.org//BuildingLibcxx.html](url) Introduces the concept of a 'Default Build', but building compiler-rt in this style causes the compiler-rt libraries to be put in the wrong place.

In the file .../compiler-rt/cmake/base-config-ix.cmake line: 33
```
# Setting these variables from an LLVM build is sufficient that compiler-rt can
# construct the output paths, so it can behave as if it were in-tree here.
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSION)
  set(LLVM_TREE_AVAILABLE On)
endif()

if (LLVM_TREE_AVAILABLE)
  # Compute the Clang version from the LLVM version.
  # FIXME: We should be able to reuse CLANG_VERSION variable calculated
  #        in Clang cmake files, instead of copying the rules here.
  string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION
         ${PACKAGE_VERSION})
  # Setup the paths where compiler-rt runtimes and headers should be stored.
  set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION})
  set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
  set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION})
  option(COMPILER_RT_INCLUDE_TESTS "Generate and build compiler-rt unit tests."
         ${LLVM_INCLUDE_TESTS})
  option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered"
         ${LLVM_ENABLE_WERROR})
```
The PACKAGE_VERSION is unavailble (but both LLVM_LIBRARY_OUTPUT_INTDIR and LLVM_RUNTIME_OUTPUT_INTDIR are)
and therefore depending on the value of LLVM_ENABLE_PER_TARGET_RUNTIME_DIR  the libraries are put in either: 
> \<build directory>/compiler-rt/lib/\<triple> or
>  \<build directory>/compiler-rt/lib/\<operating system>

and installed to 
> \<parent directory>/lib/\<triple> or
>  \<parent directory>/lib/\<operating system>

where \<parent directory> represents the parent directory of the clang binary or library

clang looks for them in:
> \<parent directory>/lib/clang/\<clang version>/lib/\<triple> or
> \<parent directory>/lib/clang/\<clang version>/lib/\<operating system>

 If we used CMAKE_C_COMPILER_ID and CMAKE_C_COMPILER_VERSION they would go in the correct place.
> \<build directory>/compiler-rt/lib/\<CMAKE_C_COMPILER_ID>/\<CMAKE_C_COMPILER_VERSION>/\<triple> or
> \<build directory>/lib/<CMAKE_C_COMPILER_ID>/\<CMAKE_C_COMPILER_VERSION>/lib/\<operating system>
```
# Setting these variables from an LLVM build is sufficient that compiler-rt can
# construct the output paths, so it can behave as if it were in-tree here.
if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND CMAKE_C_COMPILER_VERSION)
  set(LLVM_TREE_AVAILABLE On)
endif()

if (LLVM_TREE_AVAILABLE)
  # Setup the paths where compiler-rt runtimes and headers should be stored.
  set(COMPILER_RT_OUTPUT_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${CMAKE_C_COMPILER_ID}/${CMAKE_C_COMPILER_VERSION})
  set(COMPILER_RT_EXEC_OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
  set(COMPILER_RT_INSTALL_PATH lib${LLVM_LIBDIR_SUFFIX}/clang/${CMAKE_C_COMPILER_VERSION})
```
Fixing the FIXME: on line 41 in time for your release?





</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzlWNty4jgQ_RrzooICG0LywINjTMY1QFLEycw-uWRbBu0YyyXLSfj76ZYN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