This page documents the requirements and special instructions for building Traffic Server on macOS.

To build Traffic Server, you will need to retrieve yourself a copy of PCRE, libtool, and automake. You can get it yourself from the source or elsewhere like macports or Homebrew.

Traffic Server only builds with clang on macOS We do not support building with gcc on this platform. You will need to install the latest version of Xcode.

Building Traffic Server with Homebrew

First, visit http://brew.sh to install the Homebrew package manager.

Next, install the build dependencies:

$ brew install automake autoconf libtool pcre openssl

On certain versions of macOS / OS X and Xcode, you will also have to install libxml2:

$ brew install libxml2
$ brew link --force libxml2

After you have PCRE development libraries installed on your system, you should get the Traffic Server code with git.

$ git clone https://github.com/apache/trafficserver.git

Run autoreconf to generate the configure script:

$ cd trafficserver   # enter the new checkout directory
$ autoreconf -i      # generate the configure script

From the checkout directory, run `configure` to generate the Makefile files. You may need to specify the base path where the development files (headers and libraries) for PCRE are installed, e.g. if you installed pcre with MacPorts, you will need to specify the directory '/opt/local'. When building against Homebrew, specify the openssl library with --with-openssl=/usr/local/opt/openssl

$ ./configure --with-openssl=/usr/local/opt/openssl

Now you can make and install:

$ make
$ sudo make install

Generates a compilation database for clang tooling with Bear

JSON Compilation Database ( compile_commands.json ) is used by clang based tools.   For autotools based project (like Traffic Server), Bear is a tool that generates a compilation database.

On macOS or Fedora there is a know issue that bear generates empty compilation database because of SIP. Below is instruction to avoid the issue. Assuming above instruction is done. (automake autoconf libtool are already installed).

In short, all building tool chain should not be under certain directories which is protected by SIP. 

$ cp /bin/sh /usr/loca/bin/
$ brew install bear llvm make
$ which clang clang++ gmake
/usr/local/opt/llvm/bin/clang
/usr/local/opt/llvm/bin/clang++
/usr/local/bin/gmake
$ CONFIG_SHELL=/usr/local/bin/sh CC=clang CXX=clang++ ./configure --ADD-OPTIONS-YOU-WANT
$ bear gmake 
  • Mac Ports - package retrieval and installation system.
  • Homebrew - package retrieval and installation system.
  • Xcode - if you want to use the latest version of GCC from Apple. Requires free registration to get to the download page.
  • PCRE - required software for building Traffic Server from the source.

3 Comments

  1. Anonymous

    The compilation fails on Snow Leopard, with a segmentation fault during "make"

    /bin/sh ../../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../lib -I/opt/local/include -D_LARGEFILE64_SOURCE=1 -D_COMPILE64BIT_SOURCE=1 -D_GNU_SOURCE -D_REENTRANT -Ddarwin -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -I/usr/local/Cellar/include -g -pipe -Wall -Werror -Wno-deprecated-declarations -O3 -feliminate-unused-debug-symbols -fno-strict-aliasing -Wno-invalid-offsetof -MT Diags.lo -MD -MP -MF .deps/Diags.Tpo -c -o Diags.lo Diags.cc
    libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../../lib -I/opt/local/include -D_LARGEFILE64_SOURCE=1 -D_COMPILE64BIT_SOURCE=1 -D_GNU_SOURCE -D_REENTRANT -Ddarwin -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -I/usr/local/Cellar/include -g -pipe -Wall -Werror -Wno-deprecated-declarations -O3 -feliminate-unused-debug-symbols -fno-strict-aliasing -Wno-invalid-offsetof -MT Diags.lo -MD -MP -MF .deps/Diags.Tpo -c Diags.cc -fno-common -DPIC -o .libs/Diags.o
    Diags.cc:547: internal compiler error: Segmentation fault: 11
    Please submit a full bug report,
    with preprocessed source if appropriate.
    See <URL:http://developer.apple.com/bugreporter> for instructions.

    Unknown macro: {standard input}

    :1240:End-of-File not at end of a line

    :unknown:Partial line at end of file ignored

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str1

    :unknown:Undefined local symbol L_.str2

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str3

    :unknown:Undefined local symbol L_.str4

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str5

    :unknown:Undefined local symbol L_.str6

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str7

    :unknown:Undefined local symbol L_.str8

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str

    :unknown:Undefined local symbol L_.str9

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str10

    :unknown:Undefined local symbol L_.str11

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str12

    :unknown:Undefined local symbol L_.str13

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str14

    :unknown:Undefined local symbol L_.str15

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str16

    :unknown:Undefined local symbol L_.str17

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str18

    :unknown:Undefined local symbol L_.str19

    Unknown macro: {standard input}

    :unknown:Undefined local symbol L_.str20

    :unknown:Undefined local symbol L_.str21

    Unknown macro: {standard input}

    :unknown:Undefined local symbol LBB8_5
    make[3]: *** [Diags.lo] Error 1
    make[2]: *** [all] Error 2
    make[1]: *** [all-recursive] Error 1
    make: *** [all-recursive] Error 1

    1. Anonymous

      I am also getting a segmentation fault when compiling diags.cc on snow leopard. Is there a fix for this? Based on internet search, I replaced CC with clang and clang++ and it almost solved teh problem. I had to add a copy constructor for MultiCacheHeader and it all compiled.

      1. Yes, you have to build with clang. Apple's version of GCC is not supported.

        Typically, we support the latest version of Mac OS X, but would be happy to accept patches to build on older versions.