Bug 245514 - net/librsync 2.3.0 fails to build
Summary: net/librsync 2.3.0 fails to build
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Matthias Andree
Depends on:
Reported: 2020-04-10 18:24 UTC by Simeon Simeonov
Modified: 2020-05-17 12:24 UTC (History)
9 users (show)

See Also:
mandree: maintainer-feedback-

Build log (40.10 KB, text/plain)
2020-04-10 18:24 UTC, Simeon Simeonov
no flags Details
pkg info (21.17 KB, text/plain)
2020-04-10 18:25 UTC, Simeon Simeonov
no flags Details
localbase:ldflag patch (338 bytes, patch)
2020-04-29 14:05 UTC, Franco Fichtner
mandree: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simeon Simeonov 2020-04-10 18:24:53 UTC
Created attachment 213255 [details]
Build log

net/librsync-2.3.0 fails to build with the following error:

[69/69] : && /usr/bin/cc -O2 -pipe -fno-strict-aliasing  -fstack-protector-strong -Wall -std=c99 -pedantic -O2 -pipe -fno-strict-aliasing  -fstack-protector-strong  -fstack-protector-strong CMakeFiles/rdiff.dir/src/rdiff.c.o CMakeFiles/rdiff.dir/src/isprefix.c.o  -o rdiff  -Wl,-rpath,/usr/ports/net/librsync/work/.build:  librsync.so.2.3.0  -lpopt && :
FAILED: rdiff 
: && /usr/bin/cc -O2 -pipe -fno-strict-aliasing  -fstack-protector-strong -Wall -std=c99 -pedantic -O2 -pipe -fno-strict-aliasing  -fstack-protector-strong  -fstack-protector-strong CMakeFiles/rdiff.dir/src/rdiff.c.o CMakeFiles/rdiff.dir/src/isprefix.c.o  -o rdiff  -Wl,-rpath,/usr/ports/net/librsync/work/.build:  librsync.so.2.3.0  -lpopt && :
ld: error: unable to find library -lpopt
cc: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

make: stopped in /usr/ports/net/librsync

Attaching full log and pkg info.

[root@SagaBOX /usr/ports/net/librsync]# uname -a
FreeBSD SagaBOX 12.1-STABLE FreeBSD 12.1-STABLE r359151 SagaBOX  amd64
Comment 1 Simeon Simeonov 2020-04-10 18:25:45 UTC
Created attachment 213256 [details]
pkg info
Comment 2 Peter Putzer 2020-04-11 21:56:56 UTC
I've noticed the same issue today:

[54/69] : && /usr/local/libexec/ccache/world/cc -O3 -pipe -funroll-loops -march=native  -fstack-protector-strong -fno-strict-aliasing -Wall -std=c99 -pedantic -O3 -pipe -funroll-loops -march=native  -fstack-protector-strong -fno-strict-aliasing  -fstack-protector-strong CMakeFiles/rdiff.dir/src/rdiff.c.o CMakeFiles/rdiff.dir/src/isprefix.c.o  -o rdiff  -Wl,-rpath,/usr/ports/net/librsync/work/.build:  librsync.so.2.3.0  -lpopt && :
FAILED: rdiff 
: && /usr/local/libexec/ccache/world/cc -O3 -pipe -funroll-loops -march=native  -fstack-protector-strong -fno-strict-aliasing -Wall -std=c99 -pedantic -O3 -pipe -funroll-loops -march=native  -fstack-protector-strong -fno-strict-aliasing  -fstack-protector-strong CMakeFiles/rdiff.dir/src/rdiff.c.o CMakeFiles/rdiff.dir/src/isprefix.c.o  -o rdiff  -Wl,-rpath,/usr/ports/net/librsync/work/.build:  librsync.so.2.3.0  -lpopt && :
ld: error: unable to find library -lpopt
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 3 Peter Putzer 2020-04-12 10:43:42 UTC
Somehow, the linker is not searching /usr/local/lib. Adding the following snippet to /etc/make.conf allowed for successful compilation:

.if ${.CURDIR:M*/ports/net/librsync}
  LDFLAGS += -L/usr/local/lib

Normally, configure should pick up the LD paths, but somehow this is not happening here.
Comment 4 Simeon Simeonov 2020-04-15 07:22:48 UTC
Thank you for the fint, Peter. Worked for me.
Comment 5 Simeon Simeonov 2020-04-15 07:23:22 UTC
*the hint
Comment 6 Sunpoet Po-Chuan Hsieh freebsd_committer 2020-04-15 17:24:04 UTC
The build failure does not happen on a clean box.


