From eac9c41c0d7a24a97383c285616a3d6f9ad98e5b Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 22 Apr 2025 10:20:09 +0800 Subject: [PATCH 1/2] Fix mlir exports & Add BiSheng-Autotuner/ACPO build --- ...e-Use-correct-exports-for-MLIR-tools.patch | 39 +++++++++++++++++++ ...Fix-for-building-autotuner-with-mlir.patch | 12 ++++++ llvm.spec | 23 ++++++++++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 0006-CMake-Use-correct-exports-for-MLIR-tools.patch create mode 100644 0007-Fix-for-building-autotuner-with-mlir.patch diff --git a/0006-CMake-Use-correct-exports-for-MLIR-tools.patch b/0006-CMake-Use-correct-exports-for-MLIR-tools.patch new file mode 100644 index 0000000..d147ade --- /dev/null +++ b/0006-CMake-Use-correct-exports-for-MLIR-tools.patch @@ -0,0 +1,39 @@ +From b443e55162861125a50048ae9bc521e98058b273 Mon Sep 17 00:00:00 2001 +From: Nikita Popov +Date: Mon, 16 Dec 2024 14:44:43 +0100 +Subject: [PATCH] [CMake] Use correct exports file for MLIR tools + +llvm_add_tool() currently does not respect the passed project and +puts all tools into LLVMExports.cmake. This means that we end up +with binaries like mlir-opt in LLVMExports.cmake instead of +MLIRTargets.cmake, where they should be. + +Adjust llvm_add_tool() to take the project into account. +--- + llvm/cmake/modules/AddLLVM.cmake | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake +index 006dfb6de3a199..6cf0ee1a54dbdb 100644 +--- a/llvm/cmake/modules/AddLLVM.cmake ++++ b/llvm/cmake/modules/AddLLVM.cmake +@@ -1483,7 +1483,7 @@ macro(llvm_add_tool project name) + + if ( ${name} IN_LIST LLVM_TOOLCHAIN_TOOLS OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY) + if( LLVM_BUILD_TOOLS ) +- get_target_export_arg(${name} LLVM export_to_llvmexports) ++ get_target_export_arg(${name} ${project} export_to_llvmexports) + install(TARGETS ${name} + ${export_to_llvmexports} + RUNTIME DESTINATION ${${project}_TOOLS_INSTALL_DIR} +@@ -1497,7 +1497,8 @@ macro(llvm_add_tool project name) + endif() + endif() + if( LLVM_BUILD_TOOLS ) +- set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name}) ++ string(TOUPPER "${project}" project_upper) ++ set_property(GLOBAL APPEND PROPERTY ${project_upper}_EXPORTS ${name}) + endif() + set_target_properties(${name} PROPERTIES FOLDER "Tools") + endif() +-- \ No newline at end of file diff --git a/0007-Fix-for-building-autotuner-with-mlir.patch b/0007-Fix-for-building-autotuner-with-mlir.patch new file mode 100644 index 0000000..eeadc49 --- /dev/null +++ b/0007-Fix-for-building-autotuner-with-mlir.patch @@ -0,0 +1,12 @@ +diff --git a/mlir/lib/CMakeLists.txt b/mlir/lib/CMakeLists.txt +index c71664a3f006..76fbb3c10570 100644 +--- a/mlir/lib/CMakeLists.txt ++++ b/mlir/lib/CMakeLists.txt +@@ -1,5 +1,5 @@ + # Enable errors for any global constructors. +-add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR) ++# add_flag_if_supported("-Werror=global-constructors" WERROR_GLOBAL_CONSTRUCTOR) + + add_subdirectory(Analysis) + add_subdirectory(AsmParser) +-- \ No newline at end of file diff --git a/llvm.spec b/llvm.spec index 76de520..6ef1c09 100644 --- a/llvm.spec +++ b/llvm.spec @@ -10,6 +10,8 @@ %bcond_without sys_llvm %bcond_without check %bcond_without toolchain_clang +%bcond_without bisheng_autotuner +%bcond_without ACPO # mlir requires pybind11-2.9 but 22.03 only have pybind11-2.8 %if %{os_version} <= 2203 @@ -150,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 36 +Release: 37 Summary: The Low Level Virtual Machine License: NCSA @@ -170,6 +172,10 @@ Patch0003: 0003-fedora-standalone.patch Patch0004: 0004-remove-cmake_minimum_required.patch %endif Patch0005: 0005-Bugfix-ARM-fix-for-backported-test-case-for-CVE-2024-7883.patch +Patch0006: 0006-CMake-Use-correct-exports-for-MLIR-tools.patch +%if %{with bisheng_autotuner} +Patch0007: 0007-Fix-for-building-autotuner-with-mlir.patch +%endif BuildRequires: gcc BuildRequires: gcc-c++ @@ -816,6 +822,11 @@ export ASMFLAGS="%{build_cflags}" -DCMAKE_USE_LINKER=lld %endif +%if %{with bisheng_autotuner} +%global cmake_config_args %{cmake_config_args} \\\ + -DLLVM_ENABLE_AUTOTUNER=ON +%endif + #region clang options %global cmake_config_args %{cmake_config_args} \\\ -DCLANG_BUILD_EXAMPLES:BOOL=OFF \\\ @@ -1001,6 +1012,12 @@ export ASMFLAGS="%{build_cflags}" extra_cmake_args='' #endregion cmake options +%if %{with ACPO} + echo "enable ACPO" + export CFLAGS="-Wp,-DENABLE_ACPO ${CFLAGS}" + export CXXFLAGS="-Wp,-DENABLE_ACPO ${CXXFLAGS}" +%endif + %if %{os_version} <= 2403 mkdir _build cd _build @@ -2831,6 +2848,10 @@ fi #endregion files %changelog +* Tue Apr 22 2025 liyunfei - 17.0.6-37 +- Fix mlir exports +- Add BiSheng-Autotuner && ACPO build + * Thu Apr 17 2025 liyunfei - 17.0.6-36 - switch back to clang compiler -- Gitee From 5ee782ac71316a8907cfeab6506e86855ec12cea Mon Sep 17 00:00:00 2001 From: liyunfei Date: Thu, 24 Apr 2025 15:17:07 +0800 Subject: [PATCH 2/2] llvm-mlir add obsoletes mlir --- llvm.spec | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/llvm.spec b/llvm.spec index 6ef1c09..e16fc53 100644 --- a/llvm.spec +++ b/llvm.spec @@ -152,7 +152,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 37 +Release: 38 Summary: The Low Level Virtual Machine License: NCSA @@ -524,7 +524,7 @@ URL: http://openmp.llvm.org Requires: %{pkg_name_llvm}-libs%{?_isa} = %{version}-%{release} Requires: elfutils-libelf -Provides: libomp(major) = %{maj_ver} +Provides: %{?scl_prefix}libomp = %{version}-%{release} Obsoletes: %{?scl_prefix}libomp < %{version}-%{release} %description -n %{pkg_name_libomp} @@ -538,7 +538,7 @@ URL: http://openmp.llvm.org Requires: %{pkg_name_libomp}%{?_isa} = %{version}-%{release} Requires: %{pkg_name_clang}-resource-filesystem%{?_isa} = %{version}-%{release} -Provides: libomp-devel(major) = %{maj_ver} +Provides: %{?scl_prefix}libomp-devel = %{version}-%{release} Obsoletes: %{?scl_prefix}libomp-devel < %{version}-%{release} %description -n %{pkg_name_libomp}-devel @@ -630,6 +630,9 @@ Summary: Multi-Level Intermediate Representation Overview License: Apache-2.0 WITH LLVM-exception URL: http://mlir.llvm.org +Provides: %{?scl_prefix}mlir = %{version}-%{release} +Obsoletes: %{?scl_prefix}mlir < %{version}-%{release} + %description -n %{pkg_name_mlir} The MLIR project is a novel approach to building reusable and extensible compiler infrastructure. MLIR aims to address software fragmentation, @@ -640,6 +643,8 @@ existing compilers together. %package -n %{pkg_name_mlir}-static Summary: MLIR static files Requires: %{pkg_name_mlir}%{?_isa} = %{version}-%{release} +Provides: %{?scl_prefix}mlir-static = %{version}-%{release} +Obsoletes: %{?scl_prefix}mlir-static < %{version}-%{release} %description -n %{pkg_name_mlir}-static MLIR static files. @@ -648,6 +653,8 @@ MLIR static files. Summary: MLIR development files Requires: %{pkg_name_mlir}%{?_isa} = %{version}-%{release} Requires: %{pkg_name_mlir}-static%{?_isa} = %{version}-%{release} +Provides: %{?scl_prefix}mlir-devel = %{version}-%{release} +Obsoletes: %{?scl_prefix}mlir-devel < %{version}-%{release} %description -n %{pkg_name_mlir}-devel MLIR development files. @@ -2848,6 +2855,10 @@ fi #endregion files %changelog +* Tue Apr 22 2025 liyunfei - 17.0.6-38 +- llvm-mlir add obsoletes mlir +- openmp add obsoletes libomp + * Tue Apr 22 2025 liyunfei - 17.0.6-37 - Fix mlir exports - Add BiSheng-Autotuner && ACPO build -- Gitee