stlink-org/stlink

Can't build stlink 1.8.0 for Fedora

Vascom opened this issue · 8 comments

  • I made serious effort to avoid creating duplicate or nearly similar issue

In order to allow developers to isolate and target your respective issue, please take some time to select the check boxes below and fill out each of the following items appropriate to your specific problem.

  • Programmer/board type: [no]
  • Operating system an version: [Fedora GNU/Linux Rawhide]
  • stlink tools version and/or git commit hash: [1.8.0]
  • stlink commandline tool name: [no]
  • Target chip (and board, if applicable): [no]

Further we kindly ask you to describe the detected problem as detailed as possible and to add debug output if available, by using the following template:

Commandline output:

/builddir/build/BUILD/stlink-1.8.0/src/stlink-lib/chipid.c: In function ‘process_chipfile’:
/builddir/build/BUILD/stlink-1.8.0/src/stlink-lib/chipid.c:68:22: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
   68 |   ts = calloc(sizeof(struct stlink_chipid_params), 1);
      |                      ^~~~~~
/builddir/build/BUILD/stlink-1.8.0/src/stlink-lib/chipid.c:68:22: note: earlier argument should specify number of elements, later size of each element
/builddir/build/BUILD/stlink-1.8.0/src/stlink-lib/chipid.c: In function ‘process_chipfile’:
/builddir/build/BUILD/stlink-1.8.0/src/stlink-lib/chipid.c:68:22: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
   68 |   ts = calloc(sizeof(struct stlink_chipid_params), 1);
      |                      ^~~~~~
/builddir/build/BUILD/stlink-1.8.0/src/stlink-lib/chipid.c:68:22: note: earlier argument should specify number of elements, later size of each element

Expected:
Successful build.

I can't build stlink 1.8.0 for Fedora. Please help me fix it?

Interesting, it does not occur on debian (testing).
Please share the build-tool versions of your current toolchain to allow for further investigation.

eh, could you strip that down to the relevant information on the build tools used in the form of name, version, etc. ?

gcc 14.0.1
cmake 3.27.7
gtk3 3.24.41
libusb1 1.0.26
systemd 255.3

@Vascom It's a gcc 14.x issue:

Try to use gcc13.x for now. (which works, I used it for the compilation and package generation.)
As far as I can see it does not seem to be a toolset related issue.
However we would need to address it somewhen...

@Vascom: I seem to have found an unexpected solution for this issue: Try to swap the arguments of calloc - it should resolve the issue. There are no further similar findings by the gcc-14 compiler.
Please verify this at your side and report back.
Unless there is not more to it, I'll push the fix soon together with other resolved issues.

Thanks.
With gcc 13.2.1 there is no problem. But upcoming Fedora 40 have gcc 14.

Also if I swap calloc arguments in src/stlink-lib/chipid.c line 68 it compiled succesfully with gcc 13 and gcc 14.