(In reply to Simeon Simeonov from comment #0)
I guess the problem would go away if you uninstall librsync-2.2.1 first.

(In reply to Peter Putzer from comment #2)
Do you have old version installed?
Comment 7 Peter Putzer 2020-04-15 17:30:11 UTC
(In reply to Sunpoet Po-Chuan Hsieh from comment #6)

Of course.
Comment 8 mark burdett 2020-04-25 12:11:52 UTC
Uninstalling the old librsync did not resolve the problem for me.
Comment 9 Franco Fichtner 2020-04-28 06:52:31 UTC
I'm also seeing this consistently even in clean chroot environments.
Comment 10 Franco Fichtner 2020-04-28 07:08:48 UTC
Oddly, this doesn't work:

USES+= localbase

But this works for me:

LDFLAGS= -L/usr/local/lib

Comment 11 Franco Fichtner 2020-04-29 14:05:16 UTC
Created attachment 213914 [details]
localbase:ldflag patch

The attached patch should meet the quality standard for inclusion.  ;)

Comment 12 Matthias Andree freebsd_committer 2020-05-16 15:28:45 UTC
claiming, maintainer timeout and also fixing breakage
Comment 13 Matthias Andree freebsd_committer 2020-05-16 15:40:36 UTC
Something appears to be hosed inside librsync-2.3.0/cmake/FindPOPT.cmake, but not being too experienced with cmake, I don't see exactly what breaks and where the rsync upstream got it from. 

I was debugging the same thing after reports on FreeBSD-ports@, and figured that if pkg-config was available during "make configure", then the build broke.  The popt.pc file seems harmless, but is apparently not processed properly.

Bug report filed upstream.
Comment 14 Sunpoet Po-Chuan Hsieh freebsd_committer 2020-05-16 15:48:18 UTC
(In reply to Matthias Andree from comment #12)

I just don't think the patch is correct. But thanks for your investigation that the existance of pkgconfig seems to be the cause. That's why it does not happen in a clean jail.
Comment 15 commit-hook freebsd_committer 2020-05-16 15:55:02 UTC
A commit references this bug:

Author: mandree
Date: Sat May 16 15:54:06 UTC 2020
New revision: 535474
URL: https://svnweb.freebsd.org/changeset/ports/535474

  net/librsync 2.3.0: fix build with pkg-config available [1]

  While here, enable "make test" (requires upstream file missing from
  tarball and adaptations as to bash's install path, which add).

  This bug shows building the ports directly because pkg-config is often
  available, but does not show in poudriere because pkgconf/pkg-config
  is not a listed requisite und therefore missing from the build jail.

  PR:		245514 [2]
  Submitted by:	Franco Fichtner <franco@opnsense.org> [1][2]
  Reported by:	Simeon Simeonov <sgs@pichove.org> [2]
  Reported by:	Xavier Humbert <xavier@groumpf.org> (through freebsd-ports@)
  Reported by:	Jakob Breivik Grimstveit <jakob@grimstveit.no> (through freebsd-ports@)
  Approved by:	sunpoet@ (maintainer timeout, 17 days; also blanket fix broken port approval)

Comment 16 commit-hook freebsd_committer 2020-05-16 15:58:05 UTC
A commit references this bug:

Author: mandree
Date: Sat May 16 15:57:52 UTC 2020
New revision: 535475
URL: https://svnweb.freebsd.org/changeset/ports/535475

  net/librsync 2.3.0: fixup make test

  psvn did not add the svn:executable property when I'd committed r535474.
  Add that, and a chmod +x in-depth ("paranoia") fix.

  PR:		245514
  Approved by:	portmgr@ (blanket approval to fix broken port (feature))

_U  head/net/librsync/files/rdiff_bad_option.sh
Comment 17 Matthias Andree freebsd_committer 2020-05-16 15:58:43 UTC
Comment on attachment 213914 [details]
localbase:ldflag patch

approved through maintainer timeout and found working in my tests (hat: committer)
Comment 18 Matthias Andree freebsd_committer 2020-05-16 16:27:56 UTC
(In reply to Sunpoet Po-Chuan Hsieh from comment #14)
Well, feel free to commit a better solution, or if you want, I can revert it and add LDFLAGS+=-L${LOCALBASE}/lib instead, which also fixes the issue.
Comment 19 Franco Fichtner 2020-05-17 07:54:25 UTC
It would be of use if we do not claim "clean jail" is actually the Poudriere jail as actually any clean jail in the FreeBSD sense has the bug because we simply use the ports tree to build it which doesn't always track dependencies in case of auxiliary build dependencies.  "Poudriere" is perfectly sufficient to address the special jail situation.  Furthermore, having the ports tree by itself in a working state is more effective than having a third party tool that outsmarts the ports build progress.

As far as I can see the ports tree was built to enable building third party software and provide workarounds so that upstream does not necessarily need to be fixed so that localbase:ldflags seems like a sensible thing to do until the upstream situation changes.

In any case, thanks for committing the workaround.  :)

Comment 20 Matthias Andree freebsd_committer 2020-05-17 12:24:25 UTC
It's actually one possible fix to the root cause, not just a workaround.

cmake's pkg-config support is, at best, incomplete, and severly underdocumented, after all those years. 

librsync's cmake stuff (main CMakeLists.txt, cmake/FindPOPT.cmake) disregards LDFLAGS.  Only the -l options (pkg-config --libs-only-l) end up in the POPT_LIBRARY variable the that the linker command gets passed in the top-level CMakeLists.txt file, however the LDFLAGS and LDFLAGS_OTHER are not added and lost.  

The "hunt without pkg-config" code path obtains the absolute path to libpopt and therefore does not need the -L option.

You can see for yourself adding CMAKE_ARGS+=--trace to Makefile and then reading the log from the "make configure" phase and comparing from a build with, and a build without pkg-config.