Bug 257708 - devel/stlink: Fails to build on 32-bit architectures: error: implicit conversion loses integer precision
Summary: devel/stlink: Fails to build on 32-bit architectures: error: implicit convers...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: i386 Any
: --- Affects Some People
Assignee: Yasuhiro Kimura
URL: https://lists.freebsd.org/archives/fr...
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-09 12:14 UTC by Robert Clausecker
Modified: 2021-10-27 16:45 UTC (History)
3 users (show)

See Also:
koobs: maintainer-feedback? (lev)
yasu: merge-quarterly+


Attachments
devel/stlink/files/patch-src_common.c (263 bytes, patch)
2021-08-22 14:42 UTC, Robert Clausecker
fuz: maintainer-approval-
Details | Diff
devel/stlink: fix build on 32 bit platforms (6.39 KB, patch)
2021-09-15 10:15 UTC, Robert Clausecker
koobs: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Clausecker freebsd_committer freebsd_triage 2021-08-09 12:14:54 UTC
As reported by Port Fallouts [1], devel/stlink fails to build on various 32 bit platforms.  This appears to be due to an overly zealous warning:

/usr/bin/cc -DSTLINK_HAVE_SYS_MMAN_H -DSTLINK_HAVE_SYS_TIME_H -DSTLINK_HAVE_UNISTD_H -I/wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/inc -I/wrkdirs/usr/ports/devel/stlink/work/.build/inc -I/wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/src -I/wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/src/st-flash -I/wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/src/stlink-lib -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c99 -std=gnu11 -std=gnu18 -Wall -Wextra -Wshadow -D_FORTIFY_SOURCE=2 -fstrict-aliasing -Wundef -Wformat -Wformat-security -Wmissing-variable-declarations -Wshorten-64-to-32 -Wimplicit-function-declaration -Wredundant-decls -fPIC -O2 -Werror -O2 -pipe  -fstack-protector-strong -fno-strict-aliasing -std=c99 -MD -MT CMakeFiles/stlink-static.dir/src/common.c.o -MF CMakeFiles/stlink-static.dir/src/common.c.o.d -o CMakeFiles/stlink-static.dir/src/common.c.o -c /wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/src/common.c
/wrkdirs/usr/ports/devel/stlink/work/stlink-1.7.0/src/common.c:2222:16: error: implicit conversion loses integer precision: 'off_t' (aka 'long long') to 'size_t' (aka 'unsigned int') [-Werror,-Wshorten-64-to-32]
  mf->len = st.st_size;
          ~ ~~~^~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.

A patch for this issue had already existed in am old revision [2], but was taken out last year.  Perhaps it is required to reintroduce the patch.  I have meanwhile reported the issue back to upstream, so perhaps they may fix it once again. [3]

[1]: https://lists.freebsd.org/archives/freebsd-pkg-fallout/2021-August/073895.html
[2]: https://cgit.freebsd.org/ports/commit/devel/stlink?id=fa323644a47f359c2bf843fd98aaa956e14ba845
[3]: https://github.com/stlink-org/stlink/issues/1175
Comment 1 Robert Clausecker freebsd_committer freebsd_triage 2021-08-22 14:42:21 UTC
Created attachment 227367 [details]
devel/stlink/files/patch-src_common.c

Attached is a patch that fixes the build once again.  It can be added to the port as

    /usr/ports/devel/stlink/files/patch-src_common.c

to fix the build.  Tested on armv7 FreeBSD 13.0-RELEASE.

The contents of this patch have been proposed upstream and may be included in a future release:

https://github.com/stlink-org/stlink/issues/1175

Please also consider making the GTK3 option into a flavour in a future version of the port.
Comment 2 Robert Clausecker freebsd_committer freebsd_triage 2021-08-29 13:55:06 UTC
maintainer timeout.
Comment 3 Robert Clausecker freebsd_committer freebsd_triage 2021-09-07 00:46:03 UTC
Comment on attachment 227367 [details]
devel/stlink/files/patch-src_common.c

Maintainer timeout for patch.
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2021-09-14 23:37:25 UTC
@Robert Thanks for the report and patch. Could you:

- Update the patch to include a comment in the header
- Look for a method to disable, or override -Werror, which shouldn't be used/included in release builds.
Comment 5 Robert Clausecker freebsd_committer freebsd_triage 2021-09-15 10:15:08 UTC
Created attachment 227911 [details]
devel/stlink: fix build on 32 bit platforms

