[Tizen] Add gbs support
authorGleb Balykov <g.balykov@samsung.com>
Mon, 5 Aug 2019 13:26:44 +0000 (16:26 +0300)
committerMikhail Kurinnoi <m.kurinnoi@samsung.com>
Tue, 5 Dec 2023 16:28:21 +0000 (19:28 +0300)
[Tizen] Add gbs support

[Tizen] Publish diagnostic tools

- Remove devel package
- Create tools package for new managed tools (e.g. dotnet-trace)
- Organize BuildRequires and etc.

[Tizen] Set permissions and smack rules (#9)

[Tizen] Use -mstackrealign to sync up with Tizen build changes

Tizen i586 now builds with -mstackrealign by default:

    "Realign the stack at entry. On the x86, the -mstackrealign option
    generates an alternate prologue and epilogue that realigns the
    run-time stack if necessary. This supports mixing legacy codes that
    keep 4-byte stack alignment with modern codes that keep 16-byte
    stack alignment for SSE compatibility. ..."

[Tizen] Create a symlink to libsos.so path (#13)

[Tizen] Version bump to 3.1.0

[Tizen] Add dotnet-gcdump

[Tizen] Generate tools R2R images

[Tizen] Move Tools directory (#24)

The new location is now /home/owner/share/.dotnet/tools.

[Tizen] Remove native images of executables (#25)

[Tizen] Fix build command (#26)

eng/build.sh
packaging/coreclr-diagnostics-rpmlintrc [new file with mode: 0644]
packaging/coreclr-diagnostics.manifest [new file with mode: 0755]
packaging/coreclr-diagnostics.spec [new file with mode: 0755]

index db449d4ac0d4d14f677e5ff6f411a08f1afe49e1..4c353bceaf2f0ea722136a94a6b34728ec6877a9 100755 (executable)
@@ -135,6 +135,75 @@ if [[ "$__TargetArch" == "armel" ]]; then
     __PortableBuild=0
 fi
 
+# Configure environment if we are doing a cross compile.
+if [ "$__CrossBuild" == true ]; then
+    __CrossBuild=true
+    export CROSSCOMPILE=1
+    if [ "${__BuildOS}" != "OSX" ]; then
+        if ! [[ -n "$ROOTFS_DIR" ]]; then
+            echo "ERROR: ROOTFS_DIR not set for cross build"
+            exit 1
+        fi
+        echo "ROOTFS_DIR: $ROOTFS_DIR"
+    fi
+fi
+
+mkdir -p "$__IntermediatesDir"
+mkdir -p "$__LogDir"
+mkdir -p "$__CMakeBinDir"
+
+build_native()
+{
+    platformArch="$1"
+    intermediatesForBuild="$2"
+    extraCmakeArguments="$3"
+
+    # All set to commence the build
+    echo "Commencing $__DistroRid build for $__BuildOS.$__BuildArch.$__BuildType in $intermediatesForBuild"
+
+    generator=""
+    buildFile="Makefile"
+    buildTool="make"
+    scriptDir="$__ProjectRoot/eng"
+
+    pushd "$intermediatesForBuild"
+    echo "Invoking \"$scriptDir/gen-buildsys-clang.sh\" \"$__ProjectRoot\" $__ClangMajorVersion \"$__ClangMinorVersion\" $platformArch "$scriptDir" $__BuildType $generator $extraCmakeArguments"
+    "$scriptDir/gen-buildsys-clang.sh" "$__ProjectRoot" $__ClangMajorVersion "$__ClangMinorVersion" $platformArch "$scriptDir" $__BuildType $generator "$extraCmakeArguments"
+    popd
+
+    if [ ! -f "$intermediatesForBuild/$buildFile" ]; then
+        echo "Failed to generate build project!"
+        exit 1
+    fi
+
+    # Check that the makefiles were created.
+    pushd "$intermediatesForBuild"
+
+    echo "Executing $buildTool install -j $__NumProc"
+
+    $buildTool install -j $__NumProc | tee $__LogDir/make.log
+    if [ $? != 0 ]; then
+        echo "Failed to build."
+        exit 1
+    fi
+
+    popd
+}
+
+initTargetDistroRid()
+{
+    source "$__ProjectRoot/eng/init-distro-rid.sh"
+
+    local passedRootfsDir=""
+
+    # Only pass ROOTFS_DIR if cross is specified and the current platform is not OSX that doesn't use rootfs
+    if [ $__CrossBuild == true  -a "$__HostOS" != "OSX" ]; then
+        passedRootfsDir=${ROOTFS_DIR}
+    fi
+
+    initDistroRidGlobal ${__BuildOS} ${__BuildArch} ${__PortableBuild} ${passedRootfsDir}
+}
+
 #
 # Managed build
 #
diff --git a/packaging/coreclr-diagnostics-rpmlintrc b/packaging/coreclr-diagnostics-rpmlintrc
new file mode 100644 (file)
index 0000000..edcdd8e
--- /dev/null
@@ -0,0 +1,2 @@
+# This package should install an ELF binary in the /usr/share hierarchy.
+addFilter("E: arch-dependent-file-in-usr-share")
diff --git a/packaging/coreclr-diagnostics.manifest b/packaging/coreclr-diagnostics.manifest
new file mode 100755 (executable)
index 0000000..712cb40
--- /dev/null
@@ -0,0 +1,8 @@
+<manifest>
+  <request>
+    <domain name="_"/>
+  </request>
+  <assign>
+    <filesystem path="/home/owner/share/.dotnet" label="User::App::Shared" type="transmutable" />
+  </assign>
+</manifest>
diff --git a/packaging/coreclr-diagnostics.spec b/packaging/coreclr-diagnostics.spec
new file mode 100755 (executable)
index 0000000..c60a151
--- /dev/null
@@ -0,0 +1,202 @@
+%{!?dotnet_buildtype: %define dotnet_buildtype Release}
+
+%define dotnet_version 6.0.0
+
+Name:       coreclr-diagnostics
+Version:    6.0.0
+Release:    0
+Summary:    Microsoft .NET Core runtime diagnostic tools
+Group:      Development/Languages
+License:    MIT
+URL:        https://github.com/dotnet/diagnostics
+Source0:    %{name}-%{version}.tar.gz
+Source1:    %{name}.manifest
+
+ExcludeArch: aarch64
+
+BuildRequires: clang >= 3.8
+BuildRequires: clang-devel >= 3.8
+BuildRequires: cmake
+BuildRequires: coreclr-devel
+BuildRequires: corefx-managed
+BuildRequires: gettext-tools
+BuildRequires: libopenssl1.1-devel
+BuildRequires: libstdc++-devel
+BuildRequires: lldb >= 3.8
+BuildRequires: lldb-devel >= 3.8
+BuildRequires: llvm >= 3.8
+BuildRequires: llvm-devel >= 3.8
+BuildRequires: pkgconfig(libunwind)
+BuildRequires: pkgconfig(lttng-ust)
+BuildRequires: pkgconfig(uuid)
+BuildRequires: python
+BuildRequires: tizen-release
+
+%ifarch %{arm}
+BuildRequires: python-accel-armv7l-cross-arm
+BuildRequires: clang-accel-armv7l-cross-arm
+BuildRequires: patchelf
+%endif
+
+%ifarch aarch64
+BuildRequires: python-accel-aarch64-cross-aarch64
+BuildRequires: clang-accel-aarch64-cross-aarch64
+%endif
+
+%ifarch %{ix86}
+BuildRequires: patchelf
+BuildRequires: glibc-64bit
+BuildRequires: libgcc-64bit
+BuildRequires: libopenssl11-64bit
+BuildRequires: libstdc++-64bit
+BuildRequires: libunwind-64bit
+BuildRequires: libuuid-64bit
+BuildRequires: zlib-64bit
+%endif
+
+AutoReq: 0
+Requires: coreclr
+Requires: corefx-managed
+Requires: glibc
+Requires: libgcc
+Requires: libstdc++
+Requires: libunwind
+Requires: libuuid
+
+%description
+This package contains components for basic .NET debugging and diagnostic support.
+
+%package tools
+Summary:  Diagnostic tools
+Requires: coreclr-diagnostics
+
+%description tools
+This package contains a collection of .NET diagnostic tools.
+
+%prep
+%setup -q -n %{name}-%{version}
+cp %{SOURCE1} .
+
+%ifarch %{arm}
+# Detect interpreter name from cross-gcc
+LD_INTERPRETER=$(patchelf --print-interpreter /emul/usr/bin/gcc)
+LD_RPATH=$(patchelf --print-rpath /emul/usr/bin/gcc)
+for file in $(find .dotnet -type f -name dotnet)
+do
+    patchelf --set-interpreter ${LD_INTERPRETER} ${file}
+    patchelf --set-rpath ${LD_RPATH}:%{_builddir}/%{name}-%{version}/libicu-57.1/ ${file}
+done
+for file in $(find .dotnet libicu-57.1 -iname *.so -or -iname *.so.*)
+do
+    patchelf --set-rpath ${LD_RPATH}:%{_builddir}/%{name}-%{version}/libicu-57.1/ ${file}
+done
+%endif
+
+%ifarch %{ix86}
+for file in $(find .dotnet libicu-57.1 -iname *.so -or -iname *.so.*)
+do
+    patchelf --set-rpath %{_builddir}/%{name}-%{version}/libicu-57.1/ ${file}
+done
+%endif
+
+%build
+BASE_FLAGS=" --target=%{_host} "
+
+%ifarch x86_64
+# Even though build architectur is x86_64, it will be running on arm board.
+# So we need to pass the arch argument as arm.
+%define _barch  %{?cross:%{cross}}%{!?cross:x64}
+%else
+%ifarch aarch64
+%define _barch  arm64
+%else
+%ifarch %{ix86}
+%define _barch  x86
+export CLANG_NO_LIBDIR_SUFFIX=1
+BASE_FLAGS=$(echo $BASE_FLAGS | sed -e 's/--target=i686/--target=i586/')
+BASE_FLAGS="$BASE_FLAGS -mstackrealign"
+%else
+%ifarch %{arm}
+%define _barch  armel
+export CLANG_NO_LIBDIR_SUFFIX=1
+%else
+
+%endif
+%endif
+%endif
+%endif
+
+export CFLAGS=$BASE_FLAGS
+export CXXFLAGS=$BASE_FLAGS
+
+%define _buildtype %{dotnet_buildtype}
+%define _artifacts artifacts/bin
+
+%ifarch %{arm}
+%if %{dotnet_buildtype} == "Release"
+export CXXFLAGS+="-fstack-protector-strong -D_FORTIFY_SOURCE=2"
+%else
+export CXXFLAGS+="-fstack-protector-strong"
+%endif
+%endif
+
+export NUGET_PACKAGES=%{_builddir}/%{name}-%{version}/packages
+export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/libicu-57.1
+
+./build.sh --configuration %{_buildtype} --build --restore /p:EnableSourceLink=false /p:EnableSourceControlManagerQueries=false
+./eng/build-native.sh --build-native --architecture %{_barch} --configuration %{_buildtype}
+
+%install
+%define netcoreappdir   %{_datadir}/dotnet/shared/Microsoft.NETCore.App/%{dotnet_version}
+%define toolsdir        /home/owner/share/.dotnet/tools
+
+%ifarch x86_64
+%define rid linux-x64
+%else
+%ifarch aarch64
+%define rid linux-arm64
+%else
+%ifarch %{ix86}
+%define rid linux-x86
+%else
+%ifarch %{arm}
+%define rid linux-arm
+%else
+
+%endif
+%endif
+%endif
+%endif
+
+# SOS
+mkdir -p %{buildroot}%{netcoreappdir}
+cp %{_artifacts}/Linux.%{_barch}.%{_buildtype}/*.so %{buildroot}%{netcoreappdir}
+cp %{_artifacts}/Linux.%{_barch}.%{_buildtype}/SOS.NETCore.dll %{buildroot}%{netcoreappdir}
+cp %{_artifacts}/Linux.%{_barch}.%{_buildtype}/Microsoft.FileFormats.dll %{buildroot}%{netcoreappdir}
+cp %{_artifacts}/Linux.%{_barch}.%{_buildtype}/Microsoft.SymbolStore.dll %{buildroot}%{netcoreappdir}
+
+# Tools
+mkdir -p %{buildroot}%{toolsdir}/%{rid}
+cp %{_artifacts}/Linux.%{_barch}.%{_buildtype}/*.so %{buildroot}%{toolsdir}/%{rid}
+for name in counters dump gcdump trace; do
+  cp -f %{_artifacts}/dotnet-${name}/%{_buildtype}/netcoreapp*/publish/*.dll %{buildroot}%{toolsdir}
+done
+find %{buildroot}%{toolsdir} -type f -exec chmod 644 {} +
+
+%ifnarch %{ix86}
+for f in $(grep -L "dotnet-" %{buildroot}%{toolsdir}/*.dll); do
+  %{_datarootdir}/dotnet.tizen/netcoreapp/crossgen /ReadyToRun /p %{_datarootdir}/dotnet.tizen/netcoreapp:`dirname $f` $f
+done
+%endif
+
+%files
+%manifest %{name}.manifest
+%{netcoreappdir}/*
+
+%files tools
+%manifest %{name}.manifest
+%dir %{toolsdir}
+%{toolsdir}/*
+
+%post tools
+chown -R owner:users /home/owner/share/.dotnet