09/01/2019 11:39, Pavan Nikhilesh Bhagavatula: > From: Jerin Jacob <jer...@marvell.com> > > Introduce rte_cc_has_argument() Makefile helper to > check a given argument is support by the compiler. > > Example Usage: > > include $(RTE_SDK)/mk/rte.helper.mk > MACHINE_CFLAGS += $(call rte_cc_has_argument, -mcpu=octeontx2) > > This would allow adding -mcpu=octeontx2 in MACHINE_CFLAGS > if it is only supported by the compiler. The use case for such > scheme is to enable the mcpu optimization if the compiler > supports else it needs to compile the source code without > any errors. > > This patch also moves inclusion of toolchain's rte.vars.mk > to before the machine's rte.vars.mk inclusion to make > correct CC available for the cross compile case. > > Signed-off-by: Jerin Jacob <jer...@marvell.com> > Signed-off-by: Pavan Nikhilesh <pbhagavat...@marvell.com> > --- > --- /dev/null > +++ b/mk/rte.helper.mk > @@ -0,0 +1,12 @@ > +# SPDX-License-Identifier: BSD-3-Clause > +# Copyright(c) 2018 Marvell International Ltd > + > +# rte_cc_has_argument > +# Usage: MACHINE_CFLAGS += $(call rte_cc_has_argument, -mno-avx512f) > +# Return the argument if the argument is supported by the compiler. > +# > +define rte_cc_has_argument > + $(shell $(CC) -Werror $(1) -c -x c /dev/null -o tmp$$ 2> /dev/null && > rm -f tmp$$ && echo $(1) | xargs echo -n) > +endef
What is tmp$$ ? If the command is interrupted in the middle, temp file is not cleaned. We could fix it with "trap". Is it possible to just avoid creating a temporary file?