[PATCH 1/2] multipath-tools: fix compilation with gcc < 4.9 on dash shell

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The dash shell does not interpret '&>' as bash does, so instead
of stdout/stderr redirect, it runs the command in background [1].

    $ for shell in bash dash; do
        echo -n "$shell rc = "
        $shell -c 'echo "int main(void){return 0;}" \
                     | gcc -o /dev/null -c -fFAIL -xc - &>/dev/null; echo $?';
      done
    bash rc = 1
    dash rc = 0
    $ gcc: error: unrecognized command line option ‘-fFAIL’

This misleads the check for C compiler option in Makefile.inc
on Ubuntu 14.04 at least, which uses dash as /bin/sh, and has
GCC 4.8 (no -fstack-protector-strong), then the build fails.

So, replace '&>' with the equivalent '>' and '>&2'.

No regression on Ubuntu 18.04 (GCC 7.3, -fstack-protector-strong used).

Fixes: a8dd838c
"multipath-tools: fix compilation with gcc < 4.9"

[1] https://wiki.ubuntu.com/DashAsBinSh (see '&>' section)

Signed-off-by: Mauricio Faria de Oliveira <mfo@xxxxxxxxxxxxx>
---
 Makefile.inc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.inc b/Makefile.inc
index af2f5bae09d3..a12b46ef315e 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -78,7 +78,7 @@ INSTALL_PROGRAM	= install
 # Test if the C compiler supports the option.
 # Evaluates to "option" if yes, and "fallback" otherwise.
 TEST_CC_OPTION = $(shell \
-	if echo 'int main(void){return 0;}' | $(CC) -o /dev/null -c "$(1)" -xc - &>/dev/null; \
+	if echo 'int main(void){return 0;}' | $(CC) -o /dev/null -c "$(1)" -xc - >/dev/null 2>&1; \
 	then \
 		echo "$(1)"; \
 	else \
-- 
2.17.1

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux