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

[libcxx] modules: compile library interface object files of std and std.compat modules into libc++experimental.a #85832

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions libcxx/modules/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ file(RELATIVE_PATH LIBCXX_MODULE_RELATIVE_PATH
${CMAKE_INSTALL_PREFIX}/${LIBCXX_INSTALL_MODULES_DIR})
configure_file(
"modules.json.in"
"${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
"${LIBCXX_LIBRARY_DIR}/libc++experimental.modules.json"
@ONLY
)

Expand All @@ -229,6 +229,27 @@ if (LIBCXX_INSTALL_MODULES)
)
endforeach()

if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.28.0")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note we're not using this CMake version in the CI so this will fail. But I can look at this locally.

# Build the "library interface object files" as part of the library artifact.
# For now, this adds just the module initializer symbols for modules "std"
# and "std.compat".
target_sources(cxx_experimental PUBLIC FILE_SET CXX_MODULES
BASE_DIRS
"${LIBCXX_GENERATED_MODULE_DIR}"
FILES
"${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
"${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm"
)
set_source_files_properties(
"${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
"${LIBCXX_GENERATED_MODULE_DIR}/std.compat.cppm"
TARGET_DIRECTORY cxx_experimental
PROPERTIES COMPILE_OPTIONS "-U_LIBCPP_BUILDING_LIBRARY;-Wno-reserved-module-identifier")
add_dependencies(cxx_experimental generate-cxx-modules)
else()
message(WARNING "CMake 3.28.0 needed for module symbol support in libc++experimental")
endif()

# Install the generated module files.
install(FILES
"${LIBCXX_GENERATED_MODULE_DIR}/std.cppm"
Expand All @@ -240,7 +261,7 @@ if (LIBCXX_INSTALL_MODULES)

# Install the module manifest.
install(FILES
"${LIBCXX_LIBRARY_DIR}/libc++.modules.json"
"${LIBCXX_LIBRARY_DIR}/libc++experimental.modules.json"
DESTINATION "${LIBCXX_INSTALL_LIBRARY_DIR}"
COMPONENT cxx-modules
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
Expand Down
Loading