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

Cannot build with -flto #903

Open
ZeroChaos- opened this issue Feb 16, 2023 · 4 comments
Open

Cannot build with -flto #903

ZeroChaos- opened this issue Feb 16, 2023 · 4 comments

Comments

@ZeroChaos-
Copy link
Contributor

Link time optimization is increasingly common across linux distros, but this fails to build on gentoo when lto is enabled.

I would expect this is easy to replicate with CFLAGS=-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

Gentoo Bug https://bugs.gentoo.org/861872

@ZeroChaos-
Copy link
Contributor Author

Min test case to reproduce CFLAGS="-flto" cmake .. will show the warning
Min test case to make it a build failure so it doesn't get lost by accident CFLAGS="-flto -Werror=lto-type-mismatch" cmake ..

[  4%] Linking C shared library ../../output/libbladeRF.so
/home/zero/development/bladeRF/host/libraries/libbladeRF/src/board/bladerf2/common.h:200:25: warning: type of ‘bladerf2_rfic_init_params_fastagc_burst’ does not match original declaration [-Wlto-type-mismatch]
  200 | extern AD9361_InitParam bladerf2_rfic_init_params_fastagc_burst;
      |                         ^
/home/zero/development/bladeRF/fpga_common/src/ad936x_params.c:308:18: note: ‘bladerf2_rfic_init_params_fastagc_burst’ was previously declared here
  308 | AD9361_InitParam bladerf2_rfic_init_params_fastagc_burst = {
      |                  ^
/home/zero/development/bladeRF/fpga_common/src/ad936x_params.c:308:18: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
/home/zero/development/bladeRF/host/libraries/libbladeRF/src/board/bladerf2/common.h:199:25: warning: type of ‘bladerf2_rfic_init_params’ does not match original declaration [-Wlto-type-mismatch]
  199 | extern AD9361_InitParam bladerf2_rfic_init_params;
      |                         ^
/home/zero/development/bladeRF/fpga_common/src/ad936x_params.c:20:18: note: ‘bladerf2_rfic_init_params’ was previously declared here
   20 | AD9361_InitParam bladerf2_rfic_init_params = {
      |                  ^
/home/zero/development/bladeRF/fpga_common/src/ad936x_params.c:20:18: note: code may be misoptimized unless ‘-fno-strict-aliasing’ is used
lto-wrapper: warning: using serial compilation of 6 LTRANS jobs
lto-wrapper: note: see the ‘-flto’ option documentation for more information

@Jannik2099
Copy link

The definitions of AD9361_InitParam differ.

thirdparty/analogdevicesinc/no-OS/ad9361/sw/ad9361_api.h : size 528 bytes.
fpga_common/include/ad936x.h : size 536 bytes.

diff between small and big (comments removed):

88d87
<     uint32_t fagc_lock_level;
170a170,175
>     uint8_t clk_out_drive;
>     uint8_t dataclk_drive;
>     uint8_t data_port_drive;
>     uint8_t clk_out_slew;
>     uint8_t dataclk_slew;
>     uint8_t data_port_slew;

@rghilduta
Copy link
Collaborator

Yup that's it! Thanks for spotting it!

@ZeroChaos-
Copy link
Contributor Author

How we doing @rghilduta ? Any chance a fix is on the horizon?

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