Skip to content

Build BAT on travis with all standards >= C++03 #329

Open

Description

@fredRos

sparked by #326

Activity

  1. self-assigned this
    on May 22, 2019
  2. fredRos commented on Aug 3, 2020

    @fredRos
    ContributorAuthor

    An even simpler way might be to enforce the C++ standard in the build flags to ensure that future deprecations don't lead to trouble. But of course that would lead to problems when integrated in more modern software that needs a newer standard. I guess the best of both worlds would be if just the headers were written in the common subset of C++03, up to C++20

    gcc 9.3 available in ubuntu 20.04 has full support for C++17. There is no full support for C++20 yet, even in g++11 https://gcc.gnu.org/projects/cxx-status.html#cxx17

  3. fredRos commented on Aug 3, 2020

    @fredRos
    ContributorAuthor

    An example issue reported by a user

    ~/BAT-0.9.4.1$ make
    /Library/Developer/CommandLineTools/usr/bin/make  all-recursive
    Making all in src
    /usr/local/bin/rootcling -f libBAT_rdict.cxx.tmp -s libBAT`test .odule = .yes && echo .so || echo .dylib` -rml libBAT`test .odule = .yes && echo .so || echo .dylib` -rmf libBAT.rootmap -c   -I/usr/local/include ../BAT/BCDataPoint.h ../BAT/BCDataSet.h ../BAT/BCH1D.h ../BAT/BCH2D.h ../BAT/BCParameter.h ../BAT/BCParameterSet.h ../BAT/BCEngineMCMC.h ../BAT/BCIntegrate.h ../BAT/BCModel.h ../BAT/BCModelManager.h ../BAT/BCModelOutput.h ../BAT/BCGoFTest.h ../BAT/BCLog.h ../BAT/BCMath.h ../BAT/BCAux.h ../BAT/BCSummaryTool.h ../BAT/BCSummaryPriorModel.h LinkDef.h
    In file included from input_line_12:16:
    ./../BAT/BCMath.h:218:78: error: ISO C++17 does not allow dynamic exception specifications [-Wdynamic-exception-spec]
                      const unsigned & chain_length, const bool & strict = true) throw (std::invalid_argument, std::domain_error);
                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ./../BAT/BCMath.h:218:78: note: use 'noexcept(false)' instead
                      const unsigned & chain_length, const bool & strict = true) throw (std::invalid_argument, std::domain_error);
    
  4. oschulz commented on Aug 4, 2020

    @oschulz
    Member

    I guess the best of both worlds would be if just the headers were written in the common subset of C++03, up to C++20

    Yes, I agree. As for the concrete case, I guess we can just take the exception specification out?

  5. fredRos commented on Aug 4, 2020

    @fredRos
    ContributorAuthor

    I build bat with g++-9.3 and root 6.22 that sets -std=c++11 itself

    ../configure  CXXFLAGS='-std=c++03' # fails with root6
    ../configure  CXXFLAGS='-std=c++11' # works
    ../configure  CXXFLAGS='-std=c++14' # works
    ../configure  CXXFLAGS='-std=c++17' 
    make[3]: Entering directory '/home/fred/workspace/bat/build/src'
    /bin/bash ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../src -I..    -pthread -std=c++11 -m64 -Wall -fPIC -I../../BAT -I.includes -I/home/fred/software/root-6.22.00/include  -O2 -Wno-unknown-pragmas -std=c++17 -MT BCHistogramBase.lo -MD -MP -MF .deps/BCHistogramBase.Tpo -c -o BCHistogramBase.lo ../../src/BCHistogramBase.cxx
    libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../src -I.. -pthread -std=c++11 -m64 -Wall -fPIC -I../../BAT -I.includes -I/home/fred/software/root-6.22.00/include -O2 -Wno-unknown-pragmas -std=c++17 -MT BCHistogramBase.lo -MD -MP -MF .deps/BCHistogramBase.Tpo -c ../../src/BCHistogramBase.cxx  -fPIC -DPIC -o .libs/BCHistogramBase.o
    In file included from /home/fred/software/root-6.22.00/include/TString.h:28,
                     from /home/fred/software/root-6.22.00/include/TPave.h:17,
                     from /home/fred/software/root-6.22.00/include/TLegend.h:16,
                     from ../../BAT/BCHistogramBase.h:25,
                     from ../../src/BCHistogramBase.cxx:11:
    /home/fred/software/root-6.22.00/include/ROOT/RStringView.hxx:32:10: error: conflicting declaration of template ‘template<class _CharT, class _Traits> using basic_string_view = std::experimental::__ROOT::basic_string_view<_CharT, _Traits>’
       32 |    using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
          |          ^~~~~~~~~~~~~~~~~
    In file included from /usr/include/c++/9/bits/basic_string.h:48,
                     from /usr/include/c++/9/string:55,
                     from ../../BAT/BCHistogramBase.h:22,
                     from ../../src/BCHistogramBase.cxx:11:
    /usr/include/c++/9/string_view:90:11: note: previous declaration ‘template<class _CharT, class _Traits> class std::basic_string_view’
       90 |     class basic_string_view
          |           ^~~~~~~~~~~~~~~~~
    

    So I conclude root itself doesn't build with c++17 and there is nothing gained in making BAT ready for C++17 yet. I'd rather set the c++ standard in BAT to c++11. We just didn't do this before to support even older compilers before gcc 4.8. But it's 2020 now, and I rather support existing users with modern compilers than an unknown user with a very old compiler.

    I read that gcc11 will use c++17 by default, so future distros shipping that compiler would also get users into trouble if we don't specify a standard and someone used an older version root5

  6. oschulz commented on Aug 4, 2020

    @oschulz
    Member

    Looks like building ROOT with C++-17 compatibility may be possible, but needs special build options: https://ph-root-2.cern.ch/install/build_from_source/#building-root-with-cuda-support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions