Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 917123 - media-sound/tenacity-1.3.2::xwing fails to compile (lto): ffmpeg-3.4.8-single-header.h:2680:16: error: type ‘struct AVCodecContext’ violates the C++ One Definition Rule [-Werror=odr]
Summary: media-sound/tenacity-1.3.2::xwing fails to compile (lto): ffmpeg-3.4.8-single...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Overlays (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Guillaume Castagnino
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: lto
  Show dependency tree
 
Reported: 2023-11-10 14:47 UTC by ppw0
Modified: 2024-08-12 20:40 UTC (History)
3 users (show)

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


Attachments
build log (media-sound:tenacity-1.3.2:20231110-144157.log,834.22 KB, text/x-log)
2023-11-10 14:47 UTC, ppw0
Details
emerge --info (emerge_info.log,7.69 KB, text/x-log)
2023-11-10 14:48 UTC, ppw0
Details
patch 1 (tenacity-1.3.3-drop-old-ffmpeg-headers.patch,444.84 KB, patch)
2024-07-20 18:38 UTC, ppw0
Details | Diff
patch 2 (tenacity-1.3.3-fix-strict-aliasing.patch,863 bytes, patch)
2024-07-20 18:39 UTC, ppw0
Details | Diff
patch 3 (tenacity-1.3.3-fix-effects-odr-violations.patch,1.27 KB, patch)
2024-07-20 18:39 UTC, ppw0
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ppw0 2023-11-10 14:47:50 UTC
Created attachment 874467 [details]
build log

In a stricter lto environment, media-sound/tenacity-1.3.2 will fail to compile with the following errors:
```
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:2680:16: error: type ‘struct AVCodecContext’ violates the C++ One Definition Rule [-Werror=odr]
 2680 | typedef struct AVCodecContext {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:2757:16: note: a different type is defined in another translation unit
 2757 | typedef struct AVCodecContext {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:2689:22: note: the first difference of corresponding definitions is field ‘codec_name’
 2689 |     char             codec_name[32];
      |                      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:2764:24: note: a field with different name is defined in another translation unit
 2764 |     enum AVCodecID     codec_id;
      |                        ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:3382:16: error: type ‘struct AVCodec’ violates the C++ One Definition Rule [-Werror=odr]
 3382 | typedef struct AVCodec {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:3442:16: note: a different type is defined in another translation unit
 3442 | typedef struct AVCodec {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:3400:9: note: the first difference of corresponding definitions is field ‘priv_data_size’
 3400 |     int priv_data_size;
      |         ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:3460:17: note: a field with different name is defined in another translation unit
 3460 |     const char *wrapper_name;
      |                 ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4780:16: error: type ‘struct AVFormatContext’ violates the C++ One Definition Rule [-Werror=odr]
 4780 | typedef struct AVFormatContext {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/58/../../ffmpeg-4.2.4-single-header.h:4838:16: note: a different type is defined in another translation unit
 4838 | typedef struct AVFormatContext {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4800:13: note: the first difference of corresponding definitions is field ‘start_time’
 4800 |     int64_t start_time;
      |             ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/58/../../ffmpeg-4.2.4-single-header.h:4859:11: note: a field with different name is defined in another translation unit
 4859 |     char *url;
      |           ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4498:16: error: type ‘struct AVInputFormat’ violates the C++ One Definition Rule [-Werror=odr]
 4498 | typedef struct AVInputFormat {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/58/../../ffmpeg-4.2.4-single-header.h:4544:16: note: a different type is defined in another translation unit
 4544 | typedef struct AVInputFormat {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4520:11: note: the first difference of corresponding definitions is field ‘read_probe’
 4520 |     int (*read_probe)(AVProbeData *);
      |           ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/58/../../ffmpeg-4.2.4-single-header.h:4566:11: note: a field of same name but different type is defined in another translation unit
 4566 |     int (*read_probe)(const AVProbeData *);
      |           ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4498:16: note: type mismatch in parameter 1
 4498 | typedef struct AVInputFormat {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4498:16: note: type ‘struct AVProbeData’ itself violates the C++ One Definition Rule
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/57/../../ffmpeg-3.4.8-single-header.h:4198:16: error: type ‘struct AVIOContext’ violates the C++ One Definition Rule [-Werror=odr]
 4198 | typedef struct AVIOContext {
      |                ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avformat/58/../../ffmpeg-4.2.4-single-header.h:4253:16: note: a different type is defined in another translation unit
 4253 | typedef struct AVIOContext {
      |                ^
.
.
.

/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:1488:6: error: type ‘AVFrameSideDataType’ violates the C++ One Definition Rule [-Werror=odr]
 1488 | enum AVFrameSideDataType {
      |      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:1499:6: note: an enum with different number of values is defined in another translation unit
 1499 | enum AVFrameSideDataType {
      |      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:4547:6: error: type ‘AVStreamParseType’ violates the C++ One Definition Rule [-Werror=odr]
 4547 | enum AVStreamParseType {
      |      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:4593:6: note: an enum with different value name is defined in another translation unit
 4593 | enum AVStreamParseType {
      |      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:4553:5: note: name ‘AVSTREAM_PARSE_FULL_RAW’ is defined to 1463898624 while another translation unit defines it as 5
 4553 |     AVSTREAM_PARSE_FULL_RAW=MKTAG(0,'R','A','W'),
      |     ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/58/../../ffmpeg-4.2.4-single-header.h:4599:5: note: mismatching definition
 4599 |     AVSTREAM_PARSE_FULL_RAW,
      |     ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:1078:6: error: type ‘AVColorPrimaries’ violates the C++ One Definition Rule [-Werror=odr]
 1078 | enum AVColorPrimaries {
      |      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/59/../../ffmpeg-5.0.1-single-header.h:1126:6: note: an enum with different value name is defined in another translation unit
 1126 | enum AVColorPrimaries {
      |      ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/57/../../ffmpeg-3.4.8-single-header.h:1094:5: note: name ‘AVCOL_PRI_JEDEC_P22’ differs from name ‘AVCOL_PRI_EBU3213’ defined in another translation unit
 1094 |     AVCOL_PRI_JEDEC_P22   = 22,
      |     ^
/var/tmp/portage/media-sound/tenacity-1.3.2/work/tenacity-1.3.2/libraries/lib-ffmpeg-support/impl/avcodec/59/../../ffmpeg-5.0.1-single-header.h:1142:5: note: mismatching definition
 1142 |     AVCOL_PRI_EBU3213     = 22,
      |     ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
```

Attaching logs.
Comment 1 ppw0 2023-11-10 14:48:13 UTC
Created attachment 874468 [details]
emerge --info
Comment 2 Guillaume Castagnino 2023-11-12 06:24:33 UTC
Hello,

Honestly, I do not know what to do with this.
You have enable CFLAGS that clash with the upstream multi ffmpeg version compatibility layer here: https://codeberg.org/tenacityteam/tenacity/src/branch/main/libraries/lib-ffmpeg-support/impl

Do you agree if I say it’s purely an upstream issue?
Comment 3 ppw0 2023-11-12 11:21:37 UTC
It's an issue inherited from Audacity (bug 915226). I still think it'd be worthwhile to notify the Tenacity project maintainer that this is a real issue that could prevent having a stable LTO Tenacity binary (and maybe give the project another opportunity to differentiate itself from its predecessor).
Comment 4 ppw0 2024-07-20 18:38:39 UTC
Created attachment 898041 [details, diff]
patch 1
Comment 5 ppw0 2024-07-20 18:39:05 UTC
Created attachment 898042 [details, diff]
patch 2
Comment 6 ppw0 2024-07-20 18:39:25 UTC
Created attachment 898043 [details, diff]
patch 3
Comment 7 ppw0 2024-07-20 18:39:46 UTC
For fun, I decided to patch the various errors that arise from using the stricter LTO checks.

The first patch (a brute force approach) drops the old ffmpeg headers and resolves the ODR violations reported here. The second patch fixes a strict aliasing warning. The third patch deals with ODR violations in the Effects section.

Applying all three resolves all of the warnings and allows for a successful LTO build. My tests, though not extensive, show everything to be OK at first glance.

You can use these in the ebuild if you want, or you can just use filter-lto for a more canonical, safer approach, but upstream should at least look at this.
Comment 8 Guillaume Castagnino 2024-07-27 07:37:07 UTC
For now, I only added filter-lto to my ebuild. Your patches are huge :)
You should definitively report upstream.

By the way, there is a work going on in supporting linking ffmpeg rather than dynamically loading it: https://codeberg.org/tenacityteam/tenacity/issues/404
It may fix the issue too in tenacity 1.4.
Comment 9 Eli Schwartz gentoo-dev 2024-08-12 01:28:02 UTC
Yes, please report it upstream.

For now, given it is filtered in the ebuild, I suppose there's not much left to do as far as the overlay is concerned:

https://git.xwing.info/casta/portage/commit/1fabdd364ffcae29796008e6c796e095cc84b450