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@canonical.com>
# 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 \