gcc: enable multilib for target gcc
- add a task to setup multilib configuration for target gcc
- this commit adapts Nitin Kamble's work to gcc 4.7
- use a hash for storing arch-dependent multilib options
- patch gcc in order to use the multilib config files from the
build directory
Tests:
root@qemux86-64:~# gcc -m64 t.c -o t
root@qemux86-64:~# file t
t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
root@qemux86-64:~# ./t
Hello World !
root@qemux86-64:~# gcc -m32 t.c -o t
root@qemux86-64:~# file t
t: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
root@qemux86-64:~# ./t
Hello World !
[YOCTO #1369]
(From OE-Core rev: b26819c85881e82ee1b5c68840011e78c321f18e)
Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-17 11:46:20 +00:00
|
|
|
require gcc-multilib-config.inc
|
2014-11-25 17:58:10 +00:00
|
|
|
require gcc-shared-source.inc
|
2008-03-18 10:41:39 +00:00
|
|
|
#
|
|
|
|
# Build the list of lanaguages to build.
|
|
|
|
#
|
|
|
|
# These can be overridden by the version specific .inc file.
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2008-03-18 10:41:39 +00:00
|
|
|
# Java (gcj doesn't work on all architectures)
|
2006-12-28 23:22:59 +00:00
|
|
|
JAVA ?= ",java"
|
|
|
|
JAVA_arm ?= ""
|
|
|
|
JAVA_armeb ?= ""
|
|
|
|
JAVA_mipsel ?= ""
|
|
|
|
JAVA_sh3 ?= ""
|
2008-03-18 10:41:39 +00:00
|
|
|
# gcc 3.x expects 'f77', 4.0 expects 'f95', 4.1 and 4.2 expect 'fortran'
|
2006-12-28 23:22:59 +00:00
|
|
|
FORTRAN ?= ",f77"
|
|
|
|
LANGUAGES ?= "c,c++${FORTRAN}${JAVA}"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2008-05-16 09:06:00 +00:00
|
|
|
EXTRA_OECONF_BASE ?= ""
|
|
|
|
EXTRA_OECONF_PATHS ?= ""
|
2010-03-31 16:28:08 +00:00
|
|
|
EXTRA_OECONF_INITIAL ?= ""
|
2008-05-16 09:06:00 +00:00
|
|
|
|
gcc: enable multilib for target gcc
- add a task to setup multilib configuration for target gcc
- this commit adapts Nitin Kamble's work to gcc 4.7
- use a hash for storing arch-dependent multilib options
- patch gcc in order to use the multilib config files from the
build directory
Tests:
root@qemux86-64:~# gcc -m64 t.c -o t
root@qemux86-64:~# file t
t: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
root@qemux86-64:~# ./t
Hello World !
root@qemux86-64:~# gcc -m32 t.c -o t
root@qemux86-64:~# file t
t: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.16, not stripped
root@qemux86-64:~# ./t
Hello World !
[YOCTO #1369]
(From OE-Core rev: b26819c85881e82ee1b5c68840011e78c321f18e)
Signed-off-by: Constantin Musca <constantinx.musca@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2012-12-17 11:46:20 +00:00
|
|
|
GCCMULTILIB ?= "--disable-multilib"
|
2012-09-26 09:45:18 +00:00
|
|
|
GCCTHREADS ?= "posix"
|
2009-09-17 00:04:09 +00:00
|
|
|
|
2014-08-14 19:05:51 +00:00
|
|
|
EXTRA_OECONF = "\
|
|
|
|
${@['--enable-clocale=generic', ''][d.getVar('USE_NLS', True) != 'no']} \
|
|
|
|
--with-gnu-ld \
|
|
|
|
--enable-shared \
|
|
|
|
--enable-languages=${LANGUAGES} \
|
|
|
|
--enable-threads=${GCCTHREADS} \
|
|
|
|
${GCCMULTILIB} \
|
|
|
|
--enable-c99 \
|
|
|
|
--enable-long-long \
|
|
|
|
--enable-symvers=gnu \
|
|
|
|
--enable-libstdcxx-pch \
|
|
|
|
--program-prefix=${TARGET_PREFIX} \
|
|
|
|
--without-local-prefix \
|
|
|
|
${EXTRA_OECONF_BASE} \
|
2014-08-14 19:05:56 +00:00
|
|
|
${EXTRA_OECONF_GCC_FLOAT} \
|
2014-08-14 19:05:51 +00:00
|
|
|
${EXTRA_OECONF_PATHS} \
|
|
|
|
${@get_gcc_mips_plt_setting(bb, d)} \
|
2015-11-02 14:52:28 +00:00
|
|
|
${@get_gcc_ppc_plt_settings(bb, d)} \
|
2014-08-14 19:05:57 +00:00
|
|
|
${@get_long_double_setting(bb, d)} \
|
2014-08-14 19:05:51 +00:00
|
|
|
${@get_gcc_multiarch_setting(bb, d)} \
|
|
|
|
"
|
2005-08-31 10:45:47 +00:00
|
|
|
|
2012-07-05 10:30:14 +00:00
|
|
|
export gcc_cv_collect2_libs = 'none required'
|
|
|
|
# We need to set gcc_cv_collect2_libs else there is cross-compilation badness
|
|
|
|
# in the config.log files (which might not get generated until do_compile
|
|
|
|
# hence being missed by the insane do_configure check).
|
|
|
|
|
2008-03-18 10:41:39 +00:00
|
|
|
# Build uclibc compilers without cxa_atexit support
|
2014-08-14 19:05:51 +00:00
|
|
|
EXTRA_OECONF_append_linux = " --enable-__cxa_atexit"
|
|
|
|
EXTRA_OECONF_append_libc-uclibc = " --enable-__cxa_atexit"
|
2012-04-25 22:35:39 +00:00
|
|
|
|
2014-08-14 19:05:51 +00:00
|
|
|
EXTRA_OECONF_append_mips64 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
|
|
|
|
EXTRA_OECONF_append_mips64el = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
|
2015-01-22 04:45:28 +00:00
|
|
|
EXTRA_OECONF_append_mips64n32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
|
|
|
|
EXTRA_OECONF_append_mips64eln32 = " --with-abi=64 --with-arch-64=mips64 --with-tune-64=mips64"
|
2012-04-25 22:35:39 +00:00
|
|
|
|
2014-08-14 19:05:59 +00:00
|
|
|
# ARMv6+ adds atomic instructions that affect the ABI in libraries built
|
|
|
|
# with TUNE_CCARGS in gcc-runtime. Make the compiler default to a
|
|
|
|
# compatible architecture. armv6 and armv7a cover the minimum tune
|
|
|
|
# features used in OE.
|
|
|
|
EXTRA_OECONF_append_armv6 = " --with-arch=armv6"
|
|
|
|
EXTRA_OECONF_append_armv7a = " --with-arch=armv7-a"
|
2016-01-07 22:29:10 +00:00
|
|
|
EXTRA_OECONF_append_armv7ve = " --with-arch=armv7-a"
|
2014-08-14 19:05:59 +00:00
|
|
|
|
2014-08-14 19:05:56 +00:00
|
|
|
EXTRA_OECONF_GCC_FLOAT ??= ""
|
2005-08-31 10:45:47 +00:00
|
|
|
CPPFLAGS = ""
|
|
|
|
|
2009-09-17 14:23:29 +00:00
|
|
|
SYSTEMHEADERS = "${target_includedir}"
|
2010-07-15 09:19:12 +00:00
|
|
|
SYSTEMLIBS = "${target_base_libdir}/"
|
2009-09-17 14:23:29 +00:00
|
|
|
SYSTEMLIBS1 = "${target_libdir}/"
|
2009-09-17 00:05:15 +00:00
|
|
|
|
2011-08-09 17:51:44 +00:00
|
|
|
do_configure_prepend () {
|
Share gcc work directories
This patched is derived from Richard, make gcc use the shared source
directory during the different building:
1) Make gcc-cross, gcc-cross-initial, gcc-cross-intermediate and
gcc-runtime share the same source directory.
2) The source directory is ${TMPDIR}/work-shared/gcc-${PV}, for example:
tmp/work-shared/gcc-4.5.1
3) Fix do_clean to clean the shared source directory and stamps
4) gcc uses sed and creates config files against ${S} which means the
directory should not be shared. Change the way to make it work:
* The configure option --with-headers=${STAGING_DIR_TARGET}${SYSTEMHEADERS}
can replace the sed command, see the code in configure:
if test "x$with_headers" != x; then
glibc_header_dir=$with_headers
This has the same effect as the sed command:
sed -i 's:^\([ ]*\)glibc_header_dir=\"${with_build_sysroot}/usr/include\": ...
so add the --with-headers=${STAGING_DIR_TARGET}${SYSTEMHEADERS} to
gcc-configure-cross.inc( not add to gcc-configure-common.inc, since
not all the gcc building need this, the one which has its own do_configure
doesn't need it).
* Move t-oe from ${T} to ${B}/gcc, so that the patched Makefile.in
can read it easily, please see the commit for gcc-4.5.1 and
gcc-4.6.0.
* Use the defaults.h in ${B}/gcc instead of ${S}/gcc, and the patched
configure.ac(configure) can read it correctly, please see the
commit for gcc-4.5.1 and gcc-4.6.0.
* The gcc-crosssdk.inc used sed to edit ${S}/config/*/linux*.h
to change the GLIBC_DYNAMIC_LINKER, which made the source
incompatible. To make the source compatible:
- Use:
sed -i ${S}/gcc/config/*/linux*.h -e \
's#\(GLIBC_DYNAMIC_LINKER[^ ]*\)\( *"/lib.*\)#\1 SYSTEMLIBS_DIR\2#'
so entries in the files that look like:
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
would become
#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR"/ld-linux-x86-64.so.2"
and we define SYSTEMLIBS_DIR in defaults.h.
NOTE:
#define GLIBC_DYNAMIC_LINKER64 (SYSTEMLIBS_DIR "/ld-linux-x86-64.so.2")
doesn't work in in the following define:
#define LINUX_DYNAMIC_LINKER \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
so use
#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR"/ld-linux-x86-64.so.2"
5) Add do_configure_prepend to gcc-configure-common.inc and remove the
one in gcc-crosssdk.inc, this makes it easy to share the source,
otherwise we need do extra changes in gcc-configure-sdk.inc.
6) Use "cat > file <_EOF" to replace the "echo > file"
(From OE-Core rev: 934d38530c9a67562e53d4034aee5531f0f26750)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-06-28 20:31:04 +00:00
|
|
|
# teach gcc to find correct target includedir when checking libc ssp support
|
|
|
|
mkdir -p ${B}/gcc
|
|
|
|
echo "NATIVE_SYSTEM_HEADER_DIR = ${SYSTEMHEADERS}" > ${B}/gcc/t-oe
|
|
|
|
cat ${S}/gcc/defaults.h | grep -v "\#endif.*GCC_DEFAULTS_H" > ${B}/gcc/defaults.h.new
|
|
|
|
cat >>${B}/gcc/defaults.h.new <<_EOF
|
2014-05-30 12:32:54 +00:00
|
|
|
#define NATIVE_SYSTEM_HEADER_DIR "${SYSTEMHEADERS}"
|
Share gcc work directories
This patched is derived from Richard, make gcc use the shared source
directory during the different building:
1) Make gcc-cross, gcc-cross-initial, gcc-cross-intermediate and
gcc-runtime share the same source directory.
2) The source directory is ${TMPDIR}/work-shared/gcc-${PV}, for example:
tmp/work-shared/gcc-4.5.1
3) Fix do_clean to clean the shared source directory and stamps
4) gcc uses sed and creates config files against ${S} which means the
directory should not be shared. Change the way to make it work:
* The configure option --with-headers=${STAGING_DIR_TARGET}${SYSTEMHEADERS}
can replace the sed command, see the code in configure:
if test "x$with_headers" != x; then
glibc_header_dir=$with_headers
This has the same effect as the sed command:
sed -i 's:^\([ ]*\)glibc_header_dir=\"${with_build_sysroot}/usr/include\": ...
so add the --with-headers=${STAGING_DIR_TARGET}${SYSTEMHEADERS} to
gcc-configure-cross.inc( not add to gcc-configure-common.inc, since
not all the gcc building need this, the one which has its own do_configure
doesn't need it).
* Move t-oe from ${T} to ${B}/gcc, so that the patched Makefile.in
can read it easily, please see the commit for gcc-4.5.1 and
gcc-4.6.0.
* Use the defaults.h in ${B}/gcc instead of ${S}/gcc, and the patched
configure.ac(configure) can read it correctly, please see the
commit for gcc-4.5.1 and gcc-4.6.0.
* The gcc-crosssdk.inc used sed to edit ${S}/config/*/linux*.h
to change the GLIBC_DYNAMIC_LINKER, which made the source
incompatible. To make the source compatible:
- Use:
sed -i ${S}/gcc/config/*/linux*.h -e \
's#\(GLIBC_DYNAMIC_LINKER[^ ]*\)\( *"/lib.*\)#\1 SYSTEMLIBS_DIR\2#'
so entries in the files that look like:
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
would become
#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR"/ld-linux-x86-64.so.2"
and we define SYSTEMLIBS_DIR in defaults.h.
NOTE:
#define GLIBC_DYNAMIC_LINKER64 (SYSTEMLIBS_DIR "/ld-linux-x86-64.so.2")
doesn't work in in the following define:
#define LINUX_DYNAMIC_LINKER \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
so use
#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR"/ld-linux-x86-64.so.2"
5) Add do_configure_prepend to gcc-configure-common.inc and remove the
one in gcc-crosssdk.inc, this makes it easy to share the source,
otherwise we need do extra changes in gcc-configure-sdk.inc.
6) Use "cat > file <_EOF" to replace the "echo > file"
(From OE-Core rev: 934d38530c9a67562e53d4034aee5531f0f26750)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-06-28 20:31:04 +00:00
|
|
|
#define STANDARD_STARTFILE_PREFIX_1 "${SYSTEMLIBS}"
|
|
|
|
#define STANDARD_STARTFILE_PREFIX_2 "${SYSTEMLIBS1}"
|
2011-08-02 22:33:17 +00:00
|
|
|
#define SYSTEMLIBS_DIR "${SYSTEMLIBS}"
|
Share gcc work directories
This patched is derived from Richard, make gcc use the shared source
directory during the different building:
1) Make gcc-cross, gcc-cross-initial, gcc-cross-intermediate and
gcc-runtime share the same source directory.
2) The source directory is ${TMPDIR}/work-shared/gcc-${PV}, for example:
tmp/work-shared/gcc-4.5.1
3) Fix do_clean to clean the shared source directory and stamps
4) gcc uses sed and creates config files against ${S} which means the
directory should not be shared. Change the way to make it work:
* The configure option --with-headers=${STAGING_DIR_TARGET}${SYSTEMHEADERS}
can replace the sed command, see the code in configure:
if test "x$with_headers" != x; then
glibc_header_dir=$with_headers
This has the same effect as the sed command:
sed -i 's:^\([ ]*\)glibc_header_dir=\"${with_build_sysroot}/usr/include\": ...
so add the --with-headers=${STAGING_DIR_TARGET}${SYSTEMHEADERS} to
gcc-configure-cross.inc( not add to gcc-configure-common.inc, since
not all the gcc building need this, the one which has its own do_configure
doesn't need it).
* Move t-oe from ${T} to ${B}/gcc, so that the patched Makefile.in
can read it easily, please see the commit for gcc-4.5.1 and
gcc-4.6.0.
* Use the defaults.h in ${B}/gcc instead of ${S}/gcc, and the patched
configure.ac(configure) can read it correctly, please see the
commit for gcc-4.5.1 and gcc-4.6.0.
* The gcc-crosssdk.inc used sed to edit ${S}/config/*/linux*.h
to change the GLIBC_DYNAMIC_LINKER, which made the source
incompatible. To make the source compatible:
- Use:
sed -i ${S}/gcc/config/*/linux*.h -e \
's#\(GLIBC_DYNAMIC_LINKER[^ ]*\)\( *"/lib.*\)#\1 SYSTEMLIBS_DIR\2#'
so entries in the files that look like:
#define GLIBC_DYNAMIC_LINKER64 "/lib64/ld-linux-x86-64.so.2"
would become
#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR"/ld-linux-x86-64.so.2"
and we define SYSTEMLIBS_DIR in defaults.h.
NOTE:
#define GLIBC_DYNAMIC_LINKER64 (SYSTEMLIBS_DIR "/ld-linux-x86-64.so.2")
doesn't work in in the following define:
#define LINUX_DYNAMIC_LINKER \
CHOOSE_DYNAMIC_LINKER (GLIBC_DYNAMIC_LINKER, UCLIBC_DYNAMIC_LINKER)
so use
#define GLIBC_DYNAMIC_LINKER64 SYSTEMLIBS_DIR"/ld-linux-x86-64.so.2"
5) Add do_configure_prepend to gcc-configure-common.inc and remove the
one in gcc-crosssdk.inc, this makes it easy to share the source,
otherwise we need do extra changes in gcc-configure-sdk.inc.
6) Use "cat > file <_EOF" to replace the "echo > file"
(From OE-Core rev: 934d38530c9a67562e53d4034aee5531f0f26750)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2011-06-28 20:31:04 +00:00
|
|
|
#endif /* ! GCC_DEFAULTS_H */
|
|
|
|
_EOF
|
|
|
|
mv ${B}/gcc/defaults.h.new ${B}/gcc/defaults.h
|
|
|
|
}
|
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
do_configure () {
|
|
|
|
# Setup these vars for cross building only
|
|
|
|
# ... because foo_FOR_TARGET apparently gets misinterpreted inside the
|
|
|
|
# gcc build stuff when the build is producing a cross compiler - i.e.
|
|
|
|
# when the 'current' target is the 'host' system, and the host is not
|
|
|
|
# the target (because the build is actually making a cross compiler!)
|
|
|
|
if [ "${BUILD_SYS}" != "${HOST_SYS}" ]; then
|
|
|
|
export CC_FOR_TARGET="${CC}"
|
|
|
|
export GCC_FOR_TARGET="${CC}"
|
|
|
|
export CXX_FOR_TARGET="${CXX}"
|
|
|
|
export AS_FOR_TARGET="${HOST_PREFIX}as"
|
|
|
|
export LD_FOR_TARGET="${HOST_PREFIX}ld"
|
|
|
|
export NM_FOR_TARGET="${HOST_PREFIX}nm"
|
|
|
|
export AR_FOR_TARGET="${HOST_PREFIX}ar"
|
2006-12-28 23:22:59 +00:00
|
|
|
export GFORTRAN_FOR_TARGET="gfortran"
|
2005-08-31 10:45:47 +00:00
|
|
|
export RANLIB_FOR_TARGET="${HOST_PREFIX}ranlib"
|
|
|
|
fi
|
|
|
|
export CC_FOR_BUILD="${BUILD_CC}"
|
|
|
|
export CXX_FOR_BUILD="${BUILD_CXX}"
|
|
|
|
export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
|
|
|
|
export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
|
|
|
|
export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
|
|
|
|
export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
|
2012-03-28 14:22:44 +00:00
|
|
|
export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
|
|
|
|
export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
|
|
|
|
export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
|
|
|
|
export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
|
2014-04-27 00:24:31 +00:00
|
|
|
|
gcc: fix check for target libc ssp support
gcc uses hardcoded path "${with-build-sysroot}/usr/include" to check target
libc ssp support. Based on GLIBC version strings in features.h in that search
path, gcc knows whether target (e)glibc implements stack protector itself.
However this breaks meta-toolchain, which actually has target libc headers
installed under {with-build-sysroot}/opt/... This way features.h is not found
and thus gcc-crosssdk-intermediate thinks that target (e)glibc doesn't support ssp.
Later when building eglibc-nativesdk, undefined reference to "__stack_chk_guard"
occurs which was caused by:
o eglibc do_configure found that gcc-crosssdk-intermediate supports ssp,
and thus enable -fstack-protector for nscd
o eglibc itself supports stack smash proctection for some architectures such
as i386, x86-64, etc. It's expected to use its own method to provide stack
protection, instead of relying on gcc. So eglibc rtld.os doesn't export
__stack_chk_guard to other modules
o then when installing nscd objects, gcc-crosssdk-intermediate sees the
flag "-fstack-protector", while it thought this eglibc doesn't implement
ssp itself, so gcc turns to the alternative to find a valid
__stack_chk_guard exported. eglibc doesn'g export it, while
gcc-crosssdk-intermediate itself disables libssp.
Then the undefined reference happens. If enabling libssp for gcc-crosssdk-
intermediate, it may also work-around this issue. But the ideal fix is still
to replace hard coded path with the actual one where target libc gets installed.
glibc-nativesdk doesn't encounter this issue because it thinks gcc doesn't
support ssp, and thus doesn't enable "-fstack-protector" for nscd. Don't know
the reason yet
This fix [BUGID #366]
Signed-off-by: Dexuan Cui <dexuan.cui@intel.com>
Signed-off-by: Kevin Tian <kevin.tian@intel.com>
2010-09-29 00:54:33 +00:00
|
|
|
|
2005-08-31 10:45:47 +00:00
|
|
|
oe_runconf
|
|
|
|
}
|
2008-03-18 10:41:39 +00:00
|
|
|
|