[Rd] Default R-3.4.0 RC CXXFLAGS without -O2 on x86_64-linux-gnu with g++-5.4.0 causes WARNING from stl_list.h

Neumann, Steffen sneumann at ipb-halle.de
Wed Apr 19 14:19:40 CEST 2017

Hi r-devel,

a recent install of R-3.4.0 RC (2017-04-13 r72510) 
on Linux (Ubuntu 16.04.1 LTS) x86_64-linux-gnu 
with g++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
(see http://bioconductor.org/checkResults/devel/bioc-LATEST/malbec2-NodeInfo.html for more) 
results in CXXFLAGS not containing "-O2" as optimisation flag,
there is only "	-Wall", while CFLAGS are happy with "-g -O2

This has an influence in at least one place
where we have WARNINGS in R CMD check from "Found ‘abort’, 
possibly from ‘abort’ (C)" in packages xcms/mzR.
The abort() call is not coming from XCMS, but rather 
from the C++ code in the STL:

	# 1770 "/usr/include/c++/5/bits/stl_list.h"
	void _M_check_equal_allocators(list& __x) {
	 if (_M_get_Node_allocator())

If we compile with -O2 optimisation, this getting rid of 
the abort() symbol, as shown 
in https://github.com/sneumann/xcms/issues/150#issuecomment-293545521

Martin Morgan created a minimum example that shows that 
the symbol is indeed deep down in the STL (see below and in:
https://stat.ethz.ch/pipermail/bioc-devel/2017-April/010837.html )

This raises several questions:

1) is there any way to avoid the WARNING / abort() inside 
   the STL list implementation ? Or just live with it ?

2) If not, is there a reason why the Bioconductor build farm 
   Ubuntu machine is not using -O2 as default CXXFLAG ?
   BioC admins are trying to have a vanilla R installation with defaults. 
   According to Herve Pages, CXXFLAGS without -O2 is default 
   since R-3.4 beta, but I don't know enough about the package 
   build logic to point to a particular R commit. 

3) I thought about cheating the system and add -O2 
   in the package CXXFLAGS, but Martin Morgan 
   recommends packages shouldn't mess and override system build defaults
   to mask and paper over the actual issue having a nasty abort() 
   lurking somewhere.
   But I couldn't add PKG_CXXFLAGS=-O2 in first place, since that 
   triggers the different WARNING that -O2 is not portable. 

=> Any help and input would be highly appreciated. 

Thanks in advance, 

tmp.cpp by Martin Morgan (also in above linked mail thread)
#include <list>

int foo(int argc, const char *argv[]) {
     std::list<int> l1, l2;
     std::list<int>::iterator it;

     it = l1.begin();
     l1.splice (it, l2); // mylist1: 1 10 20 30 2 3 4

     return 0;

Test with

   rm -f tmp.o && R CMD SHLIB tmp.cpp && nm tmp.o | grep abort

with compiler settings in ~/.R/Makevars with/without -O2 

IPB Halle                    AG Massenspektrometrie &
Dr. Steffen Neumann          http://www.IPB-Halle.DE
Weinberg 3                   Tel. +49 (0) 345 5582 - 1470
06120 Halle                       +49 (0) 345 5582 - 0           
sneumann(at)IPB-Halle.DE     Fax. +49 (0) 345 5582 - 1409

More information about the R-devel mailing list