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

Compile warnings (using both gcc-14.2 and gcc-15 (prerelease )) #1095

Open
heitbaum opened this issue Jan 12, 2025 · 2 comments
Open

Compile warnings (using both gcc-14.2 and gcc-15 (prerelease )) #1095

heitbaum opened this issue Jan 12, 2025 · 2 comments

Comments

@heitbaum
Copy link

Please see the template, inline and c20 warnings in the log file.


Executing (target): cmake -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_TOOLCHAIN_FILE=/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/etc/cmake-x86_64-libreelec-linux-gnu.conf -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DALSOFT_BACKEND_OSS=off -DALSOFT_BACKEND_PULSEAUDIO=off -DALSOFT_BACKEND_WAVE=off -DALSOFT_EXAMPLES=off -DALSOFT_UTILS=off /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/openal-soft-1.24.2
-- The C compiler identification is GNU 15.0.0
-- The CXX compiler identification is GNU 15.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/bin/pkg-config (found version "0.29.2")
-- {fmt} version: 11.1.1
-- Build type: Release
-- Performing Test HAVE_STDC_FORMAT_MACROS
-- Performing Test HAVE_STDC_FORMAT_MACROS - Success
-- Performing Test HAVE_LIBATOMIC
-- Performing Test HAVE_LIBATOMIC - Failed
-- Performing Test HAVE_WNO_CXX20_ATTR_EXT
-- Performing Test HAVE_WNO_CXX20_ATTR_EXT - Success
-- Performing Test HAVE_WNO_INTERFERENCE_SIZE
-- Performing Test HAVE_WNO_INTERFERENCE_SIZE - Success
-- Performing Test HAVE_FTRIVIAL_AUTO_VAR_INIT
-- Performing Test HAVE_FTRIVIAL_AUTO_VAR_INIT - Success
-- Performing Test HAVE_FNO_MATH_ERRNO
-- Performing Test HAVE_FNO_MATH_ERRNO - Success
-- Performing Test HAVE_GCC_PROTECTED_VISIBILITY
-- Performing Test HAVE_GCC_PROTECTED_VISIBILITY - Success
-- Performing Test HAVE_MSSE2_SWITCH
-- Performing Test HAVE_MSSE2_SWITCH - Success
-- Looking for xmmintrin.h
-- Looking for xmmintrin.h - found
-- Looking for emmintrin.h
-- Looking for emmintrin.h - found
-- Looking for pmmintrin.h
-- Looking for pmmintrin.h - found
-- Looking for smmintrin.h
-- Looking for smmintrin.h - found
-- Looking for arm_neon.h
-- Looking for arm_neon.h - not found
-- Performing Test HAVE_SSE_INTRINSICS
-- Performing Test HAVE_SSE_INTRINSICS - Success
-- Looking for cpuid.h
-- Looking for cpuid.h - found
-- Looking for intrin.h
-- Looking for intrin.h - not found
-- Looking for guiddef.h
-- Looking for guiddef.h - not found
-- Looking for pow in m
-- Looking for pow in m - found
-- Looking for clock_gettime in rt
-- Looking for clock_gettime in rt - found
-- Looking for dlfcn.h
-- Looking for dlfcn.h - found
-- Looking for dlopen in dl
-- Looking for dlopen in dl - found
-- Performing Test HAVE_GCC_GET_CPUID
-- Performing Test HAVE_GCC_GET_CPUID - Success
-- Looking for proc_pidpath
-- Looking for proc_pidpath - not found
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test HAVE_PTHREAD
-- Performing Test HAVE_PTHREAD - Success
-- Looking for pthread_setschedparam
-- Looking for pthread_setschedparam - found
-- Looking for include files pthread.h, pthread_np.h
-- Looking for include files pthread.h, pthread_np.h - not found
-- Looking for pthread_setname_np
-- Looking for pthread_setname_np - not found
-- Looking for pthread_set_name_np
-- Looking for pthread_set_name_np - not found
-- Checking for module 'libpipewire-0.3>=0.3.23'
--   No package 'libpipewire-0.3' found
-- Found ALSA: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/lib/libasound.so (found version "1.2.13")
-- Could NOT find AudioIO (missing: AUDIOIO_INCLUDE_DIR) 
-- Could NOT find JACK (missing: JACK_LIBRARY JACK_INCLUDE_DIR) 
-- Could NOT find OpenSL (missing: OPENSL_LIBRARY OPENSL_INCLUDE_DIR OPENSL_ANDROID_INCLUDE_DIR) 
-- Could NOT find PortAudio (missing: PORTAUDIO_LIBRARY PORTAUDIO_INCLUDE_DIR) 
-- Found Git: /usr/bin/git (found version "2.43.0")
-- 
-- Building OpenAL with support for the following backends:
--     ALSA, Null
-- 
-- Building with support for CPU extensions:
--     Default, SSE, SSE2, SSE3, SSE4.1
-- 
-- Embedding HRTF datasets
-- 
-- Installing library and headers
-- Installing sample configuration
-- Installing HRTF data files
-- Installing AmbDec presets
-- 
-- Configuring done (0.8s)
-- Generating done (0.0s)
-- Build files have been written to: /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-13.0-devel/build/openal-soft-1.24.2/.x86_64-libreelec-linux-gnu
Executing (target): ninja 
[7/102] Building CXX object CMakeFiles/alsoft.common.dir/common/pffft.cpp.o
../common/pffft.cpp:1470:18: warning: ignoring attributes on template argument '{anonymous}::v4sf' {aka '__m128'} [-Wignored-attributes]
 1470 |     al::span<v4sf> e; /* N/4*3 elements */
      |                  ^
