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

[C++20] [Modules] Should module partitions be embedded in the primary BMI? #62837

Closed
aaronmondal opened this issue May 21, 2023 · 4 comments
Closed
Labels
clang:modules C++20 modules and Clang Header Modules

Comments

@aaronmondal
Copy link
Member

After e22fa1d it is now required to explicitly specify all dependencies that make up a module. This is a good change in terms of correctness and ease of downstream build system integration, but it exposed some issues regarding target encapsulation and command line length. For instance, below is how the command line for a hello world looks like with libcxx module std in rules_ll:

import std;

auto main() -> int {
  std::cout << "Hello, World!" << std::endl;
  return 0;
}
Details

clang version 17.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/clang
 (in-process)
 "bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/clang/clang++" -cc1 -triple x86_64-unknown-linux-gn
u -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=
all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=standalone -dwarf-version=5
 -debugger-tuning=lldb -v -fprofile-instrument=clang -fcoverage-mapping -fcoverage-compilation-dir=. -nostdsysteminc -nobuiltininc -resource-dir bazel-out/k8-fastbuild/bin/ex
ternal/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/clang/staging -idirafter bazel-out/k8-fastbuild/bin/external/llvm-project-overlay~17-init-bcr.3~ll
vm_project_overlay~llvm-project/clang/staging/include -isystem bazel-out/k8-fastbuild/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx
/include -isystem external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/include -isystem external/llvm-project-overlay~17-init-bcr.3~llvm_proje
ct_overlay~llvm-project/libcxxabi/include -isystem external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libunwind/include -isystem /nix/store/rfw51dq
r3qn7b6fjy8hmx6f0x3hfwbx6-glibc-2.37-8-dev/include -isystem /nix/store/fxhq0kn94fi877clk03ksrvxxpv234x8-libxcrypt-4.4.33/include -isystem /nix/store/qi7q5hkzj7rdiwyzyrkzkrnrs
8jml30k-libdrm-2.4.115-dev/include -isystem /nix/store/qi7q5hkzj7rdiwyzyrkzkrnrs8jml30k-libdrm-2.4.115-dev/include/libdrm -isystem /nix/store/064sjbh3l2b0hicr5lv0y9wxgpmjj7rs
-elfutils-0.189-dev/include -isystem /nix/store/1zq3bi0xs3m3lsq4r4vlspx9vzygg2xk-numactl-2.0.16-dev/include -isystem /nix/store/syfid5mrc3w354m9dpsknhkz80c7a7pm-libglvnd-1.6.
0-dev/include -isystem /nix/store/1xsnjfdqb7ha3jmy05nd437v3wmj887s-libX11-1.8.4-dev/include -isystem /nix/store/x5bim40wygc2847f3fz2c7g93p9c9fc2-xorgproto-2021.5/include -I /
nix/store/yqcfva8mcsg230bmhcczw5pw2sjxbvnh-openssl-3.0.8-dev/include -D _LIBCPP_ENABLE_EXPERIMENTAL -D _LIBCPP_REMOVE_TRANSITIVE_INCLUDES -D _LIBCPP_NO_ABI_TAG -Wdate-time -s
td=c++2b -fdeprecated-macro -fdebug-compilation-dir=. -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fmodule-file=std=bazel-out/k8-fastbuild-ST-1b2103630309/bin
/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/libcxx/std.pcm -fmodule-file=std:algorithm=bazel-out/k8-fastbuild-ST-1b210363030
9/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/algorithm.pcm -fmodule-file=std:any=bazel-out/k8-fastbuild-ST-1b
2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/any.pcm -fmodule-file=std:array=bazel-out/k8-fastbuild-
ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/array.pcm -fmodule-file=std:atomic=bazel-out/k8-fa
stbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/atomic.pcm -fmodule-file=std:barrier=bazel
-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/barrier.pcm -fmodule-file=std:bi
t=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/bit.pcm -fmodule-file=std
:bitset=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/bitset.pcm -fmodule
-file=std:cassert=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cassert.p
cm -fmodule-file=std:cctype=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx
/cctype.pcm -fmodule-file=std:cerrno=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/s
td/libcxx/cerrno.pcm -fmodule-file=std:cfenv=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/m
odules/std/libcxx/cfenv.pcm -fmodule-file=std:cfloat=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/
libcxx/modules/std/libcxx/cfloat.pcm -fmodule-file=std:charconv=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~ll
vm-project/libcxx/modules/std/libcxx/charconv.pcm -fmodule-file=std:chrono=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project
_overlay~llvm-project/libcxx/modules/std/libcxx/chrono.pcm -fmodule-file=std:cinttypes=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~
llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cinttypes.pcm -fmodule-file=std:climits=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~1
7-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/climits.pcm -fmodule-file=std:clocale=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-projec
t-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/clocale.pcm -fmodule-file=std:cmath=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/ll
vm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cmath.pcm -fmodule-file=std:codecvt=bazel-out/k8-fastbuild-ST-1b2103630309/bin/ex
ternal/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/codecvt.pcm -fmodule-file=std:compare=bazel-out/k8-fastbuild-ST-1b210363
0309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/compare.pcm -fmodule-file=std:complex=bazel-out/k8-fastbuild-
ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/complex.pcm -fmodule-file=std:concepts=bazel-out/k
8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/concepts.pcm -fmodule-file=std:conditi
on_variable=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/condition_varia
ble.pcm -fmodule-file=std:coroutine=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/st
d/libcxx/coroutine.pcm -fmodule-file=std:csetjmp=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libc
xx/modules/std/libcxx/csetjmp.pcm -fmodule-file=std:csignal=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-p
roject/libcxx/modules/std/libcxx/csignal.pcm -fmodule-file=std:cstdarg=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_ove
rlay~llvm-project/libcxx/modules/std/libcxx/cstdarg.pcm -fmodule-file=std:cstddef=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_
project_overlay~llvm-project/libcxx/modules/std/libcxx/cstddef.pcm -fmodule-file=std:cstdio=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-b
cr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cstdio.pcm -fmodule-file=std:cstdlib=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay
~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cstdlib.pcm -fmodule-file=std:cstdint=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-proj
ect-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cstdint.pcm -fmodule-file=std:cstring=bazel-out/k8-fastbuild-ST-1b2103630309/bin/externa
l/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cstring.pcm -fmodule-file=std:ctime=bazel-out/k8-fastbuild-ST-1b2103630309/bi
n/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/ctime.pcm -fmodule-file=std:cuchar=bazel-out/k8-fastbuild-ST-1b21036
30309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cuchar.pcm -fmodule-file=std:cwchar=bazel-out/k8-fastbuild-S
T-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cwchar.pcm -fmodule-file=std:cwctype=bazel-out/k8-f
astbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/cwctype.pcm -fmodule-file=std:deque=bazel
-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/deque.pcm -fmodule-file=std:exce
ption=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/exception.pcm -fmodul
e-file=std:execution=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/execut
ion.pcm -fmodule-file=std:expected=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std
/libcxx/expected.pcm -fmodule-file=std:filesystem=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/lib
cxx/modules/std/libcxx/filesystem.pcm -fmodule-file=std:flat_map=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~l
lvm-project/libcxx/modules/std/libcxx/flat_map.pcm -fmodule-file=std:flat_set=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_proj
ect_overlay~llvm-project/libcxx/modules/std/libcxx/flat_set.pcm -fmodule-file=std:format=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.
3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/format.pcm -fmodule-file=std:forward_list=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overl
ay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/forward_list.pcm -fmodule-file=std:fstream=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/ll
vm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/fstream.pcm -fmodule-file=std:functional=bazel-out/k8-fastbuild-ST-1b2103630309/b
in/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/functional.pcm -fmodule-file=std:future=bazel-out/k8-fastbuild-ST-1
b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/future.pcm -fmodule-file=std:generator=bazel-out/k8-fa
stbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/generator.pcm -fmodule-file=std:initialize
r_list=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/initializer_list.pcm
 -fmodule-file=std:iomanip=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/
