[Tizen] Enable PGO for Linux/arm
authorKonstantin Baladurin <k.baladurin@samsung.com>
Thu, 18 Apr 2019 09:29:56 +0000 (12:29 +0300)
committerKonstantin Baladurin <k.baladurin@samsung.com>
Wed, 25 Sep 2019 21:24:27 +0000 (00:24 +0300)
.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/clrjit.profdata [new file with mode: 0644]
.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/coreclr.profdata [new file with mode: 0644]
packaging/coreclr.spec
pgosupport.cmake

diff --git a/.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/clrjit.profdata b/.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/clrjit.profdata
new file mode 100644 (file)
index 0000000..5377cc5
Binary files /dev/null and b/.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/clrjit.profdata differ
diff --git a/.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/coreclr.profdata b/.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/coreclr.profdata
new file mode 100644 (file)
index 0000000..483d897
Binary files /dev/null and b/.packages/optimization.linux-arm.pgo.coreclr/99.99.99-master-20190912.1/data/coreclr.profdata differ
index 021938d..58450e4 100755 (executable)
@@ -2,6 +2,10 @@
 
 %define skipnative 0
 %define skipmscorlib 0
+
+%define pgo_instrument 0
+%define pgo_optimize 1
+
 %ifarch %{ix86}
 %define dotnet_buildtype Release
 %endif
@@ -78,6 +82,11 @@ BuildRequires:  libopenssl-64bit
 %endif
 %endif
 
+%if 0%{pgo_instrument} || 0%{pgo_optimize}
+BuildRequires:  binutils-gold
+BuildRequires:  compiler-rt
+%endif
+
 %description
 The CoreCLR repo contains the complete runtime implementation for .NET Core. It includes RyuJIT, the .NET GC, native interop and many other components. It is cross-platform, with multiple OS and CPU ports in progress.
 
@@ -178,6 +187,20 @@ export CXXFLAGS+="-fstack-protector-strong"
 %endif
 %endif
 
+%if 0%{skipnative}
+%else
+%if 0%{pgo_instrument}
+%define _pgo_flags -pgoinstrument
+%else
+%if 0%{pgo_optimize}
+# pgo optimization is enabled by default
+%define _pgo_flags ""
+%else
+%define _pgo_flags -nopgooptimize
+%endif
+%endif
+%endif
+
 %ifarch %{arm}
 %define _ngen_relocs_opts cmakeargs "-DFEATURE_NGEN_RELOCS_OPTIMIZATIONS=true"
 %else
@@ -191,7 +214,7 @@ export CXXFLAGS+="-fstack-protector-strong"
 # Build native only.
 export NUGET_PACKAGES=%{_builddir}/%{name}-%{version}/.packages/
 export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/libicu-57.1/
-./build.sh -%{_barch} -%{_buildtype} -numproc %{_numproc} -clang3.8 -skipmscorlib -skipgenerateversion -skipnuget -msbuildonunsupportedplatform -cmakeargs "-DFEATURE_GDBJIT=TRUE -DFEATURE_PREJIT=true -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro" %{_ngen_relocs_opts}
+./build.sh -%{_barch} -%{_buildtype} -numproc %{_numproc} -skipmscorlib -skipgenerateversion -skipnuget -msbuildonunsupportedplatform -cmakeargs "-DFEATURE_GDBJIT=TRUE -DFEATURE_PREJIT=true -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro" %{_ngen_relocs_opts} %{_pgo_flags}
 %endif
 %else
 %if 0%{skipnative}
@@ -203,7 +226,7 @@ export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/libicu-57.1/
 # Build native and mscorlib.
 export NUGET_PACKAGES=%{_builddir}/%{name}-%{version}/.packages/
 export LD_LIBRARY_PATH=%{_builddir}/%{name}-%{version}/libicu-57.1/
-./build.sh -%{_barch} -%{_buildtype} -numproc %{_numproc} -clang3.8 -skipgenerateversion -skiprestore -skiprestoreoptdata -skipnuget -skipcrossgen -msbuildonunsupportedplatform -cmakeargs "-DFEATURE_GDBJIT=TRUE -DFEATURE_PREJIT=true -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro" %{_ngen_relocs_opts}
+./build.sh -%{_barch} -%{_buildtype} -numproc %{_numproc} -skipgenerateversion -skiprestore -skiprestoreoptdata -skipnuget -skipcrossgen -msbuildonunsupportedplatform -cmakeargs "-DFEATURE_GDBJIT=TRUE -DFEATURE_PREJIT=true -DFEATURE_ENABLE_NO_ADDRESS_SPACE_RANDOMIZATION=true -DCLR_ADDITIONAL_LINKER_FLAGS=-Wl,-z,relro" %{_ngen_relocs_opts} %{_pgo_flags}
 %endif
 %endif
 
index dec0500..514c725 100644 (file)
@@ -22,8 +22,8 @@ function(add_pgo TargetName)
             set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS_RELWITHDEBINFO " /LTCG /GENPROFILE")
         else(WIN32)
             if(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
-                target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-generate)
-                set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-generate")
+                target_compile_options(${TargetName} PRIVATE -flto -fprofile-instr-generate=/tmp/${TargetName}-%p.profdata)
+                set_property(TARGET ${TargetName} APPEND_STRING PROPERTY LINK_FLAGS " -flto -fuse-ld=gold -fprofile-instr-generate=/tmp/${TargetName}-%p.profdata")
             endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
         endif(WIN32)
     elseif(CLR_CMAKE_PGO_OPTIMIZE)