[compiler-rt] [compiler-rt] Make add_custom_libcxx() resilient to DESTDIR being set (PR #115525)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 10:05:48 PST 2024


https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/115525

If DESTDIR is set in the environment during the build/test stage, the
local libc++ installation will be installed under DESTDIR instead of being
in the build directory.

See https://github.com/llvm/llvm-project/pull/115077#issuecomment-2464640457
and https://gitlab.kitware.com/cmake/cmake/-/issues/18165.


>From e336a2a7e2c5e80764bf4935b3a4517ad0f9e203 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Fri, 8 Nov 2024 10:05:29 -0800
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6-beta.1
---
 compiler-rt/cmake/Modules/AddCompilerRT.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index 6b96a5147753e7..b196278209a364 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -713,6 +713,9 @@ macro(add_custom_libcxx name prefix)
     USES_TERMINAL_INSTALL 1
     LIST_SEPARATOR |
     EXCLUDE_FROM_ALL TRUE
+    # Ensure that DESDIR=... set in the out environment does not affect this
+    # target (we always need to install to the build directory).
+    INSTALL_COMMAND env DESTDIR= ${CMAKE_COMMAND} --build ${prefix}/build --target install
     INSTALL_BYPRODUCTS "${prefix}/lib/libc++.a" "${prefix}/lib/libc++abi.a"
     )
 



More information about the llvm-commits mailing list