Skip to content

Commit

Permalink
Require C++17 (#1893)
Browse files Browse the repository at this point in the history
* flex: require >= 2.6 to avoid register keyword.
* flex/c++ standard documentation and fixes.
* Use std:: prefix on cout, endl, istream, ostream etc.
* drop gcc5 and gcc6, do not explicitly specify default cmake option values.
* Use newer python patch versions and target macOS 10.14 instead of 10.9.
* Dockerfile: newer flex 
* Dockerfile_gpu: base on `latest-x86_64`

* C++17 in submodules.
  *  Require C++17 in CoreNEURON too -> BlueBrain/CoreNeuron#834.
  *  Require C++17 in InterViews too->  iv#43 & Bump to C++17 iv#44.
  *  Require C++17 in NMODL too -> BlueBrain/nmodl#889 

Co-authored-by: Alexandru Săvulescu <[email protected]>
  • Loading branch information
olupton and alexsavulescu authored Jul 6, 2022
1 parent f20c3dc commit c63f8df
Show file tree
Hide file tree
Showing 39 changed files with 276 additions and 270 deletions.
4 changes: 2 additions & 2 deletions .clang-format.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SortIncludes: false
Standard: c++14
StatementMacros: [MKDLL, MKDLLdec, MKDLLif, MKDLLvp, MKDLLvpf]
Standard: c++17
StatementMacros: [MKDLL, MKDLLdec, MKDLLif, MKDLLvp, MKDLLvpf]
21 changes: 12 additions & 9 deletions .github/workflows/neuron-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ jobs:
matrix:
os: [ macOS-10.15, ubuntu-18.04]
config:
- { matrix_eval : "CC=gcc CXX=g++" , build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=ON -DNRN_ENABLE_INTERVIEWS=ON -DNRN_ENABLE_CORENEURON=ON" }
- { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "setuptools" }
- { matrix_eval : "CC=gcc-5 CXX=g++-5", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_CORENEURON=ON" }
- { matrix_eval : "CC=gcc-6 CXX=g++-6", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=ON -DNRN_ENABLE_INTERVIEWS=ON -DNRN_ENABLE_CORENEURON=OFF" }
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_PYTHON=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_CORENEURON=ON" }
- { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "cmake", python_dynamic : ON }
# GitHub Actions's ubuntu-18.04 image should provide g++ versions 9 and
# 10 even though those are not available in vanilla Ubuntu 18.04
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "setuptools"}
- { matrix_eval : "CC=gcc-8 CXX=g++-8", build_mode: "cmake"}
- { matrix_eval : "CC=gcc-9 CXX=g++-9", build_mode: "cmake", python_dynamic: ON}
- { matrix_eval : "CC=gcc-7 CXX=g++-7" , build_mode: "cmake", cmake_option: "-DNRN_ENABLE_CORENEURON=ON"}
- { matrix_eval : "CC=gcc-7 CXX=g++-7", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_MPI=OFF -DNRN_ENABLE_INTERVIEWS=OFF -DNRN_ENABLE_CORENEURON=ON"}
- { matrix_eval : "CC=gcc-10 CXX=g++-10", build_mode: "cmake", cmake_option: "-DNRN_ENABLE_PYTHON=OFF -DNRN_ENABLE_RX3D=OFF -DNRN_ENABLE_CORENEURON=ON"}
include:
- os: ubuntu-22.04
config:
Expand Down Expand Up @@ -79,10 +81,11 @@ jobs:
- name: Install homebrew packages
if: startsWith(matrix.os, 'macOS')
run: |
brew install ccache coreutils doxygen mpich ninja xz
brew install ccache coreutils doxygen flex mpich ninja xz
brew unlink mpich
brew install openmpi
brew install --cask xquartz
echo /usr/local/opt/flex/bin >> $GITHUB_PATH
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
echo CTEST_PARALLEL_LEVEL=3 >> $GITHUB_ENV
Expand All @@ -97,7 +100,7 @@ jobs:
openmpi-bin patchelf
# The sanitizer builds use ubuntu 22.04
if [[ "${{matrix.os}}" == "ubuntu-18.04" ]]; then
sudo apt-get install g++-5 g++-6 g++-8 g++-9
sudo apt-get install g++-7 g++-8
fi
# Core https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=2 >> $GITHUB_ENV
Expand Down Expand Up @@ -165,7 +168,7 @@ jobs:
run: |
# OS related
if [ "$RUNNER_OS" == "Linux" ]; then
eval $MATRIX_EVAL;
export ${MATRIX_EVAL};
export SHELL="/bin/bash"
else
export CXX=${CXX:-g++};
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ project(
# =============================================================================
# CMake common project settings
# =============================================================================
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -251,7 +251,7 @@ include(cmake/SanitizerHelper.cmake)
# Find required packages
# =============================================================================
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
find_package(FLEX 2.6 REQUIRED)

# When shipping the wheels we want to link readline libs statically.
if(NRN_WHEEL_STATIC_READLINE)
Expand Down
12 changes: 7 additions & 5 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,19 @@ stages:
matrix:
Python37:
python.version: '3.7'
python.org.version: '3.7.7'
python.org.version: '3.7.9'
python.installer.name: 'macosx10.9.pkg'
Python38:
python.version: '3.8'
python.org.version: '3.8.2'
python.org.version: '3.8.10'
python.installer.name: 'macosx10.9.pkg'
Python39:
python.version: '3.9'
python.org.version: '3.9.0'
python.org.version: '3.9.13'
python.installer.name: 'macosx10.9.pkg'
Python310:
python.version: '3.10'
python.org.version: '3.10.0'
python.org.version: '3.10.5'
python.installer.name: 'macos11.pkg'

steps:
Expand Down Expand Up @@ -186,8 +186,10 @@ stages:
inputs:
secureFile: 'readline7.0.tar.gz'

# 10.14 is required for full C++17 support, see:
# https://cibuildwheel.readthedocs.io/en/stable/cpp_standards
- script: |
export MACOSX_DEPLOYMENT_TARGET=10.9
export MACOSX_DEPLOYMENT_TARGET=10.14
export PATH=/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH
export SDKROOT=$(xcrun --sdk macosx --show-sdk-path)
export NRN_BUILD_FOR_UPLOAD=1
Expand Down
2 changes: 1 addition & 1 deletion bin/nrnivmodl_makefile_cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ endif
ifeq ($(origin CXX), default)
CXX = @CMAKE_CXX_COMPILER@
endif
CXXFLAGS = @BUILD_TYPE_CXX_FLAGS@ @CMAKE_CXX_FLAGS@ @CMAKE_CXX14_STANDARD_COMPILE_OPTION@
CXXFLAGS = @BUILD_TYPE_CXX_FLAGS@ @CMAKE_CXX_FLAGS@ @CMAKE_CXX17_STANDARD_COMPILE_OPTION@
CXXCOMPILE = $(CXX) $(CXXFLAGS) @NRN_COMPILE_DEFS_STRING@ @NRN_COMPILE_FLAGS_STRING@
CXX_LINK_EXE = $(CXX) $(CXXFLAGS) @CMAKE_EXE_LINKER_FLAGS@ @NRN_LINK_FLAGS_STRING@
CXX_LINK_SHARED = $(CXX) $(CXXFLAGS) @CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS@ @CMAKE_SHARED_LIBRARY_CXX_FLAGS@ @CMAKE_SHARED_LINKER_FLAGS@
Expand Down
6 changes: 0 additions & 6 deletions cmake/CompilerHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ else()
set(USING_PGI_COMPILER_TRUE "#")
set(USING_PGI_COMPILER_FALSE "")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "PGI")
# CMake adds strict standard complaint PGI flag "-A" which breaks compilation of old codes (e.g.
# spdlog, fmt)
set(CMAKE_CXX14_STANDARD_COMPILE_OPTION --c++14)
endif()
4 changes: 2 additions & 2 deletions docs/install/install_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ from source.
In order to build NEURON from source, the following packages must be available:

- Bison
- Flex
- C/C++ compiler suite
- Flex >= 2.6
- C/C++ compiler suite supporting C++17
- CMake 3.15.0

The following packages are optional (see build options):
Expand Down
2 changes: 1 addition & 1 deletion external/coreneuron
2 changes: 1 addition & 1 deletion external/iv
Submodule iv updated 173 files
13 changes: 12 additions & 1 deletion packaging/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,25 @@ RUN yum -y install \
curl \
unzip \
bison \
flex \
autoconf \
automake \
openssh-server \
libtool

# required for rpmbuild
RUN yum -y install \
gettext \
gcc-c++ \
help2man \
rpm-build

WORKDIR /root

# newer flex with rpmbuild (manylinux2014 based on Centos7 currently has flex < 2.6)
RUN rpmbuild --rebuild https://vault.centos.org/8-stream/AppStream/Source/SPackages/flex-2.6.1-9.el8.src.rpm \
&& yum install -y /root/rpmbuild/RPMS/x86_64/flex-2.6.1-9.el7.x86_64.rpm \
&& rm -rf rpmbuild

RUN wget http://ftpmirror.gnu.org/ncurses/ncurses-6.2.tar.gz \
&& tar -xvzf ncurses-6.2.tar.gz \
&& cd ncurses-6.2 \
Expand Down
2 changes: 1 addition & 1 deletion packaging/python/Dockerfile_gpu
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM neuronsimulator/neuron_wheel
FROM neuronsimulator/neuron_wheel:latest-x86_64
LABEL authors="Pramod Kumbhar, Olli Lupton, Fernando Pereira, Alexandru Savulescu"

WORKDIR /root
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/apwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ void OcGlyph::def_size(Coord& w, Coord& h) const {
}
}

void OcGlyph::save(ostream&) {
void OcGlyph::save(std::ostream&) {
printf("OcGlyph::save (not implemented for relevant class)\n");
}

Expand Down
6 changes: 3 additions & 3 deletions src/ivoc/axis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
GAxisItem(Glyph* g)
: GraphItem(g) {}
virtual ~GAxisItem(){};
virtual void save(ostream&, Coord, Coord) {}
virtual void save(std::ostream&, Coord, Coord) {}
virtual void erase(Scene* s, GlyphIndex i, int type) {
if (type & GraphItem::ERASE_AXIS) {
s->remove(i);
Expand Down Expand Up @@ -85,7 +85,7 @@ void Axis::size(float& min, float& max) {
max = float(amax_);
}

void Axis::save(ostream& o) {
void Axis::save(std::ostream& o) {
char buf[256];
int c;
if (d_ == Dimension_X) {
Expand All @@ -103,7 +103,7 @@ void Axis::save(ostream& o) {
nminor_,
invert_,
number_);
o << buf << endl;
o << buf << std::endl;
}

void Axis::update(Observable*) {}
Expand Down
2 changes: 1 addition & 1 deletion src/ivoc/axis.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Axis: public Glyph, public Observer {
int invert = 0,
bool number = true);
virtual ~Axis();
virtual void save(ostream&);
virtual void save(std::ostream&);
virtual void update(Observable*);
virtual void size(float&, float&);

Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/epsprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ save 20 dict begin\n\
\n\
";

EPSPrinter::EPSPrinter(ostream* o)
EPSPrinter::EPSPrinter(std::ostream* o)
: Printer(o) {}

EPSPrinter::~EPSPrinter() {}

void EPSPrinter::eps_prolog(ostream& out, Coord width, Coord height, const char* creator) {
void EPSPrinter::eps_prolog(std::ostream& out, Coord width, Coord height, const char* creator) {
int bbw = int(width);
int bbh = int(height);
// need to describe it as EPSF = "encapsulated postscript"
Expand Down
4 changes: 2 additions & 2 deletions src/ivoc/epsprint.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

class EPSPrinter: public Printer {
public:
EPSPrinter(ostream*);
EPSPrinter(std::ostream*);
virtual ~EPSPrinter();

virtual void eps_prolog(ostream&,
virtual void eps_prolog(std::ostream&,
Coord width,
Coord height,
const char* creator = "InterViews");
Expand Down
Loading

0 comments on commit c63f8df

Please sign in to comment.