我什么时候应该使用 GCC 的 -pipe 选项?

发布于 2024-08-06 10:46:33 字数 344 浏览 5 评论 0原文

GCC 4.1.2 文档对此说说 -pipe 选项:

-管道

使用管道而不是临时文件在编译的各个阶段之间进行通信。这在汇编程序无法从管道读取的某些系统上不起作用;但 GNU 汇编器没有任何问题。

我假设我能够从错误消息中判断出我的系统的汇编程序是否不支持管道,所以除了这个问题之外,什么时候我是否使用该选项很重要?决定使用它时应考虑哪些因素?

The GCC 4.1.2 documentation has this to say about the -pipe option:

-pipe

Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble.

I assume I'd be able to tell from error message if my systems' assemblers didn't support pipes, so besides that issue, when does it matter whether I use that option? What factors should go into deciding to use it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

风尘浪孓 2024-08-13 10:46:33

它通常没有任何区别,

它有 +- 考虑因素。从历史上看,同时运行编译器和汇编器会对 RAM 资源造成压力。

按照今天的标准,Gcc 很小,并且 -pipe 添加了一些多核可访问的并行执行功能。

但出于同样的原因,CPU 的速度非常快,以至于它可以创建该临时文件并在您没有​​注意到的情况下将其读回。由于 -pipe 从来都不是默认模式,因此它偶尔会出现一些问题。单个开发人员通常会报告没有注意到时差。

现在,有一些大型项目在那里。您可以查看一棵树,它将构建所有 Firefox、NetBSD 或类似的东西,非常大的东西。包含所有 X 的东西,例如,作为次要子系统组件。当工作涉及成千上万个 C 文件中的数百万行代码时,您可能会注意到也可能不会注意到差异。我相信您知道,人们通常一次只处理此类事情的一小部分。但是,如果您是发布工程师或在构建服务器上工作,或者更改 stdio.h,< /a> 你可能很想构建整个系统来看看你是否破坏了任何东西。现在,每一点性能下降都可能很重要......

It doesn't usually make any difference

It has + and - considerations. Historically, running the compiler and assembler simultaneously would stress RAM resources.

Gcc is small by today's standards and -pipe adds a bit of multi-core accessible parallel execution.

But by the same token the CPU is so fast that it can create that temporary file and read it back without you even noticing. And since -pipe was never the default mode, it occasionally acts up a little. A single developer will generally report not noticing the time difference.

Now, there are some large projects out there. You can check out a single tree that will build all of Firefox, or NetBSD, or something like that, something that is really big. Something that includes all of X, say, as a minor subsystem component. You may or may not notice a difference when the job involves millions of lines of code in thousands and thousands of C files. As I'm sure you know, people normally work on only a small part of something like this at one time. But if you are a release engineer or working on a build server, or changing something in stdio.h, you may well want to build the whole system to see if you broke anything. And now, every drop of performance probably counts...

辞别 2024-08-13 10:46:33

根据我们在中型项目中的经验,添加 -pipe 对构建时间没有明显的影响。我们遇到了一些问题(有时如果遇到错误,则无法删除中间文件,IIRC),因此,由于它没有给我们带来任何好处,我们放弃使用它,而不是尝试解决这些问题。

In our experience with a medium-sized project, adding -pipe made no discernible difference in build times. We ran into a couple of problems with it (sometimes failing to delete intermediate files if an error was encountered, IIRC), and so since it wasn't gaining us anything, we quit using it rather than trying to troubleshoot those problems.

年华零落成诗 2024-08-13 10:46:33

现在尝试一下,当源/构建目标位于 NFS(Linux 网络)上时,构建速度似乎会稍微快一些。不过内存使用率很高。如果你从未填满 RAM 并且在 NFS 上有源代码,那么使用 -pipe 似乎是一个胜利。

Trying this out now, it looks to be moderately faster to build when the source / build destinations are on NFS (linux network). Memory usage is high though. If you never fill the RAM and have source on NFS, seems like a win with -pipe.

捶死心动 2024-08-13 10:46:33

老实说,没有什么理由不使用它。 -pipe 只会使用更多的内存,如果这个盒子是构建代码,我认为有相当多的内存。如果您的系统使用更保守的文件系统,该系统会写入然后删除所有临时文件(例如 ext3),那么它可以显着缩短构建时间。

Honestly there is very little reason to not use it. -pipe will only use a tad more ram, which if this box is building code, I'd assume has a decent amount. It can significantly improve build time if your system is using a more conservative filesystem that writes and then deletes all the temporary files along the way (ext3, for example.)

怪异←思 2024-08-13 10:46:33

优点之一是使用 -pipe 可以减少编译器与文件系统的交互。即使它是 RAM 磁盘,在使用临时文件时数据仍然需要经过块 I/O 和文件系统层,而使用管道则变得更直接一些。

对于文件,编译器首先需要完成编写,然后才能调用汇编器。管道的另一个优点是编译器和汇编器可以同时运行,并且它更多地利用了 SMP 架构。特别是当编译器需要等待源文件中的数据时(由于阻塞 I/O 调用),操作系统可以为汇编器提供完整的 CPU 时间并让它更快地完成工作。

One advantage is that with -pipe will the compiler interact less with a file system. Even when it is a ram disk does the data still need to go through the block I/O and file system layers when using temporary files whereas with a pipe it becomes a bit more direct.

With files does the compiler first need to finish writing before it can call the assembler. Another advantage of pipes is that both, the compiler and assembler, can run at the same time and it is making a bit more use of SMP architectures. Especially when the compiler needs to wait for the data from the source file (because of blocking I/O calls) can the operating system give the assembler full CPU time and let it do its job faster.

时光瘦了 2024-08-13 10:46:33

从硬件的角度来看,我想您会使用 -pipe 来保护硬盘的使用寿命。

From a hardware point of view I guess you would use -pipe to preserve the lifetime of your hard drive.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文