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 fails with LTO #28

Closed
eli-schwartz opened this issue Mar 3, 2024 · 5 comments
Closed

Build fails with LTO #28

eli-schwartz opened this issue Mar 3, 2024 · 5 comments

Comments

@eli-schwartz
Copy link

With the following *FLAGS, alsaplayer fails to build: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing.

/bin/sh ../libtool  --tag=CXX   --mode=link x86_64-pc-linux-gnu-g++ -D_REENTRANT -DADDON_DIR=\"/usr/lib64/alsaplayer\" -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wall -Wall  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -export-dynamic -Wl,-O1 -Wl,--as-needed -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o alsaplayer alsaplayer-AlsaSubscriber.o alsaplayer-AlsaNode.o alsaplayer-Effects.o alsaplayer-Main.o alsaplayer-CorePlayer.o alsaplayer-Playlist.o alsaplayer-SampleBuffer.o alsaplayer-reverbst.o alsaplayer-fft.o alsaplayer-convolve.o alsaplayer-utilities.o alsaplayer-ControlSocket.o alsaplayer-prefs.o alsaplayer-reader.o  -lpthread -ldl 
libtool: link: x86_64-pc-linux-gnu-g++ -D_REENTRANT -DADDON_DIR=\"/usr/lib64/alsaplayer\" -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wall -Wall -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wformat -Werror=format-security -Wl,-O1 -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing -Wl,--defsym=__gentoo_check_ldflags__=0 -o alsaplayer alsaplayer-AlsaSubscriber.o alsaplayer-AlsaNode.o alsaplayer-Effects.o alsaplayer-Main.o alsaplayer-CorePlayer.o alsaplayer-Playlist.o alsaplayer-SampleBuffer.o alsaplayer-reverbst.o alsaplayer-fft.o alsaplayer-convolve.o alsaplayer-utilities.o alsaplayer-ControlSocket.o alsaplayer-prefs.o alsaplayer-reader.o -Wl,--export-dynamic  -Wl,--as-needed -lpthread -ldl
../alsaplayer/stream_info.h:35:16: error: type 'struct _stream_info' violates the C++ One Definition Rule [-Werror=odr]
   35 | typedef struct _stream_info
      |                ^
../alsaplayer/stream_info.h:35:16: note: a different type is defined in another translation unit
   35 | typedef struct _stream_info
      |                ^
../alsaplayer/stream_info.h:79:17: note: the first difference of corresponding definitions is field 'path'
   79 |         char    path[PATH_MAX+1];
      |                 ^
../alsaplayer/stream_info.h:79:17: note: a field of same name but different type is defined in another translation unit
   79 |         char    path[PATH_MAX+1];
      |                 ^
../alsaplayer/stream_info.h:35:16: note: array types have different bounds
   35 | typedef struct _stream_info
      |                ^
lto1: some warnings being treated as errors
lto-wrapper: fatal error: 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

Downstream report: https://bugs.gentoo.org/860423
Full logs: build.log

@thesamesam
Copy link

thesamesam commented Mar 3, 2024

The error is interesting here.

alsaplayer/stream_info.h doesn't include the header for PATH_MAX, so the definition of the struct.. depends on what you included before you included the header:

#ifndef PATH_MAX
#define PATH_MAX 1024
#endif

I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114218 for GCC to make this clearer.

@domichel
Copy link
Member

domichel commented Apr 9, 2024

Thank You both for reporting and taking care of alsaplayer and gcc.

If I understand well and take a look into git master, alsaplayer/stream_info.h include the header for PATH_MAX, which imply that bug is fixed into master.

I think I will make a release with master. It was a long time ago Erik de Castro Lopo stopped to work on it, and I was waiting from him to do that, but maybe as English is not my mother language and I learned it mostly into documentations and other readings, as well than in the streets, I missed it into the mailing list.

@domichel
Copy link
Member

domichel commented Apr 9, 2024

No, it is not fixed in master, I get the same error with these flags.

@domichel
Copy link
Member

domichel commented Apr 9, 2024

I find a solution that work here, and it is consistent with what is into alsaplayer/Core.h:

#ifdef __linux__
#include <linux/limits.h>
#endif // __linux__' >> stream_info.h
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif

Maybe and as in alsaplayer/Core.h, I could even remove

#ifndef PATH_MAX
#define PATH_MAX 1024
#endif

I am not a C/C++ programmer, so what do You think about that?

@domichel
Copy link
Member

domichel commented Apr 9, 2024

Or maybe it is better to add

#ifndef PATH_MAX
#define PATH_MAX 1024
#endif

into alsaplayer/Core.h

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

3 participants