Bug 107662 - --enable-relocation support breaks assumptions made by mingw32-install-post.sh
Summary: --enable-relocation support breaks assumptions made by mingw32-install-post.sh
Status: RESOLVED MOVED
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: git master
Hardware: Other Windows (All)
: medium normal
Assignee: D-Bus Maintainers
QA Contact: D-Bus Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-23 06:28 UTC by Ralf Habacker
Modified: 2018-10-12 21:36 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
fix-order-of-dbus-1.pc.patch (266 bytes, patch)
2018-08-23 06:28 UTC, Ralf Habacker
Details | Splinter Review
add-enable-relocation-force.patch (1.11 KB, patch)
2018-08-23 06:28 UTC, Ralf Habacker
Details | Splinter Review
fix-order-of-dbus-1.pc.patch (update1) (705 bytes, patch)
2018-08-27 07:35 UTC, Ralf Habacker
Details | Splinter Review
Build log of dbus consumer showing order of dbus-1.pc line order issue (253.68 KB, application/gzip)
2018-08-28 13:46 UTC, Ralf Habacker
Details
dbus build log (25.96 KB, application/gzip)
2018-08-29 06:01 UTC, Ralf Habacker
Details
build: Give better error messages if relocation is impossible (1.89 KB, patch)
2018-08-29 13:11 UTC, Simon McVittie
Details | Splinter Review
build: Make --enable-relocation compatible with hard-coding directories (1.99 KB, patch)
2018-08-29 13:12 UTC, Simon McVittie
Details | Splinter Review
[UNTESTED] build: Don't indirect pkg-config $prefix via $original_prefix (1.95 KB, patch)
2018-08-30 18:52 UTC, Simon McVittie
Details | Splinter Review

Description Ralf Habacker 2018-08-23 06:28:10 UTC
Created attachment 141245 [details] [review]
fix-order-of-dbus-1.pc.patch

Cross building dbus from git master with autotools for windows fails because of two issues

1.cross pkg-config 0.28 is confused to not have prefix= in the first line of dbus-1.pc 

2. relocation support in configure.ac does not recognize --exec_prefix expanded to ${prefix} and --libdir to ${prefix}/lib


For both issues a related patch has been appended.
Comment 1 Ralf Habacker 2018-08-23 06:28:35 UTC
Created attachment 141246 [details] [review]
add-enable-relocation-force.patch
Comment 2 Simon McVittie 2018-08-23 17:36:55 UTC
Comment on attachment 141245 [details] [review]
fix-order-of-dbus-1.pc.patch

Review of attachment 141245 [details] [review]:
-----------------------------------------------------------------

Please use `git format-patch` to include a commit message in proposed patches.

The actual change here seems fine, based on the justification you gave in the bug.
Comment 3 Simon McVittie 2018-08-23 17:42:01 UTC
(In reply to Ralf Habacker from comment #0)
> 2. relocation support in configure.ac does not recognize --exec_prefix
> expanded to ${prefix} and --libdir to ${prefix}/lib

It's meant to, so something must be going wrong.

What are the arguments you are passing to configure? (Note that the correct argument is --exec-prefix, not --exec_prefix - I'm assuming that was a typo while filing the bug.)

If you change the AC_MSG_ERROR like this:

-  [AC_MSG_ERROR([Relocatable pkg-config metadata requires --exec-prefix='\${prefix}' and the default libdir])])
+  [AC_MSG_ERROR([Relocatable pkg-config metadata requires --exec-prefix='\${prefix}' (have $exec_prefix) and the default libdir (have $libdir)])])

