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.

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>
(cherry picked from commit ee66819a0c1a9efa98b76a1c18af6233bda1e233)

Change-Id: Ia38d4701aeb4f690b12a6ffdbb42b8ec8c499486
Reviewed-on: https://gerrit.openafs.org/13544
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Marcio Brito Barbosa <mbarbosa@sinenomine.net>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
This commit is contained in:
Andrew Deason 2018-07-26 17:57:38 -05:00 committed by Stephan Wiesand
parent 63a1ee4e23
commit e93dfb1ad9
11 changed files with 4 additions and 17 deletions

View File

@ -10,7 +10,7 @@
# Each MakefileProto includes Makefile.config, so we should only need
# minor tweaks here.
MODULE_CFLAGS=-DKERNEL
MODULE_CFLAGS=${UAFS_CFLAGS} -DKERNEL -I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
LT_objs = \
afs_atomlist.lo \
@ -216,7 +216,7 @@ ${TOP_LIBDIR}/perl/AFS/ukernel.pm: setup_perllib PERLUAFS/ukernel.pm
LIBUAFS_BUILD_PERL: ${TOP_LIBDIR}/perl/ukernel.so ${TOP_LIBDIR}/perl/AFS/ukernel.pm
linktest: libuafs.a
$(CC) $(TEST_CFLAGS) $(TEST_LDFLAGS) \
$(CC) $(CFLAGS) $(TEST_CFLAGS) $(TEST_LDFLAGS) \
$(LDFLAGS_roken) $(LDFLAGS_hcrypto) -o linktest \
${srcdir}/linktest.c $(MODULE_INCLUDE) -DUKERNEL \
libuafs.a ${TOP_LIBDIR}/libcmd.a \

View File

@ -16,7 +16,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
# System specific build commands and flags
DEFINES= -DKERNEL -DUKERNEL
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
AR = /usr/bin/ar
ARFLAGS = -r
RANLIB = /bin/ranlib

View File

@ -16,7 +16,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
# System specific build commands and flags
DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
KOPTS=
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS) $(ARCHFLAGS)
UAFS_CFLAGS=$(ARCHFLAGS)
TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV $(XCFLAGS) $(ARCHFLAGS)
TEST_LDFLAGS=$(XLDFLAGS) $(ARCHFLAGS)

View File

@ -16,7 +16,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
CC = @CC@
DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
KOPTS=
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_DFFBSD_ENV $(XCFLAGS)
TEST_LDFLAGS=

View File

@ -17,7 +17,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
CC = @CC@
DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
KOPTS=
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_FBSD50_ENV $(XCFLAGS)
TEST_LDFLAGS=

View File

@ -19,9 +19,6 @@ DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
KOPTS=-Wp,-H200000 -Wl,-a,archive +DA1.0 +z
<ia64_hpux1122 ia64_hpux1123>
KOPTS=-Wp,-H200000 -Wl,-a,archive_shared
<all>
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
<hp_ux102 hp_ux110 hp_ux11i>
TEST_CFLAGS= -Wp,-H200000 +DA1.0 +z -D_POSIX_C_SOURCE=199506L -DAFS_PTHREAD_ENV -Dhpux -DAFS_HPUX_ENV $(XCFLAGS)
<ia64_hpux1122 ia64_hpux1123>

View File

@ -15,7 +15,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
# System specific build commands and flags
CC = cc
DEFINES=-D_SGI_MP_SOURCE -DKERNEL -DUKERNEL
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS=-D_SGI_MP_SOURCE -DAFS_PTHREAD_ENV -Dirix -DAFS_SGI_ENV $(XCFLAGS)
TEST_LDFLAGS=-ignore_minor

View File

@ -19,11 +19,8 @@ DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
KOPTS=
SYS_NAME=@AFS_SYSNAME@
ifeq (${SYS_NAME}, ppc64_linux26)
CFLAGS=-fPIC
else
CFLAGS=
UAFS_CFLAGS=-fPIC
endif
CFLAGS+= -I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS=-pthread -D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_LINUX22_ENV $(XCFLAGS)
TEST_LDFLAGS=

View File

@ -17,7 +17,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
CC = gcc
DEFINES= -DKERNEL -DUKERNEL
KOPTS=
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS= -DAFS_NBSD_ENV $(XCFLAGS)
TEST_LDFLAGS=

View File

@ -17,7 +17,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
CC = gcc
DEFINES= -DKERNEL -DUKERNEL
KOPTS=
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS= -DAFS_OBSD_ENV $(XCFLAGS)
TEST_LDFLAGS=

View File

@ -14,7 +14,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
# System specific build commands and flags
DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
TEST_CFLAGS=-mt -DAFS_PTHREAD_ENV -Dsolaris -DAFS_SUN5_ENV $(XCFLAGS)
TEST_LDFLAGS=