<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        font-size:10.0pt;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">This is a workaround, not a fix, but does configuring with -DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE help? That should prevent CMake from having to adjust the rpath at install time.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-left:.5in"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">llvm-dev <llvm-dev-bounces@lists.llvm.org> on behalf of Roland Schatz via llvm-dev <llvm-dev@lists.llvm.org><br>
<b>Reply-To: </b>Roland Schatz <roland.schatz@oracle.com><br>
<b>Date: </b>Friday, December 3, 2021 at 2:28 AM<br>
<b>To: </b>"llvm-dev@lists.llvm.org" <llvm-dev@lists.llvm.org><br>
<b>Subject: </b>[llvm-dev] cmake 3.22 breaks libc++ build<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<p style="margin-left:.5in">Hi,<br>
<br>
I'm currently debugging a problem in our Github Actions build. We're doing a custom build of libc++ and libc++abi, and this is failing since the cmake version in the base image was updated to version 3.22.<br>
<br>
The issue can be reproduced by following the instructions at <a href="https://libcxx.llvm.org/BuildingLibcxx.html">https://libcxx.llvm.org/BuildingLibcxx.html</a>.<br>
<br>
The setup I'm using is this:<br>
* Linux<br>
* cmake version 3.22<br>
* I've tried llvm-project sources 12.0.0, 13.0.0 and the tip of main<br>
* system compiler is clang 12.0.1 (but I don't think that matters here)<br>
<br>
The exact commands I'm running are (the last one is failing [1]):<br>
<span style="font-family:"Courier New";color:black;background:white">cd llvm-project<br>
mkdir build<br>
cmake -G Ninja -S runtimes -B build "-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi" -DCMAKE_INSTALL_PREFIX=install<br>
ninja -C build cxx cxxabi</span><span style="font-family:"Courier New""><br>
<span style="color:black;background:white">ninja -C build install-cxxabi<br>
ninja -C build install-cxx</span></span><o:p></o:p></p>
<p style="margin-left:.5in"><br>
What seems to be happening is that cmake tries to patch the RPATH of libc++.so. But libc++.so is not a symlink to a shared object, it's a linker script.<br>
I have bisected that to a particular cmake change [2].<br>
<br>
<br>
One thing I noticed is that the build works just fine when I'm doing the build of libc++ and libc++abi separately:<o:p></o:p></p>
<pre style="margin-left:.5in">cmake -S libcxxabi ...<o:p></o:p></pre>
<pre style="margin-left:.5in">// build, install, ...<o:p></o:p></pre>
<pre style="margin-left:.5in">cmake -S libcxx -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_LIBRARY_PATH=path/to/install/from/prev/step ...<o:p></o:p></pre>
<p style="margin-left:.5in"><br>
That works on Linux, but breaks the build on Darwin, it seems to be missing the re-exports of libc++abi symbols in libc++ then.<br>
Also that's the "deprecated" way of doing things, so not sure if it's good to pursue that path.<br>
<br>
<br>
To be honest, I'm not sure I fully understand the problem, or how these different ways of building even make a difference.<br>
<br>
Am I doing something wrong? Is this a bug in LLVM's cmake scripts? Or a bug in cmake?<br>
Any hints what I can try to fix this?<br>
<br>
<br>
Thanks!<br>
Roland<o:p></o:p></p>
<p style="margin-left:.5in"><br>
[1] failing build output:<o:p></o:p></p>
<pre style="margin-left:.5in">...<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Installing: /home/roland/test/cmake/llvm-project/install/include/c++/v1/wctype.h<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Installing: /home/roland/test/cmake/llvm-project/install/include/c++/v1/__config_site<o:p></o:p></pre>
<pre style="margin-left:.5in">[4/4] cd /home/roland/test/cmake/llvm-project/build/libcxx/src && /nix/store/n7j...ENT=cxx -P /home/roland/test/cmake/llvm-project/build/libcxx/cmake_install.cmake<o:p></o:p></pre>
<pre style="margin-left:.5in">FAILED: libcxx/src/CMakeFiles/install-cxx /home/roland/test/cmake/llvm-project/build/libcxx/src/CMakeFiles/install-cxx<o:p></o:p></pre>
<pre style="margin-left:.5in">cd /home/roland/test/cmake/llvm-project/build/libcxx/src && /nix/store/n7jz18i0cspdkfd1y0w1mg5rqvs15kdr-cmake-3.22.0/bin/cmake -DCMAKE_INSTALL_COMPONENT=cxx -P /home/roland/test/cmake/llvm-project/build/libcxx/cmake_install.cmake<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Install configuration: ""<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Installing: /home/roland/test/cmake/llvm-project/install/lib/libc++.so.1.0<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Installing: /home/roland/test/cmake/llvm-project/install/lib/libc++.so.1<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Set runtime path of "/home/roland/test/cmake/llvm-project/install/lib/libc++.so.1.0" to ""<o:p></o:p></pre>
<pre style="margin-left:.5in">-- Installing: /home/roland/test/cmake/llvm-project/install/lib/libc++.so<o:p></o:p></pre>
<pre style="margin-left:.5in">CMake Error at cmake_install.cmake:88 (file):<o:p></o:p></pre>
<pre style="margin-left:.5in">  file RPATH_CHANGE could not write new RPATH:<o:p></o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in">  to the file:<o:p></o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in">    /home/roland/test/cmake/llvm-project/install/lib/libc++.so<o:p></o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in">Call Stack (most recent call first):<o:p></o:p></pre>
<pre style="margin-left:.5in">  /home/roland/test/cmake/llvm-project/build/libcxx/cmake_install.cmake:56 (include)<o:p></o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<pre style="margin-left:.5in">ninja: build stopped: subcommand failed.<o:p></o:p></pre>
<pre style="margin-left:.5in"><o:p> </o:p></pre>
<p style="margin-left:.5in">[2] <a href="https://github.com/Kitware/CMake/commit/2e1149874d34b63cc16c7330ce1ef5ef779e5140">https://github.com/Kitware/CMake/commit/2e1149874d34b63cc16c7330ce1ef5ef779e5140</a><o:p></o:p></p>
</div>
</body>
</html>