cc1plus: note: unrecognized command-line option '-Wno-c++20-attribute-extensions' may have been intended to silence earlier diagnostics
[19/102] Building CXX object CMakeFiles/OpenAL.dir/al/buffer.cpp.o
In file included from ../al/buffer.h:18,
                 from ../al/buffer.cpp:23:
../common/alnumeric.h: In function 'void alBufferiDirect(ALCcontext*, ALuint, ALenum, ALint)':
../common/alnumeric.h:42:16: warning: inlining failed in call to 'constexpr std::string_view GetCounterSuffix(size_t) noexcept': call is unlikely and code size would grow [-Winline]
   42 | constexpr auto GetCounterSuffix(size_t count) noexcept -> std::string_view
      |                ^~~~~~~~~~~~~~~~
../al/buffer.cpp:1083:37: note: called from here
 1083 |                     GetCounterSuffix(albuf->mAmbiOrder));
      |                     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
../common/alnumeric.h:42:16: warning: inlining failed in call to 'constexpr std::string_view GetCounterSuffix(size_t) noexcept': call is unlikely and code size would grow [-Winline]
   42 | constexpr auto GetCounterSuffix(size_t count) noexcept -> std::string_view
      |                ^~~~~~~~~~~~~~~~
../al/buffer.cpp:1099:37: note: called from here
 1099 |                     GetCounterSuffix(albuf->mAmbiOrder));
      |                     ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In function 'void {anonymous}::LoadData(ALCcontext*, ALbuffer*, ALsizei, ALuint, FmtChannels, FmtType, al::span<const std::byte>, ALbitfieldSOFT)',
    inlined from 'void alBufferStorageDirectSOFT(ALCcontext*, ALuint, ALenum, const ALvoid*, ALsizei, ALsizei, ALbitfieldSOFT)' at ../al/buffer.cpp:788:13:
../common/alnumeric.h:42:16: warning: inlining failed in call to 'constexpr std::string_view GetCounterSuffix(size_t) noexcept': call is unlikely and code size would grow [-Winline]
   42 | constexpr auto GetCounterSuffix(size_t count) noexcept -> std::string_view
      |                ^~~~~~~~~~~~~~~~
../al/buffer.cpp:314:33: note: called from here
  314 |                 GetCounterSuffix(ALBuf->mAmbiOrder));
      |                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
