From: Greg Turner <gmt@malth.us>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] Re: crossdev and multilib interference
Date: Sat, 21 Jun 2014 03:31:30 -0700 [thread overview]
Message-ID: <CA+VB3NRVgaNHjgK+m_rXECO-mznhiJndURRK7+brvkUdhZ8vkw@mail.gmail.com> (raw)
In-Reply-To: <53A4954E.20002@gentoo.org>
[-- Attachment #1: Type: text/plain, Size: 11198 bytes --]
On Fri, Jun 20, 2014 at 1:10 PM, Ian Stakenvicius <axs@gentoo.org> wrote:
> Thoughts [about wrapping gcc, so that non-native multilib-build ABI's can
finally return to a world where [[ ${GCC} != *' '* ]] ]?
TLDR: good idea, I'm strongly in favor of it.
A wrapper would fix horrors like the following, which, last I checked, was
sort-of required* on ABI_X86="*32*" DEFAULT_ABI="amd64" systems with
crossdev i686-pc-linux-gnu targets in ${PATH}:
--- /usr/portage/eclass/cmake-utils.eclass 2014-05-06
08:31:17.000000000 -0700
+++ /usr/local/portage/gogogmt/eclass/cmake-utils.eclass 2014-06-01
12:36:40.753904765 -0700
@@ -373,14 +373,115 @@ enable_cmake-utils_src_prepare() {
}
+
+# retrieve a variable (i.e.: FOO) using i.e.: tc_getFOO,
+# unless the variable is already defined to a nonempty value,
+# in which case, it is returned unaltered
+_cmake-utils_tc_get_if_needed() {
+ local v="$1" s
+ if [[ ${!v} ]] ; then
+ s="${!v}"
+ else
+ s=$(tc-get${v})
+ fi
+ echo "${s}"
+}
+ +
+# trim the preceeding and trailing whitespace from a string,
+# leaving inner spaces intact
+_cmake-utils_trimmed() {
+ local s="$*"
+ while [[ ${s:0:1} =~ [[:space:]] ]] ; do
+ s="${s:1}"
+ done
+ while [[ ${s:$((${#s}-1))} =~ [[:space:]] ]] ; do
+ s="${s:0:$((${#s}-1))}"
+ done
+ echo "${s}"
+}
+
+# given a string, retrieve the first word (consisting of non-space
characters)
+# after trimming any leading whitespace.
+_cmake-utils_first_word_of() {
+ local s=$(_cmake-utils_trimmed "$*")
+ echo "${s%% *}"
+}
+
+# given a string, retrieve the rest of the string after the first word,
+# with any whitespace trimmed, retaining any whitespace between words
+# (except whitespace that was between the first and second word)
+_cmake-utils_subsequent_words_of() {
+ local s=$(_cmake-utils_trimmed "$*")
+ if [[ ${s} ]] ; then
+ s="${s#$(_cmake-utils_first_word_of "${s}")}"
+ echo "$(_cmake-utils_trimmed "${s}")"
+ else
+ echo ""
+ fi
+}
+
+# given a variable-name, retrieve it with _cmake-utils_tc_get_if_needed
+# and then from that retreive the first word
+_cmake-utils_get_first_word() {
+ local s=$(_cmake-utils_tc_get_if_needed "$1")
+ echo "$(_cmake-utils_first_word_of "${s}")"
+}
+
+# given a command-containing variable as the first argument,
+# uses _cmake-utils_tc_get_if_needed to retrieve the var, and then
+# returns type -P of the first word of it, ignoring rest.
+_cmake-utils_get_first_word_executable() {
+ local w=$(_cmake-utils_get_first_word "$1")
+ if [[ ${w} ]] ; then
+ echo "$(type -P "${w}")"
+ else
+ echo ""
+ fi
+}
+
+# fetches any additional bits of a variable not included in
+# _cmake-utils_get_first_word. takes the variable name as an input.
+# May return an empty string.
+_cmake-utils_get_subsequent_words() {
+ local s=$(_cmake-utils_tc_get_if_needed "$1")
+ echo "$(_cmake-utils_subsequent_words_of "${s}")"
}
# @VARIABLE: mycmakeargs
@@ -433,17 +534,46 @@ enable_cmake-utils_src_configure() {
# Prepare Gentoo override rules (set valid compiler, append
CPPFLAGS etc.)
local build_rules=${BUILD_DIR}/gentoo_rules.cmake
+
+ local _CMAKE_C_COMPILER=$(_cmake-utils_get_first_word_executable CC)
+ local _CCORPHANS=$(_cmake-utils_get_subsequent_words CC)
+ local _CMAKE_C_COMPILER_ARG1_COMMAND=
+ local _CMAKE_CXX_COMPILER=$(_cmake-utils_get_first_word_executable
CXX)
+ local _CXXORPHANS=$(_cmake-utils_get_subsequent_words CXX)
+ local _CMAKE_CXX_COMPILER_ARG1_COMMAND=
+
+ # This seems fairly rediculous to me, but if C{,XX}ORPHANS is
nonempty, then, in order to prevent
+ # duplication of the first argument, we must handle the first word
specially
+ if [[ ${_CCORPHANS} ]] ; then
+ _CMAKE_C_COMPILER_ARG1_COMMAND="SET (CMAKE_C_COMPILER_ARG1
$(_cmake-utils_first_word_of "${_CCORPHANS}") CACHE STRING \"C compiler
first argument\" FORCE)"
+ _CCORPHANS=$(_cmake-utils_subsequent_words_of
"${_CCORPHANS}")
+ fi
+ if [[ ${_CXXORPHANS} ]] ; then
+ _CMAKE_CXX_COMPILER_ARG1_COMMAND="SET
(CMAKE_CXX_COMPILER_ARG1 $(_cmake-utils_first_word_of "${_CXXORPHANS}")
CACHE STRING \"C++ compiler first argument\" FORCE)"
+ _CXXORPHANS=$(_cmake-utils_subsequent_words_of
"${_CXXORPHANS}")
+ fi
+
cat > "${build_rules}" <<- _EOF_
- SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH
"Archive manager" FORCE)
- SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES>
${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile
command" FORCE)
- SET (CMAKE_C_COMPILER $(type -P $(tc-getCC)) CACHE FILEPATH
"C compiler" FORCE)
- SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES>
${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile
command" FORCE)
- SET (CMAKE_CXX_COMPILER $(type -P $(tc-getCXX)) CACHE
FILEPATH "C++ compiler" FORCE)
- SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER>
<DEFINES> ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++
compile command" FORCE)
- SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH
"Archive index generator" FORCE)
- SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG))
CACHE FILEPATH "pkg-config executable" FORCE)
+ SET (CMAKE_C_COMPILER "${_CMAKE_C_COMPILER}" CACHE FILEPATH
"C compiler" FORCE)
+ ${_CMAKE_C_COMPILER_ARG1_COMMAND}
+ SET (CMAKE_CXX_COMPILER "${_CMAKE_CXX_COMPILER}" CACHE
FILEPATH "C++ compiler" FORCE)
+ ${_CMAKE_CXX_COMPILER_ARG1_COMMAND}
+ SET (CMAKE_AR "$(_cmake-utils_get_first_word_executable
AR)" CACHE FILEPATH "Archive manager" FORCE)
+ SET (CMAKE_RANLIB "$(_cmake-utils_get_first_word_executable
RANLIB)" CACHE FILEPATH "Archive index generator" FORCE)
+ SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER>
${_CCORPHANS}${_CCORPHANS:+ }<DEFINES> ${CFLAGS}${CFLAGS:+ }<FLAGS> -o
<OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
+ SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER>
${_CCORPHANS}${_CCORPHANS:+ }<DEFINES> ${CFLAGS}${CFLAGS:+ }<FLAGS> -o
<OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
+ SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER>
${_CXXORPHANS}${_CXXORPHANS:+ }<DEFINES> ${CXXFLAGS}${CXXFLAGS:+ }<FLAGS>
-o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
+ SET (CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER>
${_CCORPHANS}${_CCORPHANS:+ }<FLAGS> ${LDFLAGS}${LDFLAGS:+
}<CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>"
CACHE STRING "C link command for executables" FORCE)
+ SET (CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER>
${_CCORPHANS}${_CCORPHANS:+ }<CMAKE_SHARED_LIBRARY_C_FLAGS>
<LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> ${LDFLAGS}${LDFLAGS:+
}<CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS>
<CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS>
<LINK_LIBRARIES>" CACHE STRING "C shared library link command" FORCE)
+ SET (CMAKE_C_CREATE_SHARED_MODULE
"\${CMAKE_C_CREATE_SHARED_LIBRARY}" CACHE STRING "C shared module link
command" FORCE)
+ SET (CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER>
${_CXXORPHANS}${_CXXORPHANS:+ }<FLAGS> ${LDFLAGS}${LDFLAGS:+
}<CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET>
<LINK_LIBRARIES>" CACHE STRING "C++ link command for executables" FORCE)
+ SET (CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER>
${_CXXORPHANS}${_CXXORPHANS:+ }<CMAKE_SHARED_LIBRARY_CXX_FLAGS>
<LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> ${LDFLAGS}${LDFLAGS:+
}<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>
<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS>
<LINK_LIBRARIES>" CACHE STRING "C++ shared library link command" FORCE)
+ SET (CMAKE_CXX_CREATE_SHARED_MODULE
"\${CMAKE_CXX_CREATE_SHARED_LIBRARY}" CACHE STRING "C++ shared module link
command" FORCE)
+ SET (PKG_CONFIG_EXECUTABLE
"$(_cmake-utils_get_first_word_executable PKG_CONFIG)" CACHE FILEPATH
"pkg-config executable" FORCE)
_EOF_
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
Perhaps a straw-man argument, since, the above code could be made more
beautiful, and then it would not be so ugly :P
But, it's not just that cmake can't properly handle a C{C,XX} variables
with spaces in them**. There are a bunch of similar places where we had to
patch Makefiles and autotools to wedge GCC="foo bar" support in.
Without hyperbole, I can honestly say, it's a lame and inelegant hack to
put an /argument/ into GCC. -m${foo} is a CFLAG, not a compiler.
"Everyone" knows GCC is a variable that names an executable -- but in
multilib-build, for some god-awful reason, we've made it into some other
thing, a hybrid-psuedo-thing that really only makes sense in a shell
script, and even then, only in an improperly coded shell script :).
Even if that rubicon was already crossed by ccache, distcc, etc, there is a
reason none of them /require/ it. It's just asking for trouble. We'll
just keep wasting time fixing subtle bugs like the above, because of it
until we break down and fix it. I'd lay pretty long odds that five years
from now we are still clinging to it, should we decide to stick with the
status quo for now. So why not bite the bullet and save ourselves the
hassle?
-gmt
* perhaps today the problem is mitigated, due to the same
gcc-${pseudo-CHOST} executables now existing for upstream multilib-build
pseudo-targets -- but, I'll bet, not solved. Usually trouble only crops up
for larger framework builds with lots of sub-dirs, like qt or mysql-server,
and manifests as incorrect attempts to link native libraries in -- which
the compiler might or might not manage to save you from at the last
moment... also note that patch is mocked up for easy reading -- it won't
apply. See my overlay for the real code. Finally, sorry for the HTML --
I'm writing from the gmail ajax which obstinately refuses to allow
plain-text inline patches.
** IIRC, it would be more precise to say something like "cmake's in-built
hacks for the CC='exectutable argument' circumstance are subtly
incompatible with our means of injecting the portage compiler values into
cmake (or so things used to be; I suspect the problem still lurks to some
extent), and that this ultimately manifests as confusing, intermittent
build failures and correctly issued QA warnings in larger
multilib-build-based ebuilds (or will in the near future; I actually
wouldn't know as I run with the above patches :P), esp. in cases where a
${CC}-${CHOST} or ${CXX}-${CHOST} executables are to be found in ${PATH}."
But if any unlucky person is still reading, they can see fully why I
didn't bother to say all that :P
[-- Attachment #2: Type: text/html, Size: 21746 bytes --]
next prev parent reply other threads:[~2014-06-21 10:31 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-12 15:46 [gentoo-dev] crossdev and multilib interference hasufell
2014-03-12 16:06 ` Alexandre Rostovtsev
2014-03-12 18:56 ` Alexis Ballier
2014-03-16 11:50 ` Greg Turner
2014-03-26 6:07 ` Mike Frysinger
2014-03-26 12:25 ` [gentoo-dev] " Steven J. Long
2014-03-26 16:12 ` Mike Frysinger
2014-03-26 16:23 ` Ian Stakenvicius
2014-03-27 2:41 ` Mike Frysinger
2014-03-27 4:41 ` Alexandre Rostovtsev
2014-03-27 6:07 ` Mike Frysinger
2014-03-27 6:31 ` Alexandre Rostovtsev
2014-03-27 6:41 ` Mike Frysinger
2014-03-27 6:51 ` Michał Górny
2014-03-27 7:23 ` Mike Frysinger
2014-03-27 6:58 ` Samuli Suominen
2014-03-27 8:41 ` [gentoo-dev] " Steven J. Long
2014-03-28 6:36 ` Mike Frysinger
2014-03-30 9:53 ` [gentoo-dev] " Steven J. Long
2014-06-15 20:35 ` hasufell
2014-06-15 20:43 ` Chí-Thanh Christopher Nguyễn
2014-06-16 13:37 ` hasufell
2014-06-16 18:42 ` Steev Klimaszewski
2014-06-16 19:31 ` hasufell
2014-06-16 19:42 ` Jeroen Roovers
2014-06-16 19:47 ` hasufell
2014-06-16 20:05 ` Joshua Kinard
2014-06-16 20:24 ` hasufell
2014-06-16 20:59 ` Joshua Kinard
2014-06-16 22:10 ` hasufell
2014-06-16 23:38 ` Joshua Kinard
2014-06-17 1:47 ` hasufell
2014-06-17 2:17 ` Joshua Kinard
2014-06-17 12:30 ` hasufell
2014-06-17 12:49 ` Rich Freeman
2014-06-17 13:53 ` hasufell
2014-06-17 14:17 ` Joshua Kinard
2014-06-17 14:56 ` Alexandre Rostovtsev
2014-06-17 15:10 ` Michał Górny
2014-06-18 15:24 ` Peter Stuge
2014-06-19 7:58 ` Michał Górny
2014-06-17 15:20 ` Joshua Kinard
2014-06-18 5:08 ` Alexandre Rostovtsev
2014-06-18 6:24 ` Joshua Kinard
2014-06-18 14:18 ` Ian Stakenvicius
2014-06-19 21:20 ` [gentoo-dev] " Steven J. Long
2014-06-20 20:10 ` [gentoo-dev] " Ian Stakenvicius
2014-06-21 10:31 ` Greg Turner [this message]
2014-06-21 20:47 ` Michał Górny
2014-08-01 9:05 ` Steven J. Long
2014-08-01 14:36 ` Ian Stakenvicius
2014-08-01 18:17 ` [gentoo-dev] " Steven J. Long
2014-06-18 4:29 ` [gentoo-dev] " Ryan Hill
2014-06-17 14:04 ` [gentoo-dev] Re: " Joshua Kinard
2014-06-17 14:38 ` hasufell
2014-06-17 15:02 ` Joshua Kinard
2014-06-17 15:18 ` hasufell
2014-06-17 15:37 ` hasufell
2014-06-17 12:48 ` hasufell
2014-06-17 14:31 ` Joshua Kinard
2014-06-17 13:25 ` Ian Stakenvicius
2014-06-17 14:22 ` Michał Górny
2014-06-17 14:34 ` Joshua Kinard
2014-06-16 23:25 ` Patrick Lauer
2014-06-16 20:27 ` Ian Stakenvicius
2014-06-16 21:42 ` [gentoo-dev] " Jeroen Roovers
2014-06-17 0:03 ` Joshua Kinard
2014-06-16 20:25 ` [gentoo-dev] Re: Re: " hasufell
2014-06-16 2:24 ` [gentoo-dev] " Ryan Hill
2014-06-16 13:27 ` hasufell
2014-06-17 4:52 ` Ryan Hill
2014-06-17 12:29 ` hasufell
2014-03-29 1:21 ` [gentoo-dev] " Maciej Mrozowski
2014-03-16 12:01 ` Greg Turner
2014-03-13 8:55 ` Michał Górny
2014-03-13 12:20 ` Alexandre Rostovtsev
2014-03-26 5:17 ` Mike Frysinger
2014-03-27 6:13 ` Mike Frysinger
2014-03-27 6:51 ` Michał Górny
2014-03-27 7:18 ` Mike Frysinger
2014-03-27 9:10 ` Michał Górny
2014-03-27 14:23 ` Mike Frysinger
2014-03-27 14:31 ` Michał Górny
2014-03-28 6:33 ` Mike Frysinger
2014-03-29 21:39 ` Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+VB3NRVgaNHjgK+m_rXECO-mznhiJndURRK7+brvkUdhZ8vkw@mail.gmail.com \
--to=gmt@malth.us \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox