Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 662670 - sys-apps/portage 10ignored-flags does not check effective flags
Summary: sys-apps/portage 10ignored-flags does not check effective flags
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Enhancement/Feature Requests (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-02 18:31 UTC by Rick Farina (Zero_Chaos)
Modified: 2018-08-03 16:27 UTC (History)
0 users

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rick Farina (Zero_Chaos) gentoo-dev 2018-08-02 18:31:19 UTC
10ignored-flags checks to make sure the use flags are set, but not if they are effective or not.

For example, if the user CFLAGS are "-O1" this will pass:

floppym@cisdev ~ $ gcc -o hello -O1 -frecord-gcc-switches -O2 -Os -O3 hello.c
floppym@cisdev ~ $ readelf -p .GCC.command.line hello

String dump of section '.GCC.command.line':
  [     0]  hello.c
  [     8]  -mtune=generic
  [    17]  -march=x86-64
  [    25]  -O1
  [    29]  -O2
  [    2d]  -Os
  [    31]  -O3
  [    35]  -frecord-gcc-switches

Granted, this is a hard problem to solve, since we don't nessesarily know which cflags override which other cflags.  My suggestion is to at least solve the simple case where we check if "-Osomething" is in the user CFLAGS, pick the last "-Osomething" from the use cflags (in case of CFLAGS="-O1 -O2" set by user) and then check to make sure that no -Osomethingelse is after -Osomething in the binary.

Even though this would miss many cases, it will catch the most obvious case and help signal to devs that things are being injected.
Comment 1 Zac Medico gentoo-dev 2018-08-02 18:52:01 UTC
Currently the check is very simplistic, it only uses -frecord-gcc-switches as a watermark for scanelf to detect.
Comment 2 Rick Farina (Zero_Chaos) gentoo-dev 2018-08-03 16:20:03 UTC
in that case we should verify all our cflags make it in, not just -frecord-gcc-switched.
Comment 3 Zac Medico gentoo-dev 2018-08-03 16:27:55 UTC
(In reply to Rick Farina (Zero_Chaos) from comment #2)
> in that case we should verify all our cflags make it in, not just
> -frecord-gcc-switched.

We might have to add a scanelf option for that, or create another tool to implement the check.