Merge cc_supports_flag implementation from pacemaker

Main change is:

Check for compiler flags with -Werror

For example for -fstack-protector, it is accepted by gcc for
all targets, however those targets where it is actually not
supported, it will print a warning like

"-fstack-protector is not supported for this platform"

which raises an error when using -Werror later. So better
not add -fstack-protector then to the CC_EXTRA_FLAGS