internals:windows:pgobuild

HowTo: Building optimized PHP for Windows

Building the PGO-optimized version of PHP is a simple and straightforward process, however it does require a software developer with a solid understanding of setting up software, dealing with .zip files, modifying the PATH, and a general comfort working in the command line environment.

This walkthrough assumes that the reader has these skills, and does not attempt to clutter the process by getting into unnecessary detail.

While this walkthrough was built assuming that the requisite tools are installed in their default or recommended locations, the scripts and tools are somewhat flexible, and can be made to work with environments that don’t quite match.

Requirements

  1. Visual Studio 2008 Professional or Visual Studio 2008 Team System – If you don’t have one of these two versions of Visual Studio 2008, you can’t use Profile Guided Optimization to build a more optimized version of PHP—however you can use this build process to generate Visual Studio Project files (vcproj) for Visual Studio 2008 Standard and Express that allow you build the PHP stack with consistent settings across all projects.
  2. Windows SDK for Windows Server 2008 and .NET Framework 3.5. can be downloaded as either:
    • Web Setup that allows you to choose the components of the Windows SDK you wish to download and install, or
    • DVD ISO image file so that you can burn your own DVD.
  3. MySQL In order to run thru the PGO training scenarios, you will need MySQL (either 64 bit or 32 bit should be fine) MySQL Can be found here. You can grab either the .zip file or the installer. If you download the installer, read the notes in the Setup section below.
  4. ActivePerl OpenSSL requires ActivePerl to handle part of it’s compilation process.
  5. PHP Binary tools a collection of open source utilities needed to build PHP. The tools can be found here
  6. Optional: Oracle SDK (10.2 and/or 11.1) – Only needed if you want to build the Oracle database extensions. At the time of writing, the following were the files used: instantclient-sdk-win32-10.2.0.3-20061115.zip and instantclient-sdk-win32-11.1.0.7.0.zip
  7. PHP PGO Kit and Dependency Source Libraries the source code for all the dependencies libraries that are needed to build PHP.
  • PGOKit.zip - The kit with the automated build scripts and tools.

For those interested, the source code for the PGOKit utilities can be found on CodePlex : http://gsToolkit.codeplex.com

Setup

  1. Install Visual Studio and any available service packs.
  2. Install the Windows SDK.
  3. Install MySQL—Ideally this should be set to c:\program files\MySQL . You DO NOT need to run it as a service, the PGO build script can start and stop MySQL as needed. If you download the zip file, unpack it into c:\program files and rename the directory to MySQL (it will by default have the version number in the directory name).
  4. Run the installer for ActivePerl. Accepting the defaults works pretty good, and yes you want it in the PATH.
  5. Unpack the PHP binary tools into a directory, and add that directory into the PATH. It is suggested that this be c:\php-sdk
  6. Create a Work Directory where you want to do all the work. In this walkthrough, we’ll use c:\UnifiedBuild
  7. In the Work Directory, unpack the all the zip files that were downloaded (from step #7 in the requirements)
  8. Copy (not unpack) the Oracle SDK zip files into the Libraries\SpecialCases\binaries directory
  C:\UnifiedBuild\Libraries\SpecialCases\binaries\instantclient-sdk-win32-10.2.0.3-20061115.zip
  C:\UnifiedBuild\Libraries\SpecialCases\binaries\instantclient-sdk-win32-11.1.0.7.0.zip

Running the Build

Start a command shell using the shortcut in the start menu:

Microsoft Windows SDK v6.1\CMD Shell

At the command line type:

Set the SDK prompt to X86/Release:

  c:\> setenv /x86 /release
   
  Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v6.1.
  Targeting Windows Server 2008 x86 RELEASE
   
  c:\>

The OptimizedBuild.js script handles the entire build process end-to-end.

From the SDK shell, you can switch into your work directory and just type

  OptimizedBuild.js

from the command line, and it will build the whole thing.

Advanced/Alternative OptimizedBuild script usage

For additional functionality of the optimized build script, see optimized build script

Setup

  1. Install Visual Studio and any available service packs.
  2. Install the Windows SDK.
  3. Install MySQL—Ideally this should be set to c:\program files\MySQL . You DO NOT need to run it as a service, the PGO build script can start and stop MySQL as needed. If you download the zip file, unpack it into c:\program files and rename the directory to MySQL (it will by default have the version number in the directory name).
  4. Run the installer for ActivePerl. Accepting the defaults works pretty good, and yes you want it in the PATH.
  5. Unpack the PHP binary tools into a directory, and add that directory into the PATH. It is suggested that this be c:\php-sdk
  6. Create a Work Directory where you want to do all the work. In this walkthrough, we’ll use c:\UnifiedBuild
  7. In the Work Directory, unpack the all the zip files that were downloaded (from step #7 in the requirements)
  8. Copy (not unpack) the Oracle SDK zip files into the Libraries\SpecialCases\binaries directory
  C:\UnifiedBuild\Libraries\SpecialCases\binaries\instantclient-sdk-win32-10.2.0.3-20061115.zip
  C:\UnifiedBuild\Libraries\SpecialCases\binaries\instantclient-sdk-win32-11.1.0.7.0.zip

Running the Build

Start a command shell using the shortcut in the start menu:

Microsoft Windows SDK v6.1\CMD Shell

At the command line type:

Set the SDK prompt to X86/Release:

  c:\> setenv /x86 /release
   
  Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v6.1.
  Targeting Windows Server 2008 x86 RELEASE
   
  c:\>

The OptimizedBuild.js script handles the entire build process end-to-end.

From the SDK shell, you can switch into your work directory and just type

  OptimizedBuild.js

from the command line, and it will build the whole thing.

Advanced/Alternative OptimizedBuild script usage

For additional functionality of the optimized build script, see optimized build script

internals/windows/pgobuild.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1