On Mon, Oct 21, 2013 at 06:35:26AM -0500, Dirk Eddelbuettel wrote: > | > I'd appreciate it if you took a stab at it. There is a ton of special > casing > | > in there. Would we need a ton of post-processing with sed to account for > | > that? I;d hesitate to just say 'hell with it', breaking everything and > | > trying to put it back together on arch at a time. > | > > | > But yes, the added flags should probably be going in there... > | > | OK, attached is a suggested patch. It seems to work for me. > | > | There are some of the parts where I've added other flags in addition > | to the ones that were already there - I don't know if this is > > I'd prefer it if we could go over this in a bit more detail.
Hi Dirk! I've looked through the R build system. It's interesting. With a handful of exceptions, which I'll come to in a moment, every single Makefile includes $(top_builddir)/Makeconf, so that all of the settings in that file - which is generated from the configure script - are used in all of the Makefiles. In particular, this means that in the make-arch-stamp calls to $(MAKE), none of the flags are needed (also, there is no use of FC or CXX anywhere in the build system, so these are not necessary here, either). In the install-arch-stamp target, in the install-Rscript part, the RHOME variable appears as if it should be rhome (lower case) - see src/unix/Makefile. None of the earlier variables are needed for the above reasons. One unusual Makefile in the whole build system is src/library/stats/src/Makefile, which includes $(top_builddir)/etc${R_ARCH}/Makeconf instead, but that works fine. Likewise, src/library/grid/src/Makefile does the same, as do several other Makefiles in src/library. The other Makefiles which don't include the top Makeconf are all in src/gnuwin32, which I assume is not such a big deal for Debian. So my new suggested patch (which comments out those make invocations and replaces them with simplified ones) is attached. Julian
--- debian/rules.old 2013-10-20 19:06:09.000000000 +0100 +++ debian/rules 2013-11-03 15:17:07.889258096 +0000 @@ -77,86 +77,97 @@ f95compiler = gfortran compiler = "gcc -std=gnu99" cxxcompiler = g++ -optimflags = -O3 -pipe -# edd 22 Apr 2012 gcc-4.7 needs -O2 to build R (also #67359) -ifneq "$(shell gcc --version | head -1 | cut -d' ' -f4 | grep '^4.7')" "" -optimflags = -O2 -pipe -endif - -# edd 04 Sep 2001 default compiler flags, lowered for m68k -#compilerflags = -O2 -# m68k barks when using g77, and when gcc use -O2 -# edd 26 Nov 2002 switched back to g77 -# edd 02 Jun 2003 switched back -# cts 04 Jun 2003 use -O1 on m68k -#ifeq ($(arch),m68k) -#fortrancompiler = F2C=f2c -#compilerflags = -O1 -#endif - -# edd 14 Nov 2003 turn blas off on arm -# edd 12 May 2010 no longer needed -- thx to Modestas Vainius -#ifeq ($(arch),arm) -#atlas = --without-blas -#endif - -## edd 09 Nov 2001 ia64 needs gcc-3.0, hppa gets it by default -#ifeq ($(arch),ia64) -#fortrancompiler = F77=g77-3.0 -#compiler = gcc-3.0 -#cxxcompiler = g++-3.0 -#compilerflags = -O2 -#endif - -## lam...@debian.org 06 Dec 2001 hppa needs -ffunction-sections -ifeq ($(arch),hppa) -optimflags = -O2 -ffunction-sections -endif - -## edd 20 Jun 2002 no optimisation or debugging on baby systems -## edd 02 Jun 2003 use this on arm only -## edd 12 May 2010 no longer use it on arm either -- thx Modestas -## edd 04 Aug 2010 on mips and mipsel, don't use -g -##ifneq "$(findstring $(arch), m68k arm)" "" -#ifneq "$(findstring $(arch), arm)" "" -ifneq "$(findstring $(arch), mips mipsel)" "" -optimflags = -g0 -#optimflags = -O0 -g0 -endif - -## edd 04 Apr 2009 Alpha dies on deriv.c, trying will less optimisation -## edd 16 Apr 2009 commented-out as Kurt Roeckx applied a gcc patch -#ifeq ($(arch),alpha) -#optimflags = -O2 -g0 -#endif - -## edd 09 Apr 2006 per patch from Andreas Jochens in #361604 -ifeq ($(arch),powerpc64) -optimflags += -mminimal-toc -endif - -## edd 26 Jul 2013 kFreeBSD wants -O2 per #714506 -ifeq ($(buildos),kfreebsd) -optimflags = -O2 -pipe -endif - - -## edd 04 Apr 2006 generalize from old compilerflags to per-compiler -## edd 11 Oct 2011 -std=gnu goes to CC (thanks to Kurt Hornik) -cflags = $(optimflags) -cxxflags = $(optimflags) -fcflags = $(optimflags) - -## edd 17 Sep 2006 suggested by Brian Ripley in email dated 15 Sep 2006 -#ldflags = -Wl,-O1,-Bdirect,--hash-style=both -ldflags = -Wl,-O1 -## edd 06 May 2007 try it -## edd 05 Feb 2008 still no go under gcc 4.3 -#ldflags = -Wl,-O1,-Bdirect,--hash-style=both - -## edd 16 Apr 2008 add -g to optim flags to allow for -dbg package -optimflags += -g +# jdg 20 Oct 2013 remove all of the architecture-specific optimisations +# from this makefile, and let dpkg-buildflags do this work +# optimflags = -O3 -pipe +# +# # edd 22 Apr 2012 gcc-4.7 needs -O2 to build R (also #67359) +# ifneq "$(shell gcc --version | head -1 | cut -d' ' -f4 | grep '^4.7')" "" +# optimflags = -O2 -pipe +# endif +# +# # edd 04 Sep 2001 default compiler flags, lowered for m68k +# #compilerflags = -O2 +# # m68k barks when using g77, and when gcc use -O2 +# # edd 26 Nov 2002 switched back to g77 +# # edd 02 Jun 2003 switched back +# # cts 04 Jun 2003 use -O1 on m68k +# #ifeq ($(arch),m68k) +# #fortrancompiler = F2C=f2c +# #compilerflags = -O1 +# #endif +# +# # edd 14 Nov 2003 turn blas off on arm +# # edd 12 May 2010 no longer needed -- thx to Modestas Vainius +# #ifeq ($(arch),arm) +# #atlas = --without-blas +# #endif +# +# ## edd 09 Nov 2001 ia64 needs gcc-3.0, hppa gets it by default +# #ifeq ($(arch),ia64) +# #fortrancompiler = F77=g77-3.0 +# #compiler = gcc-3.0 +# #cxxcompiler = g++-3.0 +# #compilerflags = -O2 +# #endif +# +# ## lam...@debian.org 06 Dec 2001 hppa needs -ffunction-sections +# ifeq ($(arch),hppa) +# optimflags = -O2 -ffunction-sections +# endif +# +# ## edd 20 Jun 2002 no optimisation or debugging on baby systems +# ## edd 02 Jun 2003 use this on arm only +# ## edd 12 May 2010 no longer use it on arm either -- thx Modestas +# ## edd 04 Aug 2010 on mips and mipsel, don't use -g +# ##ifneq "$(findstring $(arch), m68k arm)" "" +# #ifneq "$(findstring $(arch), arm)" "" +# ifneq "$(findstring $(arch), mips mipsel)" "" +# optimflags = -g0 +# #optimflags = -O0 -g0 +# endif +# +# ## edd 04 Apr 2009 Alpha dies on deriv.c, trying will less optimisation +# ## edd 16 Apr 2009 commented-out as Kurt Roeckx applied a gcc patch +# #ifeq ($(arch),alpha) +# #optimflags = -O2 -g0 +# #endif +# +# ## edd 09 Apr 2006 per patch from Andreas Jochens in #361604 +# ifeq ($(arch),powerpc64) +# optimflags += -mminimal-toc +# endif +# +# ## edd 26 Jul 2013 kFreeBSD wants -O2 per #714506 +# ifeq ($(buildos),kfreebsd) +# optimflags = -O2 -pipe +# endif +# +# +# ## edd 04 Apr 2006 generalize from old compilerflags to per-compiler +# ## edd 11 Oct 2011 -std=gnu goes to CC (thanks to Kurt Hornik) +# cflags = $(optimflags) +# cxxflags = $(optimflags) +# fcflags = $(optimflags) +# +# ## edd 17 Sep 2006 suggested by Brian Ripley in email dated 15 Sep 2006 +# #ldflags = -Wl,-O1,-Bdirect,--hash-style=both +# ldflags = -Wl,-O1 +# ## edd 06 May 2007 try it +# ## edd 05 Feb 2008 still no go under gcc 4.3 +# #ldflags = -Wl,-O1,-Bdirect,--hash-style=both +# +# ## edd 16 Apr 2008 add -g to optim flags to allow for -dbg package +# optimflags += -g + +cflags = $(shell dpkg-buildflags --get CFLAGS) +cppflags = $(shell dpkg-buildflags --get CPPFLAGS) +cxxflags = $(shell dpkg-buildflags --get CXXFLAGS) +# The following should really be --get FFLAGS, but there appears to be +# a bug in dpkg-dev whereby FFLAGS doesn't get the hardening flags (bug#726932) +fflags = $(shell dpkg-buildflags --get CFLAGS) +ldflags = $(shell dpkg-buildflags --get LDFLAGS) #arch = kfreebsd-amd64 maketest: @@ -232,15 +243,15 @@ LIBnn=lib \ AWK=/usr/bin/awk \ CC=$(compiler) \ - CXX=${cxxcompiler} \ - ${fortrancompiler} \ - FC=${f95compiler} \ + CXX=${cxxcompiler} \ + ${fortrancompiler} \ + FC=${f95compiler} \ CFLAGS="$(cflags)" \ CXXFLAGS="$(cxxflags)" \ - FFLAGS="$(fcflags)" \ - FCFLAGS="$(fcflags)" \ - CPPFLAGS= \ - LDFLAGS= \ + FFLAGS="$(fflags)" \ + FCFLAGS="$(fflags)" \ + CPPFLAGS="$(cppflags)" \ + LDFLAGS="$(ldflags)" \ FLIBS= \ rsharedir=/usr/share/R/share \ rincludedir=/usr/share/R/include \ @@ -272,15 +283,18 @@ make-arch: configure make-arch-stamp make-arch-stamp: @echo "*** make-arch ***" - $(MAKE) CFLAGS="$(cflags)" \ - CXXFLAGS="$(cxxflags)" \ - FFLAGS="$(fcflags)" \ - FCFLAGS="$(fcflags)" \ - CC=${compiler} \ - CXX=${cxxcompiler} \ - ${fortrancompiler} \ - LDFLAGS="$(ldflags)" \ - R + $(MAKE) R +## This was the old version: the make variables are unnecessary, as the +## needed ones are picked up from the generated Makeconf file +# $(MAKE) CFLAGS="$(cflags)" \ +# CXXFLAGS="$(cxxflags)" \ +# FFLAGS="$(fflags)" \ +# FCFLAGS="$(fflags)" \ +# CC=${compiler} \ +# CXX=${cxxcompiler} \ +# ${fortrancompiler} \ +# LDFLAGS="$(ldflags)" \ +# R # the top-level 'make stamp-recommended' target implies 'make docs' # which (for the buildds) implies a lot of time wasted generating @@ -292,17 +306,22 @@ # CXX=${cxxcompiler} \ # ${fortrancompiler} \ # stamp-recommended +## Likewise, this could be simplified to $(MAKE) stamp-recommended # make standalone math lib (cd src/nmath/standalone; \ - $(MAKE) CFLAGS="$(cflags) -D_REENTRANT" \ - CXXFLAGS="$(cxxflags) -D_REENTRANT" \ - FFLAGS="$(fcflags) -D_REENTRANT" \ - CC=${compiler} \ - CXX=${cxxcompiler} \ - ${fortrancompiler} \ - libRmath_la_LDFLAGS=-Wl,-soname,libRmath.so.$(somaj) \ + $(MAKE) libRmath_la_LDFLAGS=-Wl,-soname,libRmath.so.$(somaj) \ shared static ) +## Again, the original version +# (cd src/nmath/standalone; \ +# $(MAKE) CFLAGS="$(cflags) -D_REENTRANT" \ +# CXXFLAGS="$(cxxflags) -D_REENTRANT" \ +# FFLAGS="$(fflags) -D_REENTRANT" \ +# CC=${compiler} \ +# CXX=${cxxcompiler} \ +# ${fortrancompiler} \ +# libRmath_la_LDFLAGS=-Wl,-soname,libRmath.so.$(somaj) \ +# shared static ) # edd 25 Jan 2004 make install needs html docs # edd 03 Feb 2004 new test, try without @@ -386,18 +405,25 @@ $(MAKE) DESTDIR=$(debtmp) install # edd 16 Apr 2008 make Rscript _again_ as the build is broken - # and we need an explicit RHOME + # and we need an explicit rhome (cd src/unix; \ rm -vf Rscript $(debtmp)/usr/bin/Rscript; \ - $(MAKE) CFLAGS="$(cflags) -D_REENTRANT" \ - CXXFLAGS="$(cxxflags) -D_REENTRANT" \ - FFLAGS="$(fcflags) -D_REENTRANT" \ - CC=${compiler} \ - CXX=${cxxcompiler} \ - ${fortrancompiler} \ - RHOME=/usr/lib/R \ + $(MAKE) rhome=/usr/lib/R \ DESTDIR=$(debtmp) \ install-Rscript ) +## Here is the original version; all of the needed variables except +## for rhome and DESTDIR are picked up from Makeconf +# (cd src/unix; \ +# rm -vf Rscript $(debtmp)/usr/bin/Rscript; \ +# $(MAKE) CFLAGS="$(cflags) -D_REENTRANT" \ +# CXXFLAGS="$(cxxflags) -D_REENTRANT" \ +# FFLAGS="$(fflags) -D_REENTRANT" \ +# CC=${compiler} \ +# CXX=${cxxcompiler} \ +# ${fortrancompiler} \ +# RHOME=/usr/lib/R \ +# DESTDIR=$(debtmp) \ +# install-Rscript ) #ls -ltr $(debtmp)/usr/bin/ #strings src/unix/Rscript cp -vax src/unix/Rscript $(debtmp)/usr/bin/