diff options
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/Manifest.gz | bin | 38909 -> 38915 bytes | |||
-rw-r--r-- | eclass/meson.eclass | 74 | ||||
-rw-r--r-- | eclass/toolchain-funcs.eclass | 22 | ||||
-rw-r--r-- | eclass/toolchain.eclass | 12 |
4 files changed, 78 insertions, 30 deletions
diff --git a/eclass/Manifest.gz b/eclass/Manifest.gz Binary files differindex 9ceb29cc0bf8..3674221406d4 100644 --- a/eclass/Manifest.gz +++ b/eclass/Manifest.gz diff --git a/eclass/meson.eclass b/eclass/meson.eclass index 71735fbfc67d..f493bab2d019 100644 --- a/eclass/meson.eclass +++ b/eclass/meson.eclass @@ -92,6 +92,42 @@ __MESON_AUTO_DEPEND=${MESON_AUTO_DEPEND} # See top of eclass # Optional meson arguments as Bash array; this should be defined before # calling meson_src_configure. + +read -d '' __MESON_ARRAY_PARSER <<"EOF" +import shlex +import sys + +# See http://mesonbuild.com/Syntax.html#strings +def quote(str): + escaped = str.replace("\\\\", "\\\\\\\\").replace("'", "\\\\'") + return "'{}'".format(escaped) + +print("[{}]".format( + ", ".join([quote(x) for x in shlex.split(" ".join(sys.argv[1:]))]))) +EOF + +# @FUNCTION: _meson_env_array +# @INTERNAL +# @DESCRIPTION: +# Parses the command line flags and converts them into an array suitable for +# use in a cross file. +# +# Input: --single-quote=\' --double-quote=\" --dollar=\$ --backtick=\` +# --backslash=\\ --full-word-double="Hello World" +# --full-word-single='Hello World' +# --full-word-backslash=Hello\ World +# --simple --unicode-8=© --unicode-16=𐐷 --unicode-32=𐤅 +# +# Output: ['--single-quote=\'', '--double-quote="', '--dollar=$', +# '--backtick=`', '--backslash=\\', '--full-word-double=Hello World', +# '--full-word-single=Hello World', +# '--full-word-backslash=Hello World', '--simple', '--unicode-8=©', +# '--unicode-16=𐐷', '--unicode-32=𐤅'] +# +_meson_env_array() { + python -c "${__MESON_ARRAY_PARSER}" "$@" +} + # @FUNCTION: _meson_create_cross_file # @INTERNAL # @DESCRIPTION: @@ -123,11 +159,20 @@ _meson_create_cross_file() { cat > "${T}/meson.${CHOST}" <<-EOF [binaries] - ar = '${AR}' - c = '${CC}' - cpp = '${CXX}' - pkgconfig = '${PKG_CONFIG}' - strip = '${STRIP}' + ar = '$(tc-getAR)' + c = '$(tc-getCC)' + cpp = '$(tc-getCXX)' + pkgconfig = '$(tc-getPKG_CONFIG)' + strip = '$(tc-getSTRIP)' + + [properties] + c_args = $(_meson_env_array "${CFLAGS}") + c_link_args = $(_meson_env_array "${LDFLAGS}") + cpp_args = $(_meson_env_array "${CXXFLAGS}") + cpp_link_args = $(_meson_env_array "${LDFLAGS}") + fortran_args = $(_meson_env_array "${FCFLAGS}") + objc_args = $(_meson_env_array "${OBJCFLAGS}") + objcpp_args = $(_meson_env_array "${OBJCXXFLAGS}") [host_machine] system = '${system}' @@ -166,24 +211,9 @@ meson_src_configure() { --wrap-mode nodownload ) - # Both meson(1) and _meson_create_cross_file need these - local -x AR=$(tc-getAR) - local -x CC=$(tc-getCC) - local -x CXX=$(tc-getCXX) - local -x PKG_CONFIG=$(tc-getPKG_CONFIG) - local -x STRIP=$(tc-getSTRIP) - if tc-is-cross-compiler; then _meson_create_cross_file || die "unable to write meson cross file" - mesonargs+=( - --cross-file "${T}/meson.${CHOST}" - ) - # In cross mode, meson uses these as the native/build programs - AR=$(tc-getBUILD_AR) - CC=$(tc-getBUILD_CC) - CXX=$(tc-getBUILD_CXX) - PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) - STRIP=$(tc-getBUILD_STRIP) + mesonargs+=( --cross-file "${T}/meson.${CHOST}" ) fi # https://bugs.gentoo.org/625396 @@ -196,7 +226,7 @@ meson_src_configure() { set -- meson "${mesonargs[@]}" "$@" \ "${EMESON_SOURCE:-${S}}" "${BUILD_DIR}" echo "$@" - "$@" || die + tc-env_build "$@" || die } # @FUNCTION: meson_src_compile diff --git a/eclass/toolchain-funcs.eclass b/eclass/toolchain-funcs.eclass index 4b1876b8e09b..1c8090cf75c7 100644 --- a/eclass/toolchain-funcs.eclass +++ b/eclass/toolchain-funcs.eclass @@ -247,13 +247,21 @@ tc-stack-grows-down() { # Export common build related compiler settings. tc-export_build_env() { tc-export "$@" - # Some build envs will initialize vars like: - # : ${BUILD_LDFLAGS:-${LDFLAGS}} - # So make sure all variables are non-empty. #526734 - : ${BUILD_CFLAGS:=-O1 -pipe} - : ${BUILD_CXXFLAGS:=-O1 -pipe} - : ${BUILD_CPPFLAGS:= } - : ${BUILD_LDFLAGS:= } + if tc-is-cross-compiler; then + # Some build envs will initialize vars like: + # : ${BUILD_LDFLAGS:-${LDFLAGS}} + # So make sure all variables are non-empty. #526734 + : ${BUILD_CFLAGS:=-O1 -pipe} + : ${BUILD_CXXFLAGS:=-O1 -pipe} + : ${BUILD_CPPFLAGS:= } + : ${BUILD_LDFLAGS:= } + else + # https://bugs.gentoo.org/654424 + : ${BUILD_CFLAGS:=${CFLAGS}} + : ${BUILD_CXXFLAGS:=${CXXFLAGS}} + : ${BUILD_CPPFLAGS:=${CPPFLAGS}} + : ${BUILD_LDFLAGS:=${LDFLAGS}} + fi export BUILD_{C,CXX,CPP,LD}FLAGS # Some packages use XXX_FOR_BUILD. diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass index 2cac026eefa8..47ee5495739c 100644 --- a/eclass/toolchain.eclass +++ b/eclass/toolchain.eclass @@ -1207,7 +1207,17 @@ toolchain_src_configure() { if hardened_gcc_is_stable ssp; then export gcc_cv_libc_provides_ssp=yes fi - confgcc+=( --disable-libssp ) + if use_if_iuse ssp; then + # On some targets USE="ssp -libssp" is an invalid + # configuration as target libc does not provide + # stack_chk_* functions. Do not disable libssp there. + case ${CTARGET} in + mingw*|*-mingw*) ewarn "Not disabling libssp" ;; + *) confgcc+=( --disable-libssp ) ;; + esac + else + confgcc+=( --disable-libssp ) + fi fi fi |