iomanip.pcm -fmodule-file=std:ios=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/
libcxx/ios.pcm -fmodule-file=std:iosfwd=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/module
s/std/libcxx/iosfwd.pcm -fmodule-file=std:iostream=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/li
bcxx/modules/std/libcxx/iostream.pcm -fmodule-file=std:istream=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llv
m-project/libcxx/modules/std/libcxx/istream.pcm -fmodule-file=std:iterator=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project
_overlay~llvm-project/libcxx/modules/std/libcxx/iterator.pcm -fmodule-file=std:latch=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~ll
vm_project_overlay~llvm-project/libcxx/modules/std/libcxx/latch.pcm -fmodule-file=std:limits=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-
bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/limits.pcm -fmodule-file=std:list=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~1
7-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/list.pcm -fmodule-file=std:locale=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-ov
erlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/locale.pcm -fmodule-file=std:map=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-proj
ect-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/map.pcm -fmodule-file=std:mdspan=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llv
m-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/mdspan.pcm -fmodule-file=std:memory=bazel-out/k8-fastbuild-ST-1b2103630309/bin/ext
ernal/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/memory.pcm -fmodule-file=std:memory_resource=bazel-out/k8-fastbuild-ST-1b
2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/memory_resource.pcm -fmodule-file=std:mutex=bazel-out/k
8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/mutex.pcm -fmodule-file=std:numbers=ba
zel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/numbers.pcm -fmodule-file=std
:numeric=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/numeric.pcm -fmodu
le-file=std:optional=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/option
al.pcm -fmodule-file=std:ostream=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/l
ibcxx/ostream.pcm -fmodule-file=std:print=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modu
les/std/libcxx/print.pcm -fmodule-file=std:queue=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libc
xx/modules/std/libcxx/queue.pcm -fmodule-file=std:random=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-proj
ect/libcxx/modules/std/libcxx/random.pcm -fmodule-file=std:ranges=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~
llvm-project/libcxx/modules/std/libcxx/ranges.pcm -fmodule-file=std:ratio=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_
overlay~llvm-project/libcxx/modules/std/libcxx/ratio.pcm -fmodule-file=std:regex=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_p
roject_overlay~llvm-project/libcxx/modules/std/libcxx/regex.pcm -fmodule-file=std:scoped_allocator=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17
-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/scoped_allocator.pcm -fmodule-file=std:semaphore=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/l
lvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/semaphore.pcm -fmodule-file=std:set=bazel-out/k8-fastbuild-ST-1b2103630309/bin/e
xternal/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/set.pcm -fmodule-file=std:shared_mutex=bazel-out/k8-fastbuild-ST-1b2103
630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/shared_mutex.pcm -fmodule-file=std:source_location=bazel-ou
t/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/source_location.pcm -fmodule-file=s
td:span=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/span.pcm -fmodule-f
ile=std:spanstream=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/spanstre
am.pcm -fmodule-file=std:sstream=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/l
ibcxx/sstream.pcm -fmodule-file=std:stack=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modu
les/std/libcxx/stack.pcm -fmodule-file=std:stacktrace=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project
/libcxx/modules/std/libcxx/stacktrace.pcm -fmodule-file=std:stdexcept=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_over
lay~llvm-project/libcxx/modules/std/libcxx/stdexcept.pcm -fmodule-file=std:stdfloat=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llv
m_project_overlay~llvm-project/libcxx/modules/std/libcxx/stdfloat.pcm -fmodule-file=std:stop_token=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17
-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/stop_token.pcm -fmodule-file=std:streambuf=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-pr
oject-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/streambuf.pcm -fmodule-file=std:string=bazel-out/k8-fastbuild-ST-1b2103630309/bin/exte
rnal/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/string.pcm -fmodule-file=std:string_view=bazel-out/k8-fastbuild-ST-1b21036
30309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/string_view.pcm -fmodule-file=std:strstream=bazel-out/k8-fas
tbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/strstream.pcm -fmodule-file=std:syncstream=
bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/syncstream.pcm -fmodule-fil
e=std:system_error=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/system_e
rror.pcm -fmodule-file=std:thread=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/
libcxx/thread.pcm -fmodule-file=std:tuple=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modu
les/std/libcxx/tuple.pcm -fmodule-file=std:typeindex=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/
libcxx/modules/std/libcxx/typeindex.pcm -fmodule-file=std:typeinfo=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay
~llvm-project/libcxx/modules/std/libcxx/typeinfo.pcm -fmodule-file=std:type_traits=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm
_project_overlay~llvm-project/libcxx/modules/std/libcxx/type_traits.pcm -fmodule-file=std:unordered_map=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overl
ay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/unordered_map.pcm -fmodule-file=std:unordered_set=bazel-out/k8-fastbuild-ST-1b2103630309/bin/exte
rnal/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/unordered_set.pcm -fmodule-file=std:utility=bazel-out/k8-fastbuild-ST-1b21
03630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/utility.pcm -fmodule-file=std:valarray=bazel-out/k8-fastb
uild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/valarray.pcm -fmodule-file=std:variant=bazel-
out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/variant.pcm -fmodule-file=std:vec
tor=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/vector.pcm -fmodule-fil
e=std:version=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/version.pcm -
fmodule-file=std:__new=bazel-out/k8-fastbuild-ST-1b2103630309/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/modules/std/libcxx/new.
pcm -fcxx-exceptions -fexceptions -fcolor-diagnostics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o bazel-out/k8-fastbuild/bin/std_module_example/std_module_example/main.o -x c++ std_modu
le_example/main.cpp
clang -cc1 version 17.0.0 based upon LLVM 17.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libunwind/include"
#include "..." search starts here:
#include <...> search starts here:
 /nix/store/yqcfva8mcsg230bmhcczw5pw2sjxbvnh-openssl-3.0.8-dev/include
 bazel-out/k8-fastbuild/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/include
 external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxx/include
 external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/libcxxabi/include
 /nix/store/rfw51dqr3qn7b6fjy8hmx6f0x3hfwbx6-glibc-2.37-8-dev/include
 /nix/store/fxhq0kn94fi877clk03ksrvxxpv234x8-libxcrypt-4.4.33/include
 /nix/store/qi7q5hkzj7rdiwyzyrkzkrnrs8jml30k-libdrm-2.4.115-dev/include
 /nix/store/qi7q5hkzj7rdiwyzyrkzkrnrs8jml30k-libdrm-2.4.115-dev/include/libdrm
 /nix/store/064sjbh3l2b0hicr5lv0y9wxgpmjj7rs-elfutils-0.189-dev/include
 /nix/store/1zq3bi0xs3m3lsq4r4vlspx9vzygg2xk-numactl-2.0.16-dev/include
 /nix/store/syfid5mrc3w354m9dpsknhkz80c7a7pm-libglvnd-1.6.0-dev/include
 /nix/store/1xsnjfdqb7ha3jmy05nd437v3wmj887s-libX11-1.8.4-dev/include
 /nix/store/x5bim40wygc2847f3fz2c7g93p9c9fc2-xorgproto-2021.5/include
 bazel-out/k8-fastbuild/bin/external/llvm-project-overlay~17-init-bcr.3~llvm_project_overlay~llvm-project/clang/staging/include
