From 6ae22c60728d7f7b27a353144a5542497aa56969 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Tue, 22 Apr 2025 10:20:09 +0800 Subject: [PATCH] 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 e624a90..4fd68ac 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 @@ -149,7 +151,7 @@ Name: llvm Name: llvm-toolset-%{maj_ver} %endif Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 35 +Release: 36 Summary: The Low Level Virtual Machine License: NCSA @@ -169,6 +171,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++ @@ -815,6 +821,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 \\\ @@ -1000,6 +1011,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 @@ -2830,6 +2847,10 @@ fi #endregion files %changelog +* Tue Apr 22 2025 liyunfei - 17.0.6-36 +- Fix mlir exports +- Add BiSheng-Autotuner && ACPO build + * Wed Apr 16 2025 liyunfei - 17.0.6-35 - bump release so that separated clang pacakges could be updated - update to real upstream url -- Gitee