25639599 llvm makefile cleanup and optimized build
authorShawn Walker-Salas <shawn.walker@oracle.com>
Wed, 08 Mar 2017 22:04:29 -0800
changeset 7771 46912a8a1f29
parent 7770 5efbd9a35bd0
child 7772 a5abee83989d
25639599 llvm makefile cleanup and optimized build 25591626 clang on sparc fails with unhelpful "invalid gcc installation" error 22991663 llvm has unlisted build dependencies 25677424 llvm / openmp should be updated to use gcc5 25692651 some mysql test packages deliver build files
components/intel-openmp/Makefile
components/llvm/Makefile
components/llvm/clang.p5m
components/llvm/cxa_finalize/Makefile
components/llvm/llvm-build.p5m
components/llvm/llvm.p5m
components/llvm/patches/012-solaris-clang-libclangDriver.patch
components/llvm/patches/031-solaris-build-system.patch
components/mysql-5-5/mysql-55test.p5m
components/mysql-5-6/mysql-56test.p5m
make-rules/cmake.mk
--- a/components/intel-openmp/Makefile	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/intel-openmp/Makefile	Wed Mar 08 22:04:29 2017 -0800
@@ -18,7 +18,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 export PARFAIT_BUILD=no
@@ -28,9 +28,8 @@
 
 include ../../make-rules/shared-macros.mk
 
-# We are using GCC 4.9 with LLVM, use it here too for the time being.
-# Switch to GCC 5.3 if/when LLVM can.
-GCC_ROOT=/usr/gcc/4.9
+# This and llvm must use the same version of gcc.
+GCC_ROOT=/usr/gcc/5
 
 COMPONENT_NAME        = libomp
 COMPONENT_VERSION     = 20151009
@@ -44,8 +43,6 @@
 
 TPNO = 27154
 
-BUILD_STYLE = justmake
-
 # Uses an ON header file with S12-only features.
 ifeq ($(BUILD_TYPE), evaluation)
 BUILD_32_and_64=
@@ -53,6 +50,11 @@
 PUBLISH_STAMP=
 endif
 
+# There are no tests for this version of the Intel OpenMP Library
+# OpenMP tests will be integrated in ${WS_TOP}/components/bots.
+BUILD_STYLE = cmake
+CMAKE_BUILD_TYPE = Release
+TEST_TARGET = $(NO_TESTS)
 include $(WS_MAKE_RULES)/common.mk
 
 export PATH=/usr/gnu/bin:$(GCC_ROOT)/bin:/usr/bin:/usr/perl5/5.22/bin
@@ -60,30 +62,18 @@
 PATCH_LEVEL := 0
 DEBUG_BUILD := 0
 
-# This component uses cmake to generate Makefiles and thus does not
-# run any configure script
-CMAKE = /usr/bin/cmake
-CMAKE_PREFIX = /usr
-
-CMAKE_BINDIR.32     = bin/$(MACH32)
-CMAKE_BINDIR.64     = bin
-CMAKE_LIBDIR.32     = lib
-CMAKE_LIBDIR.64     = lib/$(MACH64)
-
-ISA_CFLAGS.i386	= -fno-omit-frame-pointer -march=opteron -mtune=opteron
-ISA_CFLAGS.sparc = -mptr$(BITS) -mtune=ultrasparc3 -mcpu=ultrasparc3
-ISA_CFLAGS.sparc += -mvis2 -mhard-float -mno-unaligned-doubles
-ISA_CFLAGS.sparc += -mimpure-text
-ISA_CFLAGS = $(ISA_CFLAGS.$(MACH))
+CFLAGS += -fno-omit-frame-pointer
+CFLAGS.gcc.i386  += -march=opteron -mtune=opteron
+CFLAGS.gcc.sparc += -mtune=ultrasparc3 -mcpu=ultrasparc3
+CFLAGS.gcc.sparc += -mvis2 -mhard-float -mno-unaligned-doubles
+CFLAGS.gcc.sparc += -mimpure-text
 
 OMP_STATS = off
-OFLAG = -O2
 GFLAG =
 DFLAG = -DNDEBUG
 
 ifeq ($(DEBUG_BUILD),1)
   OMP_STATS = on
-  OFLAG = -O0
   GFLAG = -g3
   DFLAG =
 endif
@@ -92,19 +82,19 @@
 # we can't pass a -std=<N> on compile line. This is done internally
 # by the cmake configuration files.
 # The Userland default flags for GCC are broken.
-CFLAGS = -m$(BITS) $(OFLAG) $(GFLAG) $(ISA_CFLAGS) -Wall
+CFLAGS += $(GFLAG) $(DFLAG) -Wall
 CFLAGS += -fkeep-static-consts -fno-strict-aliasing
 
-CXXFLAGS = -m$(BITS) $(OFLAG) $(GFLAG) $(ISA_CFLAGS) -Wall
+CXXFLAGS += $(GFLAG) $(DFLAG) -Wall
 CXXFLAGS += -fkeep-static-consts -fno-strict-aliasing
 CXXFLAGS += -Wl,-z -Wl,relax=comdat
 
-CPPFLAGS = -D__EXTENSIONS__=1 -DKMP_GOMP_COMPAT=1
+CPPFLAGS += -D__EXTENSIONS__=1 -DKMP_GOMP_COMPAT=1
 CPPFLAGS += -DKMP_TDATA_GTID=1
 LDFLAGS += -z ignore -z relax=comdat
 
-LIBIOMP_RUNPATH_32	= /usr/gcc/4.9/lib
-LIBIOMP_RUNPATH_64	= /usr/gcc/4.9/lib/$(MACH64)
+LIBIOMP_RUNPATH_32	= /usr/gcc/5/lib
+LIBIOMP_RUNPATH_64	= /usr/gcc/5/lib/$(MACH64)
 LIBIOMP_RUNPATH	= $(LIBIOMP_RUNPATH_$(BITS))
 
 CFLAGS		+= -Wl,-R -Wl,$(LIBIOMP_RUNPATH)
@@ -112,20 +102,9 @@
 LDFLAGS		+= -R$(LIBIOMP_RUNPATH)
 LD_OPTIONS	= -z ignore -z relax=comdat
 
-CMAKE_OPTIONS = -DCMAKE_C_COMPILER=$(CC)
-CMAKE_OPTIONS += -DCMAKE_CXX_COMPILER=$(CXX)
-CMAKE_OPTIONS += -DCFLAGS="$(CPPFLAGS) $(CFLAGS)"
-CMAKE_OPTIONS += -DCXXFLAGS="$(CPPFLAGS) $(CXXFLAGS)"
-CMAKE_OPTIONS += -DLDFLAGS="$(LDFLAGS)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX=$(CMAKE_PREFIX)
-CMAKE_OPTIONS += -DINSTALL_LIBDIR:PATH=$(CMAKE_LIBDIR)
-CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBDIR:PATH=$(CMAKE_LIBDIR)
 CMAKE_OPTIONS += -DCMAKE_MAKE_PROGRAM=$(GMAKE)
 CMAKE_OPTIONS += -DCMAKE_SHARED_LIBRARY_SUFFIX=".so.5"
 
-CMAKE_OPTIONS += -DCMAKE_C_FLAGS_RELEASE:STRING="$(OFLAG) $(GFLAG) $(DFLAG)"
-CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS_RELEASE:STRING="$(OFLAG) $(GFLAG) $(DFLAG)"
-
 CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE=1
 CMAKE_OPTIONS += -DCOMPILER_SUPPORTS_QUAD_PRECISION=true
 CMAKE_OPTIONS += -DDEBUG_BUILD=false
@@ -136,7 +115,6 @@
 CMAKE_OPTIONS += -DLIBOMP_FORTRAN_MODULES=true
 CMAKE_OPTIONS += -DLIBOMP_VERSION=5
 CMAKE_OPTIONS += -DLIBOMP_OMP_VERSION=41
-CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=release
 
 COMPONENT_BUILD_ENV += LD_OPTIONS="$(LD_OPTIONS)"
 
@@ -145,25 +123,14 @@
 COMPONENT_POST_UNPACK_ACTION = \
       $(MV) libomp_oss $(COMPONENT_SRC)
 
-COMPONENT_PRE_BUILD_ACTION += cd $(@D);
-COMPONENT_PRE_BUILD_ACTION += echo Running cmake with $(CMAKE_OPTIONS) ;
-COMPONENT_PRE_BUILD_ACTION += /usr/bin/env - $(COMPONENT_BUILD_ENV) \
-			      $(CMAKE) $(CMAKE_OPTIONS) . ;
-
-build: $(BUILD_32_and_64)
-
-install: $(INSTALL_32_and_64)
-
-# There are no tests for this version of the Intel OpenMP Library
-# OpenMP tests will be integrated in ${WS_TOP}/components/bots.
-test: $(NO_TESTS)
-
-system-test:    $(NO_TESTS)
-
 REQUIRED_PACKAGES += developer/build/cmake
