ruk*_*uki 5 c++ gcc c++-modules xmake
我试图让xmake支持 gcc-11 来构建 c++20 模块,但我遇到了一些问题。
gcm.cachegcc-11默认会在当前目录生成目录。如何修改这个默认路径到指定的其他目录?
我知道clang有一个-fmodules-cache-path=修改模块缓存路径的选项,但是我没有找到gcc的类似选项。
有人知道吗?谢谢
这在 ubuntu 22.04 上对我有用gcc-11(Makefile 片段):
MAPPER_DIR := /path/to/obj/dir
CXXFLAGS += -fmodules-ts '-fmodule-mapper=|@g++-mapper-server -r'$(MAPPER_DIR)
Run Code Online (Sandbox Code Playgroud)
我遇到的警告是g++-mapper-server不会创建根目录,因此请确保首先创建它。您仍然需要计算出依赖关系,以便在编译导入代码之前创建/更新 gcm。
解释是|通过管道调用映射器进程,@从 gcc 工具目录中解析进程名称(参见gcc 手册)。该-r选项设置根目录。注意保护空间和|外壳make。
默认映射器服务器接受参数 - 您可以调整和使用它 - 这是我的版本上的选项:
$ /usr/lib/gcc/x86_64-linux-gnu/11/g++-mapper-server --help
Usage: g++-mapper-server [OPTION...] [CONNECTION] [MAPPINGS...]
C++ Module Mapper.
-a, --accept Netmask to accept from
-f, --fallback Use fallback for missing mappings
-h, --help Print this help, then exit
-n, --noisy Print progress messages
-1, --one One connection and then exit
-r, --root DIR Root compiled module directory
-s, --sequential Process connections sequentially
-v, --version Print version number, then exit
Send SIGTERM(15) to terminate
For bug reporting instructions, please see:
<file:///usr/share/doc/gcc-11/README.Bugs>.
Run Code Online (Sandbox Code Playgroud)