End of search list.
Target //std_module_example:std_module_example up-to-date:
  bazel-bin/std_module_example/std_module_example/std_module_example

This is not an issue for build systems, but it makes it hard to write command lines by hand that depend on e.g. the std module. It's also not ideal if one wants to debug a command line since there is so much noise caused by all the partitions.

My main gripe though is that this makes it hard to clearly impose boundaries on a target. A module partition, which I'd generally consider an implementation detail, will leak transitively into all downstream targets. It will always need to be present, it's path needs to be known, and it will always influence all downstream command lines.

A potential solution could be to embed partitions in the primary module interface unit by default. This would allow for shorter command lines while still being explicit. It would come at the cost of having the binary of every partition twice - once in the original partition BMI and once in the BMI of the primary module interface. This is somewhat similar to object/archive and object/shared-object relationships.

Intuitively, I believe that this is also beneficial for distributed builds, as we'd only need to query remote caches once for the existence of a module's primary BMI instead of having to query (in the case of std) 50 partitions. I haven't benchmarked this though, so I might be wrong, (the benefits of less duplication in caches might outweigh the queries?).

Note that you can't import a module partition outside of the module it belongs to. The primary module interface can always be thought of as a bottleneck target regardless of whether it embeds its partitions or not. In other words, we always need all BMIs that make up a primary module interface unit if we want to use it in a downstream target. It's just that with embedded partitions the command lines of consumers become shorter and we'd have more intuitive perceived target boundaries at the level of primary module interfaces.

