Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 503218

Summary: dev-utils/cmake - Cross-compile fixes
Product: Gentoo Linux Reporter: James Le Cuirot <chewi>
Component: Current packagesAssignee: Gentoo KDE team <kde>
Status: RESOLVED FIXED    
Severity: normal Keywords: PATCH
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on: 503216    
Bug Blocks:    
Attachments: cross-cmake-ebuild.patch
cmake-2.8.12.2-no-cross-docs.patch
cross-cmake-ebuild.patch
Patch against cmake-3.18.0.ebuild

Description James Le Cuirot gentoo-dev 2014-03-02 16:21:25 UTC
Created attachment 371568 [details, diff]
cross-cmake-ebuild.patch

I have added cross-compile support to cmake.eclass in bug #503216 and I figured I would take the extra step of fixing the CMake ebuild itself. After bootstrapping, it uses itself to build so the eclass fix is necessary.

Bootstrapping should be done using the build system toolchain and tc-env_build exists for that purpose so I have made use of that.

There are a couple of configure checks that can't be done when cross-compiling. Assuming that KWSYS_LFS_WORKS=1 seems like a fairly safe bet on any Gentoo system, for the lack of any better alternative. Although I couldn't find a concrete list, KWSYS_CHAR_IS_SIGNED=0 appears to apply exclusively to ARM and PPC.

Finally, CMake currently generates its documentation using its own binaries. This obviously won't work when cross-compiling so I am providing an additional patch that skips the documentation in this case. I was going to submit this upstream but they've completely changed the way their documentation is generated in 3.0, which is about to be released.
Comment 1 James Le Cuirot gentoo-dev 2014-03-02 16:22:12 UTC
Created attachment 371570 [details, diff]
cmake-2.8.12.2-no-cross-docs.patch
Comment 2 SpanKY gentoo-dev 2014-03-26 06:02:34 UTC
Comment on attachment 371568 [details, diff]
cross-cmake-ebuild.patch

>+		if use arm || use ppc ; then
>+			mycmakeargs+=(-DKWSYS_CHAR_IS_SIGNED=0)
>+		else
>+			mycmakeargs+=(-DKWSYS_CHAR_IS_SIGNED=1)
>+		fi

hardcoding char behavior doesn't belong in here, not to mention this logic is horribly broken.  for gcc, you need to query the compiler directly (in conjunction with $CFLAGS and such) and see if __CHAR_UNSIGNED__ is defined.
Comment 3 James Le Cuirot gentoo-dev 2014-03-26 08:25:50 UTC
Okay, didn't know there was such a macro, I'll definitely use that instead. Maybe a toolchain-funcs helper would be appropriate here but are you saying that we shouldn't set KWSYS_CHAR_IS_SIGNED at all?
Comment 4 James Le Cuirot gentoo-dev 2014-03-30 22:34:59 UTC
Created attachment 373934 [details, diff]
cross-cmake-ebuild.patch

Assuming that's not what you meant, here's a better attempt that adds a tc-has-unsigned-char function to toolchain-funcs.
Comment 5 Michael Palimaka (kensington) gentoo-dev 2015-07-22 14:49:21 UTC
We can't do anything unless the toolchain-funcs.eclass patch is applied. Also, it would be nice to send the no-cross-docs patch upstream.
Comment 6 Andreas Sturmlechner gentoo-dev 2020-07-22 15:55:49 UTC
What's the current status here?
Comment 7 James Le Cuirot gentoo-dev 2020-07-22 22:29:05 UTC
Created attachment 650248 [details, diff]
Patch against cmake-3.18.0.ebuild

Things have obviously moved on a bit since. Luckily it's an easier fix now but still along the same lines.

Bootstrapping appears to be conditional now, I don't think it was back then. has_version should check against BROOT, hence I've added the -b flag.

I was able to successfully cross-compile for m68k, with and without bootstrapping.
Comment 8 Larry the Git Cow gentoo-dev 2020-08-23 17:10:57 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=222acbcb270567379e34ebfdec3c0b5e6534628d

commit 222acbcb270567379e34ebfdec3c0b5e6534628d
Author:     James Le Cuirot <chewi@gentoo.org>
AuthorDate: 2020-07-22 22:24:17 +0000
Commit:     James Le Cuirot <chewi@gentoo.org>
CommitDate: 2020-08-23 17:10:42 +0000

    dev-util/cmake: Fix cross-compiling in 3.18.1
    
    Closes: https://bugs.gentoo.org/503218
    Package-Manager: Portage-3.0.0, Repoman-2.3.23
    Signed-off-by: James Le Cuirot <chewi@gentoo.org>

 dev-util/cmake/cmake-3.18.1.ebuild | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)