../common/alnumeric.h:42:16: warning: inlining failed in call to 'constexpr std::string_view GetCounterSuffix(size_t) noexcept': call is unlikely and code size would grow [-Winline]
   42 | constexpr auto GetCounterSuffix(size_t count) noexcept -> std::string_view
      |                ^~~~~~~~~~~~~~~~
../al/buffer.cpp:318:33: note: called from here
  318 |                 GetCounterSuffix(ALBuf->mAmbiOrder));
      |                 ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-c++20-attribute-extensions' may have been intended to silence earlier diagnostics
[34/102] Building CXX object CMakeFiles/OpenAL.dir/al/effects/vmorpher.cpp.o
../al/effects/vmorpher.cpp: In static member function 'static void VmorpherEffectHandler::SetParami(ALCcontext*, VmorpherProps&, ALenum, int)':
../al/effects/vmorpher.cpp:24:42: warning: inlining failed in call to 'constexpr std::optional<VMorpherPhenome> {anonymous}::PhenomeFromEnum(ALenum) noexcept': --param max-inline-insns-single limit reached [-Winline]
   24 | constexpr std::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) noexcept
      |                                          ^~~~~~~~~~~~~~~
../al/effects/vmorpher.cpp:147:45: note: called from here
  147 |         if(auto phenomeopt = PhenomeFromEnum(val))
      |                              ~~~~~~~~~~~~~~~^~~~~
../al/effects/vmorpher.cpp:24:42: warning: inlining failed in call to 'constexpr std::optional<VMorpherPhenome> {anonymous}::PhenomeFromEnum(ALenum) noexcept': --param max-inline-insns-single limit reached [-Winline]
   24 | constexpr std::optional<VMorpherPhenome> PhenomeFromEnum(ALenum val) noexcept
      |                                          ^~~~~~~~~~~~~~~
../al/effects/vmorpher.cpp:162:45: note: called from here
  162 |         if(auto phenomeopt = PhenomeFromEnum(val))
      |                              ~~~~~~~~~~~~~~~^~~~~
At global scope:
cc1plus: note: unrecognized command-line option '-Wno-c++20-attribute-extensions' may have been intended to silence earlier diagnostics
[102/102] Creating library symlink libopenal.so.1 libopenal.so

@kcat
Copy link
Owner

kcat commented Jan 13, 2025

Unfortunately there's not much that can be done about it. GCC still treats inline (including constexpr, templates, and other things that standard says imply inline) as a hint to inline code, while C++ has changed the keyword's meaning to "allow multiple definitions". So GCC tries to more aggressively inline these functions and will dutifully warn when it decides not to because of -Winline. Clang and MSVC, in contrast, don't try any harder to inline such functions (or at least, not much harder than normal, and don't warn when it can't). The only "fix" is to disable the -Winline warning, something I'm not keen on doing since it can indicate misoptimization (it has helped me catch instances of GCC trying to inline functions that are too large and need to be explicitly noinline'd).

There is a GCC proposal for a new feeble_inline GNU attribute, to remove the code inline semantics for such functions and leave the multiple-definitions behavior, which would clear up those warnings. Though it's been over 5 years since initially proposed, and even when implemented, I worry it will be of limited use as long as it's not the default (at least via a switch); most modern C++ code won't be expecting inline/etc to be a code inline hint, other compilers don't take it as a code inline hint, and I doubt projects will add an attribute to all their templated, constexpr, etc, code just for GCC.

The -Wno-c++20-attribute-extensions warning is because CMake checks to see if that's a valid switch, which GCC doesn't recognize but also doen't complain about for some reason. So CMake detects it as a valid switch since GCC didn't complain when testing, which it will later complain about when printing a warning for other reasons. This will be fixed once the codebase is updated to C++20 and that switch isn't necessary to suppress warning about C++20 attributes.

@heitbaum
Copy link
Author

Thanks for the extremely detailed answer

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

No branches or pull requests

2 participants