On 20 October 2013 at 22:07, Julian Gilbey wrote: | On Sun, Oct 20, 2013 at 12:34:04PM -0500, Dirk Eddelbuettel wrote: | > | Ah, I'm guessing it comes from /usr/lib/R/etc/Makeconf (I straced R | > | CMD config LDFLAGS). That seems to be created at R build time, so I | > | wonder whether simply tweaking that would do the trick? | > | > Good thinking -- yes it would. We code'em down in debian/rules for | > configure, they then tend to get passed through. | > | > That would probably be worth it! (And in case you look at the debian/rules | > for r-base, it is a bit of a mess that grew over ten+ years -- not proud of | > it but heck it works :) | > | > | I've just had a look at the debian/rules file for r-base. At present, | > | optimflags seems to be derived from a hand-written set of rules. | > | Could it be replaced by something vaguely like the following: | > | | > | optimflags = $(shell dpkg-buildflags --get CFLAGS) | > | ldflags = $(shell dpkg-buildflags --get LDFLAGS) | > | > Very nice. I was fully unaware of that option to dpkg-buildflags. | | I was unaware of the script in its entirety until today ;-)
Me too. I said that awkwardly, ie didn't come out right. I had only know about DEB_BUILD_OPTIONS and other hacks. This is much better. | | > | etc., and the same for CPPFLAGS, CXXFLAGS, FFLAGS, and then set these | > | environment variables when you run configure, instead of setting | > | LDFLAGS to be empty? I could write a whole patch if you wish, but | > | only if you would like me to. | > | > 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. | necessary or not. Also, the definition of fflags is currently broken, | as noted in the patch, as there is a bug in dpkg-dev (which I've just | reported) - it should be fixed pretty soon. | | I've left all of the old code in the file, clearly commented out. It | might be worth removing it entirely, or perhaps not. I had some issue come back to me twice, in that sense it helps as institutional memory. | Also, I noticed | that there is an old rules,v file in the debian/ directory, which made | it slightly hard to edit the rules file. I don't know how you're | currently doing your version tracking, but if it's no longer with RCS, | you may wish to delete this file! Yes, that is from way-back-when. Dirk | HTH! | | Julian | | ---------------------------------------------------------------------- | --- rules.old 2013-10-20 19:06:09.000000000 +0100 | +++ rules 2013-10-20 19:29:26.938407738 +0100 | @@ -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 \ | @@ -274,8 +285,9 @@ | @echo "*** make-arch ***" | $(MAKE) CFLAGS="$(cflags)" \ | CXXFLAGS="$(cxxflags)" \ | - FFLAGS="$(fcflags)" \ | - FCFLAGS="$(fcflags)" \ | + CPPFLAGS="$(cppflags)" \ | + FFLAGS="$(fflags)" \ | + FCFLAGS="$(fflags)" \ | CC=${compiler} \ | CXX=${cxxcompiler} \ | ${fortrancompiler} \ | @@ -297,7 +309,9 @@ | (cd src/nmath/standalone; \ | $(MAKE) CFLAGS="$(cflags) -D_REENTRANT" \ | CXXFLAGS="$(cxxflags) -D_REENTRANT" \ | - FFLAGS="$(fcflags) -D_REENTRANT" \ | + CPPFLAGS="$(cppflags)" \ | + LDFLAGS="$(ldflags)" \ | + FFLAGS="$(fflags) -D_REENTRANT" \ | CC=${compiler} \ | CXX=${cxxcompiler} \ | ${fortrancompiler} \ | @@ -391,7 +405,9 @@ | rm -vf Rscript $(debtmp)/usr/bin/Rscript; \ | $(MAKE) CFLAGS="$(cflags) -D_REENTRANT" \ | CXXFLAGS="$(cxxflags) -D_REENTRANT" \ | - FFLAGS="$(fcflags) -D_REENTRANT" \ | + CPPFLAGS="$(cppflags)" \ | + LDFLAGS="$(ldflags)" \ | + FFLAGS="$(fflags) -D_REENTRANT" \ | CC=${compiler} \ | CXX=${cxxcompiler} \ | ${fortrancompiler} \ -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org