Skip to content

Commit bb6a805

Browse files
authored
Upgrade the compiler used on Linux (#2)
We have already upgraded the macOS and Windows compilers on the master branch. This change upgrades the Linux compiler. The new compiler is gcc 7.3, upgraded from gcc 6.2. The OS used to build releases is also upgraded, to CentOS 6 from Fedora 10. gcc 7.3 is built from source with the --enable-vtable-verify option so that the -fvtable-verify=std option could possibly be used in the future. Finally, the -std flag has been changed to allow C++14 features to be used. This matches macOS and Windows. However, for ease of backporting it is best that we don't use C++14 features until version 6.x is nearing end-of-life.
1 parent c1b8d66 commit bb6a805

File tree

15 files changed

+133
-402
lines changed

15 files changed

+133
-402
lines changed

3rd_party/3rd_party.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ case `uname` in
5454
if [ -z "$CPP_CROSS_COMPILE" ] ; then
5555
ldd --version 2>&1 | grep musl > /dev/null
5656
if [ $? -ne 0 ] ; then
57-
APR_LOCATION=/usr/local/gcc62/lib
57+
APR_LOCATION=/usr/local/gcc73/lib
5858
APR_EXTENSION=1.so.0
59-
BOOST_LOCATION=/usr/local/gcc62/lib
59+
BOOST_LOCATION=/usr/local/gcc73/lib
6060
BOOST_COMPILER=gcc
6161
BOOST_EXTENSION=mt-1_65_1.so.1.65.1
6262
BOOST_LIBRARIES='date_time filesystem iostreams program_options regex system thread'
63-
LOG4CXX_LOCATION=/usr/local/gcc62/lib
63+
LOG4CXX_LOCATION=/usr/local/gcc73/lib
6464
LOG4CXX_EXTENSION=.so.10
65-
XML_LOCATION=/usr/local/gcc62/lib
65+
XML_LOCATION=/usr/local/gcc73/lib
6666
XML_EXTENSION=.so.2
6767
# Ship the version of expat that came with the apr-util library
68-
EXPAT_LOCATION=/usr/local/gcc62/lib
68+
EXPAT_LOCATION=/usr/local/gcc73/lib
6969
EXPAT_EXTENSION=.so.0
70-
GCC_RT_LOCATION=/usr/local/gcc62/lib64
70+
GCC_RT_LOCATION=/usr/local/gcc73/lib64
7171
GCC_RT_EXTENSION=.so.1
72-
STL_LOCATION=/usr/local/gcc62/lib64
72+
STL_LOCATION=/usr/local/gcc73/lib64
7373
STL_PREFIX=libstdc++
7474
STL_EXTENSION=.so.6
7575
ATOMIC_LOCATION=

build-setup/linux.md

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ You will need the following environment variables to be defined:
66

77
- `JAVA_HOME` - Should point to the JDK you want to use to run Gradle.
88
- `CPP_SRC_HOME` - Only required if building the C++ code directly using `make`, as Gradle sets it automatically.
9-
- `PATH` - Must have `/usr/local/gcc62/bin` before `/usr/bin` and `/bin`.
10-
- `LD_LIBRARY_PATH` - Must have `/usr/local/gcc62/lib64` and `/usr/local/gcc62/lib` before `/usr/lib` and `/lib`.
9+
- `PATH` - Must have `/usr/local/gcc73/bin` before `/usr/bin` and `/bin`.
10+
- `LD_LIBRARY_PATH` - Must have `/usr/local/gcc73/lib64` and `/usr/local/gcc73/lib` before `/usr/lib` and `/lib`.
1111

1212
For example, you might create a `.bashrc` file in your home directory containing something like this:
1313

1414
```
1515
umask 0002
1616
export JAVA_HOME=/usr/local/jdk1.8.0_121
17-
export LD_LIBRARY_PATH=/usr/local/gcc62/lib64:/usr/local/gcc62/lib:/usr/lib:/lib
18-
export PATH=$JAVA_HOME/bin:/usr/local/gcc62/bin:/usr/bin:/bin:/usr/sbin:/sbin:/home/vagrant/bin
17+
export LD_LIBRARY_PATH=/usr/local/gcc73/lib64:/usr/local/gcc73/lib:/usr/lib:/lib
18+
export PATH=$JAVA_HOME/bin:/usr/local/gcc73/bin:/usr/bin:/bin:/usr/sbin:/sbin:/home/vagrant/bin
1919
# Only required if building the C++ code directly using make - adjust depending on the location of your Git clone
2020
export CPP_SRC_HOME=$HOME/ml-cpp
2121
```
@@ -38,7 +38,7 @@ On other Linux distributions the package names are generally the same and you ju
3838
Most of the tools are built via a GNU "configure" script. There are some environment variables that affect the behaviour of this. Therefore, when building ANY tool on Linux, set the following environment variable:
3939

4040
```
41-
export CXX='g++ -std=gnu++0x'
41+
export CXX='g++ -std=gnu++14'
4242
unset LIBRARY_PATH
4343
```
4444

@@ -48,22 +48,47 @@ The `CXX` environment variable only needs to be set when building tools on Linux
4848

4949
We have to build on old Linux versions to enable our software to run on the older versions of Linux that users have. However, this means the default compiler on our Linux build servers is also very old. To enable use of more modern C++ features, we use the default compiler to build a newer version of gcc and then use that to build all our other dependencies.
5050

51-
Download `gcc-6.2.0.tar.bz2` from <http://ftpmirror.gnu.org/gcc/gcc-6.2.0/gcc-6.2.0.tar.bz2>.
51+
Download `gcc-7.3.0.tar.gz` from <http://ftpmirror.gnu.org/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz>.
5252

5353
Unlike most automake-based tools, gcc must be built in a directory adjacent to the directory containing its source code, so build and install it like this:
5454

5555
```
56-
tar jxvf gcc-6.2.0.tar.bz2
57-
cd gcc-6.2.0
56+
tar zxvf gcc-7.3.0.tar.gz
57+
cd gcc-7.3.0
5858
contrib/download_prerequisites
5959
cd ..
60-
mkdir gcc-6.2.0-build
61-
cd gcc-6.2.0-build
62-
../gcc-6.2.0/configure --prefix=/usr/local/gcc62 --enable-languages=c,c++ --with-system-zlib --disable-multilib
60+
mkdir gcc-7.3.0-build
61+
cd gcc-7.3.0-build
62+
unset CXX
63+
unset LD_LIBRARY_PATH
64+
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
65+
../gcc-7.3.0/configure --prefix=/usr/local/gcc73 --enable-languages=c,c++ --enable-vtable-verify --with-system-zlib --disable-multilib
6366
make -j 6
6467
sudo make install
6568
```
6669

70+
It's important that gcc itself is built using the system compiler in C++98 mode, hence the adjustment to `PATH` and unsetting of `CXX` and `LD_LIBRARY_PATH`.
71+
72+
After the gcc build is complete, if you are going to work through the rest of these instructions in the same shell remember to reset the `CXX` environment variable so that the remaining C++ components get built with C++14:
73+
74+
```
75+
export CXX='g++ -std=gnu++14'
76+
```
77+
78+
To confirm that everything works correctly run:
79+
80+
```
81+
g++ --version
82+
```
83+
84+
It should print:
85+
86+
```
87+
g++ (GCC) 7.3.0
88+
```
89+
90+
in the first line of the output. If it doesn't then double check that `/usr/local/gcc73/bin` is near the beginning of your `PATH`.
91+
6792
### Git
6893

6994
Modern versions of Linux will come with Git in their package repositories, and (since we're not redistributing it so don't really care about the exact version used) this is the easiest way to install it. The command will be:
@@ -72,7 +97,7 @@ Modern versions of Linux will come with Git in their package repositories, and (
7297
sudo yum install git
7398
```
7499

75-
on RHEL clones, or for SLES use YaST. **However**, Jenkins requires at minimum version 1.7.9 of Git, so if the version that yum installs is older you'll still have to build it from scratch. In this case, you may need to uninstall the version that yum installed:
100+
on RHEL clones. **However**, Jenkins requires at minimum version 1.7.9 of Git, so if the version that yum installs is older you'll still have to build it from scratch. In this case, you may need to uninstall the version that yum installed:
76101

77102
```
78103
git --version
@@ -107,7 +132,7 @@ Anonymous FTP to ftp.xmlsoft.org, change directory to libxml2, switch to binary
107132
Uncompress and untar the resulting file. Then run:
108133

109134
```
110-
./configure --prefix=/usr/local/gcc62 --without-python --without-readline
135+
./configure --prefix=/usr/local/gcc73 --without-python --without-readline
111136
```
112137

113138
This should build an appropriate Makefile. Assuming it does, type:
@@ -121,36 +146,36 @@ to install.
121146

122147
### APR
123148

124-
For Linux, before building log4cxx you must download the Apache Portable Runtime (APR), and its utilities from <http://mirrors.sonic.net/apache/apr/apr-1.5.2.tar.bz2>.
149+
For Linux, before building log4cxx you must download the Apache Portable Runtime (APR) from <http://archive.apache.org/dist/apr/apr-1.5.2.tar.bz2>.
125150

126151
Extract the tarball to a temporary directory:
127152

128153
```
129-
tar xvf apr-1.5.2.tar
154+
tar jxvf apr-1.5.2.tar.bz2
130155
```
131156

132157
Build using:
133158

134159
```
135-
./configure --prefix=/usr/local/gcc62
160+
./configure --prefix=/usr/local/gcc73
136161
make
137162
sudo make install
138163
```
139164

140165
### APR utilities
141166

142-
For Linux, before building log4cxx you must download the Apache Portable Runtime (APR) utilities from <http://mirrors.sonic.net/apache/apr/apr-util-1.5.4.tar.bz2>.
167+
For Linux, before building log4cxx you must download the Apache Portable Runtime (APR) utilities from <http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.bz2>.
143168

144169
Extract the tarball to a temporary directory:
145170

146171
```
147-
tar xvf apr-util-1.5.4.tar
172+
tar jxvf apr-util-1.5.4.tar.bz2
148173
```
149174

150175
Build using:
151176

152177
```
153-
./configure --prefix=/usr/local/gcc62 --with-apr=/usr/local/gcc62/bin/apr-1-config --with-expat=builtin
178+
./configure --prefix=/usr/local/gcc73 --with-apr=/usr/local/gcc73/bin/apr-1-config --with-expat=builtin
154179
make
155180
sudo make install
156181
```
@@ -179,7 +204,7 @@ to:
179204

180205
```
181206
#if LOG4CXX_HELGRIND
182-
#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x);
207+
#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x);
183208
#else
184209
#define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) {
185210
#endif
@@ -239,7 +264,7 @@ In `src/test/cpp/xml/domtestcase.cpp` replace `0x` with `(char)0x` on lines 193
239264
Once all the changes are made, configure using:
240265

241266
```
242-
./configure --prefix=/usr/local/gcc62 --with-charset=utf-8 --with-logchar=utf-8 --with-apr=/usr/local/gcc62 --with-apr-util=/usr/local/gcc62
267+
./configure --prefix=/usr/local/gcc73 --with-charset=utf-8 --with-logchar=utf-8 --with-apr=/usr/local/gcc73 --with-apr-util=/usr/local/gcc73
243268
```
244269

245270
This should build an appropriate Makefile. Assuming it does, type:
@@ -264,12 +289,12 @@ bzip2 -cd boost_1_65_1.tar.bz2 | tar xvf -
264289
In the resulting `boost_1_65_1` directory, run:
265290

266291
```
267-
./bootstrap.sh cxxflags=-std=gnu++0x --without-libraries=context --without-libraries=coroutine --without-libraries=graph_parallel --without-libraries=log --without-libraries=mpi --without-libraries=python --without-libraries=test --without-icu
292+
./bootstrap.sh cxxflags=-std=gnu++14 --without-libraries=context --without-libraries=coroutine --without-libraries=graph_parallel --without-libraries=log --without-libraries=mpi --without-libraries=python --without-libraries=test --without-icu
268293
```
269294

270295
This should build the `b2` program, which in turn is used to build Boost.
271296

272-
Edit boost/unordered/detail/implementation.hpp and change line 270 from:
297+
Edit `boost/unordered/detail/implementation.hpp` and change line 270 from:
273298

274299
```
275300
(17ul)(29ul)(37ul)(53ul)(67ul)(79ul) \
@@ -297,7 +322,7 @@ Finally, run:
297322

298323
```
299324
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
300-
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc62 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
325+
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
301326
```
302327

303328
to install the Boost headers and libraries. (Note the `env PATH="$PATH"` bit in the install command - this is because `sudo` usually resets `PATH` and that will cause Boost to rebuild everything again with the default compiler as part of the install!)
@@ -309,7 +334,7 @@ Download the latest version of cppunit from <http://dev-www.libreoffice.org/src/
309334
Untar it to a temporary directory and run:
310335

311336
```
312-
./configure --prefix=/usr/local/gcc62
337+
./configure --prefix=/usr/local/gcc73
313338
```
314339

315340
This should build an appropriate Makefile. Assuming it does, type:
@@ -334,7 +359,7 @@ bzip2 -cd patchelf-0.9.tar.bz2 | tar xvf -
334359
In the resulting `patchelf-0.9` directory, run the:
335360

336361
```
337-
./configure --prefix=/usr/local/gcc62
362+
./configure --prefix=/usr/local/gcc73
338363
```
339364

340365
script. This should build an appropriate Makefile. Assuming it does, run:

build-setup/windows.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ nmake install
161161

162162
### APR
163163

164-
Download the Windows source for version 1.5.2 of the Apache Portable Runtime (APR) from <http://apr.apache.org/download.cgi>.
164+
Download the Windows source for version 1.5.2 of the Apache Portable Runtime (APR) from <http://archive.apache.org/dist/apr/apr-1.5.2-win32-src.zip>.
165165

166-
The file should be called `apr-1.5.2-win32-src.zip`. Unzip the file into `C:\tools`. You should end up with a subdirectory called `apr-1.5.2`. Rename this to simply `apr`.
166+
Unzip the file into `C:\tools`. You should end up with a subdirectory called `apr-1.5.2`. Rename this to simply `apr`.
167167

168168
Within the files `C:\tools\apr\apr.mak` and `C:\tools\apr\libapr.mak`, globally replace:
169169

@@ -189,9 +189,9 @@ nmake -f Makefile.win PREFIX=C:\usr\local ARCH="x64 Release" install
189189

190190
### APR iconv
191191

192-
Download the Windows source for version 1.2.1 of the Apache Portable Runtime (APR) version of iconv from <http://apr.apache.org/download.cgi>.
192+
Download the Windows source for version 1.2.1 of the Apache Portable Runtime (APR) version of iconv from <http://archive.apache.org/dist/apr/apr-iconv-1.2.1-win32-src.zip>.
193193

194-
The file should be called `apr-iconv-1.2.1-win32-src.zip`. Unzip the file into `C:\tools`. You should end up with a subdirectory called `apr-iconv-1.2.1`. Rename this to simply `apr-iconv`.
194+
Unzip the file into `C:\tools`. You should end up with a subdirectory called `apr-iconv-1.2.1`. Rename this to simply `apr-iconv`.
195195

196196
Within the files `C:\tools\apr-iconv\apriconv.mak` and `C:\tools\apr-iconv\libapriconv.mak`, globally replace:
197197

@@ -229,9 +229,9 @@ Note that this does not install all the iconv utilities - this will be done when
229229

230230
### APR util
231231

232-
Download the Windows source for version 1.5.4 of the Apache Portable Runtime (APR) utilities from <http://apr.apache.org/download.cgi> .
232+
Download the Windows source for version 1.5.4 of the Apache Portable Runtime (APR) utilities from <http://archive.apache.org/dist/apr/apr-util-1.5.4-win32-src.zip>.
233233

234-
The file should be called `apr-util-1.5.4-win32-src.zip`. Unzip the file into `C:\tools`. You should end up with a subdirectory called `apr-util-1.5.4`. Rename this to simply `apr-util`.
234+
Unzip the file into `C:\tools`. You should end up with a subdirectory called `apr-util-1.5.4`. Rename this to simply `apr-util`.
235235

236236
Within the files `C:\tools\apr-util\aprutil.mak` and `C:\tools\apr-util\libaprutil.mak`, globally replace:
237237

0 commit comments

Comments
 (0)