what is the error message you get?
Comment 4 Simon McVittie 2018-08-23 17:43:11 UTC
If you are able to use a newer Automake, it's possible that that might help. 1.13 is a few years old and our support for it might have decayed - the current version is 1.16.
Comment 5 Simon McVittie 2018-08-23 17:46:06 UTC
(In reply to Simon McVittie from comment #2)
> The actual change here seems fine, based on the justification you gave in
> the bug.

On second thoughts, no, this isn't going to work. In the non-relocating case we set pkgconfig_prefix='${original_prefix}', so original_prefix must come first.

If pkg-config requires the prefix to be the first thing in the .pc file, then we will need to AC_SUBST([pkgconfig_prefix], [${prefix}]) (without single quotes!) in the non-relocating case.
Comment 6 Simon McVittie 2018-08-23 17:49:03 UTC
Comment on attachment 141246 [details] [review]
add-enable-relocation-force.patch

Review of attachment 141246 [details] [review]:
-----------------------------------------------------------------

I would prefer not to do this, because the code that sets can_relocate is trying to detect whether the prefix/libdir/etc. are set in a way that makes our relocation assumptions work - so we should fix the detection, not add a way to force relocation in situations where it's going to fail.
Comment 7 Ralf Habacker 2018-08-27 07:34:40 UTC
(In reply to Simon McVittie from comment #4)
> If you are able to use a newer Automake, it's possible that that might help.
> 1.13 is a few years old and our support for it might have decayed - the
> current version is 1.16.

Sorry for confusion - I meant dbus 1.13 branch. This issue happens with pkg-config 2.28 and an update to 2.29.1 does not fix the issue.

The issue happened on compiling Qt5 as shown in a dedicated test case here 

From https://build.opensuse.org/build/home:rhabacker:branches:windows:mingw:win32:dbus-test/openSUSE_Leap_42.2/x86_64/mingw32-libqt5-qtbase/_log

The relevant parts are:
[   12s] [6/141] cumulate mingw32-dbus-1-devel-1.13.2-31.1
[   12s] [123/141] cumulate mingw32-cross-pkg-config-0.29.2-3.1

...

[  247s] Trying source 0 (type pkgConfig) of library dbus ...
[  247s] + PKG_CONFIG_SYSROOT_DIR=/.. PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ /usr/bin/i686-w64-mingw32-pkg-config --exists --silence-errors dbus-1 '>=' 1.2
[  247s] pkg-config did not find package.
[  247s]   => source produced no result.

Applying the patch "fix-order-of-dbus-1.pc.patch" fixes the issue

More details:

abuild@blendertest:~> cat /usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/dbus-1.pc   
original_prefix=${prefix}
prefix=${pcfiledir}/../../
exec_prefix=${prefix}
bindir=${prefix}/bin
libdir=${prefix}/lib
includedir=${prefix}/include
system_bus_default_address=unix:path=${prefix}/var/run/dbus/system_bus_socket
datarootdir=${prefix}/share
datadir=${prefix}/share
sysconfdir=${prefix}/etc
session_bus_services_dir=${datadir}/dbus-1/services
system_bus_services_dir=${datadir}/dbus-1/system-services
interfaces_dir=${datadir}/dbus-1/interfaces
daemondir=${bindir}

Name: dbus
Description: Free desktop message bus
Version: 1.13.2
Libs: -L${libdir} -ldbus-1
Libs.private:  -lws2_32 -liphlpapi -ldbghelp 
Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include 

abuild@blendertest:~> PKG_CONFIG_SYSROOT_DIR=/.. PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ /usr/bin/i686-w64-mingw32-pkg-config --exists --silence-errors dbus-1 '>=' 1.2 ; echo $?
1

swapping first two lines of  /usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/dbus-1.pc let pkg-config find dbus packge

abuild@blendertest:~> PKG_CONFIG_SYSROOT_DIR=/.. PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ /usr/bin/i686-w64-mingw32-pkg-config --exists --silence-errors dbus-1 '>=' 1.2 ; echo $?
0
Comment 8 Ralf Habacker 2018-08-27 07:35:10 UTC
Created attachment 141294 [details] [review]
fix-order-of-dbus-1.pc.patch (update1)
Comment 9 Simon McVittie 2018-08-28 12:43:35 UTC
(In reply to Ralf Habacker from comment #7)
> abuild@blendertest:~> PKG_CONFIG_SYSROOT_DIR=/..
> PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/
> /usr/bin/i686-w64-mingw32-pkg-config --exists --silence-errors dbus-1 '>='
> 1.2 ; echo $?
> 1

And if you don't --silence-errors, what are the error messages?
Comment 10 Simon McVittie 2018-08-28 12:53:23 UTC
Comment on attachment 141294 [details] [review]
fix-order-of-dbus-1.pc.patch (update1)

Review of attachment 141294 [details] [review]:
-----------------------------------------------------------------

You already proposed this patch, and I already said that if the order matters, then it can't be applied, because it breaks the non-relocatable case. And indeed, it does break the non-relocatable case:

% ./autogen.sh
% make
% make install DESTDIR=$(pwd)/DESTDIR
% PKG_CONFIG_PATH=$(pwd)/DESTDIR/usr/local/lib/pkgconfig pkg-config --cflags --libs dbus-1
Variable 'original_prefix' not defined in '/home/smcv/tmp/dbus/DESTDIR/usr/local/lib/pkgconfig/dbus-1.pc'
% git reset --hard        # undo that change
% PKG_CONFIG_PATH=$(pwd)/DESTDIR/usr/local/lib/pkgconfig pkg-config --cflags --libs dbus-1
-I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -L/usr/local/lib -ldbus-1

Any patch aiming to fix this bug will need to work in both the relocatable case and the non-relocatable case, and for both Autotools and CMake.
Comment 11 Simon McVittie 2018-08-28 13:02:46 UTC
Alternatively, we could back out this relocation magic and instead do as I suggested in <https://bugs.freedesktop.org/show_bug.cgi?id=99721#c70>:

> If you use
> 
>     pkg-config --define-prefix [...]
> 
> instead of plain pkg-config, then it automatically rewrites ${prefix}, based on > the assumption that the pkg-config files are in ${prefix}/lib/pkgconfig.
> 
> So one possible solution would be to revert the use of @pkgconfig_prefix@, and > instead tell people who are compiling a relocatable library stack to use
> PKG_CONFIG="pkg-config --define-prefix".
> 
> In a pkg-config.exe compiled for Windows, --define-prefix is the default anyway.
Comment 12 Simon McVittie 2018-08-28 13:08:06 UTC
(In reply to Ralf Habacker from comment #7)
> abuild@blendertest:~> cat
> /usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/dbus-1.pc   
> original_prefix=${prefix}
> prefix=${pcfiledir}/../../

I don't understand how this could possibly work, relocation or no relocation. The first line of the .pc.in file is

original_prefix=@prefix@

so this means you have @prefix@ expanding to ${prefix}. But that's surely got to be wrong, because in a more conventional .pc.in file (e.g. dbus 1.10.x) you'd have

prefix=@prefix@

and it is clearly not useful to set

prefix=${prefix}

because that would be infinitely recursive?

So I think your configure options must be wrong?

I asked in Comment #3 what exact configure options you are using. Please answer that? (I can't seem to access your log without an OBS login.)
Comment 13 Ralf Habacker 2018-08-28 13:46:22 UTC
Created attachment 141307 [details]
Build log of dbus consumer showing order of dbus-1.pc line order issue
Comment 14 Ralf Habacker 2018-08-28 13:50:54 UTC
(In reply to Simon McVittie from comment #9)
> (In reply to Ralf Habacker from comment #7)
> > abuild@blendertest:~> PKG_CONFIG_SYSROOT_DIR=/..
> > PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/
> > /usr/bin/i686-w64-mingw32-pkg-config --exists --silence-errors dbus-1 '>='
> > 1.2 ; echo $?
> > 1
> 
> And if you don't --silence-errors, what are the error messages?

abuild@blendertest:~> PKG_CONFIG_SYSROOT_DIR=/.. PKG_CONFIG_LIBDIR=/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig/ /usr/bin/i686-w64-mingw32-pkg-config --exists --print-errors dbus-1 '>=' 1.2 ; echo $?
Variable 'prefix' not defined in '/usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig//dbus-1.pc'
1
Comment 15 Simon McVittie 2018-08-28 14:06:40 UTC
(In reply to Simon McVittie from comment #12)
> I asked in Comment #3 what exact configure options you are using. Please
> answer that? (I can't seem to access your log without an OBS login.)

Oh, sorry, I thought the log you'd linked to was for dbus itself, not a consumer of dbus. Please quote the configure options used for dbus, or attach *its* log.
Comment 16 Ralf Habacker 2018-08-29 06:01:20 UTC
Created attachment 141334 [details]
dbus build log
Comment 17 Simon McVittie 2018-08-29 12:45:33 UTC
(In reply to Ralf Habacker from comment #16)
> Created attachment 141334 [details]
> dbus build log

And did this build produce a .pc file that was wrong in the same way you quoted? (If necessary add "cat whatever-path/dbus-1.pc" in an appropriate place in the spec file)

The configure command line seems to be

./configure \
--cache-file=mingw32-config.cache \
--host=i686-w64-mingw32 \
--build=x86_64-suse-linux-gnu \
--target=i686-w64-mingw32 \
--prefix=/usr/i686-w64-mingw32/sys-root/mingw \
--exec-prefix=/usr/i686-w64-mingw32/sys-root/mingw \
--bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin \
--sbindir=/usr/i686-w64-mingw32/sys-root/mingw/sbin \
--sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc \
--datadir=/usr/i686-w64-mingw32/sys-root/mingw/share \
--includedir=/usr/i686-w64-mingw32/sys-root/mingw/include \
--libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib \
--libexecdir=/usr/i686-w64-mingw32/sys-root/mingw/libexec \
--localstatedir=/usr/i686-w64-mingw32/sys-root/mingw/var \
--sharedstatedir=/usr/i686-w64-mingw32/sys-root/mingw/com \
--mandir=/usr/i686-w64-mingw32/sys-root/mingw/share/man \
--infodir=/usr/i686-w64-mingw32/sys-root/mingw/share/info \
--enable-maintainer-mode \
--disable-static \
--enable-verbose-mode \
--enable-embedded-tests \
--enable-checks \
--enable-asserts \
--disable-xml-docs \
--disable-doxygen-docs \
--enable-relocation=force \
'--with-dbus-session-bus-listen-address=autolaunch:scope=*install-path' \
'--with-dbus-session-bus-connect-address=autolaunch:scope=*install-path;autolaunch:'

With that, I would expect @prefix@ to expand to /usr/i686-w64-mingw32/sys-root/mingw, so the .pc file should start with:

original_prefix=/usr/i686-w64-mingw32/sys-root/mingw
prefix=${pcfiledir}/../../

I don't understand why that wouldn't happen in this case, and in fact I don't understand how ${prefix} got into your .pc file at all - your configure command-line hard-codes all the relevant directories, so I would expect to see libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib etc., with no mentions of ${prefix}?

Are you sure the build you did on OBS produced the .pc file that you are quoting above?
Comment 18 Simon McVittie 2018-08-29 13:01:48 UTC
(In reply to Simon McVittie from comment #6)
> Comment on attachment 141246 [details] [review]
> add-enable-relocation-force.patch
> 
> I would prefer not to do this, because the code that sets can_relocate is
> trying to detect whether the prefix/libdir/etc. are set in a way that makes
> our relocation assumptions work - so we should fix the detection, not add a
> way to force relocation in situations where it's going to fail.

I see what's going wrong with this now: because your RPM spec file hard-codes all the individual directories instead of leaving them at their defaults (even in cases where they could have been left at their defaults, including exec_prefix='${prefix}' and libdir='${exec_prefix}/lib'), the two AS_CASE() checks fail.

I'll propose an alternative patch.
Comment 19 Simon McVittie 2018-08-29 13:11:46 UTC
Created attachment 141345 [details] [review]
build: Give better error messages if relocation is impossible

There are two reasons why we might reject relocation: the exec_prefix
differing from the prefix, or the libdir not being a first-level
subdirectory named "lib" or "lib64" of the prefix. Make it clearer
which one failed and why.
Comment 20 Simon McVittie 2018-08-29 13:12:59 UTC
Created attachment 141346 [details] [review]
build: Make --enable-relocation compatible with hard-coding directories

Open Build Service RPMs for mingw32-dbus-1 hard-code all the
directories to make everything explicit, notably:

--prefix=/usr/i686-w64-mingw32/sys-root/mingw
--exec-prefix=/usr/i686-w64-mingw32/sys-root/mingw
...
--libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib

Previously we didn't accept this as relocatable, but actually it's
fine: ${prefix} is still equivalent to ${libdir}/pkgconfig/../..,
so our relocation setup can work. Accept the result of expanding
"${prefix}" as an acceptable value for --exec-prefix, and accept the
results of expanding "${exec_prefix}/lib" etc. as acceptable values
for --libdir.

Note the use of single vs. double quotes here. A case statement that
matches '${prefix}' tests for the literal string «${prefix}»,
whereas a case that matches "${prefix}" tests for the string that is
the value of the variable named «prefix» that is set by the
--prefix command-line argument.
Comment 21 Simon McVittie 2018-08-29 13:18:34 UTC
I tried configuring git master with the same installation directories as your RPM build:

% ./configure \
--prefix=/usr/i686-w64-mingw32/sys-root/mingw \
--exec-prefix=/usr/i686-w64-mingw32/sys-root/mingw \
--bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin \
--sbindir=/usr/i686-w64-mingw32/sys-root/mingw/sbin \
--sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc \
--datadir=/usr/i686-w64-mingw32/sys-root/mingw/share \
--includedir=/usr/i686-w64-mingw32/sys-root/mingw/include \
--libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib \
--libexecdir=/usr/i686-w64-mingw32/sys-root/mingw/libexec \
--localstatedir=/usr/i686-w64-mingw32/sys-root/mingw/var \
--sharedstatedir=/usr/i686-w64-mingw32/sys-root/mingw/com \
--mandir=/usr/i686-w64-mingw32/sys-root/mingw/share/man \
--infodir=/usr/i686-w64-mingw32/sys-root/mingw/share/info \


and I get those directories in my dbus-1.pc:

% cat dbus-1.pc
original_prefix=/usr/i686-w64-mingw32/sys-root/mingw
prefix=${original_prefix}
exec_prefix=/usr/i686-w64-mingw32/sys-root/mingw
bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin
libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib
includedir=/usr/i686-w64-mingw32/sys-root/mingw/include
system_bus_default_address=unix:path=/usr/i686-w64-mingw32/sys-root/mingw/var/run/dbus/system_bus_socket
datarootdir=${prefix}/share
datadir=/usr/i686-w64-mingw32/sys-root/mingw/share
sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc
session_bus_services_dir=${datadir}/dbus-1/services
system_bus_services_dir=${datadir}/dbus-1/system-services
interfaces_dir=${datadir}/dbus-1/interfaces
daemondir=${bindir}

So I don't see how to reproduce the issue with original_prefix referencing undefined variables?
Comment 22 Simon McVittie 2018-08-29 13:26:37 UTC
If I do all that and then add --enable-relocation, this is what I get:

original_prefix=/usr/i686-w64-mingw32/sys-root/mingw
prefix=${pcfiledir}/../../
exec_prefix=/usr/i686-w64-mingw32/sys-root/mingw
bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin
libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib
includedir=/usr/i686-w64-mingw32/sys-root/mingw/include
system_bus_default_address=unix:path=/usr/i686-w64-mingw32/sys-root/mingw/var/run/dbus/system_bus_socket
datarootdir=${prefix}/share
datadir=/usr/i686-w64-mingw32/sys-root/mingw/share
sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc
session_bus_services_dir=${datadir}/dbus-1/services
system_bus_services_dir=${datadir}/dbus-1/system-services
interfaces_dir=${datadir}/dbus-1/interfaces
daemondir=${bindir}

That means --enable-relocation was not actually *helpful* in this configuration (it would work better if --exec-prefix, --bindir, etc. were not explicitly given, and were left at their defaults instead), but it also doesn't seem harmful.

If the feature is not actually helping you because your build configuration is hard-coding all those paths, then we should maybe just revert it? But if it's beneficial in other setups then we can keep it.
Comment 23 Philip Withnall 2018-08-30 10:21:59 UTC
Comment on attachment 141345 [details] [review]
build: Give better error messages if relocation is impossible

Review of attachment 141345 [details] [review]:
-----------------------------------------------------------------

r+
Comment 24 Philip Withnall 2018-08-30 10:22:04 UTC
Comment on attachment 141346 [details] [review]
build: Make --enable-relocation compatible with hard-coding directories

Review of attachment 141346 [details] [review]:
-----------------------------------------------------------------

r+
Comment 25 Simon McVittie 2018-08-30 16:50:09 UTC
Thanks, I'll merge those two commits if CI is successful.

NEEDINFO for what is going on with the first line of dbus-1.pc (see Comment #17, 21, 22).
Comment 26 Simon McVittie 2018-08-30 17:03:33 UTC
Sigh. It looks like this:

> [  211s] + /usr/lib/rpm/mingw32-install-post.sh

is postprocessing the .pc file:

> if [ -d "$RPM_BUILD_ROOT/usr/$host/sys-root/mingw/lib/pkgconfig" ]; then
>     pushd "$RPM_BUILD_ROOT/usr/$host/sys-root/mingw/lib/pkgconfig"
>     for f in `find . -type f -name "*.pc"`; do
>         mv "$f" "$f~"
>         sed \
>          -e 's#L/usr/'"$host"'/sys-root/mingw/lib#L\${libdir}#g' \
>          -e 's#I/usr/'"$host"'/sys-root/mingw/include#I\${includedir}#g' \
>          -e 's#/usr/'"$host"'/sys-root/mingw#\${prefix}#g' \
>          -e 's#^prefix=\${prefix}#prefix=/usr/'"$host"'/sys-root/mingw#g' \
>          <"$f~" >"$f"
>         rm -f "$f~"
>     done
>     popd
> fihttps://build.opensuse.org/package/view_file/windows:mingw:win32/mingw32-filesystem/mingw32-install-post.sh?expand=1

I'm sorry, but I can't support build processes that arbitrarily rewrite what we install. This is going to break the relocation support that was added in Bug #99721, which is ironic, because this and Bug #99721 are both meant to be for the benefit of people doing relocatable builds.

I'm very tempted to revert all the relocatability stuff from here and Bug #99721, and say that people who want relocatable builds will have to rely on pkg-config's built-in support for it (pkg-config --define-prefix, see https://bugs.freedesktop.org/show_bug.cgi?id=99721#c70) which seems to be what mingw32-install-post.sh is assuming they will do.
Comment 27 Ralf Habacker 2018-08-30 17:18:03 UTC
(In reply to Simon McVittie from comment #25)
> Thanks, I'll merge those two commits if CI is successful.
> 
> NEEDINFO for what is going on with the first line of dbus-1.pc (see Comment
> #17, 21, 22).

This is the dbus-1.pc file after running configure:

original_prefix=/usr/i686-w64-mingw32/sys-root/mingw
prefix=${pcfiledir}/../../
exec_prefix=/usr/i686-w64-mingw32/sys-root/mingw
bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin
libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib
includedir=/usr/i686-w64-mingw32/sys-root/mingw/include
system_bus_default_address=unix:path=/usr/i686-w64-mingw32/sys-root/mingw/var/run/dbus/system_bus_socket
datarootdir=${prefix}/share
datadir=/usr/i686-w64-mingw32/sys-root/mingw/share
sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc
session_bus_services_dir=${datadir}/dbus-1/services
system_bus_services_dir=${datadir}/dbus-1/system-services
interfaces_dir=${datadir}/dbus-1/interfaces
daemondir=${bindir}

Name: dbus
Description: Free desktop message bus
Version: 1.13.2
Libs: -L${libdir} -ldbus-1
Libs.private:  -lws2_32 -liphlpapi -ldbghelp 
Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include
Comment 28 Simon McVittie 2018-08-30 17:33:01 UTC
OK, so as I suspected, the dbus-1.pc that we produce is fine. However, mingw32-install-post.sh rewrites it into something that won't work: it rewrites the first line to "original_prefix=${prefix}".
Comment 29 Ralf Habacker 2018-08-30 17:49:29 UTC
(In reply to Simon McVittie from comment #28)
> OK, so as I suspected, the dbus-1.pc that we produce is fine. However,
> mingw32-install-post.sh rewrites it into something that won't work: it
> rewrites the first line to "original_prefix=${prefix}".

This is the installed file

original_prefix=${prefix}
prefix=${pcfiledir}/../../
exec_prefix=${prefix}
bindir=${prefix}/bin
libdir=${prefix}/lib
includedir=${prefix}/include
system_bus_default_address=unix:path=${prefix}/var/run/dbus/system_bus_socket
datarootdir=${prefix}/share
datadir=${prefix}/share
sysconfdir=${prefix}/etc
session_bus_services_dir=${datadir}/dbus-1/services
system_bus_services_dir=${datadir}/dbus-1/system-services
interfaces_dir=${datadir}/dbus-1/interfaces
daemondir=${bindir}

Name: dbus
Description: Free desktop message bus
Version: 1.13.2
Libs: -L${libdir} -ldbus-1
Libs.private:  -lws2_32 -liphlpapi -ldbghelp 
Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include
Comment 30 Simon McVittie 2018-08-30 18:45:38 UTC
Thanks, that confirms that dbus is doing the right thing, but the mingw32 library packaging infrastructure in your OBS project is rewriting our installed files based on faulty assumptions. I see two possible solutions.

Removing --enable-relocation
============================

One possible way to proceed from here would be to revert the whole --enable-relocation feature. The mingw32 packaging infrastructure seems to undo it anyway: it seems to be designed to force packages into a setup where "pkg-config --define-prefix" will do the right thing, even if those packages have hard-coded paths (which in fact dbus doesn't, but the right thing would happen anyway).

When "pkg-config --define-prefix" exists, does it actually bring you any benefit to set "prefix=${pcfiledir}/../.."? It seems like, if we went back to the dbus-1.10 situation of hard-coding our $prefix into dbus-1.pc, "pkg-config --define-prefix --cflags dbus-1" should replace that hard-coded $prefix with the equivalent of ${pcfiledir}/../.. anyway?

If we go that route, then only two configurations really need testing: cmake or Autotools. We need to check that they both produce a working (ideally identical) dbus-1.pc file, and that, when an installation of dbus is relocated to a different directory, "pkg-config --define-prefix --cflags --libs dbus" returns -I, -L that point into that directory.

Keeping --enable-relocation
===========================

Or, if "prefix=${pcfiledir}/../.." genuinely gives you some benefit that you can't get any other way, then we will need to find a workaround for the mingw32 packaging infrastructure. I have a patch that might work, but it will need testing in a matrix of 8 different configurations:

cmake or Autotools
x
--enable-relocatable or --disable-relocatable (or their CMake equivalents)
x
explicitly specifying a prefix or leaving it unspecified

to make sure that in each of those 8 configurations, the contents of dbus-1.pc are something that will work.
Comment 31 Simon McVittie 2018-08-30 18:52:54 UTC
Created attachment 141388 [details] [review]
[UNTESTED] build: Don't indirect pkg-config $prefix via $original_prefix

---

I have not tested this at all. To be usable, it would need to be tested in 8 build configurations: (Autotools or CMake) x (relocatable or not) x (explicit prefix or default prefix).

For example, Attachment #141294 [details] succeeds for (Autotools, relocatable, explicit prefix) but fails for (Autotools, not relocatable, default prefix).
Comment 32 Simon McVittie 2018-08-30 18:56:55 UTC
(In reply to Simon McVittie from comment #30)
> When "pkg-config --define-prefix" exists, does it actually bring you any
> benefit to set "prefix=${pcfiledir}/../.."? It seems like, if we went back
> to the dbus-1.10 situation of hard-coding our $prefix into dbus-1.pc,
> "pkg-config --define-prefix --cflags dbus-1" should replace that hard-coded
> $prefix with the equivalent of ${pcfiledir}/../.. anyway?

Here's what I mean by that:

% ./autogen.sh
% make
% make install DESTDIR=$(pwd)/DESTDIR
% head -n4 DESTDIR/usr/local/lib/pkgconfig/dbus-1.pc
original_prefix=/usr/local
prefix=${original_prefix}
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
% PKG_CONFIG_PATH=$(pwd)/DESTDIR/usr/local/lib/pkgconfig pkg-config --dont-define-prefix --cflags --libs dbus-1
-I/usr/local/include/dbus-1.0 -I/usr/local/lib/dbus-1.0/include -L/usr/local/lib -ldbus-1
% PKG_CONFIG_PATH=$(pwd)/DESTDIR/usr/local/lib/pkgconfig pkg-config --define-prefix --cflags --libs dbus-1
-I/home/smcv/tmp/dbus/DESTDIR/usr/local/include/dbus-1.0 -I/home/smcv/tmp/dbus/DESTDIR/usr/local/lib/dbus-1.0/include -L/home/smcv/tmp/dbus/DESTDIR/usr/local/lib -ldbus-1

This suggests that pkg-config --define-prefix makes the --enable-relocatable feature unnecessary: it will override the given prefix and discover the root of the installation from the location of the .pc file anyway.
Comment 33 Ralf Habacker 2018-10-08 12:52:46 UTC
(In reply to Simon McVittie from comment #31)
> Created attachment 141388 [details] [review] [review]
> [UNTESTED] build: Don't indirect pkg-config $prefix via $original_prefix
> 
> ---
> 
> I have not tested this at all. To be usable, it would need to be tested in 8
> build configurations: (Autotools or CMake) x (relocatable or not) x
> (explicit prefix or default prefix).
> 
> For example, Attachment #141294 [details] succeeds for (Autotools,
> relocatable, explicit prefix) but fails for (Autotools, not relocatable,
> default prefix).
A challenge for the new freedesktop gitlab-CI ?
Comment 34 Simon McVittie 2018-10-08 13:12:50 UTC
(In reply to Ralf Habacker from comment #33)
> A challenge for the new freedesktop gitlab-CI ?

I don't think fd.o has the resources to run this many parallel builds routinely for every commit, but perhaps your branch could temporarily enable them and add some extra output (cat /usr/local/pkgconfig/dbus-1.pc, etc.) so that we can verify that they all did the right thing?

But before we put any resources or thought into that, please consider whether the relocation stuff is bringing you any benefit, compared with "pkg-config --define-prefix"? (See Comment #30, Comment #32.)
Comment 35 GitLab Migration User 2018-10-12 21:36:15 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/dbus/dbus/issues/220.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.