summaryrefslogtreecommitdiff
path: root/build2/cxx-modules/modtest/README
blob: 2cb4743490d800e3abaf2ebf6302ec5b313ef490 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
Use use_modules=false command line variable override to compile without
modules:

$ b config.cxx=clang++ use_modules=true test
$ b config.cxx=cl-14u2 use_modules=true test

Other useful options:

config.cxx.coptions+=-stdlib=libc++

For now use config.bin.lib=static if compile with VC.

CLang 3.7.0, 3.9.0
==================

Notes:

* What is a header file for clang? Looks like it considers it a module. But
  what if definitions are contained in a separate (corresponding source)
  file. It sounds like such a file also imports the module it implements.
  Sounds wierd.

  Probably need to add -fmodule-name=<module-id> when compile module source
  file(s). Should make some difference (which externally is invisible).

* When clang sees #include it compiles the included file (with a separate
  compiler instance) and place the result into the cache.

* clang++ -module-file-info foo-8KLLM232DU5X.pcm prints lot of information
  about foo module.

* module.modulemap file(s) appears in the output of the "show dependencies"
  command like that:

  clang++ -I`pwd` -fmodules -std=c++1y -M -MG -MQ ^ driver.cxx

Issues:

* First run of b when configured to use CLang fails with:
  fatal error: error in backend: IO failure on output stream.

  Some bug in clang++ 3.7.0 which seems to relate to the creation/update of
  translated modules cache while using -M (dependency generation) option.
  Consequitive runs (even those which require module recompilation) work well.

  clang 3.8.0, 3.9.0 work fine.

VC 14 U2,3
==========

Notes:

* Module interface description get persisted into the separate ifc-file when
  the module source file is compiled: foo.cxx -> foo.obj, foo.ifc. To compile
  a source file which imports a module the compiler expects module's ifc-file
  to be available.

  That's currently requres to maintain a proper prerequisite's order in
  buildfile. When build an executable consuming module located in a library
  need to ensure the library source files are compiled before executable's
  source files to get lib's ifc-files ready:

  $ b config.cxx=cl-14u2 use_modules=true 'lib{bar}'
  $ b config.cxx=cl-14u2 use_modules=true

* There is a ifc.exe tool (comes with VC) which can be used to embed interface
  files into static lib or convert to object file.

* No signs of the tools/compiler switch to extract a module dependencies from a
  source file. Some people complains/asks about it:

  http://nibblestew.blogspot.ru/2015/10/some-comments-on-c-modules-talk.html
  http://stackoverflow.com/questions/35230327/how-to-use-vc-modules-in-cmake

Issues:

* Using std::string in the struct foo results in VC 14 U2 with linker's
  inability to resolve string symbols while linking foo.exe.obj. VC 14 U3
  compiler in this case fails with internal error while compiling driver.cxx.

  CLang 3.9.0 works ok in this case.

* How to only produce .ifc file without the object file? /module:export?

  Looks like compiling the header (with /TP) is the best options so far: it
  produces .obj but a small one.

  cl /c /EHsc /experimental:module /module:interface /TP foo

References
==========

A Module System for C++ (Revision 4):

  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0142r0.pdf

--

CLang modules:

  http://clang.llvm.org/docs/Modules.html

CLang module tests (examples):

  https://github.com/llvm-mirror/clang/tree/master/test/Modules

Some early presentation (Feb 2012, Doug Gregor)

  https://isocpp.org/blog/2012/11/modules-update-on-work-in-progress-doug-gregor

--

Modules Support in Visual C++ 2015 Update 1:

  https://blogs.msdn.microsoft.com/vcblog/2015/12/03/c-modules-in-vs-2015-update-1/

Compiler improvements in VS 2015 Update 2 (in regards of C++ Modules there are
seems to be just bug fixes):

  https://blogs.msdn.microsoft.com/vcblog/2016/02/11/compiler-improvements-in-vs-2015-update-2/

MS C++ Modules talk on CppCon 2015:

  https://github.com/isocpp/CppCoreGuidelines/blob/master/talks/Large-Scale-C%2B%2B-With-Modules.pdf
  https://www.youtube.com/watch?v=RwdQA0pGWa4

VC 14 Update 3

  https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update3-vs