Improved patch as per koobs' wishes.

While we are at it, pet portlint and portclippy and regenerate existing patches.

Tested with Poudriere on armv7 arm64 i386 amd64 FreeBSD 13.0-RELEASE.
Comment 6 Robert Clausecker freebsd_committer freebsd_triage 2021-10-07 14:23:32 UTC
Comment on attachment 227911 [details]
devel/stlink: fix build on 32 bit platforms

maintainer timeout
Comment 7 Kubilay Kocak freebsd_committer freebsd_triage 2021-10-08 00:10:52 UTC
^Triage: Reset assignee (maintainer/assignee timeout), open to take
Comment 8 Yasuhiro Kimura freebsd_committer freebsd_triage 2021-10-18 10:34:11 UTC
Take.
Comment 9 commit-hook freebsd_committer freebsd_triage 2021-10-27 15:57:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b6534ecd950cf32e1b76733d34a2ec929b690704

commit b6534ecd950cf32e1b76733d34a2ec929b690704
Author:     Robert Clausecker <fuz@fuz.su>
AuthorDate: 2021-08-22 16:54:30 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2021-10-27 15:53:07 +0000

    devel/stlink: Fix build on 32 bit platforms

    * Remove settings of optimization from cmake/modules/c_flags.cmake as
      per section 13.9 of Porter's Handbook
    * Switch to DISTVERSION
    * Pet portclippy
    * Reformat Makefile with portfmt

    PR:             257708
    Approved by:    maitainer timeout (> 1 month)
    Differential Revision:  https://reviews.freebsd.org/D32545

 devel/stlink/Makefile                              | 31 +++++++++-----------
 devel/stlink/files/patch-CMakeLists.txt            |  8 +++--
 .../files/patch-cmake_modules_c__flags.cmake (new) | 18 ++++++++++++
 .../files/patch-doc_dev_pkg-config_CMakeLists.txt  |  6 ++--
 devel/stlink/files/patch-doc_man_CMakeLists.txt    |  6 ++--
 devel/stlink/files/patch-src_common.c (new)        | 34 ++++++++++++++++++++++
 6 files changed, 77 insertions(+), 26 deletions(-)
Comment 10 commit-hook freebsd_committer freebsd_triage 2021-10-27 16:02:19 UTC
A commit in branch 2021Q4 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=8c44014b13ddb0392fab868ed5822e11ea3af0f4

commit 8c44014b13ddb0392fab868ed5822e11ea3af0f4
Author:     Robert Clausecker <fuz@fuz.su>
AuthorDate: 2021-08-22 16:54:30 +0000
Commit:     Yasuhiro Kimura <yasu@FreeBSD.org>
CommitDate: 2021-10-27 16:00:19 +0000

    devel/stlink: Fix build on 32 bit platforms

    * Remove settings of optimization from cmake/modules/c_flags.cmake as
      per section 13.9 of Porter's Handbook
    * Switch to DISTVERSION
    * Pet portclippy
    * Reformat Makefile with portfmt

    PR:             257708
    Approved by:    maitainer timeout (> 1 month)
    Differential Revision:  https://reviews.freebsd.org/D32545

    (cherry picked from commit b6534ecd950cf32e1b76733d34a2ec929b690704)

 devel/stlink/Makefile                              | 31 +++++++++-----------
 devel/stlink/files/patch-CMakeLists.txt            |  8 +++--
 .../files/patch-cmake_modules_c__flags.cmake (new) | 18 ++++++++++++
 .../files/patch-doc_dev_pkg-config_CMakeLists.txt  |  6 ++--
 devel/stlink/files/patch-doc_man_CMakeLists.txt    |  6 ++--
 devel/stlink/files/patch-src_common.c (new)        | 34 ++++++++++++++++++++++
 6 files changed, 77 insertions(+), 26 deletions(-)
Comment 11 Yasuhiro Kimura freebsd_committer freebsd_triage 2021-10-27 16:11:13 UTC
Committed and merged to quarterly branch. Thanks!
Comment 12 Robert Clausecker freebsd_committer freebsd_triage 2021-10-27 16:45:52 UTC
(In reply to Yasuhiro Kimura from comment #11)

Thanks!

Could you please also bump PORTREVISION for this change as it seems that it affects build flags?