首页 > 解决方案 > 尝试使用 clang++ v12 将两个 C++20 模块一起构建为一个模块

问题描述

我正在尝试使用 clang++ v12 将两个 C++20 模块链接在一起。将 C++20 模块链接到可执行文件可以正常工作,例如,下面的main是一个可执行文件:

clang++ -std=c++20 -fmodules -pedantic -Wall -fprebuilt-module-path=. main.cpp mainUi.pcm video.pcm audio.pcm CameraWidgetFactory.pcm AudioInterfaces.pcm -o main

编译没有错误,但链接到另一个模块会给出此错误。这是 Makefile 中的错误和命令:

clang++ -std=c++20 -fmodules -pedantic -Wall -fmodules-ts -c -fprebuilt-module-path=. AudioFactory.cpp AudioFactory.hpp AudioInput.pcm -Xclang -emit-module-interface

和错误:

clang-12: /home/james/llvm-project/clang/lib/Frontend/FrontendAction.cpp:636: bool clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, const clang::FrontendInputFile&): 断言`hasASTFileSupport( ) && "此操作不支持 AST 文件!"' 失败。

请向https://bugs.llvm.org/提交错误报告,并包括崩溃回溯、预处理源和相关的运行脚本。

  1. 程序参数:/usr/local/bin/clang-12 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -main-file-name AudioInput.pcm -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -fno-split-dwarf-inlining - debugger-tuning=gdb -resource-dir /usr/local/lib/clang/12.0.0 -Wall -pedantic -std=c++20 -fdebug-compilation-dir /home/james/eclipse-workspace/AudioFactory -ferror -limit 19 -fgnuc-version=4.2.1 -fmodules -fmodules-ts -fimplicit-module-maps -fmodules-cache-path=/home/james/.cache/clang/ModuleCache -fprebuilt-module-path=。-fmodules-validate-system-headers -fcolor-diagnostics -emit-module-interface -faddrsig -o AudioInput.o -x pcm AudioInput.pcm #0 0x000055822646a3d1 llvm::sys::PrintStackTrace(llvm::https://github.com/llvm/llvm-project.git a5f95887d0f8d27f1c33f19944d0c1da66aef606)目标:x86_64-unknown-linux-gnu 线程模型:posix InstalledDir:/usr/local/bin clang-12:注意:诊断消息:

请在错误报告中附加以下文件:预处理源和相关运行脚本位于:clang-12:注意:诊断消息:/tmp/AudioFactory-462949.cpp clang-12:注意:诊断消息:/tmp/AudioFactory-462949.cache clang-12:注:诊断消息:/tmp/AudioFactory-9851b0.hh clang-12:注:诊断消息:/tmp/AudioFactory-9851b0.cache clang-12:注:诊断消息:/tmp/AudioFactory-462949.sh clang-12:注意:诊断消息:


make: *** [Makefile:19: AudioFactory.pcm] 错误 254

谁能告诉这里有什么问题?

标签: c++clangclang++c++20

解决方案


推荐阅读