Enable Mono ARM & ARM64 Linux builds (#32181)
authorJo Shields <directhex@apebox.org>
Thu, 13 Feb 2020 06:15:20 +0000 (01:15 -0500)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2020 06:15:20 +0000 (01:15 -0500)
* Enable cross-compiling for ARM{64} with ./mono.sh --arch arm{64}

* Add Mono ARM/ARM64 builds to CI

* Ensure we don't use win-arm64 RID on `./mono --pack`

* Don't replace prof_ldflags on non-Linux

eng/pipelines/mono/templates/build-job.yml
eng/pipelines/runtime.yml
src/mono/configure.ac
src/mono/mono.proj
src/mono/mono/mini/Makefile.am.in
src/mono/mono/profiler/Makefile.am
src/mono/netcore/nuget/Directory.Build.props

index ea80704..37b978d 100644 (file)
@@ -10,6 +10,7 @@ parameters:
   pool: ''
   condition: true
   llvm: false
+  crossrootfsDir: ''
 
 ### Product build
 jobs:
@@ -23,6 +24,7 @@ jobs:
     enableMicrobuild: true
     pool: ${{ parameters.pool }}
     llvm: ${{ parameters.llvm }}
+    crossrootfsDir: ${{ parameters.crossroofsDir }}
     condition: ${{ parameters.condition }}
 
     # Compute job name from template parameters
index 47c8516..33a5345 100644 (file)
@@ -210,8 +210,8 @@ jobs:
     platforms:
     - OSX_x64
     - Linux_x64
-    - Linux_arm
-    - Linux_arm64
+    - Linux_arm
+    - Linux_arm64
     - Linux_musl_x64
     # - Linux_musl_arm64
     - Windows_NT_x64
@@ -237,8 +237,8 @@ jobs:
     platforms:
     - OSX_x64
     - Linux_x64
-    - Linux_arm
-    - Linux_arm64
+    - Linux_arm
+    - Linux_arm64
     - Linux_musl_x64
     # - Linux_musl_arm64
     - Windows_NT_x64
index 8fa9176..eb04971 100644 (file)
@@ -6752,6 +6752,7 @@ AC_COMPILE_IFELSE(
 AC_SUBST(CFLAGS)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(LDFLAGS)
+AC_SUBST(CCLDFLAGS)
 AC_SUBST(ZLIB_CFLAGS)
 
 # Update all submodules recursively to ensure everything is checked out
index 4e724c9..29c5031 100644 (file)
         <_MonoExtraCFLAGS>-O2 -g</_MonoExtraCFLAGS>
         <_MonoExtraCXXFLAGS>-O2 -g</_MonoExtraCXXFLAGS>
     </PropertyGroup>
+    <PropertyGroup Condition=" '$(TargetArchitecture)' == 'arm64' ">
+        <_MonoTuple>aarch64-linux-gnu</_MonoTuple>
+    </PropertyGroup>
+    <PropertyGroup Condition=" '$(TargetArchitecture)' == 'arm' ">
+        <_MonoTuple>arm-linux-gnueabihf</_MonoTuple>
+    </PropertyGroup>
+    <PropertyGroup Condition=" '$(TargetArchitecture)' == 'arm' Or '$(TargetArchitecture)' == 'arm64' ">
+        <_MonoCrossDir>$(ROOTFS_DIR)</_MonoCrossDir>
+        <_MonoExtraCFLAGS>$(_MonoExtraCFLAGS) --sysroot=$(_MonoCrossDir) --target=$(_MonoTuple)</_MonoExtraCFLAGS>
+        <_MonoExtraCXXFLAGS>$(_MonoExtraCXXFLAGS) --sysroot=$(_MonoCrossDir) --target=$(_MonoTuple)</_MonoExtraCXXFLAGS>
+        <_MonoExtraLDFLAGS>$(_MonoExtraLDFLAGS) --sysroot=$(_MonoCrossDir) --target=$(_MonoTuple)</_MonoExtraLDFLAGS>
+        <_MonoExtraCCLDFLAGS>$(_MonoExtraCCLDFLAGS) -XCClinker --target=$(_MonoTuple)</_MonoExtraCCLDFLAGS>
+        <_MonoConfigureParams>$(_MonoConfigureParams) --host=$(_MonoTuple) --target=$(_MonoTuple)</_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) RANLIB=$(_MonoTuple)-ranlib</_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) LD=$(_MonoTuple)-ld</_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) AS=$(_MonoTuple)-as</_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) AR=$(_MonoTuple)-ar</_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) STRIP=$(_MonoTuple)-strip</_MonoConfigureParams>
+    </PropertyGroup>
     <PropertyGroup>
         <_MonoConfigureParams Condition="'$(MonoEnableLLVM)' == 'true'">$(_MonoConfigureParams) --with-llvm=$(MonoLLVMDir) </_MonoConfigureParams>
