gcc: Fix strange C++ repo issues
See the patch header for a better description of the c++ -frepo issue this patch fixes.
[YOCTO #5133]
---
meta/recipes-devtools/gcc/gcc-4.8.inc +1 -0
@@ -76,6 +76,7 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://0044-gengtypes.patch \ file://0045-gcc-4.8-PR57717-PowerPC-E500v2.patch \ file://0046-libatomic-deptracking.patch \ + file://0047-repomembug.patch \ " SRC_URI[md5sum] = "3b2386c114cd74185aa3754b58a79304" SRC_URI[sha256sum] = "545b44be3ad9f2c4e90e6880f5c9d4f0a8f0e5f67e1ffb0d45da9fa01bb05813"
meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch new file +46 -0
46 lines not on this page · raw message
Khem Raj
Acked-byLooks good to me. We need to run GCC testsuites on it and also propose it upstream.
Quoted 72 lines · Richard Purdie
See the patch header for a better description of the c++ -frepo issue this patch fixes.
[YOCTO #5133]
Signed-off-by Richard Purdie <[email protected]>---
meta/recipes-devtools/gcc/gcc-4.8.inc +1
-0@@ -76,6 +76,7 @@ SRC_URI = "${GNU_MIRROR}/gcc/gcc-${PV}/gcc-${PV}.tar.bz2 \ file://0044-gengtypes.patch \ file://0045-gcc-4.8-PR57717-PowerPC-E500v2.patch \ file://0046-libatomic-deptracking.patch \ + file://0047-repomembug.patch \ "SRC_URI[md5sum] = "
3b2386c114cd74185aa3754b58a79304"
SRC_URI[sha256sum] = "545b44be3ad9f2c4e90e6880f5c9d4f0a8f0e5f67e1ffb0d45da9fa01bb05813"meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch new file +46
-0@@ -0,0 +1,46 @@ +When compiling a project using -frepo, .rpo files are written alongside +the .o file, the symbols either have O or C against them. During final linking, +the objects can be recompiled with some of the entries tweaked/chosen by the +tlink.c code (visible with TLINK_VERBOSE=3). + +My tests showed that init_repo (cp/repo.c) was correcting calling +IDENTIFIER_REPO_CHOSEN against the right identifers. + +By the time finish_repo() or emit_repo_p() were called, the pointer returned +by get_identifier() for the symbol marked during init_repo had changed and +the chosen bit was no longer set. This lead to linking bugs like: + +collect: relinking +collect2: error: '_ZNK6sudoku5ClearINS_8SequenceEEclERS1_' was assigned to 'board.rpo', but was not defined during recompilation, or vice versa + +The problem is that the garbage collection is getting called before +finish_repo() is called and ggc_protect_identifiers is set to false +so the identifiers are not preserved. They are recreated but the +chosen bits get wiped out. + +The fix is to change ggc_protect_identifiers *after* the finish_repo +calls are made. + +Reproduction is tricky since you need to trigger the garbage collector at +just the right moment. + +RP 2013/10/9 + +Index: gcc-4.8.1/gcc/toplev.c +=================================================================== +--- gcc-4.8.1.orig/gcc/toplev.c 2013-03-28 08:29:51.000000000 +0000 ++++ gcc-4.8.1/gcc/toplev.c 2013-10-09 20:27:17.089228023 +0000 +@@ -551,11 +551,11 @@ + if (flag_syntax_only || flag_wpa) + return; + +- ggc_protect_identifiers = false; +- + /* This must also call finalize_compilation_unit. */ + lang_hooks.decls.final_write_globals (); + ++ ggc_protect_identifiers = false; ++ + if (seen_error ()) + return; +
Quoted 21 lines · Richard Purdie
+++
b/meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patchmeta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch new file +19
-0@@ -0,0 +1,46 @@ +When compiling a project using -frepo, .rpo files are written alongside +the .o file, the symbols either have O or C against them. During final linking, +the objects can be recompiled with some of the entries tweaked/chosen by the +tlink.c code (visible with TLINK_VERBOSE=3). + +My tests showed that init_repo (cp/repo.c) was correcting calling +IDENTIFIER_REPO_CHOSEN against the right identifers. + +By the time finish_repo() or emit_repo_p() were called, the pointer returned +by get_identifier() for the symbol marked during init_repo had changed and +the chosen bit was no longer set. This lead to linking bugs like: + +collect: relinking +collect2: error: '_ZNK6sudoku5ClearINS_8SequenceEEclERS1_' was assigned to 'board.rpo', but was not defined during recompilation, or vice versa + +The problem is that the garbage collection is getting called before +finish_repo() is called and ggc_protect_identifiers is set to false +so the identifiers are not preserved. They are recreated but the +chosen bits get wiped out.
meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch line 29
Quoted 10 lines
meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch new file +10
-0+ +The fix is to change ggc_protect_identifiers *after* the finish_repo +calls are made. + +Reproduction is tricky since you need to trigger the garbage collector at +just the right moment. + +RP 2013/10/9 + +Index: gcc-4.8.1/gcc/toplev.c
This patch header seems to lack an Upstream-Status.
p.
Quoted 26 lines · Phil Blundell
Quoted 25 lines · Richard Purdie
+++
b/meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patchmeta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch new file +23
-0@@ -0,0 +1,46 @@ +When compiling a project using -frepo, .rpo files are written alongside +the .o file, the symbols either have O or C against them. During final linking, +the objects can be recompiled with some of the entries tweaked/chosen by the +tlink.c code (visible with TLINK_VERBOSE=3). + +My tests showed that init_repo (cp/repo.c) was correcting calling +IDENTIFIER_REPO_CHOSEN against the right identifers. + +By the time finish_repo() or emit_repo_p() were called, the pointer returned +by get_identifier() for the symbol marked during init_repo had changed and +the chosen bit was no longer set. This lead to linking bugs like: + +collect: relinking +collect2: error: '_ZNK6sudoku5ClearINS_8SequenceEEclERS1_' was assigned to 'board.rpo', but was not defined during recompilation, or vice versa + +The problem is that the garbage collection is getting called before +finish_repo() is called and ggc_protect_identifiers is set to false +so the identifiers are not preserved. They are recreated but the +chosen bits get wiped out. + +The fix is to change ggc_protect_identifiers *after* the finish_repo +calls are made. +
Quoted 8 lines
meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch line 29
Quoted 6 lines
meta/recipes-devtools/gcc/gcc-4.8/0047-repomembug.patch new file +6
-0+Reproduction is tricky since you need to trigger the garbage collector at +just the right moment. + +RP 2013/10/9 + +Index: gcc-4.8.1/gcc/toplev.cThis patch header seems to lack an Upstream-Status.
Thanks, I've already fixed that in the version in the master-next branch, along with tweaking the explanation a little more.
Cheers,
Richard