Repository: mesonbuild/meson

Issue:
How to get meson to not add the -pipe option to my cpp compilation steps
I have declared my project settings as such.
`project('MyProject', 'cpp', 'c',
    default_options: ['buildtype=plain', 'b_staticpic=false', 'b_asneeded=false', 'b_lundef=false']`

The project requires cross-compilation and neither my c _args or my cpp_args that come under the properties section of my crossfile include the '-pipe' option.

However, the build.ninja that meson generates for my build directories shows that the '-pipe' has been added as a compiler argument in all my c/cpp compilation steps. Not sure if I missed it, but I'm unable to find a way to not enable meson to do this from the documentation. Is there a default option that I can set to not allow meson to insert compilation arguments other than the ones listed in my crossfile?

System parameters:
OS: Debian stretch
Python version: 3.5.3
Meson version: 0.56.0
Ninja version; 1.7.2




Discussion:
`-pipe` is unconditionally added by meson for compilers that support it. Why do you wish to remove it?

>     -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'd like to see it removed (or made an option) because it causes OOM compilation failures on some moderately large servers we use as Jenkins agents.  Each agent has 64 cores/128 threads, and 256GB of memory, and about twice a week, we have a job failure due to an OOM caused when the automatically inserted "-pipe" causes more memory usage.  

This causes our users (40+) to interrupt our Jenkins savvy folks (~5) to ask for help when their job dies.

Machines are cheap...people are expensive.  Digging through huge logs is irritating.

"What about adding some swap to prevent the OOM?" you might ask.  I would reply that doing so causes unacceptable slowdowns when the system swaps, and adds another point of failure on machines that largely run out of RAM.  

Bottom line is, we've tuned these machines pretty carefully for turnaround on pipelined build jobs, and don't need to spend manpower diagnosing why jobs randomly fail.

One should be able to turn the generation of "-pipe" on and off, as it is not universally needed, and not always appropriate.  Make it the default, sure, but add some way to disable it, other than hacking meson each release, or post-processing the generated ninja files. I'll accept slightly slower jobs for more robustness, if *I* get to make the decision.
Happy to provide a PR that adds functionality to provide the user the option to disable the addition of the '-pipe' argument, if y'all are happy to have it in.
The problem with adding new options, toggles and switches that while each individual one of them seems good, it is all too easy to end up in a situation where you have two hundred random switches making the entire UI impenetrably awful.

That being said one option would be to just remove `-pipe` altogether. I did some testing a while ago and could not find a case where it made any difference in build speed. If someone absolutely, positively needs to have it (or thinks that they do) then they can add it manually. 
Om a distro level, `-pipe` is set in the stock `$CFLAGS` (at least for Arch Linux). I'd be fine with leaving this up to users.

Or moving it to a buildtype, though it doesn't particularly fit into either debug or optimization...

Resolving patch:
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -335,12 +335,6 @@ def get_option_compile_args(self, options: 'KeyedOptionDictType') -> T.List[str]
     def get_preprocess_only_args(self) -> T.List[str]:
         return ['-cpp', '-EP']
 
-    def get_always_args(self) -> T.List[str]:
-        """Ifort doesn't have -pipe."""
-        val = super().get_always_args()
-        val.remove('-pipe')
-        return val
-
     def language_stdlib_only_link_flags(self) -> T.List[str]:
         return ['-lifcore', '-limf']
 
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -154,7 +154,7 @@ def get_always_args(self) -> T.List[str]:
         '''
         Args that are always-on for all C compilers other than MSVC
         '''
-        return ['-pipe'] + self.get_largefile_args()
+        return self.get_largefile_args()
 
     def get_no_stdinc_args(self) -> T.List[str]:
         return ['-nostdinc']
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -4667,9 +4667,6 @@ def warn_about_builtin_args(self, args):
             elif arg == '-g':
                 mlog.warning(f'Consider using the built-in debug option instead of using "{arg}".',
                              location=self.current_node)
-            elif arg == '-pipe':
-                mlog.warning("You don't need to add -pipe, Meson will use it automatically when it is available.",
-                             location=self.current_node)
             elif arg.startswith('-fsanitize'):
                 mlog.warning(f'Consider using the built-in option for sanitizers instead of using "{arg}".',
                              location=self.current_node)


Test patch: