diff --git a/0391-oeAware-Fix-.GCC4OE_oeAware-section-dup-in-LTO.patch b/0391-oeAware-Fix-.GCC4OE_oeAware-section-dup-in-LTO.patch new file mode 100644 index 0000000000000000000000000000000000000000..0c181fc5609d3315a34843d9e0959b2b30f36f3f --- /dev/null +++ b/0391-oeAware-Fix-.GCC4OE_oeAware-section-dup-in-LTO.patch @@ -0,0 +1,79 @@ +From 19282a59163914ad9c6ac732497d5d235aeba408 Mon Sep 17 00:00:00 2001 +From: liyancheng <412998149@qq.com> +Date: Thu, 5 Jun 2025 22:06:48 +0800 +Subject: [PATCH] [oeAware] Fix .GCC4OE_oeAware section dup in LTO + +This resolves an ICE "section already exists" caused +by incorrectly creating the .GCC4OE_oeAware section +for non-global main functions with fat lto objects. +--- + gcc/testsuite/g++.dg/dg.exp | 1 + + .../oeaware-main-in-namespace.C} | 0 + gcc/testsuite/g++.dg/oeaware-with-lto.C | 12 ++++++++++++ + gcc/varasm.cc | 13 +++++++++++-- + 4 files changed, 24 insertions(+), 2 deletions(-) + rename gcc/testsuite/{gcc.dg/oeaware-main-in-namespace.cpp => g++.dg/oeaware-main-in-namespace.C} (100%) + create mode 100644 gcc/testsuite/g++.dg/oeaware-with-lto.C + +diff --git a/gcc/testsuite/g++.dg/dg.exp b/gcc/testsuite/g++.dg/dg.exp +index 23542ace8..e2cf62478 100644 +--- a/gcc/testsuite/g++.dg/dg.exp ++++ b/gcc/testsuite/g++.dg/dg.exp +@@ -18,6 +18,7 @@ + + # Load support procs. + load_lib g++-dg.exp ++load_lib oeaware.exp + + # If a testcase doesn't have special options, use these. + global DEFAULT_CXXFLAGS +diff --git a/gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp b/gcc/testsuite/g++.dg/oeaware-main-in-namespace.C +similarity index 100% +rename from gcc/testsuite/gcc.dg/oeaware-main-in-namespace.cpp +rename to gcc/testsuite/g++.dg/oeaware-main-in-namespace.C +diff --git a/gcc/testsuite/g++.dg/oeaware-with-lto.C b/gcc/testsuite/g++.dg/oeaware-with-lto.C +new file mode 100644 +index 000000000..fe77daede +--- /dev/null ++++ b/gcc/testsuite/g++.dg/oeaware-with-lto.C +@@ -0,0 +1,12 @@ ++/* { dg-do compile { target *-*-linux* *-*-gnu* } } */ ++/* { dg-options "-foeaware-policy=1 -flto -ffat-lto-objects" } */ ++ ++namespace radar8446940 { ++int main () { ++ return 0; ++} ++} ++ ++int main () { ++ return 0; ++} +\ No newline at end of file +diff --git a/gcc/varasm.cc b/gcc/varasm.cc +index 5134c0c1f..c771ede71 100644 +--- a/gcc/varasm.cc ++++ b/gcc/varasm.cc +@@ -8581,8 +8581,17 @@ create_oeaware_section () + TREE_CODE (DECL_CONTEXT (cfun->decl)) != TRANSLATION_UNIT_DECL)) + return; + +- int flags = SECTION_STRINGS; +- section *oe_section = get_section (".GCC4OE_oeAware", flags, NULL, true); ++ const char *sect_name = ".GCC4OE_oeAware"; ++ ++ /* If section already exists, just skip. */ ++ section **slot ++ = section_htab->find_slot_with_hash (sect_name, ++ htab_hash_string (sect_name), ++ INSERT); ++ if (!slot || *slot != NULL) ++ return; ++ ++ section *oe_section = get_section (sect_name, SECTION_STRINGS, NULL, false); + switch_to_section (oe_section); + + gcc_assert (oeaware_optimize_policy <= UINT8_MAX); +-- +2.34.1 + diff --git a/gcc.spec b/gcc.spec index 9f1fe44bc6b57cb404f08d27887e26ceca2c4bc3..b08faf72950f26653d4f525482602c765b2169ff 100644 --- a/gcc.spec +++ b/gcc.spec @@ -2,7 +2,7 @@ %global gcc_major 12 # Note, gcc_release must be integer, if you want to add suffixes to # %%{release}, append them after %%{gcc_release} on Release: line. -%global gcc_release 91 +%global gcc_release 92 %global _unpackaged_files_terminate_build 0 %global _performance_build 1 @@ -500,6 +500,7 @@ Patch387: 0387-x86-Correct-ASM_OUTPUT_SYMBOL_REF.patch Patch388: 0388-struct-reorg-Escapes-some-void-pointers.patch Patch389: 0389-deja-Correct-pass-number-in-options.patch Patch390: 0390-struct-reorg-Check-ADDR_EXPR-in-pointer-plus-assign.patch +Patch391: 0391-oeAware-Fix-.GCC4OE_oeAware-section-dup-in-LTO.patch # Part 1001-1999 %ifarch sw_64 @@ -1676,6 +1677,7 @@ not stable, so plugins must be rebuilt any time GCC is updated. %patch -P388 -p1 %patch -P389 -p1 %patch -P390 -p1 +%patch -P391 -p1 %ifarch sw_64 %patch -P1001 -p1 @@ -4303,6 +4305,10 @@ end %doc rpm.doc/changelogs/libcc1/ChangeLog* %changelog +* Sat Jun 7 2025 liyancheng <412998149@qq.com> - 12.3.1-92 +- Type: Sync +- DESC: Sync patches from openeuler/gcc. + * Tue Jun 3 2025 huzife <634763349@qq.com> - 12.3.1-91 - Type: Sync - DESC: Sync patches from openeuler/gcc.