Skip to content

Commit

Permalink
builder: mingw: fix libffi for i686 + improvemnts
Browse files Browse the repository at this point in the history
Add the tables DIST_EXTRA_{CPPFLAGS,CFLAGS,CXXFLAGS,OBJCXXFLAGS} for
adjustments during builds.

Add -DSYMBOL_UNDERSCORE to DIST_EXTRA_CPPFLAGS for libffi on mingw when
the target is i686, see:

https://bugzilla.mozilla.org/show_bug.cgi?id=1336569

Also set target_bits and target_cpu appropriately in the msys2 script.
  • Loading branch information
rkitover committed Dec 3, 2018
1 parent 5b0f2e8 commit 36e412d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tools/builder/core.sh
Expand Up @@ -1335,6 +1335,10 @@ build_dist() {
dist_patch "$current_dist"
dist_pre_build "$current_dist"

ORIG_CPPFLAGS=$CPPFLAGS
ORIG_CFLAGS=$CFLAGS
ORIG_CXXFLAGS=$CXXFLAGS
ORIG_OBJCXXFLAGS=$OBJCXXFLAGS
ORIG_LDFLAGS=$LDFLAGS
ORIG_LIBS=$LIBS

Expand All @@ -1344,6 +1348,10 @@ build_dist() {
export LDFLAGS="$CXXFLAGS $LDFLAGS"
fi

export CPPFLAGS="$LDFLAGS $(eval puts "$(dist_extra_cppflags "$current_dist")")"
export CFLAGS="$LDFLAGS $(eval puts "$(dist_extra_cflags "$current_dist")")"
export CXXFLAGS="$LDFLAGS $(eval puts "$(dist_extra_cxxflags "$current_dist")")"
export OBJCXXFLAGS="$LDFLAGS $(eval puts "$(dist_extra_objcxxflags "$current_dist")")"
export LDFLAGS="$LDFLAGS $(eval puts "$(dist_extra_ldflags "$current_dist")")"
export LIBS="$LIBS $(eval puts "$(dist_extra_libs "$current_dist")")"

Expand Down Expand Up @@ -1605,6 +1613,10 @@ build_dist() {
fi
fi

export CPPFLAGS="$ORIG_CPPFLAGS"
export CFLAGS="$ORIG_CFLAGS"
export CXXFLAGS="$ORIG_CXXFLAGS"
export OBJCXXFLAGS="$ORIG_OBJCXXFLAGS"
export LDFLAGS="$ORIG_LDFLAGS"
export LIBS="$ORIG_LIBS"

Expand Down Expand Up @@ -2199,6 +2211,34 @@ dist_make_install_args() {
puts "$(table_line DIST_MAKE_INSTALL_ARGS $current_dist)" || :
}

dist_extra_cppflags() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_extra_cppflags: dist name required'

puts "$(table_line DIST_EXTRA_CPPFLAGS $current_dist)" || :
}

dist_extra_cflags() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_extra_cflags: dist name required'

puts "$(table_line DIST_EXTRA_CFLAGS $current_dist)" || :
}

dist_extra_cxxflags() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_extra_cxxflags: dist name required'

puts "$(table_line DIST_EXTRA_CXXFLAGS $current_dist)" || :
}

dist_extra_objcxxflags() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_extra_objcxxflags: dist name required'

puts "$(table_line DIST_EXTRA_OBJCXXFLAGS $current_dist)" || :
}

dist_extra_ldflags() {
current_dist=$1
[ -n "$current_dist" ] || die 'dist_extra_ldflags: dist name required'
Expand Down
6 changes: 6 additions & 0 deletions tools/builder/mingw.sh
Expand Up @@ -256,6 +256,12 @@ table_insert_after DISTS cmake "dlfcn https://github.com/dlfcn-win32/dlfcn-win32

table_line_replace DIST_CONFIGURE_TYPES dlfcn cmake

if [ "$target_bits" -eq 32 ]; then
# this is necessary for a linkable libffi on i686 for whatever reason
# see: https://bugzilla.mozilla.org/show_bug.cgi?id=1336569
table_line_append DIST_EXTRA_CPPFLAGS libffi -DSYMBOL_UNDERSCORE
fi

libicu=libicu

if [ -n "$(table_line DISTS libicu-target || :)" ]; then
Expand Down
4 changes: 4 additions & 0 deletions tools/win/msys2-builder
Expand Up @@ -32,11 +32,15 @@ case "$MSYSTEM" in
export HOST_SYSTEM=i686-w64-mingw32
sys_base=/mingw32
export BUILD_ROOT="$HOME/vbam-build-msys2-i686"
target_bits=32
target_cpu=i686
;;
MINGW64)
export HOST_SYSTEM=x86_64-w64-mingw32
sys_base=/mingw64
export BUILD_ROOT="$HOME/vbam-build-msys2-x86_64"
target_bits=64
target_cpu=x86_64
;;
MSYS)
exec "$0" "$@" -64
Expand Down

0 comments on commit 36e412d

Please sign in to comment.