-        <_MonoConfigureParams>$(_MonoConfigureParams) --enable-maintainer-mode --enable-compile-warnings --with-core=only CFLAGS="$(_MonoExtraCFLAGS)" CXXFLAGS="$(_MonoExtraCXXFLAGS)"</_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) --enable-maintainer-mode --enable-compile-warnings --with-core=only </_MonoConfigureParams>
+        <_MonoConfigureParams>$(_MonoConfigureParams) CFLAGS="$(_MonoExtraCFLAGS)" CXXFLAGS="$(_MonoExtraCXXFLAGS)" LDFLAGS="$(_MonoExtraLDFLAGS)" CCLDFLAGS="$(_MonoExtraCCLDFLAGS)"</_MonoConfigureParams>
     </PropertyGroup>
 
     <Message Text="Configuring Mono with '$(_MonoConfigureParams)'" Importance="High" />
index eeff6aa..d23249e 100755 (executable)
@@ -772,13 +772,13 @@ libmonoboehm_2_0_la_SOURCES =
 libmonoboehm_2_0_la_CFLAGS = $(mono_boehm_CFLAGS) @CXX_ADD_CFLAGS@
 
 libmonoboehm_2_0_la_LIBADD = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(boehm_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
-libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) 
+libmonoboehm_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) $(CCLDFLAGS)
 
 libmonosgen_2_0_la_SOURCES =
 libmonosgen_2_0_la_CFLAGS = $(mono_sgen_CFLAGS) @CXX_ADD_CFLAGS@
 
 libmonosgen_2_0_la_LIBADD = libmini.la $(interp_libs_with_mini) $(dbg_libs_with_mini) $(sgen_libs) $(LIBMONO_DTRACE_OBJECT) $(LLVMMONOF)
-libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) 
+libmonosgen_2_0_la_LDFLAGS = $(libmonoldflags) $(monobin_platform_ldflags) $(CCLDFLAGS)
 
 noinst_LIBRARIES += libmaintest.a
 
index 4d8acff..acb1057 100644 (file)
@@ -8,6 +8,8 @@ AM_CPPFLAGS = \
 
 glib_libs = $(top_builddir)/mono/eglib/libeglib.la
 
+prof_ldflags = $(CCLDFLAGS)
+
 if !HOST_WIN32
 if !DISABLE_LIBRARIES
 if !DISABLE_PROFILER
@@ -52,9 +54,9 @@ endif
 # shared libraries, so we want errors if the profiler modules contain any.
 if HOST_DARWIN
 if BITCODE
-prof_ldflags = -no-undefined
+prof_ldflags += -no-undefined
 else
-prof_ldflags = -Wl,-undefined -Wl,suppress -Wl,-flat_namespace
+prof_ldflags += -Wl,-undefined -Wl,suppress -Wl,-flat_namespace
 endif
 endif
 
@@ -63,7 +65,7 @@ endif
 # profiler modules contain versioned sonames, things will fail to resolve
 # at runtime.
 if HOST_ANDROID
-prof_ldflags = -avoid-version
+prof_ldflags += -avoid-version
 endif
 
 # Linking to libmono on desktop can cause problems when loading a profiler
@@ -154,9 +156,9 @@ if HOST_WIN32
 # (borrowed from mono/tests/Makefile.am libtest_la_LDFLAGS)
 # the exported names created by gcc for stdcall functions are missing the leading _, so MS.NET
 # can't find them. So we use --kill-at to remove the @ suffix as well.
-libproftest_pinvokes_la_LDFLAGS = -no-undefined -rpath `pwd` -Wl,--kill-at
+libproftest_pinvokes_la_LDFLAGS = -no-undefined -rpath `pwd` $(CCLDFLAGS) -Wl,--kill-at
 else
-libproftest_pinvokes_la_LDFLAGS = -no-undefined -rpath `pwd`
+libproftest_pinvokes_la_LDFLAGS = -no-undefined -rpath `pwd` $(CCLDFLAGS)
 endif
 
 
index 56e8310..778b94b 100644 (file)
@@ -18,7 +18,7 @@
     <_distroRidIndex>$(_parseDistroRid.IndexOfAny("-"))</_distroRidIndex>
     <_archRidIndex>$([MSBuild]::Add($(_distroRidIndex), 1))</_archRidIndex>
     <OSRid Condition="'$(OSRid)' == '' and '$(_distroRidIndex)' != '-1'">$(_parseDistroRid.SubString(0, $(_distroRidIndex)))</OSRid>
-    <OSRid Condition="'$(OSRid)' == ''">win10</OSRid>
+    <OSRid Condition="'$(OSRid)' == ''">$(MonoOSGroup)</OSRid>
 
     <RuntimeOS Condition="'$(RuntimeOS)' == ''">$(OSRid)</RuntimeOS>