On Jul 7, 2025, at 07:29, Lexi Winter <i...@freebsd.org> wrote:

> Mark Millard:
>> Lexi Winter <ivy_at_FreeBSD.org> wrote on
>>> clang: install clang-scan-deps
> 
>> Would it be reasonable to also enable generation/installation of,
>> 
>> /usr/lib/libc++.module.json (a guess about where it goes)
>> 
>> /usr/include/c++/v1/std.cppm
>> /usr/include/c++/v1/v1/std.compat.cppm
> 
> i am not familiar with libc++.module.json, but yes, i was intending to
> look at whether we can ship std.cppm and related files for import std.
> 
> are you aware of any build system which is capable of consuming these,
> for testing?  i believe, at least the last time i looked, CMake did not
> have support for this.

It has been available since at least cmake 3.30 but
involves use of CMAKE_EXPERIMENTAL_CXX_IMPORT_STD .
But pure command line use is also possible without
cmake as well.

For example usage see:

https://igormcoelho.medium.com/its-time-to-use-cxx-modules-on-modern-c-41a574b77e83

for recent basic notes about both gcc15 and llvm19
in a linux context, for example. It includes material
about using cmake. That involved:

set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")

The quoted string changes sometimes with cmake
version changes. See:

https://github.com/Kitware/CMake/blob/master/Help/dev/experimental.rst

and its "C++ import std support" section. Select
which vintage to look at based on Tags, matching
the cmake version one is going to use.

(Looking around, the value can change and then in
a later version change back to a prior value.)

The notation used as an example is (cmake 4.0.0 is
used, as is clang++ 19.1.7 if the comment status
vs. gcc15 is changed):

QUOTE
cmake_minimum_required(VERSION 4.0.0)
set(CMAKE_CXX_COMPILER /usr/bin/g++-15)
# set(CMAKE_CXX_COMPILER /usr/bin/clang++-19)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")

set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
set(CMAKE_CXX_MODULE_STD 1)

project(example2 VERSION 0.1.0 LANGUAGES CXX)

add_library(demo)

target_sources(demo PUBLIC FILE_SET CXX_MODULES FILES demo.cppm)

add_executable(example2 main2.cpp)

target_link_libraries(example2 PRIVATE demo)
END QUOTE

As FreeBSD does not support use of -stdlib=libstdc++
via any clang++* , It may be that explicit
-stdlib=libc++ use is not required for any clang++ .
But lang/gcc15 and the like do support both
-stdlib=libstdc++ and -stdlib=libc++ . But I do not
know if the likes of gcc15 are set up to allow
"import std;" or "import std.compat;" for either
or both of those.

The old, original cmake material about "import std;"
support is at:

https://www.kitware.com/import-std-in-cmake-3-30/

It actually used: cmake 3.29.20240416 and a patched
llvm18.1.1 .

It seem far enough along at this point to experiment
with if things were enabled to allow such.

===
Mark Millard
marklmi at yahoo.com


Reply via email to