From 44ee416289b08dc454f4d63864314f0ef6c2ba7f Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Fri, 27 Nov 2015 18:19:28 +0000 Subject: expat: Tidy up and correct configure flags Build shared builds for host unless CT_STATIC_TOOLCHAIN. In all other situations, build statically, as before. It is necessary that the static/shared-ness of expat matches that of gettext on Cygwin/MinGW-w64 as they can't be linked together if they don't match, so we follow the same logic. Signed-off-by: Ray Donnelly diff --git a/scripts/build/companion_libs/210-expat.sh b/scripts/build/companion_libs/210-expat.sh old mode 100644 new mode 100755 index 304482c..7801d33 --- a/scripts/build/companion_libs/210-expat.sh +++ b/scripts/build/companion_libs/210-expat.sh @@ -22,13 +22,18 @@ if [ "${CT_EXPAT}" = "y" ]; then # Do not need expat for build at this time. do_expat_for_host() { + local -a expat_opts + CT_DoStep INFO "Installing expat for host" CT_mkdir_pushd "${CT_BUILD_DIR}/build-expat-host-${CT_HOST}" - do_expat_backend host="${CT_HOST}" \ - prefix="${CT_HOST_COMPLIBS_DIR}" \ - cflags="${CT_CFLAGS_FOR_HOST}" \ - ldflags="${CT_LDFLAGS_FOR_HOST}" + expat_opts+=( "host=${CT_HOST}" ) + expat_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" ) + expat_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" ) + expat_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" ) + expat_opts+=( "static_build=${CT_STATIC_TOOLCHAIN}" ) + + do_expat_backend "${expat_opts[@]}" CT_Popd CT_EndStep @@ -37,12 +42,17 @@ fi if [ "${CT_EXPAT_TARGET}" = "y" ]; then do_expat_for_target() { + local -a expat_opts + CT_DoStep INFO "Installing expat for target" CT_mkdir_pushd "${CT_BUILD_DIR}/build-expat-target-${CT_TARGET}" - do_expat_backend host="${CT_TARGET}" \ - prefix="/usr" \ - destdir="${CT_SYSROOT_DIR}" + expat_opts+=( "host=${CT_TARGET}" ) + expat_opts+=( "prefix=/usr" ) + expat_opts+=( "destdir=${CT_SYSROOT_DIR}" ) + expat_opts+=( "static_build=y" ) + + do_expat_backend "${expat_opts[@]}" CT_Popd CT_EndStep @@ -60,11 +70,17 @@ do_expat_backend() { local cflags local ldflags local arg + local -a extra_config for arg in "$@"; do eval "${arg// /\\ }" done + if [ "${static_build}" = "y" ]; then + extra_config+=("--disable-shared") + extra_config+=("--enable-static") + fi + CT_DoLog EXTRA "Configuring expat" CT_DoExecLog CFG \ @@ -74,8 +90,7 @@ do_expat_backend() { --build=${CT_BUILD} \ --host=${host} \ --prefix="${prefix}" \ - --enable-static \ - --disable-shared + "${extra_config[@]}" CT_DoLog EXTRA "Building expat" CT_DoExecLog ALL ${make} ${JOBSFLAGS} -- cgit v0.10.2-6-g49f6 From 29f03e3295f506e65fa5d064ae33164413f4bb1b Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Mon, 30 Nov 2015 20:14:25 +0000 Subject: Cygwin + MinGW-w64: GCC 5+ plugin support Define PICFLAG, UNDEFINEDPREAMBLE and UNDEFINEDCODE to nothing since Windows doesn't have -fPIC (GCC warns) and can't handle undefined variable references (which are not needed anyway). Signed-off-by: Ray Donnelly diff --git a/patches/gcc/5.3.0/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch b/patches/gcc/5.3.0/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch new file mode 100644 index 0000000..d8986d5 --- /dev/null +++ b/patches/gcc/5.3.0/370-gcc-plugin-Win-Dont-need-undefined-extern-var-refs-nor-fpic.patch @@ -0,0 +1,160 @@ +diff -urN gcc-5.3.0.orig/config/gcc-plugin.m4 gcc-5.3.0/config/gcc-plugin.m4 +--- gcc-5.3.0.orig/config/gcc-plugin.m4 2015-12-19 14:39:04.120734900 +0000 ++++ gcc-5.3.0/config/gcc-plugin.m4 2015-12-20 01:28:45.381965300 +0000 +@@ -20,6 +20,9 @@ + + pluginlibs= + ++ PICFLAG="-fPIC" ++ UNDEFINEDPREAMBLE="extern int X;" ++ UNDEFINEDCODE="return X == 0;" + case "${host}" in + *-*-darwin*) + if test x$build = x$host; then +@@ -30,6 +33,11 @@ + export_sym_check= + fi + ;; ++ *-*-mingw*|*-*-cygwin*|*-*-msys*) ++ PICFLAG="" ++ UNDEFINEDPREAMBLE="" ++ UNDEFINEDCODE="" ++ ;; + *) + if test x$build = x$host; then + export_sym_check="objdump${exeext} -T" +@@ -81,17 +89,17 @@ + case "${host}" in + *-*-darwin*) + CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g` +- CFLAGS="$CFLAGS -fPIC" ++ CFLAGS="$CFLAGS ${PICFLAG}" + LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup" + ;; + *) +- CFLAGS="$CFLAGS -fPIC" +- LDFLAGS="$LDFLAGS -fPIC -shared" ++ CFLAGS="$CFLAGS ${PICFLAG}" ++ LDFLAGS="$LDFLAGS ${PICFLAG} -shared" + ;; + esac +- AC_MSG_CHECKING([for -fPIC -shared]) ++ AC_MSG_CHECKING([for ${PICFLAG} -shared]) + AC_TRY_LINK( +- [extern int X;],[return X == 0;], ++ [${UNDEFINEDPREAMBLE}],[${UNDEFINEDCODE}], + [AC_MSG_RESULT([yes]); have_pic_shared=yes], + [AC_MSG_RESULT([no]); have_pic_shared=no]) + if test x"$have_pic_shared" != x"yes" -o x"$ac_cv_search_dlopen" = x"no"; then +diff -urN gcc-5.3.0.orig/gcc/configure gcc-5.3.0/gcc/configure +--- gcc-5.3.0.orig/gcc/configure 2015-12-19 14:40:16.893975900 +0000 ++++ gcc-5.3.0/gcc/configure 2015-12-20 01:28:45.472476700 +0000 +@@ -28386,6 +28386,9 @@ + + pluginlibs= + ++ PICFLAG="-fPIC" ++ UNDEFINEDPREAMBLE="extern int X;" ++ UNDEFINEDCODE="return X == 0;" + case "${host}" in + *-*-darwin*) + if test x$build = x$host; then +@@ -28396,6 +28399,11 @@ + export_sym_check= + fi + ;; ++ *-*-mingw*|*-*-cygwin*|*-*-msys*) ++ PICFLAG="" ++ UNDEFINEDPREAMBLE="" ++ UNDEFINEDCODE="" ++ ;; + *) + if test x$build = x$host; then + export_sym_check="objdump${exeext} -T" +@@ -28508,23 +28516,23 @@ + case "${host}" in + *-*-darwin*) + CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g` +- CFLAGS="$CFLAGS -fPIC" ++ CFLAGS="$CFLAGS ${PICFLAG}" + LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup" + ;; + *) +- CFLAGS="$CFLAGS -fPIC" +- LDFLAGS="$LDFLAGS -fPIC -shared" ++ CFLAGS="$CFLAGS ${PICFLAG}" ++ LDFLAGS="$LDFLAGS ${PICFLAG} -shared" + ;; + esac +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fPIC -shared" >&5 +-$as_echo_n "checking for -fPIC -shared... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${PICFLAG} -shared" >&5 ++$as_echo_n "checking for ${PICFLAG} -shared... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-extern int X; ++${UNDEFINEDPREAMBLE} + int + main () + { +-return X == 0; ++${UNDEFINEDCODE} + ; + return 0; + } +diff -urN gcc-5.3.0.orig/libcc1/configure gcc-5.3.0/libcc1/configure +--- gcc-5.3.0.orig/libcc1/configure 2015-12-19 14:40:20.855979000 +0000 ++++ gcc-5.3.0/libcc1/configure 2015-12-20 01:28:45.504980900 +0000 +@@ -14500,6 +14500,9 @@ + + pluginlibs= + ++ PICFLAG="-fPIC" ++ UNDEFINEDPREAMBLE="extern int X;" ++ UNDEFINEDCODE="return X == 0;" + case "${host}" in + *-*-darwin*) + if test x$build = x$host; then +@@ -14510,6 +14513,11 @@ + export_sym_check= + fi + ;; ++ *-*-mingw*|*-*-cygwin*|*-*-msys*) ++ PICFLAG="" ++ UNDEFINEDPREAMBLE="" ++ UNDEFINEDCODE="" ++ ;; + *) + if test x$build = x$host; then + export_sym_check="objdump${exeext} -T" +@@ -14622,23 +14630,23 @@ + case "${host}" in + *-*-darwin*) + CFLAGS=`echo $CFLAGS | sed s/-mdynamic-no-pic//g` +- CFLAGS="$CFLAGS -fPIC" ++ CFLAGS="$CFLAGS ${PICFLAG}" + LDFLAGS="$LDFLAGS -shared -undefined dynamic_lookup" + ;; + *) +- CFLAGS="$CFLAGS -fPIC" +- LDFLAGS="$LDFLAGS -fPIC -shared" ++ CFLAGS="$CFLAGS ${PICFLAG}" ++ LDFLAGS="$LDFLAGS ${PICFLAG} -shared" + ;; + esac +- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -fPIC -shared" >&5 +-$as_echo_n "checking for -fPIC -shared... " >&6; } ++ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${PICFLAG} -shared" >&5 ++$as_echo_n "checking for ${PICFLAG} -shared... " >&6; } + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +-extern int X; ++${UNDEFINEDPREAMBLE} + int + main () + { +-return X == 0; ++${UNDEFINEDCODE} + ; + return 0; + } -- cgit v0.10.2-6-g49f6 From 9b4b569741f820b4b8ff725dc37f0323dbe0ead8 Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Tue, 1 Dec 2015 00:15:49 +0000 Subject: POSIX: Fix GCC 5+ plugin build failure on Cygwin Cygwin follows POSIX IEEE Std 1003.1, 2004 Edition spec for the select() fuction as described at: http://pubs.opengroup.org/onlinepubs/009695399/functions/pselect.html .. so we must #include for the declaration. Signed-off-by: Ray Donnelly diff --git a/patches/gcc/5.3.0/380-gcc-plugin-POSIX-include-sys-select-h.patch b/patches/gcc/5.3.0/380-gcc-plugin-POSIX-include-sys-select-h.patch new file mode 100644 index 0000000..12ef48e --- /dev/null +++ b/patches/gcc/5.3.0/380-gcc-plugin-POSIX-include-sys-select-h.patch @@ -0,0 +1,11 @@ +diff -urN gcc-5.3.0.orig/libcc1/connection.cc gcc-5.3.0/libcc1/connection.cc +--- gcc-5.3.0.orig/libcc1/connection.cc 2015-12-19 14:40:20.860479600 +0000 ++++ gcc-5.3.0/libcc1/connection.cc 2015-12-20 01:31:04.346611500 +0000 +@@ -21,6 +21,7 @@ + #include + #include + #include ++#include + #include + #include + #include "marshall.hh" -- cgit v0.10.2-6-g49f6 From 644522fcd0e1788ba2d03630c19835ea617e452d Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Tue, 1 Dec 2015 22:05:58 +0000 Subject: libiconv: configure with --disable-nls On Windows a build failure can be triggered during the build of the static iconv if a dynamic iconv is already present: There's a circular dependency between libiconv and gettext which (on a system with a dynamic gettext (and thus iconv) installed in the system prefix) causes a failure to build iconv.exe statically if it is built with nls .. .. Which needs gettext .. which depends on libiconv .. so libtool finds a dynamically linked libgettext.la .. and therefore presents ld with the dll import library libiconv.dll.a when linking iconv.exe .. as well as the static libiconv.a that it has just built! .. leading to multiply defined symbols from iconv. Therefore, we build it without nls. If it later turns out that we need it to be built with nls, then I will have to build it in two passes (common practice when bootstrapping GNU/Linux distros, MSYS2 and probably Cygwin and Homebrew). Signed-off-by: Ray Donnelly diff --git a/scripts/build/companion_libs/320-libiconv.sh b/scripts/build/companion_libs/320-libiconv.sh index 06908b5..0c9e5cf 100644 --- a/scripts/build/companion_libs/320-libiconv.sh +++ b/scripts/build/companion_libs/320-libiconv.sh @@ -102,6 +102,7 @@ do_libiconv_backend() { --build=${CT_BUILD} \ --host="${host}" \ --prefix="${prefix}" \ + --disable-nls \ "${extra_config[@]}" \ CT_DoLog EXTRA "Building libiconv" -- cgit v0.10.2-6-g49f6 From 24d17220a1a11410c980c784b729f4466ab11f3b Mon Sep 17 00:00:00 2001 From: Ray Donnelly Date: Tue, 8 Dec 2015 23:17:06 +0000 Subject: libelf: Cygwin fix for UNC paths If destdir was / and prefix began with / then we would attempt to install libelf to a path beginning with // which is a UNC path on Cygwin. This is generally incorrect. Signed-off-by: Ray Donnelly diff --git a/scripts/build/companion_libs/200-libelf.sh b/scripts/build/companion_libs/200-libelf.sh index 58aa315..529bba2 100644 --- a/scripts/build/companion_libs/200-libelf.sh +++ b/scripts/build/companion_libs/200-libelf.sh @@ -135,6 +135,13 @@ do_libelf_backend() { CT_DoExecLog ALL ${make} CT_DoLog EXTRA "Installing libelf" + + # Guard against $destdir$prefix == // + # which is a UNC path on Cygwin/MSYS2 + if [[ ${destdir} == / ]] && [[ ${prefix} == /* ]]; then + destdir= + fi + CT_DoExecLog ALL ${make} instroot="${destdir}" install } -- cgit v0.10.2-6-g49f6