summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexey Neyman <stilor@att.net>2017-01-10 18:46:57 (GMT)
committerGitHub <noreply@github.com>2017-01-10 18:46:57 (GMT)
commit50aa6b583b89b2f4c031e581dda15051d1c2f721 (patch)
treefaf6c28589d312ef9be24fb448433cfcc5c05aa7 /scripts
parentabdaa36b5ab0a46055248bc437d0f74183984d78 (diff)
parentc69e593a9272ad186b6669bc5b12886890cea7fe (diff)
Merge pull request #510 from stilor/pass-flags-for-build
Pass flags for build & MacOS fixes.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/cc/100-gcc.sh38
-rw-r--r--scripts/build/companion_libs/121-isl.sh18
-rw-r--r--scripts/build/companion_libs/320-libiconv.sh6
-rw-r--r--scripts/build/companion_libs/330-gettext.sh6
-rw-r--r--scripts/build/debug/300-gdb.sh6
-rw-r--r--scripts/build/debug/500-strace.sh30
-rw-r--r--scripts/build/libc/glibc.sh23
-rw-r--r--scripts/crosstool-NG.sh.in54
8 files changed, 114 insertions, 67 deletions
diff --git a/scripts/build/cc/100-gcc.sh b/scripts/build/cc/100-gcc.sh
index 164fb9b..947d4af 100644
--- a/scripts/build/cc/100-gcc.sh
+++ b/scripts/build/cc/100-gcc.sh
@@ -478,14 +478,13 @@ do_gcc_core_backend() {
host_libstdcxx_flags+=("-static-libgcc")
host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
host_libstdcxx_flags+=("-lm")
- elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
- # When companion libraries are build static (eg !shared),
- # the libstdc++ is not pulled automatically, although it
- # is needed. Shoe-horn it in our LDFLAGS
- # Ditto libm on some Fedora boxen
- core_LDFLAGS+=("-lstdc++")
- core_LDFLAGS+=("-lm")
fi
+ # When companion libraries are build static (eg !shared),
+ # the libstdc++ is not pulled automatically, although it
+ # is needed. Shoe-horn it in our LDFLAGS
+ # Ditto libm on some Fedora boxen
+ core_LDFLAGS+=("-lstdc++")
+ core_LDFLAGS+=("-lm")
fi
if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
@@ -561,7 +560,11 @@ do_gcc_core_backend() {
;; # ARCH is mips
esac
- [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
+ if [ "${CT_TOOLCHAIN_ENABLE_NLS}" = "y" ]; then
+ extra_config+=("--with-libintl-prefix=${complibs}")
+ else
+ extra_config+=("--disable-nls")
+ fi
if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then
extra_config+=("--with-system-zlib")
@@ -985,14 +988,13 @@ do_gcc_backend() {
host_libstdcxx_flags+=("-static-libgcc")
host_libstdcxx_flags+=("-Wl,-Bstatic,-lstdc++,-Bdynamic")
host_libstdcxx_flags+=("-lm")
- elif [ "${CT_COMPLIBS_SHARED}" != "y" ]; then
- # When companion libraries are build static (eg !shared),
- # the libstdc++ is not pulled automatically, although it
- # is needed. Shoe-horn it in our LDFLAGS
- # Ditto libm on some Fedora boxen
- final_LDFLAGS+=("-lstdc++")
- final_LDFLAGS+=("-lm")
fi
+ # When companion libraries are build static (eg !shared),
+ # the libstdc++ is not pulled automatically, although it
+ # is needed. Shoe-horn it in our LDFLAGS
+ # Ditto libm on some Fedora boxen
+ final_LDFLAGS+=("-lstdc++")
+ final_LDFLAGS+=("-lm")
fi
if [ "${CT_CC_GCC_USE_GMP_MPFR}" = "y" ]; then
@@ -1086,7 +1088,11 @@ do_gcc_backend() {
;; # ARCH is mips
esac
- [ "${CT_TOOLCHAIN_ENABLE_NLS}" != "y" ] && extra_config+=("--disable-nls")
+ if [ "${CT_TOOLCHAIN_ENABLE_NLS}" = "y" ]; then
+ extra_config+=("--with-libintl-prefix=${complibs}")
+ else
+ extra_config+=("--disable-nls")
+ fi
if [ "${CT_CC_GCC_SYSTEM_ZLIB}" = "y" ]; then
extra_config+=("--with-system-zlib")
diff --git a/scripts/build/companion_libs/121-isl.sh b/scripts/build/companion_libs/121-isl.sh
index 823dbd5..8cc6dc2 100644
--- a/scripts/build/companion_libs/121-isl.sh
+++ b/scripts/build/companion_libs/121-isl.sh
@@ -29,8 +29,6 @@ do_isl_extract() {
# - install in build-tools prefix
do_isl_for_build() {
local -a isl_opts
- local isl_cflags
- local isl_cxxflags
case "${CT_TOOLCHAIN_TYPE}" in
native|cross) return 0;;
@@ -39,13 +37,10 @@ do_isl_for_build() {
CT_DoStep INFO "Installing ISL for build"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-isl-build-${CT_BUILD}"
- isl_cflags="${CT_CFLAGS_FOR_BUILD}"
- isl_cxxflags="${CT_CFLAGS_FOR_BUILD}"
-
isl_opts+=( "host=${CT_BUILD}" )
isl_opts+=( "prefix=${CT_BUILDTOOLS_PREFIX_DIR}" )
- isl_opts+=( "cflags=${isl_cflags}" )
- isl_opts+=( "cxxflags=${isl_cxxflags}" )
+ isl_opts+=( "cflags=${CT_CFLAGS_FOR_BUILD}" )
+ isl_opts+=( "cxxflags=${CT_CFLAGS_FOR_BUILD}" )
isl_opts+=( "ldflags=${CT_LDFLAGS_FOR_BUILD}" )
do_isl_backend "${isl_opts[@]}"
@@ -56,19 +51,14 @@ do_isl_for_build() {
# Build ISL for running on host
do_isl_for_host() {
local -a isl_opts
- local isl_cflags
- local isl_cxxflags
CT_DoStep INFO "Installing ISL for host"
CT_mkdir_pushd "${CT_BUILD_DIR}/build-isl-host-${CT_HOST}"
- isl_cflags="${CT_CFLAGS_FOR_HOST}"
- isl_cxxflags="${CT_CFLAGS_FOR_HOST}"
-
isl_opts+=( "host=${CT_HOST}" )
isl_opts+=( "prefix=${CT_HOST_COMPLIBS_DIR}" )
- isl_opts+=( "cflags=${isl_cflags}" )
- isl_opts+=( "cxxflags=${isl_cxxflags}" )
+ isl_opts+=( "cflags=${CT_CFLAGS_FOR_HOST}" )
+ isl_opts+=( "cxxflags=${CT_CFLAGS_FOR_HOST}" )
isl_opts+=( "ldflags=${CT_LDFLAGS_FOR_HOST}" )
do_isl_backend "${isl_opts[@]}"
diff --git a/scripts/build/companion_libs/320-libiconv.sh b/scripts/build/companion_libs/320-libiconv.sh
index 55da586..3f3ce24 100644
--- a/scripts/build/companion_libs/320-libiconv.sh
+++ b/scripts/build/companion_libs/320-libiconv.sh
@@ -22,10 +22,8 @@ do_libiconv_extract() {
do_libiconv_for_build() {
local -a libiconv_opts
- case "$CT_BUILD" in
- *darwin*|*linux*)
- return 0
- ;;
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross) return 0;;
esac
CT_DoStep INFO "Installing libiconv for build"
diff --git a/scripts/build/companion_libs/330-gettext.sh b/scripts/build/companion_libs/330-gettext.sh
index 07ea02b..88384f8 100644
--- a/scripts/build/companion_libs/330-gettext.sh
+++ b/scripts/build/companion_libs/330-gettext.sh
@@ -22,10 +22,8 @@ do_gettext_extract() {
do_gettext_for_build() {
local -a gettext_opts
- case "$CT_BUILD" in
- *linux*)
- return 0
- ;;
+ case "${CT_TOOLCHAIN_TYPE}" in
+ native|cross) return 0;;
esac
CT_DoStep INFO "Installing gettext for build"
diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh
index ba13591..3d3af7b 100644
--- a/scripts/build/debug/300-gdb.sh
+++ b/scripts/build/debug/300-gdb.sh
@@ -105,6 +105,12 @@ do_debug_gdb_build() {
CC_for_gdb+=" -static"
LD_for_gdb+=" -static"
fi
+ case "${CT_HOST}" in
+ *darwin*)
+ # FIXME: Really, we should be testing for host compiler being clang.
+ CC_for_gdb+=" -Qunused-arguments"
+ ;;
+ esac
# Fix up whitespace. Some older GDB releases (e.g. 6.8a) get confused if there
# are multiple consecutive spaces: sub-configure scripts replace them with a
diff --git a/scripts/build/debug/500-strace.sh b/scripts/build/debug/500-strace.sh
index 0d33ca0..2961879 100644
--- a/scripts/build/debug/500-strace.sh
+++ b/scripts/build/debug/500-strace.sh
@@ -14,17 +14,29 @@ do_debug_strace_extract() {
do_debug_strace_build() {
CT_DoStep INFO "Installing strace"
- mkdir -p "${CT_BUILD_DIR}/build-strace"
- CT_Pushd "${CT_BUILD_DIR}/build-strace"
+
+ # Strace needs _IOC definitions, and it tries to pick them up from <linux/ioctl.h>.
+ # While cross-compiling on a non-Linux host, we don't have this header. Replacing
+ # <linux/ioctl.h> with <sys/ioctl.h>, as suggested by many internet "solutions",
+ # is wrong: for example, MacOS defines _IOC macros differently, and we need the
+ # definitions for the target!
+ # Hence, create a "window" into target includes.
+ CT_DoExecLog ALL mkdir -p "${CT_BUILD_DIR}/build-strace-headers"
+ for d in linux asm asm-generic; do
+ CT_DoExecLog ALL ln -sf "${CT_HEADERS_DIR}/${d}" "${CT_BUILD_DIR}/build-strace-headers/${d}"
+ done
+
+ CT_mkdir_pushd "${CT_BUILD_DIR}/build-strace"
CT_DoLog EXTRA "Configuring strace"
- CT_DoExecLog CFG \
- CC="${CT_TARGET}-gcc" \
- CPP="${CT_TARGET}-cpp" \
- LD="${LD_TARGET}-ld" \
- "${CT_SRC_DIR}/strace-${CT_STRACE_VERSION}/configure" \
- --build=${CT_BUILD} \
- --host=${CT_TARGET} \
+ CT_DoExecLog CFG \
+ CFLAGS_FOR_BUILD="-I ${CT_BUILD_DIR}/build-strace-headers" \
+ CC="${CT_TARGET}-gcc" \
+ CPP="${CT_TARGET}-cpp" \
+ LD="${CT_TARGET}-ld" \
+ "${CT_SRC_DIR}/strace-${CT_STRACE_VERSION}/configure" \
+ --build=${CT_BUILD} \
+ --host=${CT_TARGET} \
--prefix=/usr
CT_DoLog EXTRA "Building strace"
diff --git a/scripts/build/libc/glibc.sh b/scripts/build/libc/glibc.sh
index 2db69cb..019dd90 100644
--- a/scripts/build/libc/glibc.sh
+++ b/scripts/build/libc/glibc.sh
@@ -96,6 +96,7 @@ do_libc_backend() {
# multi_* : as defined in CT_IterateMultilibs : (varies) :
do_libc_backend_once() {
local multi_flags multi_dir multi_os_dir multi_root multi_index multi_count
+ local build_cflags build_cppflags build_ldflags
local startfiles_dir
local src_dir="${CT_SRC_DIR}/${CT_LIBC}-${CT_LIBC_VERSION}"
local -a extra_config
@@ -277,23 +278,21 @@ do_libc_backend_once() {
;;
esac
- CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}"
- CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}"
- extra_make_args+=( "BUILD_CFLAGS=${CT_CFLAGS_FOR_BUILD}" "BUILD_LDFLAGS=${CT_LDFLAGS_FOR_BUILD}" )
+ build_cflags="${CT_CFLAGS_FOR_BUILD}"
+ build_cppflags=
+ build_ldflags="${CT_LDFLAGS_FOR_BUILD}"
case "$CT_BUILD" in
- *mingw*|*cygwin*|*msys*)
- # When installing headers on Cygwin, MSYS2 and MinGW-w64 sunrpc needs
+ *mingw*|*cygwin*|*msys*|*darwin*)
+ # When installing headers on Cygwin, Darwin, MSYS2 and MinGW-w64 sunrpc needs
# gettext for building cross-rpcgen.
- extra_make_args+=( BUILD_CPPFLAGS="-I${CT_BUILDTOOLS_PREFIX_DIR}/include/" )
- extra_make_args+=( BUILD_LDFLAGS="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib -Wl,-Bstatic -lintl -liconv -Wl,-Bdynamic" )
- ;;
- *darwin*)
- # .. and the same goes for Darwin.
- extra_make_args+=( BUILD_CPPFLAGS="-I${CT_BUILDTOOLS_PREFIX_DIR}/include/" )
- extra_make_args+=( BUILD_LDFLAGS="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib -lintl" )
+ build_cppflags="${build_cppflags} -I${CT_BUILDTOOLS_PREFIX_DIR}/include/"
+ build_ldflags="${build_ldflags} -lintl -liconv"
;;
esac
+ extra_make_args+=( "BUILD_CFLAGS=${build_cflags}" )
+ extra_make_args+=( "BUILD_CPPFLAGS=${build_cppflags}" )
+ extra_make_args+=( "BUILD_LDFLAGS=${build_ldflags}" )
if [ "${libc_mode}" = "startfiles" -a ! -r "${multi_root}/.libc_headers_installed" ]; then
CT_DoLog EXTRA "Installing C library headers"
diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in
index bbefb1f..ba36bc8 100644
--- a/scripts/crosstool-NG.sh.in
+++ b/scripts/crosstool-NG.sh.in
@@ -469,30 +469,68 @@ if [ -z "${CT_RESTART}" ]; then
# - fall back to searching user's PATH
# Of course, neither cross-native nor canadian can run on BUILD,
# so don't add those PATHs in this case...
+ # For native and simple cross, build==host, combine the extra CFLAGS/LDFLAGS
+ # supplied for both (so that it doesn't matter where the user supplied them).
case "${CT_TOOLCHAIN_TYPE}" in
- cross) export PATH="${CT_PREFIX_DIR}/bin:${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}";;
- canadian) export PATH="${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}";;
- *) ;;
+ cross|native)
+ export PATH="${CT_PREFIX_DIR}/bin:${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}"
+ bh_cflags="${CT_EXTRA_CFLAGS_FOR_BUILD} ${CT_EXTRA_CFLAGS_FOR_HOST}"
+ bh_ldflags="${CT_EXTRA_LDFLAGS_FOR_BUILD} ${CT_EXTRA_LDFLAGS_FOR_HOST}"
+ CT_EXTRA_CFLAGS_FOR_BUILD="${bh_cflags}"
+ CT_EXTRA_CFLAGS_FOR_HOST="${bh_cflags}"
+ CT_EXTRA_LDFLAGS_FOR_BUILD="${bh_ldflags}"
+ CT_EXTRA_LDFLAGS_FOR_HOST="${bh_ldflags}"
+ ;;
+ canadian|cross-native)
+ export PATH="${CT_BUILDTOOLS_PREFIX_DIR}/bin:${PATH}"
+ # build!=host in this case
+ ;;
+ *)
+ ;;
esac
# Help build gcc
# Explicitly optimise, else the lines below will overide the
# package's default optimisation flags
- CT_CFLAGS_FOR_BUILD="-O2 -g"
+ CT_CFLAGS_FOR_BUILD="-O2 -g -I${CT_BUILDTOOLS_PREFIX_DIR}/include"
CT_CFLAGS_FOR_BUILD+=" ${CT_EXTRA_CFLAGS_FOR_BUILD}"
- CT_LDFLAGS_FOR_BUILD=
+ CT_LDFLAGS_FOR_BUILD="-L${CT_BUILDTOOLS_PREFIX_DIR}/lib"
CT_LDFLAGS_FOR_BUILD+=" ${CT_EXTRA_LDFLAGS_FOR_BUILD}"
+ case "${CT_BUILD}" in
+ *darwin*)
+ # Two issues while building on MacOS. Really, we should be checking for
+ # clang instead.
+ # - gettext static library fails to link unless CoreFoundation framework
+ # is included
+ # - ranlib on MacOS does not include common symbols into the symbol index
+ # for a static library, and hence linker fails to pull in the right
+ # archive members; hence, avoid common symbols. Alternative is to
+ # have ranlib wrapper in buildtools/bin supply -c option.
+ CT_CFLAGS_FOR_BUILD+=" -fno-common"
+ CT_LDFLAGS_FOR_BUILD+=" -framework CoreFoundation"
+ ;;
+ esac
+
+ CT_DoLog DEBUG "CFLAGS for build compiler: '${CT_CFLAGS_FOR_BUILD}'"
+ CT_DoLog DEBUG "LDFLAGS for build compiler: '${CT_LDFLAGS_FOR_BUILD}'"
+
# Help host gcc
# Explicitly optimise, else the lines below will overide the
# package's default optimisation flags
CT_CFLAGS_FOR_HOST="-O2 -g"
[ "${CT_USE_PIPES}" = "y" ] && CT_CFLAGS_FOR_HOST+=" -pipe"
+ CT_CFLAGS_FOR_HOST+=" -I${CT_HOST_COMPLIBS_DIR}/include"
CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
- CT_LDFLAGS_FOR_HOST=
+ CT_LDFLAGS_FOR_HOST="-L${CT_HOST_COMPLIBS_DIR}/lib"
CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}"
- CT_CFLAGS_FOR_HOST+=" -I${CT_HOST_COMPLIBS_DIR}/include"
- CT_LDFLAGS_FOR_HOST+=" -L${CT_HOST_COMPLIBS_DIR}/lib"
+ case "${CT_HOST}" in
+ *darwin*)
+ # Same as above, for host
+ CT_CFLAGS_FOR_HOST+=" -fno-common"
+ CT_LDFLAGS_FOR_HOST+=" -framework CoreFoundation"
+ ;;
+ esac
CT_DoLog DEBUG "CFLAGS for host compiler: '${CT_CFLAGS_FOR_HOST}'"
CT_DoLog DEBUG "LDFLAGS for host compiler: '${CT_LDFLAGS_FOR_HOST}'"