Skip to content

release/18.x: Reapply [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#86020) #86197

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024

Conversation

llvmbot
Copy link
Member

@llvmbot llvmbot commented Mar 21, 2024

Backport 50801f1

Requested by: @mstorsjo

@llvmbot llvmbot requested a review from a team as a code owner March 21, 2024 20:48
@llvmbot llvmbot added this to the LLVM 18.X Release milestone Mar 21, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Mar 21, 2024

@mordante What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from mordante March 21, 2024 20:48
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 21, 2024
@llvmbot
Copy link
Member Author

llvmbot commented Mar 21, 2024

@llvm/pr-subscribers-libcxx

Author: None (llvmbot)

Changes

Backport 50801f1

Requested by: @mstorsjo


Full diff: https://github.com/llvm/llvm-project/pull/86197.diff

1 Files Affected:

  • (modified) libcxx/modules/CMakeLists.txt (+13-2)
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 0dea8cfca94ac3..d47d19a4755317 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -206,9 +206,20 @@ add_custom_target(generate-cxx-modules
 # Configure the modules manifest.
 # Use the relative path between the installation and the module in the json
 # file. This allows moving the entire installation to a different location.
+if("${CMAKE_INSTALL_PREFIX}" STREQUAL "")
+  set(BASE_DIRECTORY "/")
+else()
+  set(BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX})
+endif()
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
+  BASE_DIRECTORY ${BASE_DIRECTORY}
+  OUTPUT_VARIABLE ABS_LIBRARY_DIR)
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
+  BASE_DIRECTORY ${BASE_DIRECTORY}
+  OUTPUT_VARIABLE ABS_MODULES_DIR)
 file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
-  ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_LIBRARY_DIR}
-  ${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
+  ${ABS_LIBRARY_DIR}
+  ${ABS_MODULES_DIR})
 configure_file(
   "modules.json.in"
   "${LIBCXX_LIBRARY_DIR}/libc++.modules.json"

@tstellar
Copy link
Collaborator

Hi @mstorsjo (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix.

@tstellar
Copy link
Collaborator

@mordante Is the test failure legitimate?

@mordante
Copy link
Member

@mordante Is the test failure legitimate?

I've checked and the test failure is unrelated to this patch.

…STALL_MODULES_DIR (llvm#86020)

This reapplies 272d1b4 (from llvm#85756),
which was reverted in
4079370.

In the previous attempt, empty CMAKE_INSTALL_PREFIX was handled by
quoting them, in d209d13. That made the
calls to cmake_path(ABSOLUTE_PATH) succeed, but the output paths of that
weren't actually absolute, which was required by file(RELATIVE_PATH).

Avoid this issue by constructing a non-empty base directory variable
to use for calculating the relative path.

(cherry picked from commit 50801f1)
@tstellar tstellar merged commit 0cd4bab into llvm:release/18.x Mar 28, 2024
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
Development

Successfully merging this pull request may close these issues.

4 participants