Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 365817 - app-admin/chrpath: multilib patch breaks *BSD
Summary: app-admin/chrpath: multilib patch breaks *BSD
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All FreeBSD
: Normal normal (vote)
Assignee: Markos Chandras (RETIRED)
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2011-05-03 13:14 UTC by Fabian Groffen
Modified: 2011-08-29 19:23 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
chrpath-0.13-libdl-1.patch (chrpath-0.13-libdl-1.patch,1.46 KB, patch)
2011-08-28 18:20 UTC, Mario Fetka (geos_one)
Details | Diff
complete patch (chrpath-0.13-multilib.patch,4.03 KB, patch)
2011-08-29 15:45 UTC, Markos Chandras (RETIRED)
Details | Diff
config.log (config.log,33.68 KB, text/plain)
2011-08-29 15:55 UTC, Markos Chandras (RETIRED)
Details
build.log (build.log,18.12 KB, text/plain)
2011-08-29 15:59 UTC, Markos Chandras (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Groffen gentoo-dev 2011-05-03 13:14:24 UTC
multilib patch adds unconditional -ldl, it should have checked for this using configure instead.  This breaks on FreeBSD (and OpenBSD), where dl is part of libc.
Comment 1 Fabian Groffen gentoo-dev 2011-08-28 16:52:59 UTC
@hwoarang: you've committed the patch that breaks.  I've given you lots of time.  Perhaps this disappeared under your radar because it wasn't assigned to you.  You've got until 04-09-2011 and then I'll drop your patch if you haven't fix the breakage.
Comment 2 Markos Chandras (RETIRED) gentoo-dev 2011-08-28 17:14:20 UTC
Sorry, I forgot about this. You can remove my patch ( or I can do it for you ) since I don't know how to satisfy your request
Comment 3 Fabian Groffen gentoo-dev 2011-08-28 17:16:48 UTC
Well, you know how to check for a library with configure, right?  So just check if -ldl is necessary, store it in LDLIBS or something and use it instead of hardcoded -ldl.
Comment 4 Markos Chandras (RETIRED) gentoo-dev 2011-08-28 17:53:19 UTC
Yes but the actual multilib patch is a bit more complicated than that. I will have a look as soon as possible but I given the fact that I am not that familiar with autotools, I would suggest you to remove it until I provide a correct solution to that problem
Comment 5 Fabian Groffen gentoo-dev 2011-08-28 17:55:15 UTC
I suggest to work on it together then, so we don't have to drop it, thereby introducing a new bug.
Comment 6 Fabian Groffen gentoo-dev 2011-08-28 18:08:58 UTC
In Makefile.am you just add -ldl to chrpath_LDADD (libtool var).

Since Makefile.am is processed by automake, it ends up as a Makefile.in file, which gets expanded by configure.  So, you can:

- use chrpath_LDADD = @LDLIBS@ and have configure expand it, or
- use chrpath_LDADD = $(LDLIBS) and have autoconf/make define a variable for it in configure, AC_SUBST(LDLIBS), see
http://www.gnu.org/s/hello/manual/autoconf/Setting-Output-Variables.html
this is the proper way to do it

So, what's left then, is to define the check in configure.ac that actually sets LDLIBS (shell variable) inside configure to the right value (-ldl on Linux) before calling AC_SUBST(LDLIBS).

Simplest approach would be to make a simple case statement based on $host or $host_os (set by configure after AC_CANONICAL_HOST).  A bit more neat would be to use AC_SEARCH_LIBS([dlopen], [dl] [LDLIBS="-ldl"]), which just checks if -ldl is necessary to use the function dlopen, see http://www.gnu.org/s/hello/manual/autoconf/Libraries.html.

Because AC_SEARCH_LIBS actually modifies the value of LIBS, you may actually drop the entire LDADD stuff, or (cleaner) make sure you restore the original LIBS after the AC_SEARCH_LIBS function.
Comment 7 Markos Chandras (RETIRED) gentoo-dev 2011-08-28 18:16:39 UTC
Thank you so much for your help. I will rework my patch and post it here for review as soon as I am done.
Comment 8 Mario Fetka (geos_one) 2011-08-28 18:20:18 UTC
Created attachment 284907 [details, diff]
chrpath-0.13-libdl-1.patch

this patch schould correct the libdl detection on bsd and unix systems.

i can't test it but it schould work
Comment 9 Fabian Groffen gentoo-dev 2011-08-28 18:25:20 UTC
Heh, Darwin doesn't need -ldl, it's in libSystem (libc).  If you prefer to take the switch statement way, fine with me, the only platforms I know which need -ldl for dlopen are Linux and Solaris, but it may be others as well.
Comment 10 Mario Fetka (geos_one) 2011-08-28 18:31:36 UTC
i have taken the ld from this http://svn.cherokee-project.com/filedetails.php?repname=Cherokee&path=%2Fcherokee%2Ftrunk%2Fconfigure.in
Comment 11 Fabian Groffen gentoo-dev 2011-08-28 18:32:39 UTC
how about something like this?

% diff -u configure.ac{.orig,}
--- configure.ac.orig   2011-08-28 20:28:52.000000000 +0200
+++ configure.ac        2011-08-28 20:31:48.000000000 +0200
@@ -31,6 +31,15 @@
 dnl Checks for library functions.
 AC_CHECK_FUNCS(getopt_long)
 
+dnl See if we need -ldl on this platform for dlopen
+LDLIBS=
+save_LIBS="$LIBS"
+LIBS=
+AC_SEARCH_LIBS([dlopen], [dl] [LDLIBS="-ldl"])
+LIBS="${save_LIBS}"
+AC_SUBST([LDLIBS])
+
+
 if eval "test x$GCC = xyes"; then
   for flag in \
       -ansi \
Comment 12 Mario Fetka (geos_one) 2011-08-29 08:04:35 UTC
(In reply to comment #11)
> how about something like this?
> 
its simpler
Comment 13 Markos Chandras (RETIRED) gentoo-dev 2011-08-29 09:03:02 UTC
I am going offline until the 5th of September so give me some more time to create the full patch unless you come up with it on your own :)
Comment 14 Fabian Groffen gentoo-dev 2011-08-29 09:44:05 UTC
If you combine my snippet with Mario's one you've got the full patch, IMO.  Should be a 5 minute job.  :)
Comment 15 Markos Chandras (RETIRED) gentoo-dev 2011-08-29 15:45:10 UTC
Created attachment 285017 [details, diff]
complete patch

