Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 855011 - app-text/gv-3.7.3.90 fails to compile (lto): Scrollbar.c:1372:39: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
Summary: app-text/gv-3.7.3.90 fails to compile (lto): Scrollbar.c:1372:39: error: dere...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Printing Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2022-06-29 07:23 UTC by Agostino Sarubbo
Modified: 2022-08-27 15:29 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log (build.log,91.20 KB, text/plain)
2022-06-29 07:23 UTC, Agostino Sarubbo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Agostino Sarubbo gentoo-dev 2022-06-29 07:23:55 UTC
https://blogs.gentoo.org/ago/2020/07/04/gentoo-tinderbox/

Issue: app-text/gv-3.7.3.90 fails to compile (lto).
Discovered on: amd64 (internal ref: lto_tinderbox)

NOTE:
This machine uses lto with CFLAGS=-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
Comment 1 Agostino Sarubbo gentoo-dev 2022-06-29 07:23:57 UTC
Created attachment 788594 [details]
build.log

build log and emerge --info
Comment 2 Agostino Sarubbo gentoo-dev 2022-07-26 09:00:33 UTC
Here is a bit of explanation:

-Werror=lto-type-mismatch:
User to find possible runtime issues in packages. It likely means the package is unsafe to build & use with LTO.
For projects using the same identifier but with different types across different files, they must be fixed to be consistent across the codebase.

-Werror=odr:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO. C++ code must comply with the One Definition Rule (ODR) - see https://en.cppreference.com/w/cpp/language/definition#One_Definition_Rule.

-Werror=strict-aliasing:
Used to find possible runtime issues in packages. These bugs are a problem anyway but may be even worse when combined with LTO.

Workarounds:
- If upstream is friendly and still active, file a bug upstream. For emulators, codecs, games, or multimedia packages, it may be worth just applying a workaround instead, as upstreams sometimes aren't receptive to these bugs (VALID FOR ALL).
- Use the new 'filter-lto' from flag-o-matic.eclass as it's likely to be unsafe with LTO (VALID FOR lto-type-mismatch - odr).
- Fix it yourself if interested, of course (VALID FOR ALL).
- Append-flags -fno-strict-aliasing (VALID FOR strict-aliasing).
- Use memcpy() but a union is sometimes suitable too (VALID FOR strict-aliasing).
- -fstrict-aliasing is implied by -O2, so this must be addressed in some form (VALID FOR strict-aliasing).

See also: https://marc.info/?l=gentoo-dev&m=165639574126280&w=2
Comment 3 Matt Turner gentoo-dev 2022-08-27 13:58:28 UTC
Looks gross. It's passing a float (by value) through the "XtPointer call_data" argument to the XtNthumbProc virtual (???) function. I can't figure out what the implementation of that function is...

So the code is

>    /*
>       thumbProc is not pretty, but is necessary for backwards
>       compatibility on those architectures for which it work{s,ed};
>       the intent is to pass a (truncated) float by value.  
>    */
>   XtCallCallbacks (w, XtNthumbProc, *(XtPointer*)&TOP); 
>   XtCallCallbacks (w, XtNjumpProc, (XtPointer)&TOP);

and I also see

>     XtCallbackList      thumbProc;              /* jump (to position) scroll */
>    XtCallbackList      jumpProc;               /* same as thumbProc but pass data by ref */

so maybe we can just remove the callback to XtNthumbProc entirely?
Comment 4 Larry the Git Cow gentoo-dev 2022-08-27 15:29:44 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bad533b8968d8ad4a78854aee6caf4c9d811bbfe

commit bad533b8968d8ad4a78854aee6caf4c9d811bbfe
Author:     Matt Turner <mattst88@gentoo.org>
AuthorDate: 2022-08-27 14:02:06 +0000
Commit:     Matt Turner <mattst88@gentoo.org>
CommitDate: 2022-08-27 15:29:37 +0000

    app-text/gv: Version bump to 3.7.4
    
    v3.7.4 was released in 2013, so this is a little overdue...
    
    * Bump to EAPI=8
    * Fix build with CFLAGS=-lflto (bug #855011)
    * Fix build to call toolchain's AR (bug #729564)
    * Add (+) to x11-libs/libXaw3d's unicode USE-dep
    * Run gnuconfig_update since the included config.guess is ancient
    * Apply a bunch of patches from Fedora
    
    Closes: https://bugs.gentoo.org/729564
    Closes: https://bugs.gentoo.org/855011
    Signed-off-by: Matt Turner <mattst88@gentoo.org>

 app-text/gv/Manifest                               |  1 +
 app-text/gv/files/gv-3.7.4-bounding-box.patch      | 15 ++++++
 app-text/gv/files/gv-3.7.4-bug1071238.patch        | 22 ++++++++
 app-text/gv/files/gv-3.7.4-bz1536211.patch         | 28 ++++++++++
 app-text/gv/files/gv-3.7.4-dat.patch               | 15 ++++++
 app-text/gv/files/gv-3.7.4-overflow.patch          | 27 ++++++++++
 .../files/gv-3.7.4-remove-aliasing-violation.patch | 18 +++++++
 app-text/gv/files/gv-3.7.4-resource.patch          | 33 ++++++++++++
 app-text/gv/gv-3.7.4.ebuild                        | 62 ++++++++++++++++++++++
 9 files changed, 221 insertions(+)