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

build(linux): disable GCC 12 Wrestrict warning #2925

Merged
merged 1 commit into from
Aug 4, 2024

Conversation

FrogTheFrog
Copy link
Collaborator

Description

This is an actual "fix" for #2919 and other places where the warning cannot be resolved easily (https://github.com/FrogTheFrog/Sunshine/actions/runs/10126414768/job/28003050801).

There is a bug for GCC 12 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105651) which unfortunately is used by flatpak.
Since we are treating all warnings as errors, such a bogus warning will prevent Sunshine from compiling. In some cases it is impossible to avoid this warning as it happens somewhere outside of Sunshine's code, like GTest:

test_sunshine.dir/unit/test_display_device.cpp.o -c /run/build/sunshine/tests/unit/test_display_device.cpp
In file included from /usr/include/c++/12.2.0/string:40,
                 from /usr/include/c++/12.2.0/bitset:47,
                 from /run/build/sunshine/src/config.h:7,
                 from /run/build/sunshine/tests/unit/test_display_device.cpp:5:
In static member function ‘static constexpr std::char_traits<char>::char_type* std::char_traits<char>::copy(char_type*, const char_type*, std::size_t)’,
    inlined from ‘static constexpr void std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12.2.0/bits/basic_string.h:423:21,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12.2.0/bits/basic_string.tcc:532:22,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12.2.0/bits/basic_string.h:2171:19,
    inlined from ‘constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]’ at /usr/include/c++/12.2.0/bits/basic_string.h:2196:22,
    inlined from ‘std::string testing::internal::CanonicalizeForStdLibVersioning(std::string)’ at /run/build/sunshine/third-party/googletest/googletest/include/gtest/internal/gtest-type-util.h:83:14:
/usr/include/c++/12.2.0/bits/char_traits.h:431:56: error: ‘void* __builtin_memcpy(void*, const void*, long unsigned int)’ accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Werror=restrict]
  431 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2, __n));
      |                                        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors

In this case, GTest is calling CanonicalizeForStdLibVersioning to pretty print a type name. Even if the function would never reach the "bad code" branch, it still produces a warning and there is no way around it.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Copy link

codecov bot commented Jul 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.66%. Comparing base (7737d6f) to head (444dfe2).
Report is 135 commits behind head on master.

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #2925   +/-   ##
======================================
  Coverage    9.66%   9.66%           
======================================
  Files          97      97           
  Lines       17556   17556           
  Branches     8230    8230           
======================================
  Hits         1696    1696           
+ Misses      15076   15068    -8     
- Partials      784     792    +8     
Flag Coverage Δ
Linux 7.16% <ø> (ø)
Windows 5.08% <ø> (ø)
macOS-12 10.29% <ø> (-0.02%) ⬇️
macOS-13 10.20% <ø> (-0.02%) ⬇️
macOS-14 10.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 11 files with indirect coverage changes

@ReenigneArcher
Copy link
Member

Is this only occurring in the flatpak build?

@FrogTheFrog
Copy link
Collaborator Author

Is this only occurring in the flatpak build?

The warning itself occurs on GCC12 only, which is only used in flatpak, but I have not checked the dockers as they do not run in forks.

@ReenigneArcher
Copy link
Member

but I have not checked the dockers as they do not run in forks

They should, but not from your master branch. You'd need to make a PR into the master and replicate how we run things.

@FrogTheFrog
Copy link
Collaborator Author

@ReenigneArcher This bug affects both flatpak and Docker-debian-bookworm

@ReenigneArcher ReenigneArcher changed the title fix!: disable bogus GCC 12 Wrestrict warning fix: disable GCC 12 Wrestrict warning Jul 28, 2024
@ReenigneArcher ReenigneArcher changed the title fix: disable GCC 12 Wrestrict warning build(linux): disable GCC 12 Wrestrict warning Aug 4, 2024
@ReenigneArcher ReenigneArcher enabled auto-merge (squash) August 4, 2024 01:06
@ReenigneArcher ReenigneArcher merged commit c6ed640 into LizardByte:master Aug 4, 2024
47 checks passed
@FrogTheFrog FrogTheFrog deleted the bogus-warning branch August 4, 2024 18:34
KuleRucket pushed a commit to KuleRucket/Sunshine that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants