libuafs: Stop clobbering CFLAGS 62/13262/3
authorAndrew Deason <adeason@sinenomine.net>
Thu, 26 Jul 2018 22:57:38 +0000 (17:57 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 27 Jul 2018 22:29:29 +0000 (18:29 -0400)
commitee66819a0c1a9efa98b76a1c18af6233bda1e233
treed50c0237214f511da9f68a511ca3b0aec925f5fb
parenta85aab9dfe7c2ee9e025bc15d849de2dd0a48913
libuafs: Stop clobbering CFLAGS

Currently, in the libuafs MakefileProto for every platform, CFLAGS is
set to a bunch of flags, ignoring any CFLAGS set by the 'make'
command-line provided by the user. Since most of the rest of the tree
honors CFLAGS, it is confusing and can cause errors when src/libuafs
ignore the user-set CFLAGS.

One example of this breaking the build is when building RHEL RPMs for
certain sub-architectures of the current machine. If you try to
'rpmbuild --target=i686' on 32-bit x86 RHEL 5, we will build with
-march=i686 in the CFLAGS, which will be used to build most objects
and is used in our configure tests. As a result, our configure tests
will say that gcc atomic intrinsics are available. But when we go to
build libuafs objects, we will not have -march=i686 in our CFLAGS,
which causes (on RHEL 5) gcc to default to building for i386, which
does not have gcc atomic intrinsics available. This causes build
errors like this:

    libuafs.a(rx.o): In function `rx_atomic_test_and_clear_bit':
    [...]/BUILD/openafs-1.8.0/src/rx/rx_atomic.h:462: undefined reference to `__sync_fetch_and_and_4'

To fix this, change the libuafs MakefileProtos to not set CFLAGS
directly; instead, set them in a new variable UAFS_CFLAGS.
Makefile.common then pulls those flags into MODULE_CFLAGS, which is
used in our *_CCRULE build rules.

While we are here, also move the common set of CFLAGS set by each
platform's MakefileProto into Makefile.common. Now, each MakefileProto
only needs to set CFLAGS that are specific to that platform, which
ends up being very few (since most platforms were using the exact same
set of CFLAGS).

Relevant issue identified and analyzed by mbarbosa@sinenomine.net.

Change-Id: I1bd21a6e7669137be3e5edee86227fd37f841d62
Reviewed-on: https://gerrit.openafs.org/13262
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/libuafs/Makefile.common.in
src/libuafs/MakefileProto.AIX.in
src/libuafs/MakefileProto.DARWIN.in
src/libuafs/MakefileProto.DFBSD.in
src/libuafs/MakefileProto.FBSD.in
src/libuafs/MakefileProto.HPUX.in
src/libuafs/MakefileProto.IRIX.in
src/libuafs/MakefileProto.LINUX.in
src/libuafs/MakefileProto.NBSD.in
src/libuafs/MakefileProto.OBSD.in
src/libuafs/MakefileProto.SOLARIS.in