diff --git a/0004-compiler-openEuler-oeaware-schedule-opt.patch b/0004-compiler-openEuler-oeaware-schedule-opt.patch new file mode 100644 index 0000000000000000000000000000000000000000..a943d81527fd3d09b1b1b1a0b3add7ce05bc67f8 --- /dev/null +++ b/0004-compiler-openEuler-oeaware-schedule-opt.patch @@ -0,0 +1,135 @@ +From fc738b99d4d5ad4e1a584c3f09b119a7134395c2 Mon Sep 17 00:00:00 2001 +From: lzy +Date: Wed, 11 Jun 2025 17:16:11 +0800 +Subject: [PATCH] compiler & openEuler oeaware schedule opt + +--- + lld/ELF/Config.h | 1 + + lld/ELF/Driver.cpp | 1 + + lld/ELF/SyntheticSections.cpp | 13 +++++++++++++ + lld/ELF/SyntheticSections.h | 15 +++++++++++++++ + lld/ELF/Writer.cpp | 1 + + lld/test/ELF/oeaware.s | 17 +++++++++++++++++ + 6 files changed, 48 insertions(+) + create mode 100644 lld/test/ELF/oeaware.s + +diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h +index 28726d48e428..4a2bf3476a3c 100644 +--- a/lld/ELF/Config.h ++++ b/lld/ELF/Config.h +@@ -338,6 +338,7 @@ struct Config { + uint8_t zStartStopVisibility; + bool zText; + bool zRetpolineplt; ++ int8_t zOeawarePolicy; + bool zWxneeded; + DiscardPolicy discard; + GnuStackKind zGnustack; +diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp +index eb6734dfd458..f874a41cd087 100644 +--- a/lld/ELF/Driver.cpp ++++ b/lld/ELF/Driver.cpp +@@ -1501,6 +1501,7 @@ static void readConfigs(opt::InputArgList &args) { + config->zStartStopVisibility = getZStartStopVisibility(args); + config->zText = getZFlag(args, "text", "notext", true); + config->zWxneeded = hasZOption(args, "wxneeded"); ++ config->zOeawarePolicy = args::getZOptionValue(args, OPT_z, "oeaware-policy", -1); + setUnresolvedSymbolPolicy(args); + config->power10Stubs = args.getLastArgValue(OPT_power10_stubs_eq) != "no"; + +diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp +index 41053c647275..78efef830af0 100644 +--- a/lld/ELF/SyntheticSections.cpp ++++ b/lld/ELF/SyntheticSections.cpp +@@ -4922,8 +4922,21 @@ template void elf::createSyntheticSections() { + add(*in.shStrTab); + if (in.strTab) + add(*in.strTab); ++ if (config->zOeawarePolicy != -1) { ++ in.oeaware = std::make_unique(); ++ add(*in.oeaware); ++ } ++} ++ ++void OeAware::writeTo(uint8_t *buf) { ++ if (config->zOeawarePolicy != -1) ++ write32(buf, config->zOeawarePolicy); + } + ++size_t OeAware::getSize() const { return 4; } ++ ++void OeAware::finalizeContents() {} ++ + InStruct elf::in; + + std::vector elf::partitions; +diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h +index d4169e1e1aca..8f11ad2b7648 100644 +--- a/lld/ELF/SyntheticSections.h ++++ b/lld/ELF/SyntheticSections.h +@@ -1425,6 +1425,20 @@ private: + SmallVector symbols; + }; + ++class OeAware : public SyntheticSection { ++public: ++ OeAware() ++ : SyntheticSection(llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_WRITE, ++ llvm::ELF::SHT_NOTE, /*alignment=*/4, ".LLVM4OE_oeAware") ++ {} ++ void writeTo(uint8_t *buf) override; ++ size_t getSize() const override; ++ void finalizeContents() override; ++ ++private: ++ uint64_t size; ++}; ++ + template void createSyntheticSections(); + InputSection *createInterpSection(); + MergeInputSection *createCommentSection(); +@@ -1512,6 +1526,7 @@ struct InStruct { + std::unique_ptr strTab; + std::unique_ptr symTab; + std::unique_ptr symTabShndx; ++ std::unique_ptr oeaware; + + void reset(); + }; +diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp +index 8e3a746a08eb..e22037f31c9e 100644 +--- a/lld/ELF/Writer.cpp ++++ b/lld/ELF/Writer.cpp +@@ -1961,6 +1961,7 @@ template void Writer::finalizeSections() { + llvm::TimeTraceScope timeScope("Finalize synthetic sections"); + + finalizeSynthetic(in.bss.get()); ++ finalizeSynthetic(in.oeaware.get()); + finalizeSynthetic(in.bssRelRo.get()); + finalizeSynthetic(in.symTabShndx.get()); + finalizeSynthetic(in.shStrTab.get()); +diff --git a/lld/test/ELF/oeaware.s b/lld/test/ELF/oeaware.s +new file mode 100644 +index 000000000000..50f66c228a34 +--- /dev/null ++++ b/lld/test/ELF/oeaware.s +@@ -0,0 +1,17 @@ ++# REQUIRES: target=aarch64{{.*}} ++# RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o ++# RUN: ld.lld %t.o -o %ta -z oeaware-policy=1 ++# RUN: llvm-objdump -j .LLVM4OE_oeAware %ta -d | FileCheck %s ++ ++# CHECK: <.LLVM4OE_oeAware>: ++# CHECK-NEXT: 00000001 ++ ++# RUN: ld.lld %t.o -o %tb -z oeaware-policy=2 ++# RUN: llvm-objdump -j .LLVM4OE_oeAware %tb -d | FileCheck %s --check-prefix=OPTION ++ ++# OPTION: <.LLVM4OE_oeAware>: ++# OPTION-NEXT: 00000002 ++ ++.globl _start ++_start: nop ++.bss; .byte 0 +-- +Gitee diff --git a/llvm-toolset-19.spec b/llvm-toolset-19.spec index 007242a8e2dab5153b195f37c20366049d3b1f88..bc933ab82e8b66f26531329c0c832d241d316df3 100644 --- a/llvm-toolset-19.spec +++ b/llvm-toolset-19.spec @@ -160,7 +160,7 @@ #region main package Name: llvm-toolset-%{maj_ver} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 9 +Release: 10 Summary: The Low Level Virtual Machine License: NCSA @@ -177,6 +177,7 @@ Source3: CMakeLists.txt.libomp Patch0001: 0001-PATCH-clang-Don-t-install-static-libraries.patch Patch0002: 0002-Always-build-shared-libs-for-LLD.patch Patch0003: 0003-PATCH-Bolt-CMake-Don-t-export-bolt-libraries-in-LLVM.patch +Patch0004: 0004-compiler-openEuler-oeaware-schedule-opt.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -2958,6 +2959,9 @@ fi #endregion files %changelog +* Thu Jun 12 2025 liyunfei - 19.1.7-10 +- Add compiler & openEuler oeaware schedule opt + * Fri May 30 2025 liyunfei - 19.1.7-9 - update to llvm-for-oE-19.1.7-2506.0.1 - release-note https://gitee.com/openeuler/llvm-project/compare/cd708029e0b2869e80abe31ddb175f7c35361f90...0c7685b92302b234e353f64d6589a63051a29cea