Skip to content
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

release/18.x: [libcxx] [modules] Fix relative paths with absolute LIBCXX_INSTALL_MODULES_DIR (#85756) #85907

Closed
wants to merge 2 commits into from

Conversation

llvmbot
Copy link
Collaborator

@llvmbot llvmbot commented Mar 20, 2024

Backport 272d1b4

Requested by: @mstorsjo

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

llvmbot commented Mar 20, 2024

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

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

llvmbot commented Mar 20, 2024

@llvm/pr-subscribers-libcxx

Author: None (llvmbot)

Changes

Backport 272d1b4

Requested by: @mstorsjo


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

1 Files Affected:

  • (modified) libcxx/modules/CMakeLists.txt (+8-2)
diff --git a/libcxx/modules/CMakeLists.txt b/libcxx/modules/CMakeLists.txt
index 0dea8cfca94ac3..8dd1b51aac2f72 100644
--- a/libcxx/modules/CMakeLists.txt
+++ b/libcxx/modules/CMakeLists.txt
@@ -206,9 +206,15 @@ 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.
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_LIBRARY_DIR
+  BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+  OUTPUT_VARIABLE ABS_LIBRARY_DIR)
+cmake_path(ABSOLUTE_PATH LIBCXX_INSTALL_MODULES_DIR
+  BASE_DIRECTORY ${CMAKE_INSTALL_PREFIX}
+  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"

…DULES_DIR (llvm#85756)

In other contexts, install directories such as
LIBCXX_INSTALL_LIBRARY_DIR and LIBCXX_INSTALL_MODULES_DIR can be
specified either as a relative path, relative to CMAKE_INSTALL_PREFIX,
or as an absolute path.

When calculating the relative path between the two, account for the fact
that LIBCXX_INSTALL_MODULES_DIR and LIBCXX_INSTALL_LIBRARY_DIR can be
absolute paths too.

(cherry picked from commit 272d1b4)
…L_PREFIX

This should hopefully fix the issue brought up at
llvm#85756 (comment).

(cherry picked from commit d209d13)
@mstorsjo
Copy link
Member

Closing this backport PR, the original commits had to be reverted (in 4079370).

@mstorsjo mstorsjo closed this Mar 20, 2024
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.

None yet

3 participants