Architecture of host must be compitable architecture with target.
authorGeunsik Lim <geunsik.lim@samsung.com>
Wed, 16 Mar 2016 13:42:14 +0000 (22:42 +0900)
committerGeunsik Lim <geunsik.lim@samsung.com>
Fri, 18 Mar 2016 13:17:16 +0000 (22:17 +0900)
Let's make exception handling for different architecture between
host pc and target board during build-time.

V3:
- Simplify the existing 'if' statement

V2:
- Added $HostArch variable to handle the required architectures.

V1:
- Handle "time ./build.sh arm debug clean verbose" command
in case that generate only mscorlib.dll for Linux/ARM as well as the
existing case of if [ $__CrossBuild != 1 ]

In this case, we need to add additional if statements because the
architecture of host pc must be same architecture with target.

Signed-off-by: Geunsik Lim geunsik.lim@samsung.com
Signed-off-by: Prajwal A N an.prajwal@samsung.com
Signed-off-by: MyungJoo Ham myungjoo.ham@samsung.com
Commit migrated from https://github.com/dotnet/coreclr/commit/27a646569f549173c4a846a2283228d4f863b422

src/coreclr/build.sh

index 2d8fb46..f7f690e 100755 (executable)
@@ -222,6 +222,18 @@ isMSBuildOnNETCoreSupported()
     fi
 }
 
+build_mscorlib_ni()
+{
+    if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
+        echo "Generating native image for mscorlib."
+        $__BinDir/crossgen $__BinDir/mscorlib.dll
+        if [ $? -ne 0 ]; then
+            echo "Failed to generate native image for mscorlib."
+            exit 1
+        fi
+    fi
+}
+
 build_mscorlib()
 {
 
@@ -251,17 +263,21 @@ build_mscorlib()
 
     # The cross build generates a crossgen with the target architecture.
     if [ $__CrossBuild != 1 ]; then
-       if [ $__SkipCoreCLR == 0 -a -e $__BinDir/crossgen ]; then
-           echo "Generating native image for mscorlib."
-           $__BinDir/crossgen $__BinDir/mscorlib.dll
-           if [ $? -ne 0 ]; then
-               echo "Failed to generate native image for mscorlib."
-               exit 1
-           fi
+       # The architecture of host pc must be same architecture with target.
+       if [[ ( "$__HostArch" == "$__BuildArch" ) ]]; then
+           build_mscorlib_ni
+       elif [[ ( "$__HostArch" == "x64" ) && ( "$__BuildArch" == "x86" ) ]]; then
+           build_mscorlib_ni
+       elif [[ ( "$__HostArch" == "arm64" ) && ( "$__BuildArch" == "arm" ) ]]; then
+           build_mscorlib_ni
+       else 
+          exit 1
        fi
     fi 
 }
 
+
+
 generate_NugetPackages()
 {
     # We can only generate nuget package if we also support building mscorlib as part of this build.
@@ -315,25 +331,30 @@ case $CPUName in
     i686)
         echo "Unsupported CPU $CPUName detected, build might not succeed!"
         __BuildArch=x86
+        __HostArch=x86
         ;;
 
     x86_64)
         __BuildArch=x64
+        __HostArch=x64
         ;;
 
     armv7l)
         echo "Unsupported CPU $CPUName detected, build might not succeed!"
         __BuildArch=arm
+        __HostArch=arm
         ;;
 
     aarch64)
         echo "Unsupported CPU $CPUName detected, build might not succeed!"
         __BuildArch=arm64
+        __HostArch=arm64
         ;;
 
     *)
         echo "Unknown CPU $CPUName detected, configuring as if for x64"
         __BuildArch=x64
+        __HostArch=x64
         ;;
 esac