gpt4 book ai didi

makefile - 如何使 make -j 产生良好的输出?

转载 作者:行者123 更新时间:2023-12-02 19:16:59 24 4
gpt4 key购买 nike

我有一个使用 make 构建的大型项目。由于项目的规模和依赖项的组织方式,使用 make -j 并行构建确实有好处。但是,make -j 生成的输出(即日志和错误消息)全部混合在一起,因为所有并行任务同时写入 stdout。

如何告诉 make 很好地组织输出?理想情况下,我希望它单独缓冲每个任务的日志,然后在任务完成时按顺序输出。有没有标准方法可以做到这一点?

最佳答案

您可以使用-O--output-sync命令行选项:

-O[type], --output-sync[=type]

When running multiple jobs in parallel with -j, ensure the output of each job is collected together rather than interspersed with output from other jobs. If type is not specified or is target the output from the entire recipe for each target is grouped together. If type is line the output from each command line within a recipe is grouped together. If type is recurse output from an entire recursive make is grouped together. If type is none output synchronization is disabled.

online manual有更多信息。

(请注意,您需要 GNU Make 4.0 才能正常工作。)

关于makefile - 如何使 make -j 产生良好的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27897608/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com