-REQUIRED_PACKAGES += developer/gcc-4/gcc-common-49
+REQUIRED_PACKAGES += developer/build/pkg-config
+REQUIRED_PACKAGES += developer/gcc/gcc-c++-5
+REQUIRED_PACKAGES += developer/gcc/gcc-c-5
+REQUIRED_PACKAGES += developer/gcc/gcc-common-5
+REQUIRED_PACKAGES += developer/gnu-binutils
 REQUIRED_PACKAGES += system/core-os
-REQUIRED_PACKAGES += system/library/gcc/gcc-runtime-49
-REQUIRED_PACKAGES += system/library/gcc/gcc-c++-runtime-49
-REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime-49
+REQUIRED_PACKAGES += system/library/gcc/gcc-runtime-5
+REQUIRED_PACKAGES += system/library/gcc/gcc-c++-runtime-5
+REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime-5
 REQUIRED_PACKAGES += system/library/math
--- a/components/llvm/Makefile	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/Makefile	Wed Mar 08 22:04:29 2017 -0800
@@ -28,8 +28,16 @@
 
 include ../../make-rules/shared-macros.mk
 
-# We use GCC version 4.9.3, and not another version for now.
-GCC_ROOT=/usr/gcc/4.9
+# This and intel-openmp must use the same version of gcc.  In addition, LLVM's
+# gcc toolchain logic we currently have for Solaris is effectively hard-coded
+# for a specific version of gcc (5.4.0 currently):
+#
+# 25682681 llvm's gcc toolchain usage should be multilib friendly and
+#          version-agnostic
+#
+# Changing to a different version of gcc currently requires an update to
+# patches/012-solaris-clang-libclangDriver.patch.
+GCC_ROOT=/usr/gcc/5
 
 COMPONENT_NAME=		llvm
 COMPONENT_VERSION=	3.8.1
@@ -72,9 +80,12 @@
 endif
 
 BUILD_STYLE = cmake
+# Building with debug info results in ~7GB of package data, so while preferred,
+# is not practical.
+CMAKE_BUILD_TYPE = Release
 CLONEY = echo
-GNUCP = /usr/gnu/bin/cp
-
+TEST_TARGET=
+SYSTEM_TEST_TARGET=
 include $(WS_MAKE_RULES)/common.mk
 
 PATCH_LEVEL := 0
@@ -84,7 +95,6 @@
 export PATH=/usr/gnu/bin:/usr/bin:/usr/perl5/$(PERL_VERSION)/bin
 
 # We're building with CMake
-CMAKE=/usr/bin/cmake
 CMAKE_VERSION := $(shell $(CMAKE) --version 2>&1 | head -n1 \
   | $(GSED) 's/cmake version \{1,\}//g')
 CMAKE_MAJOR_VERSION := $(shell echo $(CMAKE_VERSION) | cut -f1 -d'.')
@@ -99,23 +109,6 @@
   CMAKE_NEEDS_SOLARIS_HOST = 1
 endif
 
-# All of these shoujld probably be in shared-macros.mk
-CMAKE_INSTALL_BINDIR.32 = bin
-CMAKE_INSTALL_BINDIR.64 = bin/$(MACH64)
-CMAKE_INSTALL_BINDIR = $(CMAKE_INSTALL_BINDIR.$(BITS))
-
-CMAKE_INSTALL_LIBDIR.32 = lib
-CMAKE_INSTALL_LIBDIR.64 = lib/$(MACH64)
-CMAKE_INSTALL_LIBDIR = $(CMAKE_INSTALL_LIBDIR.$(BITS))
-
-CMAKE_INSTALL_LIBEXECDIR.32 = libexec
-CMAKE_INSTALL_LIBEXECDIR.64 = libexec/$(MACH64)
-CMAKE_INSTALL_LIBEXECDIR = $(CMAKE_INSTALL_LIBEXECDIR.$(BITS))
-
-CMAKE_INSTALL_INCLUDEDIR = include
-CMAKE_INSTALL_DATADIR = share
-CMAKE_INSTALL_DATAROOTDIR = share
-
 # We need the specific C++ runtime that clang/llvm was built and
 # linked with, and not some random and incompatible stuff from
 # /usr/lib.
@@ -123,23 +116,17 @@
 LLVM_RUNPATH_64 = $(GCC_ROOT)/lib/$(MACH64)
 LLVM_RUNPATH = $(LLVM_RUNPATH_$(BITS))
 
-# -O0. GCC on SPARC dies with an out-memory error in cc1plus when
-# building with either -O1 or -O2 (32-bit). If it manages to get
-# through with -O1 or -O2 (64-bit), the resulting bits are unusable.
-OFLAG="-O0"
-GFLAG=""
-
 ifeq ($(DEBUG_BUILD), 1)
-  OFLAG="-O0"
-  GFLAG="-g3"
+  CMAKE_BUILD_TYPE = Debug
+  GFLAG=-g3
+else
+  GFLAG=
 endif
 
 # Because LLVM's install target doesn't install everything that
 # needs to be installed.
 EXTRA_INSTALL_BITS=llvm-lto arcmt-test c-arcmt-test c-index-test diagtool
-LLVM_INSTALL_BINDIR.32=$(PROTOUSRBINDIR)
-LLVM_INSTALL_BINDIR.64=$(PROTOUSRBINDIR64)
-LLVM_INSTALL_BINDIR=$(LLVM_INSTALL_BINDIR.$(BITS))
+LLVM_INSTALL_BINDIR=$(PROTOUSRBINDIR)
 LLVM_BINDIR=$(BUILD_DIR_$(BITS))/bin
 
 INSTALL_CXA_FINALIZE := 0
@@ -192,10 +179,6 @@
 	done ;
 
 COMPONENT_POST_INSTALL_ACTION += \
-	cd $(COMPONENT_DIR) ; \
-	$(GNUCP) -rpd $(PROTOUSRLIBDIR64)/clang $(PROTOUSRLIBDIR)/ ;
-
-COMPONENT_POST_INSTALL_ACTION += \
 	cd $(PROTOUSRLIBDIR) ; \
 	$(PYTHON) -m compileall . ;
 
@@ -239,35 +222,6 @@
     '-e "/Built target/d"' \
     '-e "/Nothing to be done/d"'
 
-# GCC options used:
-# -ftree-vectorize | -fno-tree-vectorize:
-# Enable/disable loop vectorization in optimizations. For details:
-# https://gcc.gnu.org/projects/tree-ssa/vectorization.html
-# Disabled in debug builds, will be enabled in production/optimized
-# builds at some point in the future..
-#
-# -ftree-slp-vectorize | -fno-tree-slp-vectorize:
-# Enable/disable Basic Block tree vectorization.
-# Less aggressive vectorization than -ftree-vectorize, but useful
-# in case -ftree-slp-vectorize misses some vectorization opportunities.
-# Documentation at the same URL as above.
-# Disabled in debug builds, will be enabled in production/optimized
-# builds at some point in the future.
-#
-# -freorder-blocks | -fno-reorder-blocks
-# Enable/disable BasicBlock reordering as an optimization.
-# Disabled in debug builds, will be enabled in production/optimized
-# builds at some point in the future.
-# Documented here:
-# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
-#
-# -ftoplevel-reorder | -fno-toplevel-reorder
-# Another BasiBlock depentent optimization option.
-# Disabled in debug builds, will be enabled in production/optimized
-# builds at some point in the future.
-# Documented here:
-# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
-#
 # -fstack-protector-all:
 # Enable stack smashing (stack corruption) protection and detection.
 # This flag should always be used in conjunction with -Wstack-protector.
@@ -298,9 +252,6 @@
 # ops are always done in software. But quad-floating-point ops in a
 # compiler are virtually non-existent.
 #
-# -mptr32 | -mptr64:
-#  Tell GCC the size of a pointer on SPARC.
-#
 # -mimpure-text:
 # When used in addition to -shared on SPARC, this tells GCC to not pass
 # -z text to the linker when linking a shared object.
@@ -316,30 +267,36 @@
 # Building for Opteron - which implies SSE2 - is adequate for
 # performance purposes.
 
