Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Build of srs fails with standard attributes in middle of decl-specifiers on GCC 12 #2448

Closed
hashworks opened this issue Sep 1, 2022 · 6 comments
Labels
[build] Area: Changes in build files help wanted Indicates that a maintainer wants help on an issue or pull request Type: Bug Indicates an unexpected problem or unintended behavior
Milestone

Comments

@hashworks
Copy link

hashworks commented Sep 1, 2022

I'm currently trying to build srs which includes version 1.4.1 of this repo in trunk/3rdparty/srt-1-fit. Due to me using GCC 12.2.0 this fails with standard attributes in middle of decl-specifiers:

In file included from /build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/api.h:60,
                 from /build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/api.cpp:60:
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/netinet_any.h: In constructor ‘sockaddr_any::sockaddr_any(int)’:
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/netinet_any.h:40:15: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct sockaddr_any’; use assignment or value-initialization instead [-Wclass-memaccess]
   40 |         memset(this, 0, sizeof *this);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/netinet_any.h:28:8: note: ‘struct sockaddr_any’ declared here
   28 | struct sockaddr_any
      |        ^~~~~~~~~~~~
In file included from /build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/udt.h:70,
                 from /build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/api.h:61:
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h: At global scope:
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:84:28: error: standard attributes in middle of decl-specifiers
   84 | #define SRT_ATR_DEPRECATED [[deprecated]]
      |                            ^
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:198:9: note: in expansion of macro ‘SRT_ATR_DEPRECATED’
  198 | typedef SRT_ATR_DEPRECATED SRT_SOCKOPT SRT_SOCKOPT_DEPRECATED;
      |         ^~~~~~~~~~~~~~~~~~
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:84:28: note: standard attributes must precede the decl-specifiers to apply to the declaration, or follow them to apply to the type
   84 | #define SRT_ATR_DEPRECATED [[deprecated]]
      |                            ^
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:198:9: note: in expansion of macro ‘SRT_ATR_DEPRECATED’
  198 | typedef SRT_ATR_DEPRECATED SRT_SOCKOPT SRT_SOCKOPT_DEPRECATED;
      |         ^~~~~~~~~~~~~~~~~~
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:84:28: warning: attribute ignored [-Wattributes]
   84 | #define SRT_ATR_DEPRECATED [[deprecated]]
      |                            ^
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:198:9: note: in expansion of macro ‘SRT_ATR_DEPRECATED’
  198 | typedef SRT_ATR_DEPRECATED SRT_SOCKOPT SRT_SOCKOPT_DEPRECATED;
      |         ^~~~~~~~~~~~~~~~~~
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:84:28: note: an attribute that appertains to a type-specifier is ignored
   84 | #define SRT_ATR_DEPRECATED [[deprecated]]
      |                            ^
/build/srs-git/src/srs-git/trunk/objs/Platform-Linux-5.19.5-GCC12.2.0-SRS5-x86_64/srt-1-fit/srtcore/srt.h:198:9: note: in expansion of macro ‘SRT_ATR_DEPRECATED’
  198 | typedef SRT_ATR_DEPRECATED SRT_SOCKOPT SRT_SOCKOPT_DEPRECATED;
      |         ^~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/srt_virtual.dir/build.make:76: CMakeFiles/srt_virtual.dir/srtcore/api.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:115: CMakeFiles/srt_virtual.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
Build srt-1-fit failed, ret=2

To Reproduce
Steps to reproduce the behavior:

  1. Use a Linux with GCC 12
  2. git clone -b develop https://gitee.com/ossrs/srs.git
  3. cd srs/trunk
  4. ./configure
  5. make
  6. See error

Expected behavior
srs with srt succeeds to build with the latest GCC version.

Desktop (please provide the following information):

  • OS: Arch Linux
  • SRT Version / commit ID: Tested latest daf838e and tag 1.4.1

Additional context

ossrs/srs#3155

https://www.gnu.org/software/gcc/gcc-12/changes.html

Stricter checking of attributes on friend declarations: if a friend declaration has an attribute, that declaration must be a definition. Moreover, a C++11 attribute cannot appear in the middle of the decl-specifier-seq. (PR99032)

@hashworks hashworks added the Type: Bug Indicates an unexpected problem or unintended behavior label Sep 1, 2022
@maxsharabayko maxsharabayko added help wanted Indicates that a maintainer wants help on an issue or pull request [build] Area: Changes in build files labels Sep 1, 2022
@maxsharabayko
Copy link
Collaborator

What about the latest SRT v1.5.0?

@hashworks
Copy link
Author

As mentioned in "SRT Version / commit ID", I also tested the latest master commit (daf838e) which is newer than tag 1.5.0 (38 commits since then). But I could still test the older v1.5.0 if you want?

@maxsharabayko
Copy link
Collaborator

As mentioned in "SRT Version / commit ID", I also tested the latest master commit (daf838e) which is newer than tag 1.5.0 (38 commits since then). But I could still test the older v1.5.0 if you want?

Sorry, missed that. No need to retest with v1.5.0 then.

@maxsharabayko maxsharabayko added this to the v1.5.1 milestone Sep 12, 2022
@maxsharabayko
Copy link
Collaborator

The following command line works for me with GNU 12.0.1 on Ubuntu 22.04.1 LTS.

$ cmake .. -DUSE_CXX_STD=c++17
-- The C compiler identification is GNU 12.0.1
-- The CXX compiler identification is GNU 12.0.1
...

$ make

SRS build fails building OPUS.

...
Building opus-1.3.1.
/usr/bin/gzip: 1: �ELF����: not found
/usr/bin/gzip: 3: ���: not found
/usr/bin/gzip: 4: Syntax error: "(" unexpected
tar: Child returned status 2
tar: Error is not recoverable: exiting now
Build opus-1.3.1 failed, ret=2

@hashworks
Copy link
Author

Hm, after additional tests I can confirm that everything from v1.4.3 onwards builds just fine with GCC 12.2.0, -DUSE_CXX_STD=c++17 isn't needed as well.

It seems like I failed to test it properly before, my bad. I'll close this, since it's not an issue with newer versions of srt.

@maxsharabayko
Copy link
Collaborator

@hashworks Glad the issue has resolved itself. 🙂
Thanks for reporting back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[build] Area: Changes in build files help wanted Indicates that a maintainer wants help on an issue or pull request Type: Bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants