Bug 34162 - check that things have been compiled with %optflags
Summary: check that things have been compiled with %optflags
Status: NEW
Alias: None
Product: Sisyphus
Classification: Development
Component: rpm-build (show other bugs)
Version: unstable
Hardware: all Linux
: P3 enhancement
Assignee: placeholder@altlinux.org
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks: 34161
  Show dependency tree
 
Reported: 2017-11-09 14:08 MSK by Ivan Zakharyaschev
Modified: 2021-08-02 04:01 MSK (History)
10 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Zakharyaschev 2017-11-09 14:08:06 MSK
4.0.4-alt105

A BRP check that would check that the resulting files have been compiled with flags which include all %optflags would help to see which packages have problems with honoring %optflags.

This would warn the maintainers that their attention is needed to fix this before someone changes %optflags to rebuild packages differently en masse (on another platform or with a different mechanism for passing %optflags to the compiler as in https://bugzilla.altlinux.org/show_bug.cgi?id=34161 ).

bircoph@ had this idea and suggested to use a special GCC flag to record the actually used flags in the resulting files.
Comment 1 Dmitry V. Levin 2017-12-12 00:07:03 MSK
(In reply to comment #0)
> bircoph@ had this idea and suggested to use a special GCC flag to record the
> actually used flags in the resulting files.

The option is called -frecord-gcc-switches; it adds .GCC.command.line section in each generated ELF file.  These sections have the same type (PROGBITS) and flags (MERGE, STRINGS) as .comment sections. Like .comment sections, .GCC.command.line sections are moved to .debug files by debugedit.
Comment 2 Michael Shigorin 2018-01-07 20:11:19 MSK
rpm-build:

Sun Jan 07 2018 Dmitry V. Levin <ldv@altlinux> 4.0.4-alt107
- compare_deps: fixed a bug in handling epochs.
- platform.in:
  + %optflags_core: added -frecord-gcc-switches (see: #34162);
  + %make_build: implemented as a simple command (closes: #34237).
- genCpioListAndHeader: implemented remapping of device and inode numbers
  (by Vladimir D. Seleznev and me; closes: #34398).
Comment 3 Vitaly Lipatov 2018-05-28 18:17:43 MSK
А как теперь поступать с такой ошибкой при сборке:

 "/usr/bin/clang"

 is not able to compile a simple test program.

 It fails with the following output:

  clang-6.0: error: unknown argument: '-frecord-gcc-switches'
Comment 4 Dmitry V. Levin 2018-05-28 18:26:14 MSK
(In reply to comment #3)
> А как теперь поступать с такой ошибкой при сборке:
> 
>  "/usr/bin/clang"
> 
>  is not able to compile a simple test program.
> 
>  It fails with the following output:
> 
>   clang-6.0: error: unknown argument: '-frecord-gcc-switches'

не передавать -frecord-gcc-switches в clang?
не использовать clang?
Comment 5 Vitaly Lipatov 2018-05-28 18:33:00 MSK
(В ответ на комментарий №4)
...
> не передавать -frecord-gcc-switches в clang?
> не использовать clang?
Хороший совет, но по строке changelog
  + %optflags_core: added -frecord-gcc-switches (see: #34162);
я ожидал хоть где-то найти его, чтобы не передавать, но
$ rpm --showrc | grep optflags_core
-14: optflags_core	-pipe

А... Ах вот оно что...
$ rpmbuild --showrc | grep optflags_core
-14: optflags_core	-pipe -frecord-gcc-switches

А точно нельзя, чтобы команда rpm --showrc выдавала те же макросы, или не работала бы вообще. А то я теперь даже не знаю, откуда она берёт свой вывод.
Comment 6 Vitaly Lipatov 2018-05-28 18:47:16 MSK
(В ответ на комментарий №4)
...
> не передавать -frecord-gcc-switches в clang?
так и сделаю, спасибо:
%remove_optflags -frecord-gcc-switches
Comment 7 Vitaly Chikunov 2021-07-29 06:01:09 MSK
FYI: `%remove_optflags -frecord-gcc-switches` не нужен начиная с clang8.