From e93dfb1ad90dd7e6cb85783d27b4175d74bc40a0 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Thu, 26 Jul 2018 17:57:38 -0500 Subject: [PATCH] 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 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk (cherry picked from commit ee66819a0c1a9efa98b76a1c18af6233bda1e233) Change-Id: Ia38d4701aeb4f690b12a6ffdbb42b8ec8c499486 Reviewed-on: https://gerrit.openafs.org/13544 Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Reviewed-by: Benjamin Kaduk Reviewed-by: Cheyenne Wills Reviewed-by: Andrew Deason Reviewed-by: Marcio Brito Barbosa Tested-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/libuafs/Makefile.common.in | 4 ++-- src/libuafs/MakefileProto.AIX.in | 1 - src/libuafs/MakefileProto.DARWIN.in | 2 +- src/libuafs/MakefileProto.DFBSD.in | 1 - src/libuafs/MakefileProto.FBSD.in | 1 - src/libuafs/MakefileProto.HPUX.in | 3 --- src/libuafs/MakefileProto.IRIX.in | 1 - src/libuafs/MakefileProto.LINUX.in | 5 +---- src/libuafs/MakefileProto.NBSD.in | 1 - src/libuafs/MakefileProto.OBSD.in | 1 - src/libuafs/MakefileProto.SOLARIS.in | 1 - 11 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/libuafs/Makefile.common.in b/src/libuafs/Makefile.common.in index daf09494c2..e062c7c2eb 100644 --- a/src/libuafs/Makefile.common.in +++ b/src/libuafs/Makefile.common.in @@ -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 \ diff --git a/src/libuafs/MakefileProto.AIX.in b/src/libuafs/MakefileProto.AIX.in index 6a27a7506e..881b3c935f 100644 --- a/src/libuafs/MakefileProto.AIX.in +++ b/src/libuafs/MakefileProto.AIX.in @@ -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 diff --git a/src/libuafs/MakefileProto.DARWIN.in b/src/libuafs/MakefileProto.DARWIN.in index 19920e2f6a..c5f99fbef5 100644 --- a/src/libuafs/MakefileProto.DARWIN.in +++ b/src/libuafs/MakefileProto.DARWIN.in @@ -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) diff --git a/src/libuafs/MakefileProto.DFBSD.in b/src/libuafs/MakefileProto.DFBSD.in index 0c49f05ee4..fac1a852d4 100644 --- a/src/libuafs/MakefileProto.DFBSD.in +++ b/src/libuafs/MakefileProto.DFBSD.in @@ -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= diff --git a/src/libuafs/MakefileProto.FBSD.in b/src/libuafs/MakefileProto.FBSD.in index c7dfea6599..2c910f5932 100644 --- a/src/libuafs/MakefileProto.FBSD.in +++ b/src/libuafs/MakefileProto.FBSD.in @@ -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= diff --git a/src/libuafs/MakefileProto.HPUX.in b/src/libuafs/MakefileProto.HPUX.in index d8dc557d5b..109c219701 100644 --- a/src/libuafs/MakefileProto.HPUX.in +++ b/src/libuafs/MakefileProto.HPUX.in @@ -19,9 +19,6 @@ DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL KOPTS=-Wp,-H200000 -Wl,-a,archive +DA1.0 +z KOPTS=-Wp,-H200000 -Wl,-a,archive_shared - -CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS) - TEST_CFLAGS= -Wp,-H200000 +DA1.0 +z -D_POSIX_C_SOURCE=199506L -DAFS_PTHREAD_ENV -Dhpux -DAFS_HPUX_ENV $(XCFLAGS) diff --git a/src/libuafs/MakefileProto.IRIX.in b/src/libuafs/MakefileProto.IRIX.in index 757e71bf62..3b1b67c8ee 100644 --- a/src/libuafs/MakefileProto.IRIX.in +++ b/src/libuafs/MakefileProto.IRIX.in @@ -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 diff --git a/src/libuafs/MakefileProto.LINUX.in b/src/libuafs/MakefileProto.LINUX.in index d415a4a163..3647a4d5fa 100644 --- a/src/libuafs/MakefileProto.LINUX.in +++ b/src/libuafs/MakefileProto.LINUX.in @@ -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= diff --git a/src/libuafs/MakefileProto.NBSD.in b/src/libuafs/MakefileProto.NBSD.in index 6a2150861d..f2883268f5 100644 --- a/src/libuafs/MakefileProto.NBSD.in +++ b/src/libuafs/MakefileProto.NBSD.in @@ -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= diff --git a/src/libuafs/MakefileProto.OBSD.in b/src/libuafs/MakefileProto.OBSD.in index 8db60b07fc..9bd7be191c 100644 --- a/src/libuafs/MakefileProto.OBSD.in +++ b/src/libuafs/MakefileProto.OBSD.in @@ -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= diff --git a/src/libuafs/MakefileProto.SOLARIS.in b/src/libuafs/MakefileProto.SOLARIS.in index 8e51a95250..3be917b99a 100644 --- a/src/libuafs/MakefileProto.SOLARIS.in +++ b/src/libuafs/MakefileProto.SOLARIS.in @@ -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=