-CFLAGS = -m$(BITS) $(GFLAG) $(OFLAG) -pthread -std=c99 -fno-strict-aliasing
-CFLAGS += -fno-tree-slp-vectorize -fno-tree-vectorize
-CFLAGS += -fno-reorder-blocks -fno-toplevel-reorder
+CFLAGS += $(GFLAG) -pthread -std=c99 -fno-strict-aliasing
 CFLAGS += -Wall -Wcast-align -Wno-long-long -Woverflow
 CFLAGS += -Wstack-protector -fdata-sections -fstack-protector-all
 CFLAGS += -fkeep-static-consts -ffunction-sections
+# Never omit frame pointer; not worth the very minor performance gains for the
+# loss of debugging capability.  Additionally, on sparc, omitting the frame
+# pointer also currently causes bad code generation by gcc (4.x, 5.x):
+#
+#	Many sparc testcases FAIL at -O0 with -fomit-frame-pointer
+#	https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79749
+#
+CFLAGS += -fno-omit-frame-pointer
 CFLAGS += -Wl,-z -Wl,relax=common
 CFLAGS += -Wl,-z -Wl,relax=secadj
 CFLAGS += -Wl,-z -Wl,relax=transtls
 CFLAGS += -Wl,-z -Wl,relax=symbound
 CFLAGS += -Wl,-R -Wl,$(LLVM_RUNPATH)
-CFLAGS.i386 += -mtune=opteron -mno-sse3 -mno-ssse3 -fno-common
-ifeq ($(DEBUG_BUILD),1)
-  CFLAGS.i386 += -fno-omit-frame-pointer
-endif
-CFLAGS.sparc += -mtune=ultrasparc -mcpu=ultrasparc -mvis -mhard-float
-CFLAGS.sparc += -mptr$(BITS) -fdata-sections -falign-functions=8
-CFLAGS.sparc += -mno-unaligned-doubles -mimpure-text
-CFLAGS += $(CFLAGS.$(MACH))
+CFLAGS.gcc.i386 += -mtune=opteron -mno-sse3 -mno-ssse3 -fno-common 
 
-CXXFLAGS = -m$(BITS) $(GFLAG) $(OFLAG) -pthread -fno-strict-aliasing
+# At optimization levels above O0, gcc can either crash or generates unusable
+# code on SPARC.  Disabling delay-slot instruction scheduling avoids this
+# problem.
+CFLAGS.gcc.sparc += -fno-delayed-branch
+CFLAGS.gcc.sparc += -mtune=ultrasparc -mcpu=ultrasparc -mvis -mhard-float
+CFLAGS.gcc.sparc += -fdata-sections -falign-functions=8
+CFLAGS.gcc.sparc += -mno-unaligned-doubles -mimpure-text
+
+CXXFLAGS += $(CFLAGS.$(COMPILER).$(MACH))
+CXXFLAGS += $(GFLAG) -pthread -fno-strict-aliasing
 CXXFLAGS += -fexceptions -frtti -fstack-protector-all
-CXXFLAGS += -fno-tree-vectorize -fno-tree-slp-vectorize
-CXXFLAGS += -fno-reorder-blocks -fno-toplevel-reorder
 CXXFLAGS += -Wall -Wcast-align -Wno-long-long -Woverflow
 CXXFLAGS += -Wstack-protector -fkeep-static-consts
 CXXFLAGS += -std=c++11 -fdata-sections -ffunction-sections
@@ -349,10 +306,8 @@
 CXXFLAGS += -Wl,-z -Wl,relax=symbound
 CXXFLAGS += -Wl,-z -Wl,relax=comdat
 CXXFLAGS += -Wl,-R -Wl,$(LLVM_RUNPATH)
-CXXFLAGS.sparc += -mptr$(BITS)
-CXXFLAGS += $(CFLAGS.$(MACH))
 
-CPPFLAGS = -D_GNU_SOURCE -DLLVM_SOLARIS -I/usr/gnu/include
+CPPFLAGS += -D_GNU_SOURCE -DLLVM_SOLARIS -I/usr/gnu/include
 
 ifeq ($(DEBUG_BUILD),1)
   CPPFLAGS += -D_DEBUG
@@ -367,10 +322,6 @@
 CPPFLAGS.sparc = -DLLVM_SPARC
 CPPFLAGS += $(CPPFLAGS.$(MACH))
 
-LLVM_LIBEXECDIR_32 = /usr/libexec
-LLVM_LIBEXECDIR_64 = /usr/libexec/$(MACH64)
-LLVM_LIBEXECDIR = $(LLVM_LIBEXECDIR_$(BITS))
-
 LIBFFI_INCDIR_32 = $(shell pkg-config --cflags-only-I libffi | sed -e s,-I,,)
 LIBFFI_INCDIR_64 = $(shell env PKG_CONFIG_PATH=$(PKG_CONFIG_PATH.64) pkg-config --cflags-only-I libffi | sed -e s,-I,,)
 LIBFFI_INCDIR = $(LIBFFI_INCDIR_$(BITS))
@@ -385,29 +336,20 @@
 LD_OPTIONS += -M /usr/lib/ld/map.pagealign
 LD_OPTIONS_SO = $(LD_Z_DEFS) $(LD_DEF_LIBS)
 
-CMAKE_OPTIONS = -DCMAKE_C_COMPILER:FILEPATH=$(CC)
-CMAKE_OPTIONS += -DCMAKE_CXX_COMPILER:FILEPATH=$(CXX)
-CMAKE_OPTIONS += -DCMAKE_C_CFLAGS:STRING="$(CPPFLAGS) $(CFLAGS)"
-CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS:STRING="$(CPPFLAGS) $(CXXFLAGS)"
-CMAKE_OPTIONS += -DCMAKE_EXE_LINKER_FLAGS:STRING="$(LDFLAGS)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX:FILEPATH=$(CMAKE_PREFIX)
-CMAKE_OPTIONS += -DCMAKE_AR:FILEPATH=/usr/bin/ar
-
-CMAKE_OPTIONS += -DCMAKE_INSTALL_BINDIR:STRING="$(CMAKE_INSTALL_BINDIR)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBDIR:STRING="$(CMAKE_INSTALL_LIBDIR)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBEXECDIR:STRING="$(CMAKE_INSTALL_LIBEXECDIR)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_INCLUDEDIR:STRING="$(CMAKE_INSTALL_INCLUDEDIR)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_DATADIR:STRING="$(CMAKE_INSTALL_DATADIR)"
-CMAKE_OPTIONS += -DCMAKE_INSTALL_DATAROOTDIR:STRING="$(CMAKE_INSTALL_DATAROOTDIR)"
-
+# The default target triple must be set so that the OS release is included by
+# default as LLVM will use this to find the installed gcc internal libraries
+# and headers (e.g.  /usr/gcc/5/lib/gcc/sparcv9-sun-solaris2.11/5.4.0/).  This
+# also means that when specifying a --target to clang, developers must also
+# include the OS release (e.g. --target=sparcv9-sun-solaris2.11).
 ifeq ($(MACH),sparc)
   CMAKE_OPTIONS += -DLLVM_TARGETS_TO_BUILD:STRING="Sparc"
+  CMAKE_OPTIONS += -DLLVM_DEFAULT_TARGET_TRIPLE:STRING="sparcv9-sun-solaris$(SOLARIS_VERSION)"
 endif
 ifeq ($(MACH),i386)
   CMAKE_OPTIONS += -DLLVM_TARGETS_TO_BUILD:STRING="X86"
+  CMAKE_OPTIONS += -DLLVM_DEFAULT_TARGET_TRIPLE:STRING="x86_64-pc-solaris$(SOLARIS_VERSION)"
 endif
 
-CMAKE_OPTIONS += -DCMAKE_MAKE_PROGRAM:STRING="/usr/bin/gmake"
 CMAKE_OPTIONS += -DCMAKE_ASM_COMPILER:STRING="/usr/gnu/bin/as"
 CMAKE_OPTIONS += -DCMAKE_INSTALL_RPATH:STRING="$(LLVM_RUNPATH)"
 CMAKE_OPTIONS += -DLLVM_BUILD_TOOLS:BOOL=ON
@@ -419,31 +361,19 @@
 
 # CMake tries really hard to be too smart for its own good.
 ifeq ($(DEBUG_BUILD),1)
