diff options
Diffstat (limited to 'build.sh')
-rwxr-xr-x | build.sh | 109 |
1 files changed, 76 insertions, 33 deletions
@@ -19,7 +19,7 @@ fi usage() { - echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [configureonly] [skipconfigure] [skipnative] [skipmscorlib] [skiptests] [cmakeargs] [bindir]" + echo "Usage: $0 [BuildArch] [BuildType] [verbose] [coverage] [cross] [clangx.y] [ninja] [configureonly] [skipconfigure] [skipnative] [skipmscorlib] [skiptests] [stripsymbols] [cmakeargs] [bindir]" echo "BuildArch can be: x64, x86, arm, armel, arm64" echo "BuildType can be: debug, checked, release" echo "coverage - optional argument to enable code coverage build (currently supported only for Linux and OSX)." @@ -30,13 +30,15 @@ usage() echo "crosscomponent - optional argument to build cross-architecture component," echo " - will use CAC_ROOTFS_DIR environment variable if set." echo "pgoinstrument - generate instrumented code for profile guided optimization enabled binaries." + echo "ibcinstrument - generate IBC-tuning-enabled native images when invoking crossgen." echo "configureonly - do not perform any builds; just configure the build." echo "skipconfigure - skip build configuration." echo "skipnative - do not build native components." echo "skipmscorlib - do not build mscorlib.dll." echo "skiptests - skip the tests in the 'tests' subdirectory." echo "skipnuget - skip building nuget packages." - echo "portableLinux - build for Portable Linux Distribution" + echo "skiprestoreoptdata - skip restoring optimization data used by profile-based optimizations." + echo "portable - build for portable RID." echo "verbose - optional argument to enable verbose build output." echo "-skiprestore: skip restoring packages ^(default: packages are restored during build^)." echo "-disableoss: Disable Open Source Signing for System.Private.CoreLib." @@ -44,11 +46,12 @@ usage() echo " using all processors^)." echo "-officialbuildid=^<ID^>: specify the official build ID to be used by this build." echo "-Rebuild: passes /t:rebuild to the build projects." + echo "stripSymbols - Optional argument to strip native symbols during the build." echo "skipgenerateversion - disable version generation even if MSBuild is supported." echo "cmakeargs - user-settable additional arguments passed to CMake." echo "bindir - output directory (defaults to $__ProjectRoot/bin)" echo "buildstandalonegc - builds the GC in a standalone mode. Can't be used with \"cmakeargs\"." - + echo "msbuildonunsupportedplatform - build managed binaries even if distro is not officially supported." exit 1 } @@ -81,9 +84,13 @@ initTargetDistroRid() export __DistroRid="$__HostDistroRid" fi - # Portable builds target the base RID only for Linux based platforms - if [ $__PortableLinux == 1 ]; then - export __DistroRid="linux-$__BuildArch" + # Portable builds target the base RID + if [ $__PortableBuild == 1 ]; then + if [ "$__BuildOS" == "Linux" ]; then + export __DistroRid="linux-$__BuildArch" + elif [ "$__BuildOS" == "OSX" ]; then + export __DistroRid="osx-$__BuildArch" + fi fi } @@ -116,6 +123,19 @@ check_prereqs() } +restore_optdata() +{ + # if msbuild is not supported, then set __SkipRestoreOptData to 1 + if [ $__isMSBuildOnNETCoreSupported == 0 ]; then __SkipRestoreOptData=1; fi + if [ $__SkipRestoreOptData == 0 ]; then + echo "Restoring the OptimizationData package" + "$__ProjectRoot/run.sh" sync -optdata + if [ $? != 0 ]; then + echo "Failed to restore the optimization data package." + exit 1 + fi + fi +} generate_event_logging_sources() { @@ -214,6 +234,7 @@ build_native() fi fi + pushd "$intermediatesForBuild" # Regenerate the CMake solution echo "Invoking \"$__ProjectRoot/src/pal/tools/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion $__ClangMinorVersion $platformArch $__BuildType $__CodeCoverage $__IncludeTests $generator $extraCmakeArguments $__cmakeargs" @@ -277,6 +298,8 @@ build_cross_arch_component() export __CMakeBinDir="$__CrossComponentBinDir" export CROSSCOMPONENT=1 + __IncludeTests= + if [ $CROSSCOMPILE == 1 ]; then TARGET_ROOTFS="$ROOTFS_DIR" if [ -n "$CAC_ROOTFS_DIR" ]; then @@ -286,7 +309,7 @@ build_cross_arch_component() fi fi - __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument" + __ExtraCmakeArgs="-DCLR_CMAKE_TARGET_ARCH=$__BuildArch -DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_VERSION=$__PgoOptDataVersion" build_native $__SkipCrossArchBuild "$__CrossArch" "$__CrossCompIntermediatesDir" "$__ExtraCmakeArgs" "cross-architecture component" # restore ROOTFS_DIR, CROSSCOMPONENT, and CROSSCOMPILE @@ -311,13 +334,10 @@ isMSBuildOnNETCoreSupported() "debian.8-x64") __isMSBuildOnNETCoreSupported=1 ;; - "fedora.23-x64") - __isMSBuildOnNETCoreSupported=1 - ;; "fedora.24-x64") __isMSBuildOnNETCoreSupported=1 ;; - "opensuse.13.2-x64") + "fedora.25-x64") __isMSBuildOnNETCoreSupported=1 ;; "opensuse.42.1-x64") @@ -339,6 +359,7 @@ isMSBuildOnNETCoreSupported() __isMSBuildOnNETCoreSupported=1 ;; *) + __isMSBuildOnNETCoreSupported=$__msbuildonunsupportedplatform esac elif [ "$__HostOS" == "OSX" ]; then __isMSBuildOnNETCoreSupported=1 @@ -350,19 +371,12 @@ build_CoreLib_ni() { if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then echo "Generating native image for System.Private.CoreLib." - $__BinDir/crossgen $__BinDir/System.Private.CoreLib.dll + $__BinDir/crossgen $__IbcTuning $__BinDir/System.Private.CoreLib.dll if [ $? -ne 0 ]; then echo "Failed to generate native image for System.Private.CoreLib." exit 1 fi - echo "Generating native image for MScorlib Facade." - $__BinDir/crossgen $__BinDir/mscorlib.dll - if [ $? -ne 0 ]; then - echo "Failed to generate native image for mscorlib facade." - exit 1 - fi - if [ "$__BuildOS" == "Linux" ]; then echo "Generating symbol file for System.Private.CoreLib." $__BinDir/crossgen /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.ni.dll @@ -390,7 +404,12 @@ build_CoreLib() echo "Commencing build of managed components for $__BuildOS.$__BuildArch.$__BuildType" # Invoke MSBuild - $__ProjectRoot/run.sh build -Project=$__ProjectDir/build.proj -MsBuildLog="/flp:Verbosity=normal;LogFile=$__LogsDir/System.Private.CoreLib_$__BuildOS__$__BuildArch__$__BuildType.log" -BuildTarget -__IntermediatesDir=$__IntermediatesDir -__RootBinDir=$__RootBinDir -BuildNugetPackage=false -UseSharedCompilation=false $__RunArgs $__UnprocessedBuildArgs + __ExtraBuildArgs="" + if [[ "$__IbcTuning" -eq "" ]]; then + __ExtraBuildArgs="$__ExtraBuildArgs -OptimizationDataDir=\"$__PackagesDir/optimization.$__BuildOS-$__BuildArch.IBC.CoreCLR/$__IbcOptDataVersion/data/\"" + __ExtraBuildArgs="$__ExtraBuildArgs -EnableProfileGuidedOptimization=true" + fi + $__ProjectRoot/run.sh build -Project=$__ProjectDir/build.proj -MsBuildLog="/flp:Verbosity=normal;LogFile=$__LogsDir/System.Private.CoreLib_$__BuildOS__$__BuildArch__$__BuildType.log" -BuildTarget -__IntermediatesDir=$__IntermediatesDir -__RootBinDir=$__RootBinDir -BuildNugetPackage=false -UseSharedCompilation=false $__RunArgs $__ExtraBuildArgs $__UnprocessedBuildArgs if [ $? -ne 0 ]; then echo "Failed to build managed components." @@ -475,7 +494,6 @@ case $CPUName in ;; aarch64) - echo "Unsupported CPU $CPUName detected, build might not succeed!" __BuildArch=arm64 __HostArch=arm64 ;; @@ -542,12 +560,14 @@ __MSBCleanBuildArgs= __UseNinja=0 __VerboseBuild=0 __PgoInstrument=0 +__IbcTuning="" __ConfigureOnly=0 __SkipConfigure=0 __SkipRestore="" __SkipNuget=0 __SkipCoreCLR=0 __SkipMSCorLib=0 +__SkipRestoreOptData=0 __CrossBuild=0 __ClangMajorVersion=0 __ClangMinorVersion=0 @@ -557,7 +577,10 @@ __DistroRid="" __cmakeargs="" __SkipGenerateVersion=0 __DoCrossArchBuild=0 -__PortableLinux=0 +__PortableBuild=0 +__msbuildonunsupportedplatform=0 +__PgoOptDataVersion="" +__IbcOptDataVersion="" while :; do if [ $# -le 0 ]; then @@ -611,18 +634,17 @@ while :; do __CrossBuild=1 ;; - portablelinux) - if [ "$__BuildOS" == "Linux" ]; then - __PortableLinux=1 - else - echo "ERROR: portableLinux not supported for non-Linux platforms." - exit 1 - fi + -portable) + __PortableBuild=1 ;; - + verbose) - __VerboseBuild=1 - ;; + __VerboseBuild=1 + ;; + + stripsymbols) + __cmakeargs="$__cmakeargs -DSTRIP_SYMBOLS=true" + ;; clang3.5) __ClangMajorVersion=3 @@ -657,6 +679,10 @@ while :; do __PgoInstrument=1 ;; + ibcinstrument) + __IbcTuning="/Tuning" + ;; + configureonly) __ConfigureOnly=1 __SkipMSCorLib=1 @@ -689,6 +715,10 @@ while :; do __SkipGenerateVersion=1 ;; + skiprestoreoptdata) + __SkipRestoreOptData=1 + ;; + includetests) ;; @@ -728,6 +758,9 @@ while :; do buildstandalonegc) __cmakeargs="-DFEATURE_STANDALONE_GC=1" ;; + msbuildonunsupportedplatform) + __msbuildonunsupportedplatform=1 + ;; *) __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" ;; @@ -807,6 +840,13 @@ if [ $__CrossBuild == 1 ]; then fi fi +# Parse the optdata package version from its project.json file +optDataProjectJsonPath="$__ProjectRoot/src/.nuget/optdata/project.json" +if [ -f $optDataProjectJsonPath ]; then + __PgoOptDataVersion=$("$__ProjectRoot/extract-from-json.py" -rf $optDataProjectJsonPath dependencies optimization.PGO.CoreCLR) + __IbcOptDataVersion=$("$__ProjectRoot/extract-from-json.py" -rf $optDataProjectJsonPath dependencies optimization.IBC.CoreCLR) +fi + # init the target distro name initTargetDistroRid @@ -816,11 +856,14 @@ setup_dirs # Check prereqs. check_prereqs +# Restore the package containing profile counts for profile-guided optimizations +restore_optdata + # Generate event logging infrastructure sources generate_event_logging_sources # Build the coreclr (native) components. -__ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument" +__ExtraCmakeArgs="-DCLR_CMAKE_TARGET_OS=$__BuildOS -DCLR_CMAKE_PACKAGES_DIR=$__PackagesDir -DCLR_CMAKE_PGO_INSTRUMENT=$__PgoInstrument -DCLR_CMAKE_OPTDATA_VERSION=$__PgoOptDataVersion" build_native $__SkipCoreCLR "$__BuildArch" "$__IntermediatesDir" "$__ExtraCmakeArgs" "CoreCLR component" # Build cross-architecture components |