commit 85eb98687d6337eaeb07d59a51a339a2c52c48ef
Author: Daniel Gottlieb <daniel.gottlieb@mongodb.com>
Date:   Mon Sep 10 15:03:52 2018 -0400

    SERVER-36352: Add zstd as a required system library. Exposing using zstd compression for WT collections/journal.

diff --git a/SConstruct b/SConstruct
index 032aec6402..39a08ce9e3 100644
--- a/SConstruct
+++ b/SConstruct
@@ -1613,7 +1613,7 @@ elif env.TargetOSIs('windows'):
     #env.Append( CCFLAGS=['/Yu"pch.h"'] )
 
     # Don't send error reports in case of internal compiler error
-    env.Append( CCFLAGS= ["/errorReport:none"] ) 
+    env.Append( CCFLAGS= ["/errorReport:none"] )
 
     # Select debugging format. /Zi gives faster links but seem to use more memory
     if get_option('msvc-debugging-format') == "codeview":
@@ -1788,7 +1788,7 @@ if env.TargetOSIs('posix'):
 
     if optBuild and not optBuildForSize:
         env.Append( CCFLAGS=["-O2"] )
-    elif optBuild and optBuildForSize: 
+    elif optBuild and optBuildForSize:
         env.Append( CCFLAGS=["-Os"] )
     else:
         env.Append( CCFLAGS=["-O0"] )
@@ -3129,6 +3129,8 @@ def doConfigure(myenv):
     if use_system_version_of_library("snappy"):
         conf.FindSysLibDep("snappy", ["snappy"])
 
+    conf.FindSysLibDep("zstd", ["zstd"])
+
     if use_system_version_of_library("zlib"):
         conf.FindSysLibDep("zlib", ["zdll" if conf.env.TargetOSIs('windows') else "z"])
 
@@ -3331,7 +3333,7 @@ def doConfigure(myenv):
         if conf.CheckExtendedAlignment(size):
             conf.env.SetConfigHeaderDefine("MONGO_CONFIG_MAX_EXTENDED_ALIGNMENT", size)
             break
- 
+
     def CheckMongoCMinVersion(context):
         compile_test_body = textwrap.dedent("""
         #include <mongoc.h>
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
index 9b1e287619..9dc4fb06b9 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_global_options.cpp
@@ -63,8 +63,8 @@ Status WiredTigerGlobalOptions::add(moe::OptionSection* options) {
         .addOptionChaining("storage.wiredTiger.engineConfig.journalCompressor",
                            "wiredTigerJournalCompressor",
                            moe::String,
-                           "use a compressor for log records [none|snappy|zlib]")
-        .format("(:?none)|(:?snappy)|(:?zlib)", "(none/snappy/zlib)")
+                           "use a compressor for log records [none|snappy|zlib|zstd]")
+        .format("(:?none)|(:?snappy)|(:?zlib)|(:?zstd)", "(none/snappy/zlib/zstd)")
         .setDefault(moe::Value(std::string("snappy")));
     wiredTigerOptions.addOptionChaining("storage.wiredTiger.engineConfig.directoryForIndexes",
                                         "wiredTigerDirectoryForIndexes",
@@ -84,8 +84,8 @@ Status WiredTigerGlobalOptions::add(moe::OptionSection* options) {
                            "wiredTigerCollectionBlockCompressor",
                            moe::String,
                            "block compression algorithm for collection data "
-                           "[none|snappy|zlib]")
-        .format("(:?none)|(:?snappy)|(:?zlib)", "(none/snappy/zlib)")
+                           "[none|snappy|zlib|zstd]")
+        .format("(:?none)|(:?snappy)|(:?zlib)|(:?zstd)", "(none/snappy/zlib/zstd)")
         .setDefault(moe::Value(std::string("snappy")));
     wiredTigerOptions
         .addOptionChaining("storage.wiredTiger.collectionConfig.configString",
diff --git a/src/third_party/SConscript b/src/third_party/SConscript
index b5d801a9a4..51d6a6a359 100644
--- a/src/third_party/SConscript
+++ b/src/third_party/SConscript
@@ -200,6 +200,16 @@ snappyEnv.Library(
         'shim_snappy.cpp',
     ])
 
+zstdEnv = env.Clone(
+    SYSLIBDEPS=[
+        env['LIBDEPS_ZSTD_SYSLIBDEP'],
+    ])
+zstdEnv.Library(
+    target="shim_zstd",
+    source=[
+        'shim_zstd.cpp',
+    ])
+
 if use_system_version_of_library("zlib"):
     zlibEnv = env.Clone(
         SYSLIBDEPS=[
diff --git a/src/third_party/wiredtiger/SConscript b/src/third_party/wiredtiger/SConscript
index ac120d3aa1..81f2deab9f 100644
--- a/src/third_party/wiredtiger/SConscript
+++ b/src/third_party/wiredtiger/SConscript
@@ -8,7 +8,7 @@ Import("endian")
 
 env = env.Clone()
 
-env.InjectThirdPartyIncludePaths(libraries=['snappy', 'zlib'])
+env.InjectThirdPartyIncludePaths(libraries=['snappy', 'zlib', 'zstd'])
 
 if endian == "big":
     env.Append(CPPDEFINES=[('WORDS_BIGENDIAN', 1)])
@@ -80,6 +80,7 @@ else:
 
 useZlib = True
 useSnappy = True
+useZstd = True
 
 version_file = 'build_posix/aclocal/version-set.m4'
 
@@ -181,6 +182,10 @@ if useSnappy:
     env.Append(CPPDEFINES=['HAVE_BUILTIN_EXTENSION_SNAPPY'])
     wtsources.append("ext/compressors/snappy/snappy_compress.c")
 
+if useZstd:
+    env.Append(CPPDEFINES=['HAVE_BUILTIN_EXTENSION_ZSTD'])
+    wtsources.append("ext/compressors/zstd/zstd_compress.c")
+
 # Use hardware by default on all platforms if available.
 # If not available at runtime, we fall back to software in some cases.
 if (get_option("use-s390x-crc32") == "off"):
@@ -198,6 +203,7 @@ wtlib = env.Library(
         'wiredtiger_checksum',
         '$BUILD_DIR/third_party/shim_snappy',
         '$BUILD_DIR/third_party/shim_zlib',
+        '$BUILD_DIR/third_party/shim_zstd',
     ],
     LIBDEPS_TAGS=[
         'init-no-global-side-effects',