I tried to merge your patches. I came up with this patch. But it does not seem to work on my box. It fails due to undefined symbols in dlopen,dlsym etc. It is a bit hard for me to work on this issue because I won't have access to my boxes until the 5th and I am trying to fix this bug on my mobile phone :/
Comment 16 Fabian Groffen gentoo-dev 2011-08-29 15:47:04 UTC
ok, can you attach your configure output and config.log, then I'll take it from here.
Comment 17 Markos Chandras (RETIRED) gentoo-dev 2011-08-29 15:55:28 UTC
Created attachment 285019 [details]
config.log
Comment 18 Markos Chandras (RETIRED) gentoo-dev 2011-08-29 15:59:16 UTC
Created attachment 285021 [details]
build.log
Comment 19 Fabian Groffen gentoo-dev 2011-08-29 15:59:24 UTC
+AC_SEARCH_LIBS([dlopen], [dl] [LDLIBS="-ldl"])

hehe, you forgot the , there, so LDLIBS isn't assigned to :)  The check works as expected though.
Comment 20 Fabian Groffen gentoo-dev 2011-08-29 16:00:18 UTC
(ok, I forgot it in my snippet :p)
Comment 21 Markos Chandras (RETIRED) gentoo-dev 2011-08-29 16:04:01 UTC
Ah right. Correct. I will revbump (and remove old ebuild+patch) when I find a decent 3G signal to connect to that box :)
Comment 22 Markos Chandras (RETIRED) gentoo-dev 2011-08-29 19:23:48 UTC
OK this *should* be fixed in -r2. Old ebuild removed. thank you very much for you help.