-  CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE:STRING=Debug
-  CMAKE_OPTIONS += -DCMAKE_C_FLAGS_DEBUG:STRING="$(OFLAG) $(GFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS_DEBUG:STRING="$(OFLAG) $(GFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_ASM_FLAGS_DEBUG:STRING="$(OFLAG) $(GFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_ASM_FLAGS_RELWITHDEBINFO:STRING="$(OFLAG) $(GFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$(OFLAG) $(GFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$(OFLAG) $(GFLAG)"
   CMAKE_OPTIONS += -DLLVM_BUILD_EXAMPLES:BOOL=ON
   CMAKE_OPTIONS += -DLLVM_INCLUDE_EXAMPLES:BOOL=ON
   CMAKE_OPTIONS += -DLLVM_ENABLE_ASSERTIONS:BOOL=ON
   CMAKE_OPTIONS += -DLLVM_ENABLE_EXPENSIVE_CHECKS:BOOL=ON
 else
-  CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE:STRING=Release
-  CMAKE_OPTIONS += -DCMAKE_C_FLAGS_DEBUG:STRING="$(OFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS_DEBUG:STRING="$(OFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_ASM_FLAGS_DEBUG:STRING="$(OFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_ASM_FLAGS_RELWITHDEBINFO:STRING="$(OFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$(OFLAG)"
-  CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$(OFLAG)"
   CMAKE_OPTIONS += -DLLVM_BUILD_EXAMPLES:BOOL=OFF
   CMAKE_OPTIONS += -DLLVM_INCLUDE_EXAMPLES:BOOL=OFF
   CMAKE_OPTIONS += -DLLVM_ENABLE_ASSERTIONS:BOOL=OFF
   CMAKE_OPTIONS += -DLLVM_ENABLE_EXPENSIVE_CHECKS:BOOL=OFF
 endif
 
+CMAKE_OPTIONS += -DCMAKE_ASM_FLAGS:STRING="$(gcc_OPT) $(GFLAG)"
+
 CMAKE_OPTIONS += -DLLVM_ENABLE_EH:BOOL=ON
 CMAKE_OPTIONS += -DLLVM_ENABLE_PIC:BOOL=ON
 CMAKE_OPTIONS += -DLLVM_ENABLE_RTTI:BOOL=ON
@@ -487,20 +417,12 @@
 COMPONENT_BUILD_ENV += LD_EXEC_OPTIONS="-zaslr=disable"
 
 # Put this here for now until the gpatch problems are resolved.
-COMPONENT_BUILD_ARGS += -j4
+COMPONENT_BUILD_ARGS += -j8
 
 # use bash(1) to run the install recipes otherwise clang header installation
 # fails
 COMPONENT_INSTALL_ARGS += SHELL=/bin/bash
 
-COMPONENT_PRE_BUILD_ACTION += cd $(@D) ;
-COMPONENT_PRE_BUILD_ACTION += echo BITS: $(BITS) ;
-COMPONENT_PRE_BUILD_ACTION += echo Running cmake with $(CMAKE_OPTIONS) ;
-COMPONENT_PRE_BUILD_ACTION += /usr/bin/env - $(COMPONENT_BUILD_ENV) \
-			      $(CMAKE) $(CMAKE_OPTIONS) \
-			      $(COMPONENT_DIR)/$(COMPONENT_SRC) ;
-
-
 # There are no master test results just yet. But there will be
 # very soon.
 test:
@@ -508,7 +430,11 @@
 
 system-test:    $(SYSTEM_TESTS_NOT_IMPLEMENTED)
 
-REQUIRED_PACKAGES += developer/gcc-4/gcc-common-49
+REQUIRED_PACKAGES += developer/build/cmake
+REQUIRED_PACKAGES += developer/build/pkg-config
+REQUIRED_PACKAGES += developer/gcc/gcc-c++-5
+REQUIRED_PACKAGES += developer/gcc/gcc-c-5
+REQUIRED_PACKAGES += developer/gcc/gcc-common-5
 REQUIRED_PACKAGES += developer/gnu-binutils
 REQUIRED_PACKAGES += library/libedit
 REQUIRED_PACKAGES += library/libffi
@@ -525,10 +451,8 @@
 REQUIRED_PACKAGES += runtime/python-27
 REQUIRED_PACKAGES += system/core-os
 REQUIRED_PACKAGES += system/header
-REQUIRED_PACKAGES += system/library/gcc/gcc-runtime-49
-REQUIRED_PACKAGES += system/library/gcc/gcc-c++-runtime-49
-REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime-49
-REQUIRED_PACKAGES += system/library/gcc/gcc-gobjc-runtime-49
+REQUIRED_PACKAGES += system/library/gcc/gcc-runtime-5
+REQUIRED_PACKAGES += system/library/gcc/gcc-c++-runtime-5
+REQUIRED_PACKAGES += system/library/gcc/gcc-c-runtime-5
+REQUIRED_PACKAGES += system/library/gcc/gcc-gobjc-runtime-5
 REQUIRED_PACKAGES += system/library/math
-REQUIRED_PACKAGES += system/linker
-
--- a/components/llvm/clang.p5m	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/clang.p5m	Wed Mar 08 22:04:29 2017 -0800
@@ -39,20 +39,23 @@
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
 set name=org.opensolaris.arc-caseid value=PSARC/2013/188
 set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
-file usr/bin/$(MACH64)/arcmt-test path=usr/bin/arcmt-test
-file usr/bin/$(MACH64)/c-arcmt-test path=usr/bin/c-arcmt-test
-file usr/bin/$(MACH64)/c-index-test path=usr/bin/c-index-test
+file path=usr/bin/arcmt-test
+file path=usr/bin/c-arcmt-test
+file path=usr/bin/c-index-test
 hardlink path=usr/bin/clang target=clang-3.8
 hardlink path=usr/bin/clang++ target=clang-3.8
-file usr/bin/$(MACH64)/clang-3.8 path=usr/bin/clang-3.8
-file usr/bin/$(MACH64)/clang-format path=usr/bin/clang-format
-file usr/bin/$(MACH64)/diagtool path=usr/bin/diagtool
-file usr/bin/$(MACH64)/git-clang-format path=usr/bin/git-clang-format
-file usr/bin/$(MACH64)/scan-build path=usr/bin/scan-build
-file usr/bin/$(MACH64)/scan-view path=usr/bin/scan-view
+file path=usr/bin/clang-3.8
+file path=usr/bin/clang-check
+# Intentionally elided; msvc target driver.
+# link path=usr/bin/clang-cl target=clang
+file path=usr/bin/clang-format
+file path=usr/bin/diagtool
+file path=usr/bin/git-clang-format
+file path=usr/bin/scan-build
+file path=usr/bin/scan-view
 file path=usr/lib/$(MACH64)/libclang.so
-file usr/libexec/$(MACH64)/c++-analyzer path=usr/lib/c++-analyzer mode=0555
-file usr/libexec/$(MACH64)/ccc-analyzer path=usr/lib/ccc-analyzer mode=0555
+file path=usr/lib/c++-analyzer mode=0555
+file path=usr/lib/ccc-analyzer mode=0555
 file path=usr/lib/clang/$(COMPONENT_VERSION)/include/Intrin.h
 file path=usr/lib/clang/$(COMPONENT_VERSION)/include/__clang_cuda_runtime_wrapper.h
 file path=usr/lib/clang/$(COMPONENT_VERSION)/include/__stddef_max_align_t.h
@@ -140,13 +143,14 @@
 file path=usr/share/clang/clang-format-bbedit.applescript
 file path=usr/share/clang/clang-format.el
 file path=usr/share/man/man1/clang.1
+file path=usr/share/man/man1/scan-build.1
 file path=usr/share/scan-build/scanview.css
 file path=usr/share/scan-build/sorttable.js
 file path=usr/share/scan-view/FileRadar.scpt
 file path=usr/share/scan-view/GetRadarVersion.scpt
 file path=usr/share/scan-view/bugcatcher.ico
 license llvm.license license="University of Illinois/NCSA"
-depend type=require fmri=pkg:/developer/gcc-4/gcc-c++-49
+depend type=require fmri=pkg:/developer/gcc/gcc-c++-5
 depend type=require fmri=pkg:/developer/gnu-binutils
 # pkgdepend doesn't find the dependency on libiomp5 although
 # it is listed in REQUIRED_PACKAGES. So, we set it as an
--- a/components/llvm/cxa_finalize/Makefile	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/cxa_finalize/Makefile	Wed Mar 08 22:04:29 2017 -0800
@@ -20,10 +20,11 @@
 #
 
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 export PARFAIT_BUILD=no
 COMPILER= gcc
+COMPONENT_ARCHIVE=
 
 include ../../../make-rules/shared-macros.mk
 
@@ -36,13 +37,11 @@
 OBJECTS = cxa_finalize-32.o cxa_finalize-64.o \
 	  cxa_finalize_pic-32.o cxa_finalize_pic-64.o
 
+BUILD_STYLE= pkg
 include $(WS_MAKE_RULES)/common.mk
 
-GCC_VERSION := 4.9
-
-# We need GCC version 4.9, and not another version.
-CC=/usr/gcc/$(GCC_VERSION)/bin/gcc
-CXX=/usr/gcc/$(GCC_VERSION)/bin/g++
+# We need GCC version 5, and not another version; see components/llvm/Makefile.
+GCC_ROOT=/usr/gcc/5
 
 RELEASE_LIST=Debug+Asserts+Checks Debug+Asserts Debug Release+Debug Release Unoptimized
 
--- a/components/llvm/llvm-build.p5m	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/llvm-build.p5m	Wed Mar 08 22:04:29 2017 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 set name=pkg.fmri \
@@ -910,6 +910,7 @@
 file path=usr/share/llvm/cmake/LLVM-Config.cmake
 file path=usr/share/llvm/cmake/LLVMConfig.cmake
 file path=usr/share/llvm/cmake/LLVMConfigVersion.cmake
+file path=usr/share/llvm/cmake/LLVMExports-release.cmake
 file path=usr/share/llvm/cmake/LLVMExports.cmake
 file path=usr/share/llvm/cmake/LLVMExternalProjectUtils.cmake
 file path=usr/share/llvm/cmake/LLVMInstallSymlink.cmake
--- a/components/llvm/llvm.p5m	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/llvm.p5m	Wed Mar 08 22:04:29 2017 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 <transform file path=usr.*/man/.+ -> default mangler.man.stability uncommitted>
@@ -39,46 +39,47 @@
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
 set name=org.opensolaris.arc-caseid value=PSARC/2013/188
 set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
-file usr/bin/$(MACH64)/bugpoint path=usr/bin/bugpoint
-file usr/bin/$(MACH64)/llc path=usr/bin/llc
-file usr/bin/$(MACH64)/lli path=usr/bin/lli
-file usr/bin/$(MACH64)/llvm-ar path=usr/bin/llvm-ar
-file usr/bin/$(MACH64)/llvm-as path=usr/bin/llvm-as
-file usr/bin/$(MACH64)/llvm-bcanalyzer path=usr/bin/llvm-bcanalyzer
-file usr/bin/$(MACH64)/llvm-c-test path=usr/bin/llvm-c-test
-file usr/bin/$(MACH64)/llvm-config path=usr/bin/llvm-config
-file usr/bin/$(MACH64)/llvm-cov path=usr/bin/llvm-cov
-file usr/bin/$(MACH64)/llvm-cxxdump path=usr/bin/llvm-cxxdump
-file usr/bin/$(MACH64)/llvm-diff path=usr/bin/llvm-diff
-file usr/bin/$(MACH64)/llvm-dis path=usr/bin/llvm-dis
-file usr/bin/$(MACH64)/llvm-dsymutil path=usr/bin/llvm-dsymutil
-file usr/bin/$(MACH64)/llvm-dwarfdump path=usr/bin/llvm-dwarfdump
-file usr/bin/$(MACH64)/llvm-dwp path=usr/bin/llvm-dwp
-file usr/bin/$(MACH64)/llvm-extract path=usr/bin/llvm-extract
+file path=usr/bin/bugpoint
+file path=usr/bin/llc
+file path=usr/bin/lli
+file path=usr/bin/llvm-ar
+file path=usr/bin/llvm-as
+file path=usr/bin/llvm-bcanalyzer
+file path=usr/bin/llvm-c-test
+file path=usr/bin/llvm-config
+file path=usr/bin/llvm-cov
+file path=usr/bin/llvm-cxxdump
+file path=usr/bin/llvm-diff
+file path=usr/bin/llvm-dis
+file path=usr/bin/llvm-dsymutil
+file path=usr/bin/llvm-dwarfdump
+file path=usr/bin/llvm-dwp
+file path=usr/bin/llvm-extract
 hardlink path=usr/bin/llvm-lib target=llvm-ar
-file usr/bin/$(MACH64)/llvm-link path=usr/bin/llvm-link
-file usr/bin/$(MACH64)/llvm-lto path=usr/bin/llvm-lto
-file usr/bin/$(MACH64)/llvm-mc path=usr/bin/llvm-mc
-file usr/bin/$(MACH64)/llvm-mcmarkup path=usr/bin/llvm-mcmarkup
-file usr/bin/$(MACH64)/llvm-nm path=usr/bin/llvm-nm
-file usr/bin/$(MACH64)/llvm-objdump path=usr/bin/llvm-objdump
-file usr/bin/$(MACH64)/llvm-pdbdump path=usr/bin/llvm-pdbdump
-file usr/bin/$(MACH64)/llvm-profdata path=usr/bin/llvm-profdata
+file path=usr/bin/llvm-link
+file path=usr/bin/llvm-lto
+file path=usr/bin/llvm-mc
+file path=usr/bin/llvm-mcmarkup
+file path=usr/bin/llvm-nm
+file path=usr/bin/llvm-objdump
+file path=usr/bin/llvm-pdbdump
+file path=usr/bin/llvm-profdata
 hardlink path=usr/bin/llvm-ranlib target=llvm-ar
-file usr/bin/$(MACH64)/llvm-readobj path=usr/bin/llvm-readobj
-file usr/bin/$(MACH64)/llvm-rtdyld path=usr/bin/llvm-rtdyld
-file usr/bin/$(MACH64)/llvm-size path=usr/bin/llvm-size
-file usr/bin/$(MACH64)/llvm-split path=usr/bin/llvm-split
-file usr/bin/$(MACH64)/llvm-stress path=usr/bin/llvm-stress
-file usr/bin/$(MACH64)/llvm-symbolizer path=usr/bin/llvm-symbolizer
-file usr/bin/$(MACH64)/llvm-tblgen path=usr/bin/llvm-tblgen
-file usr/bin/$(MACH64)/obj2yaml path=usr/bin/obj2yaml
-file usr/bin/$(MACH64)/opt path=usr/bin/opt
-file usr/bin/$(MACH64)/sancov path=usr/bin/sancov
-file usr/bin/$(MACH64)/verify-uselistorder path=usr/bin/verify-uselistorder
-file usr/bin/$(MACH64)/yaml2obj path=usr/bin/yaml2obj
+file path=usr/bin/llvm-readobj
+file path=usr/bin/llvm-rtdyld
+file path=usr/bin/llvm-size
+file path=usr/bin/llvm-split
+file path=usr/bin/llvm-stress
+file path=usr/bin/llvm-symbolizer
+file path=usr/bin/llvm-tblgen
+file path=usr/bin/obj2yaml
+file path=usr/bin/opt
+file path=usr/bin/sancov
+file path=usr/bin/verify-uselistorder
+file path=usr/bin/yaml2obj
 file path=usr/lib/$(MACH64)/BugpointPasses.so
 file path=usr/lib/$(MACH64)/LLVMHello.so
+link path=usr/lib/$(MACH64)/libLLVM-3.8.1.so target=libLLVM-3.8.so
 file path=usr/lib/$(MACH64)/libLLVM-3.8.so
 link path=usr/lib/$(MACH64)/libLLVM.so target=libLLVM-3.8.so
 file path=usr/lib/$(MACH64)/libLTO.so
--- a/components/llvm/patches/012-solaris-clang-libclangDriver.patch	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/patches/012-solaris-clang-libclangDriver.patch	Wed Mar 08 22:04:29 2017 -0800
@@ -199,7 +199,7 @@
    switch (TargetTriple.getArch()) {
    case llvm::Triple::aarch64:
      LibDirs.append(begin(AArch64LibDirs), end(AArch64LibDirs));
[email protected]@ -3302,69 +3321,828 @@
[email protected]@ -3302,69 +3321,822 @@
  }
  
  /// Solaris - Solaris tool chain which can call as(1) and ld(1) directly.
@@ -218,7 +218,7 @@
 +  UseSpecifiedGCCToolChainPath(false),
 +  IsValid(false),
 +  GCCInstallDir("/usr/gcc/"),
-+  GCCMajorMinor(""),
++  GCCMajor(""),
 +  GCCMajorMinorMicro(""),
 +  GCCInternalLibDir(""),
 +  GCCInternalMultiLibDir(""),
@@ -245,7 +245,7 @@
 +        }
 +      }
 +    } else {
-+      findGCCMajorMinor();
++      findGCCMajor();
 +      findGCCMajorMinorMicro(Triple);
 +      findGCCIncludeDirs(Triple, Args);
 +      findGCCInternalLibDir(Triple, Args);
@@ -639,9 +639,8 @@
 +}
 +
 +void
-+Solaris::findGCCMajorMinor() const {
-+  // FIXME: Add 5.X after testing the ABI.
-+  static const char* const GCCMM[] = { "4.8", "4.9" };
++Solaris::findGCCMajor() const {
++  static const char* const GCCMM[] = { "5" };
 +
 +  const char* P;
 +  std::string Path;
@@ -655,7 +654,7 @@
 +      Path.append("/");
 +
 +      if (llvm::sys::fs::exists(Path.c_str())) {
-+        GCCMajorMinor = P;
++        GCCMajor = P;
 +        break;
 +      }
 +    }
@@ -664,8 +663,7 @@
 +
 +void
 +Solaris::findGCCMajorMinorMicro(const llvm::Triple& T) const {
-+  // FIXME: Add 5.X after testing the ABI.
-+  static const char* const GCCMMM[] = { "4.8.2", "4.9.3", "4.9.4" };
++  static const char* const GCCMMM[] = { "5.4.0" };
 +
 +  const char* P;
 +  std::string Path;
@@ -673,22 +671,22 @@
 +  llvm::Triple::ArchType Arch = T.getArch();
 +
 +  // GCC4 on Solaris is multilib 32/64.
-+  // GCC5 (not supported here yet) on Solaris is multilib 64/32.
-+  if (GCCMajorMinor[0] == '4') {
-+    if (TripleString.find("x86_64") != std::string::npos)
-+      TripleString.replace(0U, 6U, std::string("i386"));
-+    else if (TripleString.find("sparcv9") != std::string::npos)
-+      TripleString.replace(0U, 7U, std::string("sparc"));
++  // GCC5+ on Solaris is multilib 64/32.
++  if (GCCMajor[0] == '5') {
++    if (TripleString.find("i386") != std::string::npos)
++      TripleString.replace(0U, 4U, std::string("x86_64"));
++    else if (TripleString.find("sparc-") != std::string::npos)
++      TripleString.replace(0U, 6U, std::string("sparcv9-"));
 +  }
 +
 +  Path.reserve(std::string::size_type(PATH_MAX));
 +
 +  for (int I = (llvm::array_lengthof(GCCMMM) - 1); I >= 0; --I) {
 +    if ((P = GCCMMM[I]) != NULL) {
-+      if ((P[0] == GCCMajorMinor[0]) && (P[2] == GCCMajorMinor[2])) {
++      if (P[0] == GCCMajor[0]) {
 +        Path = GCCInstallDir;
 +        Path.append("/");
-+        Path.append(GCCMajorMinor);
++        Path.append(GCCMajor);
 +        Path.append("/lib/gcc/");
 +        Path.append(TripleString);
 +        Path.append("/");
@@ -699,15 +697,15 @@
 +          // Check if this is a real GCC installation and not just
 +          // an empty directory tree
 +          switch (Arch) {
-+          case llvm::Triple::x86:
-+          case llvm::Triple::sparc:
++          case llvm::Triple::x86_64:
++          case llvm::Triple::sparcv9:
 +            Test = Path + "/crtbegin.o";
 +            break;
-+          case llvm::Triple::x86_64:
-+            Test = Path + "/amd64/crtbegin.o";
++          case llvm::Triple::x86:
++            Test = Path + "/32/crtbegin.o";
 +            break;
-+          case llvm::Triple::sparcv9:
-+            Test = Path + "/sparcv9/crtbegin.o";
++          case llvm::Triple::sparc:
++            Test = Path + "/32/crtbegin.o";
 +            break;
 +          default:
 +            break;
@@ -743,7 +741,7 @@
 +
 +  assert(StartingPath && "Invalid GCC Toolchain starting search path!");
 +
-+  GCCMajorMinor = "";
++  GCCMajor = "";
 +  GCCMajorMinorMicro = "";
 +  UseSpecifiedGCCToolChainPath = false;
 +
@@ -825,7 +823,7 @@
 +                      (std::isdigit(DName[2])) && (DName[3] == '.') &&
 +                      (std::isdigit(DName[4])) && (DName[5] == '\0')) {
 +                    GCCMajorMinorMicro = DName;
-+                    GCCMajorMinor = GCCMajorMinorMicro.substr(0, 3);
++                    GCCMajor = GCCMajorMinorMicro.substr(0, 1);
 +                    UseSpecifiedGCCToolChainPath = true;
 +                    goto done;
 +                  }
@@ -867,7 +865,7 @@
 +  if (UseSpecifiedGCCToolChainPath)
 +    GCCInstallPath = GCCInstallDir;
 +  else
-+    GCCInstallPath = GCCInstallDir + GCCMajorMinor;
++    GCCInstallPath = GCCInstallDir + GCCMajor;
 +
 +  std::string GCCIncludeDir =
 +    GCCInstallPath + "/include/c++/" + GCCMajorMinorMicro;
@@ -877,27 +875,27 @@
 +  GCCIncludeDir += "/";
 +
 +  switch (Arch) {
-+  case llvm::Triple::x86:
++  case llvm::Triple::x86_64:
++    GCCIncludeDir += Triple.getTriple();
++    if (Args.getLastArg(options::OPT_m32))
++      GCCIncludeDir += "/32";
++    break;
++  case llvm::Triple::sparcv9:
 +    GCCIncludeDir += Triple.getTriple();
-+    if (Arg *A = Args.getLastArg(options::OPT_m64))
-+      GCCIncludeDir += "/amd64";
++    if (Args.getLastArg(options::OPT_m32))
++      GCCIncludeDir += "/32";
++    break;
++  case llvm::Triple::x86:
++    GCCIncludeDir += "x86_64-pc-";
++    GCCIncludeDir += Triple.getOSName();
++    if (Args.getLastArg(options::OPT_m32))
++      GCCIncludeDir += "/32";
 +    break;
 +  case llvm::Triple::sparc:
-+    GCCIncludeDir += Triple.getTriple();
-+    if (Arg *A = Args.getLastArg(options::OPT_m64))
-+      GCCIncludeDir += "/sparcv9";
-+    break;
-+  case llvm::Triple::x86_64:
-+    GCCIncludeDir += "i386-pc-";
++    GCCIncludeDir += "sparcv9-sun-";
 +    GCCIncludeDir += Triple.getOSName();
-+    if (Arg *A = Args.getLastArg(options::OPT_m64))
-+      GCCIncludeDir += "/amd64";
-+    break;
-+  case llvm::Triple::sparcv9:
-+    GCCIncludeDir += "sparc-sun-";
-+    GCCIncludeDir += Triple.getOSName();
-+    if (Arg *A = Args.getLastArg(options::OPT_m64))
-+      GCCIncludeDir += "/sparcv9";
++    if (Args.getLastArg(options::OPT_m32))
++      GCCIncludeDir += "/32";
 +    break;
 +  default:
 +    getDriver().Diag(diag::err_target_unsupported_arch)
@@ -920,69 +918,65 @@
 +  if (UseSpecifiedGCCToolChainPath)
 +    GCCInstallPath = GCCInstallDir;
 +  else
-+    GCCInstallPath = GCCInstallDir + GCCMajorMinor;
++    GCCInstallPath = GCCInstallDir + GCCMajor;
 +
 +  GCCInternalLibDir = GCCInstallPath + "/lib/gcc/";
 +
 +  llvm::Triple::ArchType Arch = Triple.getArch();
 +
 +  switch (Arch) {
-+  case llvm::Triple::x86:
++  case llvm::Triple::x86_64:
 +    GCCInternalLibDir += Triple.getTriple();
 +    GCCInternalLibDir += "/";
 +    GCCInternalLibDir += GCCMajorMinorMicro;
-+    if (Arg *A = Args.getLastArg(options::OPT_m64)) {
-+      GCCInternalMultiLibDir = GCCInternalLibDir;
-+      GCCInternalLibDir += "/amd64";
-+    } else if (Arg *A = Args.getLastArg(options::OPT_m32)) {
++    if (Args.getLastArg(options::OPT_m64)) {
++      GCCInternalMultiLibDir = GCCInternalLibDir + "/32";
++    } else if (Args.getLastArg(options::OPT_m32)) {
 +      GCCInternalMultiLibDir = GCCInternalLibDir;
-+      GCCInternalMultiLibDir += "/amd64";
++      GCCInternalLibDir += "/32";
 +    } else {
-+      GCCInternalMultiLibDir = GCCInternalLibDir;
-+      GCCInternalMultiLibDir += "/amd64";
++      GCCInternalMultiLibDir = GCCInternalLibDir + "/32";
 +    }
 +
 +    break;
-+  case llvm::Triple::sparc:
++  case llvm::Triple::sparcv9:
 +    GCCInternalLibDir += Triple.getTriple();
 +    GCCInternalLibDir += "/";
 +    GCCInternalLibDir += GCCMajorMinorMicro;
-+    if (Arg *A = Args.getLastArg(options::OPT_m64)) {
-+      GCCInternalMultiLibDir = GCCInternalLibDir;
-+      GCCInternalLibDir += "/sparcv9";
-+    } else if (Arg *A = Args.getLastArg(options::OPT_m32)) {
++    if (Args.getLastArg(options::OPT_m64)) {
++      GCCInternalMultiLibDir = GCCInternalLibDir + "/32";
++    } else if (Args.getLastArg(options::OPT_m32)) {
 +      GCCInternalMultiLibDir = GCCInternalLibDir;
-+      GCCInternalMultiLibDir += "/sparcv9";
++      GCCInternalLibDir += "/32";
 +    } else {
-+      GCCInternalMultiLibDir = GCCInternalLibDir;
-+      GCCInternalMultiLibDir += "/sparcv9";
++      GCCInternalMultiLibDir = GCCInternalLibDir + "/32";
 +    }
 +    break;
-+  case llvm::Triple::x86_64:
-+    GCCInternalLibDir += "i386-pc-";
++  case llvm::Triple::x86:
++    GCCInternalLibDir += "x86_64-pc-";
 +    GCCInternalLibDir += Triple.getOSName();
 +    GCCInternalLibDir += "/";
 +    GCCInternalLibDir += GCCMajorMinorMicro;
 +    GCCInternalMultiLibDir = GCCInternalLibDir;
-+    if (Arg *A = Args.getLastArg(options::OPT_m64))
-+      GCCInternalLibDir += "/amd64";
-+    else if (Arg *A = Args.getLastArg(options::OPT_m32))
-+      GCCInternalMultiLibDir += "/amd64";
++    if (Args.getLastArg(options::OPT_m64))
++      GCCInternalMultiLibDir += "/32";
++    else if (Args.getLastArg(options::OPT_m32))
++      GCCInternalLibDir += "/32";
 +    else
-+      GCCInternalLibDir += "/amd64";
++      GCCInternalMultiLibDir += "/32";
 +    break;
-+  case llvm::Triple::sparcv9:
-+    GCCInternalLibDir += "sparc-sun-";
++  case llvm::Triple::sparc:
++    GCCInternalLibDir += "sparcv9-sun-";
 +    GCCInternalLibDir += Triple.getOSName();
 +    GCCInternalLibDir += "/";
 +    GCCInternalLibDir += GCCMajorMinorMicro;
 +    GCCInternalMultiLibDir = GCCInternalLibDir;
-+    if (Arg *A = Args.getLastArg(options::OPT_m64))
-+      GCCInternalLibDir += "/sparcv9";
-+    else if (Arg *A = Args.getLastArg(options::OPT_m32))
-+      GCCInternalMultiLibDir += "/sparcv9";
++    if (Args.getLastArg(options::OPT_m64))
++      GCCInternalMultiLibDir += "/32";
++    else if (Args.getLastArg(options::OPT_m32))
++      GCCInternalLibDir += "/32";
 +    else
-+      GCCInternalLibDir += "/sparcv9";
++      GCCInternalMultiLibDir += "/32";
 +    break;
 +  default:
 +    getDriver().Diag(diag::err_target_unsupported_arch)
@@ -1003,7 +997,7 @@
 +  OS << "UseSpecifiedGCCToolChainPath: "
 +    << (UseSpecifiedGCCToolChainPath ? "true" : "false") << "\n";
 +  OS << "GCCInstallDir: " << GCCInstallDir.c_str() << "\n";
-+  OS << "GCCMajorMinor: " << GCCMajorMinor.c_str() << "\n";
++  OS << "GCCMajor: " << GCCMajor.c_str() << "\n";
 +  OS << "GCCMajorMinorMicro: " << GCCMajorMinorMicro.c_str() << "\n";
 +  OS << "GCCInternalLibDir: " << GCCInternalLibDir.c_str() << "\n";
 +  OS << "GCCInternalMultiLibDir: " << GCCInternalMultiLibDir.c_str() << "\n";
@@ -1205,7 +1199,7 @@
 +  void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
 +                             llvm::opt::ArgStringList &CC1Args) const override;
 +
-+  void findGCCMajorMinor() const;
++  void findGCCMajor() const;
 +  void findGCCMajorMinorMicro(const llvm::Triple &Triple) const;
 +  void findGCCIncludeDirs(const llvm::Triple &Triple,
 +                          const llvm::opt::ArgList &Args) const;
@@ -1218,7 +1212,7 @@
 +  StringRef getAssembler() const { return Assembler.c_str(); }
 +  StringRef getLinker() const { return Linker.c_str(); }
 +  StringRef getGCCInstallDir() const { return GCCInstallDir.c_str(); }
-+  StringRef getGCCMajorMinor() const { return GCCMajorMinor.c_str(); }
++  StringRef getGCCMajor() const { return GCCMajor.c_str(); }
 +  StringRef getMArch() const { return march.c_str(); }
 +  StringRef getMTune() const { return mtune.c_str(); }
 +  StringRef getMCpu() const { return mcpu.c_str(); }
@@ -1262,7 +1256,7 @@
 +
 +protected:
 +  mutable std::string GCCInstallDir;
-+  mutable std::string GCCMajorMinor;
++  mutable std::string GCCMajor;
 +  mutable std::string GCCMajorMinorMicro;
 +  mutable std::string GCCInternalLibDir;
 +  mutable std::string GCCInternalMultiLibDir;
@@ -1973,7 +1967,7 @@
 +      YPPath = "/lib:/usr/lib";
 +      ClangLibPath = "/usr/lib/clang/";
 +    } else {
-+      GCCLibPath = TC.getGCCInternalMultiLibDir().str();
++      GCCLibPath = TC.getGCCInternalLibDir().str();
 +      GCCLibPath += "/";
 +      LibPath += "amd64/";
 +      ShortLibPath += "amd64/";
@@ -1990,7 +1984,7 @@
 +      YPPath = "/lib:/usr/lib";
 +      ClangLibPath = "/usr/lib/clang/";
 +    } else {
-+      GCCLibPath = TC.getGCCInternalMultiLibDir().str();
++      GCCLibPath = TC.getGCCInternalLibDir().str();
 +      GCCLibPath += "/";
 +      LibPath += "sparcv9/";
 +      ShortLibPath += "sparcv9/";
@@ -2001,7 +1995,7 @@
 +    break;
 +  case llvm::Triple::x86_64:
 +    if (m32) {
-+      GCCLibPath = TC.getGCCInternalMultiLibDir().str();
++      GCCLibPath = TC.getGCCInternalLibDir().str();
 +      GCCLibPath += "/";
 +      moption = "-32";
 +      YPPath = "/lib:/usr/lib";
@@ -2009,7 +2003,7 @@
 +    } else {
 +      GCCLibPath = TC.getGCCInternalLibDir().str();
 +      GCCLibPath += "/";
-+    LibPath += "amd64/";
++      LibPath += "amd64/";
 +      ShortLibPath += "amd64/";
 +      moption = "-64";
 +      YPPath = "/lib/amd64:/usr/lib/amd64";
@@ -2018,7 +2012,7 @@
 +    break;
 +  case llvm::Triple::sparcv9:
 +    if (m32) {
-+      GCCLibPath = TC.getGCCInternalMultiLibDir().str();
++      GCCLibPath = TC.getGCCInternalLibDir().str();
 +      GCCLibPath += "/";
 +      moption = "-32";
 +      YPPath = "/lib:/usr/lib";
--- a/components/llvm/patches/031-solaris-build-system.patch	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/llvm/patches/031-solaris-build-system.patch	Wed Mar 08 22:04:29 2017 -0800
@@ -893,7 +893,7 @@
 +    COMPONENT clang-headers
 +    PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
 +    DESTINATION
-+    ${CMAKE_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include)
++    ${CMAKE_INSTALL_LIBDIR}/../clang/${CLANG_VERSION}/include)
 +else()
 +  install(FILES ${files} ${CMAKE_CURRENT_BINARY_DIR}/arm_neon.h
    COMPONENT clang-headers
@@ -1001,7 +1001,7 @@
  # They are not referenced. See set_output_directory().
 +if(CMAKE_HOST_SOLARIS)
 +  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
-+      ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINIR})
++      ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
 +  set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
 +      ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
 +  set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
@@ -1030,20 +1030,6 @@
      endif()
    endif(NOT DEFINED CMAKE_INSTALL_RPATH)
  endif()
[email protected]@ -639,6 +670,12 @@
-   llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
- endif()
- 
-+if(CMAKE_HOST_SOLARIS)
-+  llvm_replace_compiler_option(CMAKE_C_FLAGS_RELEASE "-O3" "-O0")
-+  llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O0")
-+  llvm_replace_compiler_option(CMAKE_ASM_FLAGS_RELEASE "-O3" "-O0")
-+endif()
-+
- # Put this before tblgen. Else we have a circular dependence.
- add_subdirectory(lib/Support)
- add_subdirectory(lib/TableGen)
-###
 --- cmake/modules/AddLLVM.cmake	2016-02-12 09:52:29.000000000 -0800
 +++ cmake/modules/AddLLVM.cmake	2016-05-21 11:50:17.129351767 -0700
 @@ -2,6 +2,17 @@
--- a/components/mysql-5-5/mysql-55test.p5m	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/mysql-5-5/mysql-55test.p5m	Wed Mar 08 22:04:29 2017 -0800
@@ -34,12 +34,9 @@
 set name=info.upstream-url value=$(COMPONENT_PROJECT_URL)
 set name=org.opensolaris.arc-caseid value=PSARC/2013/333
 set name=org.opensolaris.consolidation value=$(CONSOLIDATION)
-file path=usr/mysql/5.5/mysql-test/CTestTestfile.cmake
-file path=usr/mysql/5.5/mysql-test/Makefile
 file path=usr/mysql/5.5/mysql-test/README
 file path=usr/mysql/5.5/mysql-test/README.gcov
 file path=usr/mysql/5.5/mysql-test/README.stress
-file path=usr/mysql/5.5/mysql-test/cmake_install.cmake
 file path=usr/mysql/5.5/mysql-test/collections/README
 file path=usr/mysql/5.5/mysql-test/collections/README.experimental
 file path=usr/mysql/5.5/mysql-test/collections/default.daily
--- a/components/mysql-5-6/mysql-56test.p5m	Fri Jan 27 16:34:13 2017 -0800
+++ b/components/mysql-5-6/mysql-56test.p5m	Wed Mar 08 22:04:29 2017 -0800
@@ -42,12 +42,9 @@
 file path=usr/mysql/5.6/man/man1/mysql_client_test.1
 file path=usr/mysql/5.6/man/man1/mysql_client_test_embedded.1
 file path=usr/mysql/5.6/man/man1/mysqltest_embedded.1
-file path=usr/mysql/5.6/mysql-test/CTestTestfile.cmake
-file path=usr/mysql/5.6/mysql-test/Makefile
 file path=usr/mysql/5.6/mysql-test/README
 file path=usr/mysql/5.6/mysql-test/README.gcov
 file path=usr/mysql/5.6/mysql-test/README.stress
-file path=usr/mysql/5.6/mysql-test/cmake_install.cmake
 file path=usr/mysql/5.6/mysql-test/collections/README
 file path=usr/mysql/5.6/mysql-test/collections/README.experimental
 file path=usr/mysql/5.6/mysql-test/collections/default.daily
--- a/make-rules/cmake.mk	Fri Jan 27 16:34:13 2017 -0800
+++ b/make-rules/cmake.mk	Wed Mar 08 22:04:29 2017 -0800
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
 #
 
 #
@@ -33,7 +33,7 @@
 include $(WS_MAKE_RULES)/justmake.mk
 
 # Ensure correct version of libraries are linked to.
-LDFLAGS += "$(CC_BITS)"
+LDFLAGS += $(CC_BITS)
 
 # This component uses cmake to generate Makefiles and so has no configure
 CMAKE = $(shell which cmake)
@@ -47,23 +47,47 @@
 CMAKE_OPTIONS += -DCMAKE_C_COMPILER="$(CC)"
 CMAKE_OPTIONS += -DCMAKE_C_FLAGS="$(CFLAGS)"
 CMAKE_OPTIONS += -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)"
+CMAKE_OPTIONS += -DCMAKE_AR="/usr/bin/ar"
 
 # Must start install paths with a leading '/' or files will be installed into
 # wrong location!
+ifeq ($(strip $(PREFERRED_BITS)),64)
+CMAKE_BINDIR.32 ?=	$(CMAKE_PREFIX)/bin/$(MACH32)
+CMAKE_SBINDIR.32 ?=	$(CMAKE_PREFIX)/sbin/$(MACH32)
+CMAKE_EXECDIR.32 ?=	$(CMAKE_PREFIX)/lib/$(MACH32)
+CMAKE_BINDIR.64 ?=	$(CMAKE_PREFIX)/bin
+CMAKE_SBINDIR.64 ?=	$(CMAKE_PREFIX)/sbin
+CMAKE_EXECDIR.64 ?=	$(CMAKE_PREFIX)/lib
+else
+CMAKE_BINDIR.32 ?=	$(CMAKE_PREFIX)/bin
+CMAKE_SBINDIR.32 ?=	$(CMAKE_PREFIX)/sbin
+CMAKE_EXECDIR.32 ?=	$(CMAKE_PREFIX)/lib
+CMAKE_BINDIR.64 ?=	$(CMAKE_PREFIX)/bin/$(MACH64)
+CMAKE_SBINDIR.64 ?=	$(CMAKE_PREFIX)/sbin/$(MACH64)
+CMAKE_EXECDIR.64 ?=	$(CMAKE_PREFIX)/lib/$(MACH64)
+endif
+
+CMAKE_OPTIONS += -DCMAKE_MAKE_PROGRAM=$(GMAKE)
+
+# Which variables to set to control installation location has changed over time
+# for CMake, so cover all of the common ones.
 CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX="$(CMAKE_PREFIX)"
 CMAKE_OPTIONS += -DCMAKE_MODULE_LINKER_FLAGS="$(LDFLAGS)"
 CMAKE_OPTIONS += -DCMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS)"
 CMAKE_OPTIONS += -DGETTEXT_MSGFMT_EXECUTABLE="$(GNUBIN)/msgfmt"
-CMAKE_OPTIONS += -DBIN_INSTALL_DIR="$(USRBIN)"
-CMAKE_OPTIONS += -DEXEC_INSTALL_DIR="$(USRBIN)"
+CMAKE_OPTIONS += -DBIN_INSTALL_DIR="$(CMAKE_BINDIR.$(BITS))"
+CMAKE_OPTIONS += -DEXEC_INSTALL_DIR="$(CMAKE_EXECDIR.$(BITS))"
+CMAKE_OPTIONS += -DLIBEXEC_INSTALL_DIR="$(CMAKE_EXECDIR.$(BITS))"
+CMAKE_OPTIONS += -DCMAKE_INSTALL_BINDIR="$(CMAKE_BINDIR.$(BITS))"
+CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBEXECDIR="$(CMAKE_EXECDIR.$(BITS))"
 
 # Some components use LIB_INSTALL_DIR, as-is, others forcibly ignore it and set
 # based on CMAKE_INSTALL_PREFIX.  Those usually instead offer a LIB_SUFFIX
 # variable that we can generally use to accomplish the same result.  Setting
 # them both shouldn't harm anything.
 CMAKE_OPTIONS += -DLIB_INSTALL_DIR="$(USRLIB)"
+CMAKE_OPTIONS += -DCMAKE_INSTALL_LIBDIR="$(USRLIB)"
 CMAKE_OPTIONS.64 += -DLIB_SUFFIX="/$(MACH64)"
-CMAKE_OPTIONS += -DLIBEXEC_INSTALL_DIR="$(USRLIB)"
 
 # Required to ensure expected defines are set; also, ensures project's
 # optimisation level set appropriately.
@@ -71,12 +95,14 @@
 
 CMAKE_OPTIONS += $(CMAKE_OPTIONS.$(BITS))
 
+# Ensure cmake finds the matching 32/64-bit version of dependencies.
+COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
+
 COMPONENT_PRE_BUILD_ACTION += cd $(@D);
 COMPONENT_PRE_BUILD_ACTION += echo Running cmake with $(CMAKE_OPTIONS);
-COMPONENT_PRE_BUILD_ACTION += $(CMAKE) . $(CMAKE_OPTIONS);
-
-# Ensure cmake finds the matching 32/64-bit version of dependencies.
-COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
+COMPONENT_PRE_BUILD_ACTION += /usr/bin/env - $(COMPONENT_BUILD_ENV) \
+			      $(CMAKE) $(CMAKE_OPTIONS) \
+			      $(COMPONENT_DIR)/$(COMPONENT_SRC);
 
 REQUIRED_PACKAGES += developer/build/cmake
 REQUIRED_PACKAGES += developer/build/pkg-config