Related:

cc @ChuanqiXu9 @mathstuf @dwblaikie @ruoso @vsapsai

@aaronmondal aaronmondal added the clang:modules C++20 modules and Clang Header Modules label May 21, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented May 21, 2023

@llvm/issue-subscribers-clang-modules

@ChuanqiXu9
Copy link
Member

The length of command line may not be compelling to me. Given @tschuett mentions that we can use response file to include the command lines. You can also find the example by displaying the command line from cmake.

Also the size of the pcm files is a main concern for me. More than one people complain the size of pcm files to me. So if we combine several pcm files together, the size will become larger which looks bad...

And for distributed build, given the size of pcm files now, it is still unclear which one is better: to build source files in the remote or passing the pcm files. I'm worrying passing pcm files will run out all of the network bandwidths.

Given it may require a non-trivial refactorization to embed module files into another, I don't see a big benefit from the proposal.

@mathstuf
Copy link
Contributor

Note that it came up that this "repack BMIs" process doesn't really have a place to "live" in a static build graph (as CMake uses it). As an example:

module X:part;

will implicitly import X's BMI, so it needs to come first. However, consumers will want some other BMI that "repacks" the partitions. However, as we do not know the set of modules at build graph generation time to do this repacking (I suppose we could pessimize and assume that each source file is its own non-partition module…but then it is trivial to "repack"). It could be done as a pre-link step for all of the modules inside of a target, but this has two drawbacks:

  • inside of the target, partition granularity is all that is available; and
  • it adds a bottleneck for any usage of BMIs inside of the target on the link step of the target (basically bringing back CMake #15555 when modules are in use).

While it may seem useful, I don't think it's something a build system without access to dynamic nodes (basically ruling out ninja as a suitable build tool) can reliably use.

So while I think this might be a useful option, mandating it sounds like the wrong decision to me.

@aaronmondal
Copy link
Member Author

Seems like this is too niche after all. It's not clear whether the benefits of reduced number cache queries and stronger module encapsulation in distributed builds actually outweigh the reduced parallelism and larger BMI size.

I'll have to test it eventually and I'll let you know if there are any interesting results performance-wise, but at the moment I feel that this issue only distracts from more important issues related to modules.

Thank you all for the feedback ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:modules C++20 modules and Clang Header Modules
Projects
None yet
Development

No branches or pull requests

4 participants