Welcome to mirror list, hosted at ThFree Co, Russian Federation.

crossgen-corelib.sh « coreclr « src - github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8350da0f636b745bc047860fbf8a29aef5fbcce8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash

usage_list+=("-ibcinstrument: generate IBC-tuning-enabled native images when invoking crossgen.")
usage_list+=("-partialngen: build CoreLib as PartialNGen.")
usage_list+=("-pgoinstrument: generate instrumented code for profile guided optimization enabled binaries.")

setup_dirs_local()
{
    setup_dirs

    mkdir -p "$__LogsDir"
}

build_CoreLib_ni()
{
    local __CrossGenExec=$1
    local __CoreLibILDir=$2

    if [[ "$__PartialNgen" == 1 ]]; then
        COMPlus_PartialNGen=1
        export COMPlus_PartialNGen
    fi

    if [[ -e "$__CrossGenCoreLibLog" ]]; then
        rm "$__CrossGenCoreLibLog"
    fi
    echo "Generating native image of System.Private.CoreLib.dll for $__TargetOS.$__BuildArch.$__BuildType. Logging to \"$__CrossGenCoreLibLog\"."
    echo "$__CrossGenExec /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll"
    "$__CrossGenExec" /nologo /Platform_Assemblies_Paths $__CoreLibILDir $__IbcTuning /out $__BinDir/System.Private.CoreLib.dll $__CoreLibILDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1
    local exit_code="$?"
    if [[ "$exit_code" != 0 ]]; then
        echo "${__ErrMsgPrefix}Failed to generate native image for System.Private.CoreLib. Refer to $__CrossGenCoreLibLog"
        exit "$exit_code"
    fi

    if [[ "$__TargetOS" == "Linux" ]]; then
        echo "Generating symbol file for System.Private.CoreLib.dll"
        echo "$__CrossGenExec /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll"
        "$__CrossGenExec" /nologo /Platform_Assemblies_Paths $__BinDir /CreatePerfMap $__BinDir $__BinDir/System.Private.CoreLib.dll >> $__CrossGenCoreLibLog 2>&1
        local exit_code="$?"
        if [[ "$exit_code" != 0 ]]; then
            echo "${__ErrMsgPrefix}Failed to generate symbol file for System.Private.CoreLib. Refer to $__CrossGenCoreLibLog"
            exit "$exit_code"
        fi
    fi
}

handle_arguments_local() {
    case "$1" in

        ibcinstrument|-ibcinstrument)
            __IbcTuning="/Tuning"
            ;;

        partialngen|-partialngen)
            __PartialNgen=1
            ;;

        pgoinstrument|-pgoinstrument)
            __PgoInstrument=1
            ;;

        *)
            __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1"
            ;;
    esac
}

echo "Commencing Crossgenning System.Private.CoreLib"

# Argument types supported by this script:
#
# Build architecture - valid values are: x64, ARM.
# Build Type         - valid values are: Debug, Checked, Release
#
# Set the default arguments for build

# Obtain the location of the bash script to figure out where the root of the repo is.
__ProjectRoot="$(cd "$(dirname "$0")"; pwd -P)"
__RepoRootDir="$(cd "$__ProjectRoot"/../..; pwd -P)"

__BuildArch=
__BuildType=Debug

__CrossBuild=0
__IbcTuning=""
__PartialNgen=0
__PgoInstrument=0
__RootBinDir="$__RepoRootDir/artifacts"
__SkipMSCorLib=0
__SkipRestore=""
__StaticAnalyzer=0
__UnprocessedBuildArgs=

source "$__ProjectRoot"/_build-commons.sh

if [[ "${__BuildArch}" != "${__HostArch}" ]] || [[ "$__BuildOS" != "$__TargetOS" ]]; then
    __CrossBuild=1
fi

# Set dependent variables
__LogsDir="$__RootBinDir/log/$__BuildType"

# Set the remaining variables based upon the determined build configuration
__BinDir="$__RootBinDir/bin/coreclr/$__TargetOS.$__BuildArch.$__BuildType"
__IntermediatesDir="$__RootBinDir/obj/coreclr/$__TargetOS.$__BuildArch.$__BuildType"
__CrossComponentBinDir="$__BinDir"

__CrossArch="$__HostArch"
if [[ "$__CrossBuild" == 1 ]]; then
    __CrossComponentBinDir="$__CrossComponentBinDir/$__CrossArch"
fi
__CrossGenCoreLibLog="$__LogsDir/CrossgenCoreLib_$__TargetOS.$__BuildArch.$__BuildType.log"

# Crossgen System.Private.CoreLib

__CoreLibILDir=$__BinDir/IL

setup_dirs_local

# The cross build generates a crossgen with the target architecture.
if [[ "$__CrossBuild" == 0 ]]; then
    # The architecture of host pc must be same architecture with target.
    if [[ "$__HostArch" == "$__BuildArch" ]]; then
        build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir"
    elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
        build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir"
    elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
        build_CoreLib_ni "$__BinDir/crossgen" "$__CoreLibILDir"
    else
        exit 1
    fi
else
    if [[ ( "$__CrossArch" == "x86" ) && ( "$__BuildArch" == "arm" ) ]]; then
        build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir"
    elif [[ ( "$__CrossArch" == "x64" ) && ( "$__BuildArch" == "arm" ) ]]; then
        build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir"
    elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "arm64" ) ]]; then
        build_CoreLib_ni "$__CrossComponentBinDir/crossgen" "$__CoreLibILDir"
    else
        # Crossgen not performed, so treat the IL version as the final version
        cp "$__CoreLibILDir"/System.Private.CoreLib.dll "$__BinDir"/System.Private.CoreLib.dll
    fi
fi


# Build complete

echo "Native System.Private.CoreLib generated."
echo "Product binaries are available at $__BinDir"
exit 0