Compiling HHVM with GCC 4.9/5.2 and Boost

For my development environment I prefer using Debian unstable, as it usually has the latest and greatest things available. This tends to work a lot better with living-on-the-edge software like HHVM. However, in this case, GCC 5.2 was a little bit too living-on-the-edge for HHVM. Some system libraries were 'suddenly' compiled with GCC 5.2, which did not interact well with HHVM's GCC 4.9 (or even GCC 5.2) compiles. It mostly has to do with that GCC 5.1+ employs a new ABI for C++ compiled objects.

As I'm currently working on a MongoDB extension for HHVM, I really needed my own HHVM compiled — with debugging symbols. I could also not use HHVM's nightlies or binaries, as their Debian packages depend on versions of libraries that my Debian install no longer provides.

HHVM uses google-glog for some logging stuff, and this was the first library that caused issues when linking. The error message was:

../../../third-party/folly/libfolly.a(dynamic.cpp.o): In function `std::string* google::MakeCheckOpString<unsigned long, unsigned long>(unsigned long const&, unsigned long const&, char const*)':
        /usr/include/glog/logging.h:672: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
../../../third-party/folly/libfolly.a(Format.cpp.o): In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)':
        /usr/include/glog/logging.h:672: undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
collect2: error: ld returned 1 exit status
hphp/tools/bootstrap/CMakeFiles/gen-class-map.dir/build.make:123: recipe for target 'hphp/tools/bootstrap/gen-class-map' failed
make[2]: *** [hphp/tools/bootstrap/gen-class-map] Error 1
CMakeFiles/Makefile2:945: recipe for target 'hphp/tools/bootstrap/CMakeFiles/gen-class-map.dir/all' failed
make[1]: *** [hphp/tools/bootstrap/CMakeFiles/gen-class-map.dir/all] Error 2
Makefile:106: recipe for target 'all' failed
make: *** [all] Error 2

I promptly filed an issue, which wasn't going anywhere fast enough.

But the hints in the comments were good enough for me to try and find a solution.


To sort out google-glog and get a GCC 4.9 compiled version installed, I first removed the system version with apt-get remove libgoogle-glog-dev libgoogle-glog0v5. I then downloaded the source package through apt: apt-get source libgoogle-glog-dev. To compile, I ran:

  • Make sure we use the 'old' compiler:

    • export ASM=`which gcc-4.9`

    • export CXX=`which g++-4.9`

    • export CC=`which gcc-4.9`

  • cd google-glog-0.3.4

  • ./configure

  • In the generated Makefile, I changed the ACLOCAL define to aclocal-1.15 (line 613) and the AUTOMAKE define to automake-1.15 (line 629). For some reason, they were both -1.14 which isn't installed.

  • make

  • automake --add-missing to silence a warning about some installer

  • make -j 20

  • sudo make install


Boost was a bit trickier, as it's build system is "novel". I did not have to remove the packages that I installed with APT though, and HHVM's build system was clever enough to pick up on my newly compiled libraries which I installed in /usr/local.

  • Download Boost: wget

  • Extract: tar -xvjf boost_1_59_0.tar.bz2

  • Change into directory: cd boost_1_59_0/

  • Run ./

  • mkdir tools/build/v2

  • Setup our new (old) compiler as toolset (found on StackOverflow): echo "using gcc : 4.9 : /usr/bin/g++-4.9 ; " > tools/build/v2/user-config.jam

  • Compile: ./bjam --toolset=gcc-4.9 -j 16

  • Install into /usr/local: sudo ./b2 install --prefix=/usr/local --toolset=gcc-4.9

  • sudo ldconfig

That sorted out Boost.


I then compiled HHVM in my normal fashion, ensuring I was using GCC 4.9:

  • export CC=`which gcc-4.9`

  • export CXX=`which g++-4.9`

  • export ASM=`which gcc-4.9`

  • Check out the 3.9.1 release: git checkout 3.9.1 && git submodule update --recursive

  • Clean things up: git clean -dfx -f && git clean -dfx -f third-party

  • Configure (make sure it picks up the new 1.59 version of Boost that you just compiled yourself):

    cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local/hhvm/3.9.1 .

  • make -j 20

  • make install

Et voilá, a working HHVM compiled with GCC 4.9 on the latest Debian unstable.


This article has a short URL available:


No comments yet

Islay: All the Peat

Two years ago Morag and I went on a whisky tasting tour with Rabbie's to visit a few of Speyside's distilleries. Now, this August we left the smooth and sweeter whiskies aside, and instead we headed over to Islay. Again with Rabbie's.

Day 0: Edinburgh

Our train up to Edinburgh was nothing special, except that East Coast has now been replaced with Virgin Trains East Coast. No real changes, except for the name. This time however, we got into Edinburgh just as the Fringe was starting. And that made staying in Edinburgh quite a bit more expensive. We thought to be clever and book a hotel near Rabbie's pick-up point, but I had failed to realise that they actually moved it—right next to the hotel we stayed in last time.

The afternoon before the tour started, we had some free time in Edinburgh. We promptly headed to BrewDog's pub to have a beer and play some connect-four, before we headed to The Edinburgh Larder for a nice meal. On the way back, we caught the last sun rays hitting Edinburgh Castle.

Day 1: From Edinburgh to Islay

The next morning we got up quite early, had some breakfast at the hotel and headed towards our pick up point at Rabbie's Cafe. With a tour like this, it is always a bit of a guess on what sort of group you get. This time, we were touring with two Swiss, two Slovenians, three Indians, three Canadians, a very loud Australian, and our tour guide, Doug. On the way to Islay we also picked up two Japanese in Glasgow. On the previous tour, we had a few people that didn't like whisky, but this time one of the Canadians was actually allergic to whisky (and beer).

It is quite a trip to Islay, but luckily we stopped at many places on the way there. The first stop was at Luss, in the Loch Lomond and The Trossachs National Park. From there on, we travelled to Islay with a stop at The Rest and Be Thankful on the A83. The slightly funny name comes from the time where you had armies going down the Glen and having to climb up to the pass. They could only rest when they got to the top — and clearly they were thankful for that!

For lunch we stopped at the Royal Burgh Cafe in Inveraray. I had to try one of my favourite Scottish dishes, Cullen Skink, a thick soup made of smoked haddock, potatoes and onions. Inveraray itself is a small town on the coast of Loch Fyne. It has a pretty nice castle for which we didn't have time, and apparently an old jail that you can visit.

After lunch we drove for a fair bit and stopped for a quick pint in Kilmartin at the Kilmartin Hotel across from the parish church, before having a good look at a set of standing stones. After another short drive, we took some time to walk up Dunadd, a hillfort and suspected capital of the ancient kingdom of Dál Riata.

We made one last stop to stretch our legs at Tarbert on our way to the Kennacraig Ferry Terminal from where we took our ferry to Islay. After about half an hour's drive we finally arrived at our accommodation in one of Bowmore distillery's cottages. On the dining table was a bottle of Bowmore 12 waiting for us! We ignored the bottle and headed straight to the Lochside hotel to taste different whiskies instead. We sampled:

  • Tullibardine 228: Hints of dark red wine. But too young and sharp. 66

  • Tullibardine 500: Sweet smell. Toffee/fudge, and sweet woody sherry notes. 72

  • Amrut: Young and unrefined. Marzipan, vanilla, nutty. 70

  • Kavalan: Light fresh grassy sweetness. Perhaps some tropical notes and some vanilla. 73

  • Royal Lochnagar Muscat Finish: A little watery. Very light fresh berries with nuts. And of course a muscat finish. 78

  • Bunnahabhain 25: Very complex peaty whisky. Rich berries, but I think I like the Bunnahabhain 18 better. Not worth £220 a bottle! 82

Day 2: Touring distilleries on Islay, part 1

We had some spare time in the morning, as we were only going to be picked up at 09:30. That meant we had some time to run in the morning. There are not many paths around Bowmore, but I had scouted a nice route up to a local hill, and back. I ran quite a bit slower, as clearly it was hillier than my normal runs alongside the canal.

After the morning run, shower and breakfast we were picked up for our first distillery visit. But before we started the tour and tasting at Kilchoman we spend some time relaxing on the beach at Machir Bay. After getting our "fresh nose", we headed to the distillery.

Kilchoman is Islay's newest distillery at just 10 years old. It's so new that it misses on many of the maps we spotted all over Islay indicating where the 8 distilleries are. It is a "farm distillery" and by far the smallest. They malt some of their own barley, which goes into their Kilchoman 100% Islay expression. After our tour two years ago we did know nearly everything about whisky production, but it was good to get things freshened up as well as having a look at a malting floor. But of course we really came for a tasting, and lunch. We sampled the following whiskies:

We also sampled their Bramble Liqueur as an alternative tipple.

We also had lunch at the Kilchoman distillery. I think everybody from our group had Cullen Skink :-)

After lunch we popped by Bruichladdich for a quick tasting. They are also fairly new, but quite less traditional than most of the other distilleries. They call themselves "progressive". Of course, Bruichladdich is responsible for getting me into whisky in the first place, as they sponsored an evening event at WhiskyWeb many years ago.

At Bruichladdich, we tried the following whiskies (sorry, no notes as the stop was so short!):

As I already tried an Octomore 06.3 and the Classic Laddie 10, I also managed to get a wee dram of a Valinch, of which I did buy a bottle. We also had a sip of the Botanist gin.

On our way back to Bowmore, we stopped at Islay House Square to visit the Islay Ales brewery. We picked up some local beers to take home with us.

The tour at Bowmore started with a film after which we went through yet another distillery. The tour started with eyeing a £100.000 bottle of whisky, and ended with the most interesting part: the whisky tasting. This time, we tried four expressions:

After the last tasting we dropped by the local Spar, which has a wall full of whisky. I guess that's why "Spar" was tagged onto the big sign saying "The Islay Whisky Shop". We bought a Classic Laddie 10 to share with the group. Some of it made it home.

For dinner we had booked at the Bowmore Hotel. The food was good, and there was plenty of it. Actually, there was so much that we went straight to bed afterwards, without another dram!

Day 3: Touring distilleries on Islay, part 2

We had to get up a little bit earlier today for our pick-up, and slightly longer drive for our visit to the Whisky Coast. But first, a stop at the Kildalton Cross and church, for some history. The Kildalton Cross is a Celtic cross over 1200 years old. The weather was rather gloomy though, and there was a bit of rain. We were quite happy to get back on the bus and head back towards the Whisky Coast. On the way there we saw two peacocks on a fence.

The first distillery of the day was Ardbeg. The distillery is 200 years old this year, and they had "upgraded" their visitors centre for this event. Everything looked brand spanking new. During the tour it was not allowed to take photos because of "health and safety". The tour at the distillery was certainly the best one. Instead of the (now boring) process, our guide told lots of stories - even throughout the whisky tasting. Some clearly made up. During the tasting itself, we tried five whiskies:

  • Ardbeg 10: Very light, but slightly peppery and a little "burnt". A little peat, and a little sweet. 10-15 years in a Bourbon cask, 46%. 77

  • Ardbeg Uigeadail: Toffee, plum and raisins. It is aged 8 years in a Bourbon cask, and 2-7 years in a sherry cask. Apparently it goes will with dark chocolate or cheese. 54.2% 83

  • Ardbeg Corryvreckan: A lot of vanilla because it is finished in a new French oak cask. "Ice cream soda". 8 years in a Bourbon cask and 2-7 in a new French Oak Cask. 57.1%

  • Ardbeg Perpetuum: This year's festival whisky. It is a combination of many different casks to commemorate their 200th anniversary. Complex, light fruity. Would go well with cheese cake. 47.4%. 79

  • Ardbeg Auriverdes: Aged in Bourbon casks with heavily charred ends. It is dark and sugary and made with the football world cup in mind. It is a bit oily, and there is light hints of vanilla. 49.9% 82

After lunch at Ardbeg we headed down the coast towards the next distillery, Lagavulin, for a tasting only. We tried:

Just a few kilometres down the coast we can find Laphroaig. We did another tour there, and it was clearly the largest operation that we have been to. Lots more automation than Kilchoman for sure! You can just rock up for a tasting, but I failed to write down notes this time. If I remember correctly, we tried the following whiskies:

  • Laphroaig Select: "Entry" level whisky. It is meant to get people into Laphroaig and peatier whiskies, but frankly, it had the flavour and texture of water. There was very little to it. 63

  • Laphroaig Quarter Cask

  • Laphroaig 18: Clearly the best, but I don't remember much of the actual flavours!

After all the tastings, we made a little side trip to walk up the old castle of Dunnyvaig, with lovely views over the bay and Lagavulin. Back in Bowmore, we tried another run along the beach. But this was not such a great success as the pebbles were a bit too large to run on.

We had booked at the Harbour Inn for our "date-night". A posh dinner looking out over Loch Indaal with the Sun setting. Before bed, we nipped into the Lochside Hotel for a last dram on Islay.

Day 4: Back to Edinburgh

On our last day, we had to get up early so that we could make the ferry out of Port Ellen back to the mainland. We were plenty of time for the ferry, so we stopped for a photo op at the old Port Ellen distillery and the Port Ellen maltings, where Diageo produces malted barley for most of Islay's distilleries.

The ferry itself was uneventful, but extra tasty due to the availability of Bunnahabhain 12 on offer. The drive was quite long, with not much spare time. We stopped at Oban for an excellent lunch at Ee Usk and a quick trip to the Oban Distillery to taste a dram. We borrowed a tasting glass for the good reason to be able to taste a few extra drams on the bus back.

We made another stop at the The Green Wellie Stop, after which we had to make a long detour because of some accident. We dropped off the Japanese at Balloch station, saw the battlefield at Bannockburn, The Kelpies, and the Forth Bridge.

We arrived in Edinburgh just on time for our dinner at the Skerries restaurant at our hotel, The Dunstane. We finished the day with a last dram at their extensive whisky bar before retreating for the night, exhausted from another great trip to Scotland.

You can find high-resolution and more photos on my Flickr set.


This article has a short URL available:


No comments yet

Terracing Buildings

Following up from the previous article on addressing flats, in this article we deal with drawing buildings. The new area has lots of similarly looking buildings, and they're not exactly square. They do however all (broadly) share the same shape:

JOSM has a terracer plugin, which allows you to draw a rectangle, and then quickly convert it to a row of terraced houses and at the same time add house numbers to the generated houses.

You do the following steps with the plugin:



Find a spot that needs buildings added

Draw the outline

Add the building=residential tag

Select road and outline, and press Shift-T to run the terracer plugin.

Select every other middle node at the back

Use JOSM's Way Accuracy Tool w to add in the other nodes for the back

Repeat for the other 5 buildings

Select all buildings and use the Orthogonalise Shape tool Q to "square" the buildings.

Having to do step 6 and 7 for every building, especially when there are a lot of them, is a very tedious, and inaccurate process. It is sometimes even faster to draw all the building outlines by hand, select them all, and orthogonalise them.

But the terracer does already save a lot of work, so what if I could make it better and make it support the type of buildings that are common in my new neighbourhood?

I had a look into the plugin, and it seems that I have to use Java to update it. I don't really use Java, and hardly ever written any code in it. It also sadly lives on some SVN repository, so pull requests against it are difficult too. Instead, I pushed my version of the repository to — and called my version Überterrace. Oh, and I learned some Java.

After a while of figuring out some ... syntax issues, and figuring out how to build this stuff, I managed to improve the plugin with another option. The new option is "fancy outline" and automatically draws in the "extensions at the back". The new work flow is now:



Find a spot that needs buildings added

Draw the outline, including the backends

Add the building=residential tag

Select road and outline, and press Shift-T to run the terracer plugin with the "fancy outline" checkbox set.

Drag the selected middle nodes to the right position.

Press Shift-E to select all buildings, and press q to orthogonalise them.

As you can see, this makes it much faster to draw such building outlines. When you look at it in 3D however, you can see there is still a problem though:

The 3D image that is being drawn does not take into account that the "extension" at the back, isn't part of the gabled roof nor that it is only two instead of three levels. There are various possibilities of building layouts:

So the next versions of Überterrace are going to support (some of) these as well!


This article has a short URL available:



You're a hero. You can only imagine the amount of time I spent faffing around with the fancy outlines...

Of course there are other configurations of 'fancy outline', such as the back extensions being on the 'outside' edge rather than meeting on the inside edge. See this area for a muddle of shapes:


@Tom: I know! I'll get to these if I figure out how to make it draw buildings from a template that you draw first, or something.

Adressing Flats

I recently moved into a new area in London, and that means, a new area to map. That means drawing in all the buildings, but also adding shops and addresses. Unlike my old area, the new neighbourhood has lots of buildings with flats. In OpenStreetMap, you can tag addresses on flats with the addr:flats tag. In most cases, the addresses of the flats are formed by a flat number, building name (addr:housename) and street name (addr:street). Only occasionally the address consists of flat number, house number, and street name.

When I started tagging a nearby collection of flat blocks, and the flat number/house name/street name on their entrance nodes, I noticed that it rendered as:

As you can see, it ignored the addr:flats tag, and instead just rendered the addr:housename tag over and over again. Not particularly useful.

So I thought, why not "fix" the rendering. In the past, I already added a basic rendering for natural=tree_row to the "default" rendering style. So I had another look on how to make addr:flats render and show up instead of the house name 20 times.

OpenStreetMap's style sheet is developed through the Git repository at I cloned the repository and searched after the places where I needed to make modifications to add the flat numbers. The style sheets first require a "style" file to tell which data to import from the main database (or .xml file). Only fields that are copied into the rendering database are available for use in the style sheets. OpenStreetMap Carto stores these definitions in the project.mml file. But that's a nasty JSON file, so instead, you add the definition into the project.yaml file. There is a script to convert the YAML file into the project.mml file which the carto tool can use to generate a Mapnik stylesheet. Mapnik is then responsible for rendering the map.

In project.yaml, just above the - id: "housenumbers" line, I added the following section:

- id: "flatnumbers"
  name: "flatnumbers"
  class: ""
  geometry: "point"
  <<: *extents
    <<: *osm2pgsql
    table: |-
          way_area/NULLIF(!pixel_width!::real*!pixel_height!::real,0) AS way_pixels
        FROM planet_osm_polygon
        WHERE "addr:flats" IS NOT NULL
          AND building IS NOT NULL
          NULL AS way_pixels
        FROM planet_osm_point
        WHERE "addr:flats" IS NOT NULL
        ORDER BY way_pixels DESC NULLS LAST
      ) AS flatnumbers
    minzoom: 17
  advanced: {}

It basically instructs the stylesheet to run an extra query to obtain information on addr:flats and make that information available to the actual styles.

It requires an extra column in the database (addr:flats), the import "style" needs to include this data while importing from the data source into the rendering database. The file containing the import definitions is I added the following line in between the definitions for access and addr:housenumber:

node,way   addr:flats   text         linear

Adding an extra column into the "style" means that it is necessary to reimport the data from the main database (or XML file) into the rendering database. My original source is the openstreetmap.osm file, which I re-imported with:

/home/derick/install/osm2pgsql/osm2pgsql \
        -S --slim -d gis -C 2400 openstreetmap.osm

To render the flat numbers, and attach a style to them, I had to add a section to the addressing.mss file which is a sub-stylesheet that deals with address information. This stylesheet is linked from the project file. I added the following lines in between the #interpolation and #housenumbers sections:

#flatnumbers {
  [zoom >= 17] {
        text-name: "[addr:flats]";
        text-placement: interior;
        text-min-distance: 1;
        text-wrap-width: 0;
        text-face-name: @book-fonts;
        text-fill: #666;
        text-size: 8;

I picked the same style as for standard house numbers, but one size smaller.

With all the sections added to the right files I had to regenerate the project.mml file from project.yaml with:

./scripts/ < project.yaml > project.mml

And generate a Mapnik stylesheet from the project.mml file with:

carto project.mml > mapnik.osm

With all that in place, I re-rendered the area. The flat numbers are now visible on the map:

I have packaged up all the changes, and prepared a pull request for openstreetmap-carto. With some luck, the changes will make it to the OpenStreetMap website at some point in the future.


This article has a short URL available:


Nice bit of work. In reading it I've noticed that 'reimporting the database' is often mention in the context of adding a column. I dont think this is necessary:

ALTER TABLE planet_x ADD "addr:flats" VARCHAR(256) NULL;

assuming data has been imported with hstore;

UPDATE planet_x
SET "addr_flats" = tags->'addr:flats'
WHERE tags?'addr:flats'

This costs roughly a table scan per table.

Obviously you cant do anything if the tags column wasn't imported.

These ought to be capable of being wrapped up as a reversible database update (i.e., ALTER TABLE planet_x DROP "addr:flats" takes us back to where we started), which is useful if doing stuff on the live system.

Twenty Years of PHP

I know I am a day late, but PHP turned 20 yesterday! Congratulations!

Ben Ramsey wrote about his 20 years of PHP yesterday, and invited others to do the same. So here I go.

Back in 1999 during university, a few friends and I got annoyed by Schumacher's antics, and started the "Anti Schumacher Club". In order to have a membership part of our site (which thankfully can no longer be found on the Internet), we used PHP. Oh yeah, we also used it to scrape websites to find e-mail addresses to send our propaganda to.

My first patch to PHP was in June 2000 when I added support for Flash objects to getimagesize(). After an idiotic idea to implement MySQL subselects in PHP itself, I continued with my PHP career by starting to maintain the mcrypt extension later in 2000. It needed support for a new API version. Both getimagesize() and mcrypt support is something that I needed while working at the company that I started with the same guys as the Anti Schumacher Club. Throughout 2000 and later, I started to contribute little bits and bobs to PHP. These included committing Ilia's first extension, adding the 'u' modifier to printf/sprintf which prints unsigned longs, etc.

In April 2002, I started working on Xdebug. First by adding the max_nesting_level feature and functions to provide memory usage, and then later I added stack traces and support for the remote debugging. First by mimicking the PHP 3 handler, and then later by adding a GDB like debug handler, and DBGp. The PHP 3 and GDB handlers are of course a distant memory, but the DBGp protocol is still being used by IDEs to interact with Xdebug. Ilia implemented a basic profiler as well during 2002. I also "release mastered" PHP 4.1.1, various 4.2 releases during this time, and all the 4.4.x releases later.

The DBGp protocol is something that I developed with the guys from ActiveState in late 2003. Their Komodo editor still implements DBGp in the most comprehensive way, although other IDEs seem to be much more popular now. I implemented the same protocol for Maguma Workbench, and during my time there, eZ Systems approached me to come and work for them. I had previously spoken at an eZ summer camp, which provided a nice introduction to start a 5+ year employment relationship.

I started speaking a while earlier though, mostly on Xdebug, but also on SRM — some sort of application server for PHP. That never really got off the ground though, as it doesn't really fit the shared-nothing architecture of PHP. Since these first few speaking engagements, I have now given 326 talks at 201 conferences and user group meet-ups in 92 different locations.

After eZ Systems, and due to my work on Xdebug I decided to work for myself for a while. I started writing PHP extensions as a job, and due to that, I ended up contributing a little to the MongoDB driver. And that turned later into becoming an employee of MongoDB, where I now work on both the PHP and HHVM drivers.

Without PHP, none of this would have happened. I would not have moved to London without the persuasiveness of Johanna, whom I met at php[tek] in Chicago. She managed to convince me to give up the boringness of Norway and move into the "PHP House" in London. With her, Helgi, and Arpad (and on the weekends Scott), we wrote a lot of code, and threw a few parties as well. I wouldn't have met my wonderful wife Morag, met countless friends at various conferences and online, and I would certainly not have had a few dozen colourful pachyderms in my house! And it all started with Michael Schumacher, and some Danish guy that wrote some counters for his website.

Here's to another twenty years! Skål!


This article has a short URL available:


No comments yet

  • 1

    : ppm stands for Phenol parts per million, a measurement to indicate how peaty a whisky is

Life Line