Message ID | 20170805181853.10785-1-s.martin49@gmail.com |
---|---|
State | Accepted |
Headers | show |
On 05-08-17 20:18, Samuel Martin wrote: > This change is fixing the bug reported in [1]. > > Cmake may run pkg-config to find the dependencies when configuring a > package. Because of the value of PATH, and it will use the Buildroot's > pkg-config wrapper, which, by default, is configured (via some > environment variables) to find the target dependencies. > > When configuring a host package using cmake, to prevent cmake from > wrongly solving dependencies from the target tree (when the > *-config.cmake files are using pkg-config) instead of looking for them > in the Buildroot's host tree or in the host system itself, we need to > set the environment variables altering the pkg-config behavior in the > cmake configure environment. > > So, this change is fixing the cmake host-packages configuration step, > by properly setting the pkg-config environment variables to their values > for finding host dependencies. [snip] > Reported-by: "Sigalas, Antonios (Nokia - GR/Athens)" <antonios.sigalas@nokia.com> > Cc: "Sigalas, Antonios (Nokia - GR/Athens)" <antonios.sigalas@nokia.com> > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > Signed-off-by: Samuel Martin <s.martin49@gmail.com> Thank you for this extensive commit message! Applied to master, thanks. However... > > --- > > Note: > I think this fix is required on the master and cannot wait for the > next release cycle. > > changes v1->v2 > - elaborate even more the commit log > - add bug ref to the commit log (ThomasP) > --- > package/pkg-cmake.mk | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk > index 914bda7482..db78d897d8 100644 > --- a/package/pkg-cmake.mk > +++ b/package/pkg-cmake.mk > @@ -109,6 +109,11 @@ define $(2)_CONFIGURE_CMDS > cd $$($$(PKG)_BUILDDIR) && \ > rm -f CMakeCache.txt && \ > PATH=$$(BR_PATH) \ > + PKG_CONFIG="$$(PKG_CONFIG_HOST_BINARY)" \ > + PKG_CONFIG_SYSROOT_DIR="/" \ > + PKG_CONFIG_LIBDIR="$$(HOST_DIR)/lib/pkgconfig:$$(HOST_DIR)/share/pkgconfig" \ > + PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \ > + PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \ This is exactly the same as HOST_MAKE_ENV so could be refactored - but then it has to go to a new variable, perhaps. Or perhaps the variable should be renamed (because it really applies to any configure and build system, not just make) - but it's used in quite a few places so not so convenient. Also, other build systems may suffer from the same problem, e.g. python, though probably those usually don't use pkg-config. Finally, I think that what we're doing here is just plain silly. We create a wrapper script that sets some environment variables, but then we override those environment variables again half the time... A fundamentally better approach IMO is to create a HOST_DIR/cross-bin directory that contains the "cross" tools, like the pkg-config wrapper but also the foo-config scripts from STAGING_DIR and possibly some other stuff. And then for target builds we put that in front of PATH. But that, obviously, is a much bigger change. Regards, Arnout > $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \ > -DCMAKE_INSTALL_SO_NO_EXE=0 \ > -DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \ >
>>>>> "Samuel" == Samuel Martin <s.martin49@gmail.com> writes: > This change is fixing the bug reported in [1]. > Cmake may run pkg-config to find the dependencies when configuring a > package. Because of the value of PATH, and it will use the Buildroot's > pkg-config wrapper, which, by default, is configured (via some > environment variables) to find the target dependencies. > When configuring a host package using cmake, to prevent cmake from > wrongly solving dependencies from the target tree (when the > *-config.cmake files are using pkg-config) instead of looking for them > in the Buildroot's host tree or in the host system itself, we need to > set the environment variables altering the pkg-config behavior in the > cmake configure environment. > So, this change is fixing the cmake host-packages configuration step, > by properly setting the pkg-config environment variables to their values > for finding host dependencies. > Before this patch: > make O=/opt/br/abo/cmake-host-find-root-path libxml2 host-mariadb{-dirclean,-configure} && echo $? > [...] >>>> host-mariadb 10.1.25 Configuring > (mkdir -p > /opt/br/abo/cmake-host-find-root-path/build/host-mariadb-10.1.25/ && > cd /opt/br/abo/cmake-host-find-root-path/build/host-mariadb-10.1.25/ > && rm -f CMakeCache.txt && > PATH="/opt/br/abo/cmake-host-find-root-path/host/bin:/opt/br/abo/cmake-host-find-root-path/host/sbin:/home/sam/.local/bin:/sbin:/usr/sbin:/bin:/usr/bin" > /usr/bin/cmake > /opt/br/abo/cmake-host-find-root-path/build/host-mariadb-10.1.25/ > -DCMAKE_INSTALL_SO_NO_EXE=0 > -DCMAKE_FIND_ROOT_PATH="/opt/br/abo/cmake-host-find-root-path/host" > -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="BOTH" > -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" > -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" > -DCMAKE_INSTALL_PREFIX="/opt/br/abo/cmake-host-find-root-path/host" > -DCMAKE_C_FLAGS="-O2 > -I/opt/br/abo/cmake-host-find-root-path/host/include" > -DCMAKE_CXX_FLAGS="-O2 > -I/opt/br/abo/cmake-host-find-root-path/host/include" > -DCMAKE_EXE_LINKER_FLAGS="-L/opt/br/abo/cmake-host-find-root-path/host/lib > -Wl,-rpath,/opt/br/abo/cmake-host-find-root-path/host/lib" > -DCMAKE_ASM_COMPILER="/usr/bin/as" -DCMAKE_C_COMPILER="/usr/bin/gcc" > -DCMAKE_CXX_COMPILER="/usr/bin/g++" -DCMAKE_C_COMPILER_ARG1="" > -DCMAKE_CXX_COMPILER_ARG1="" -DCMAKE_COLOR_MAKEFILE=OFF > -DBUILD_DOC=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF > -DBUILD_EXAMPLES=OFF -DBUILD_TEST=OFF -DBUILD_TESTS=OFF > -DBUILD_TESTING=OFF -DWITH_SSL=bundled ) > -- Running cmake version 3.8.2 > [...] > -- Found PkgConfig: /opt/br/abo/cmake-host-find-root-path/host/bin/pkg-config (found version "0.28") > [...] > -- Found LibXml2: > /opt/br/abo/cmake-host-find-root-path/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib/libxml2.so > (found version "2.9.4") > [...] > 0 > After this patch is applied: > make O=/opt/br/abo/cmake-host-find-root-path libxml2 host-mariadb{-dirclean,-configure} && echo $? > [...] >>>> host-mariadb 10.1.25 Configuring > (mkdir -p /opt/br/abo/cmake-host-find-root-path/build/host-mariadb-10.1.25/ && cd /opt/br/abo/cmake-host-find-root-path/build/host-mariadb-10.1.25/ && rm -f CMakeCache.txt && PATH="/opt/br/abo/cmake-host-find-root-path/host/bin:/opt/br/abo/cmake-host-find-root-path/host/sbin:/home/sam/.local/bin:/sbin:/usr/sbin:/bin:/usr/bin" PKG_CONFIG="/opt/br/abo/cmake-host-find-root-path/host/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/opt/br/abo/cmake-host-find-root-path/host/lib/pkgconfig:/opt/br/abo/cmake-host-find-root-path/host/share/pkgconfig" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 /usr/bin/cmake /opt/br/abo/cmake-host-find-root-path/build/host-mariadb-10.1.25/ -DCMAKE_INSTALL_SO_NO_EXE=0 -DCMAKE_FIND_ROOT_PATH="/opt/br/abo/cmake-host-find-root-path/host" -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="BOTH" -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" -DCMAKE_INSTALL_PREFIX="/opt/br/abo/cmake-host-find- roo > t-path/host" -DCMAKE_C_FLAGS="-O2 -I/opt/br/abo/cmake-host-find-root-path/host/include" -DCMAKE_CXX_FLAGS="-O2 -I/opt/br/abo/cmake-host-find-root-path/host/include" -DCMAKE_EXE_LINKER_FLAGS="-L/opt/br/abo/cmake-host-find-root-path/host/lib -Wl,-rpath,/opt/br/abo/cmake-host-find-root-path/host/lib" -DCMAKE_ASM_COMPILER="/usr/bin/as" -DCMAKE_C_COMPILER="/usr/bin/gcc" -DCMAKE_CXX_COMPILER="/usr/bin/g++" -DCMAKE_C_COMPILER_ARG1="" -DCMAKE_CXX_COMPILER_ARG1="" -DCMAKE_COLOR_MAKEFILE=OFF -DBUILD_DOC=OFF -DBUILD_DOCS=OFF -DBUILD_EXAMPLE=OFF -DBUILD_EXAMPLES=OFF -DBUILD_TEST=OFF -DBUILD_TESTS=OFF -DBUILD_TESTING=OFF -DWITH_SSL=bundled ) > -- Running cmake version 3.8.2 > [...] > -- Found PkgConfig: /opt/br/abo/cmake-host-find-root-path/host/bin/pkg-config (found version "0.28") > [...] > -- Found LibXml2: /usr/lib/libxml2.so (found version "2.9.4") > [...] > 0 > [1] http://lists.busybox.net/pipermail/buildroot/2017-August/199776.html > Reported-by: "Sigalas, Antonios (Nokia - GR/Athens)" <antonios.sigalas@nokia.com> > Cc: "Sigalas, Antonios (Nokia - GR/Athens)" <antonios.sigalas@nokia.com> > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > Signed-off-by: Samuel Martin <s.martin49@gmail.com> > --- > Note: > I think this fix is required on the master and cannot wait for the > next release cycle. > changes v1->v2 > - elaborate even more the commit log > - add bug ref to the commit log (ThomasP) Committed to 2017.02.x, thanks.
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk index 914bda7482..db78d897d8 100644 --- a/package/pkg-cmake.mk +++ b/package/pkg-cmake.mk @@ -109,6 +109,11 @@ define $(2)_CONFIGURE_CMDS cd $$($$(PKG)_BUILDDIR) && \ rm -f CMakeCache.txt && \ PATH=$$(BR_PATH) \ + PKG_CONFIG="$$(PKG_CONFIG_HOST_BINARY)" \ + PKG_CONFIG_SYSROOT_DIR="/" \ + PKG_CONFIG_LIBDIR="$$(HOST_DIR)/lib/pkgconfig:$$(HOST_DIR)/share/pkgconfig" \ + PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \ + PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \ $$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \ -DCMAKE_INSTALL_SO_NO_EXE=0 \ -DCMAKE_FIND_ROOT_PATH="$$(HOST_DIR)" \