Skip to content

Commit

Permalink
meson.eclass: Don't mix host *FLAGS with build *FLAGS
Browse files Browse the repository at this point in the history
meson gets the build flags from the environment. When cross compiling it
will get the host flags from the cross file. The ebuild was not passing
the correct build flags when cross compiling.

By using tc-env_build the build environment flags are set when calling
meson. This results in not mixing host and build flags:

Example output:
Native C compiler: x86_64-pc-linux-gnu-clang (clang 7.0)
Appending CFLAGS from environment: '-O1 -pipe'
Appending LDFLAGS from environment: ' '
Appending CPPFLAGS from environment: ' '
Cross C compiler: armv7a-cros-linux-gnueabi-clang (clang 7.0)
Host machine cpu family: arm
Host machine cpu: armv7a
Target machine cpu family: arm
Target machine cpu: armv7a
Build machine cpu family: x86_64
Build machine cpu: x86_64

tc-env_build does not seem to load the actual build flags, but it's
better than using host flags as build flags.

See https://bugs.gentoo.org/653902 for upstream patch

BUG=b:78351764
BRANCH=none
TEST=emerge-grunt and verified mosys runs

Change-Id: I802b58cb089b27b9253a034ac00dd183e0f1955a
Signed-off-by: Raul E Rangel <[email protected]>
Closes: https://bugs.gentoo.org/653902
  • Loading branch information
Raul E Rangel authored and floppym committed May 5, 2018
1 parent 2dd9b21 commit c8570bc
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions eclass/meson.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@ _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}")
Expand Down Expand Up @@ -211,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
Expand All @@ -241,7 +226,7 @@ meson_src_configure() {
set -- meson "${mesonargs[@]}" "$@" \
"${EMESON_SOURCE:-${S}}" "${BUILD_DIR}"
echo "$@"
"$@" || die
tc-env_build "$@" || die
}

# @FUNCTION: meson_src_compile
Expand Down

0 comments on commit c8570bc

Please sign in to comment.