Merge pull request #510 from stilor/pass-flags-for-build

Pass flags for build & MacOS fixes.
This commit is contained in:
Alexey Neyman 2017-01-10 10:46:57 -08:00 committed by GitHub
commit 50aa6b583b
15 changed files with 179 additions and 71 deletions

View File

@ -1,7 +1,7 @@
# Compiler options
#
## default y
## select CC_SUPPORT_CXX
## select CC_SUPPORT_CXX if !LIBC_none
## select CC_SUPPORT_FORTRAN
## select CC_SUPPORT_JAVA
## select CC_SUPPORT_ADA

View File

@ -62,11 +62,15 @@ config COMPLIBS
bool
config LIBICONV
bool
bool "Build local libiconv"
default y if CANADIAN || CROSS_NATIVE
select COMPLIBS
config GETTEXT
bool
bool "Build local gettext"
default y if CANADIAN || CROSS_NATIVE
select LIBICONV_NEEDED
select NCURSES_NEEDED
select COMPLIBS
config GMP

View File

@ -308,6 +308,7 @@ comment "Misc options"
config TOOLCHAIN_ENABLE_NLS
bool
prompt "Enable nls"
select GETTEXT_NEEDED
help
Say 'Y' here to enable native language support (nls).

View File

@ -0,0 +1,14 @@
--- gcc-4.9.4/libtool-ldflags 2016-12-20 11:13:12.669668125 -0800
+++ gcc-4.9.4/libtool-ldflags 2016-12-20 11:28:34.894826286 -0800
@@ -36,6 +36,11 @@
for arg
do
case $arg in
+ -framework)
+ # libtool handles this option. It should not be prefixed with
+ # -Xcompiler, as that would split it from the argument that
+ # follows.
+ ;;
-f*|--*)
# Libtool does not ascribe any special meaning options
# that begin with -f or with a double-dash. So, it will

View File

@ -0,0 +1,14 @@
--- gcc-4.9.4/libtool-ldflags 2016-12-20 11:13:12.669668125 -0800
+++ gcc-4.9.4/libtool-ldflags 2016-12-20 11:28:34.894826286 -0800
@@ -36,6 +36,11 @@
for arg
do
case $arg in
+ -framework)
+ # libtool handles this option. It should not be prefixed with
+ # -Xcompiler, as that would split it from the argument that
+ # follows.
+ ;;
-f*|--*)
# Libtool does not ascribe any special meaning options
# that begin with -f or with a double-dash. So, it will

View File

@ -0,0 +1,14 @@
--- gcc-5.4.0/libtool-ldflags 2016-12-20 11:13:12.669668125 -0800
+++ gcc-5.4.0/libtool-ldflags 2016-12-20 11:28:34.894826286 -0800
@@ -36,6 +36,11 @@
for arg
do
case $arg in
+ -framework)
+ # libtool handles this option. It should not be prefixed with
+ # -Xcompiler, as that would split it from the argument that
+ # follows.
+ ;;
-f*|--*|-static-lib*|-shared-lib*|-B*)
# Libtool does not ascribe any special meaning options
# that begin with -f or with a double-dash. So, it will

View File

@ -0,0 +1,14 @@
--- gcc-6.2.0/libtool-ldflags 2016-12-20 11:13:12.669668125 -0800
+++ gcc-6.2.0/libtool-ldflags 2016-12-20 11:28:34.894826286 -0800
@@ -36,6 +36,11 @@
for arg
do
case $arg in
+ -framework)
+ # libtool handles this option. It should not be prefixed with
+ # -Xcompiler, as that would split it from the argument that
+ # follows.
+ ;;
-f*|--*|-static-lib*|-shared-lib*|-B*)
# Libtool does not ascribe any special meaning options
# that begin with -f or with a double-dash. So, it will

View File

@ -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")

View File

@ -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[@]}"

View File

@ -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"

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
CT_LDFLAGS_FOR_HOST=
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"
CT_CFLAGS_FOR_HOST+=" ${CT_EXTRA_CFLAGS_FOR_HOST}"
CT_LDFLAGS_FOR_HOST="-L${CT_HOST_COMPLIBS_DIR}/lib"
CT_LDFLAGS_FOR_HOST+=" ${CT_EXTRA_LDFLAGS_FOR_HOST}"
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}'"