diff options
author | Khem Raj <raj.khem@gmail.com> | 2011-12-16 14:33:37 -0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-12-19 09:29:18 +0000 |
commit | af9c75c8f5249728877770e3040cbc46c0038f30 (patch) | |
tree | 7b10523cbab4fee270d9a94a6d72c51962e74fd0 /meta | |
parent | 2480cc6a169f7d34d82d9e22c52f700e772ab45d (diff) | |
download | poky-af9c75c8f5249728877770e3040cbc46c0038f30.tar.gz |
gcc-4.6: Let G++ relocate gxx-include-dir when using --sysroot option
Currently we have a problem in our cross compiler since we use
/usr/include/c++ to be default gxx-include-dir and then expect
the patch we did to do the relocation w.r.t. sysroot however it
does not quite work so and we end up gxx-include-dirs not respecting
sysroot. A small test case would be
tst-unique4.cc
and it would fails like
tst-unique4.cc:1:18: fatal error: cstdio: No such file or directory
compilation terminated.
weather we use --sysroot or not it does not matter
arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
--sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
failed in same way.
so we redo the GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch based on upstream
submitted patch which tries to relocate the gxx-include-dir and to
achieve the relocation it has to be specified w.r.t to --with-sysroot
directory. e.g.
--with-sysroot=${SYSROOT}
--with-gxx-include-dir=${SYSROOT}/usr/include/c++
if we configure gcc like above then it becomes relocatable when
we run the compiler and specify --sysroot=<blah> then g++ will search
for gxx-headers under <blah>/usr/include/c++
if sysroot is not defined then it will use the default sysroot
and gxx-include-dir will be w.r.t. default sysroot.
Tested on qemuarm
/arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
--sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm
-v
...
/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++
/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/arm-oe-linux-gnueabi
/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm/usr/include/c++/backward
...
and if I now change --sysroot to something else
/arm-oe-linux-gnueabi-g++ -S tst-unique4.cc
--sysroot=/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4
-v
...
ignoring nonexistent directory
"/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++"
ignoring nonexistent directory
"/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/arm-oe-linux-gnueabi"
ignoring nonexistent directory
"/home/kraj/work/angstrom/sources/openembedded-core/build/tmp-eglibc/sysroots/qemuarm4/usr/include/c++/backward"
...
See now its looking for them in 'qemuarm4' sysroot
(From OE-Core rev: 28b772e42a20faebe1b4f415d28b42b7e0a424fb)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
4 files changed, 174 insertions, 23 deletions
diff --git a/meta/recipes-devtools/gcc/gcc-4.6.inc b/meta/recipes-devtools/gcc/gcc-4.6.inc index 18e05363f5..4bbb2d22dc 100644 --- a/meta/recipes-devtools/gcc/gcc-4.6.inc +++ b/meta/recipes-devtools/gcc/gcc-4.6.inc | |||
@@ -1,6 +1,6 @@ | |||
1 | require gcc-common.inc | 1 | require gcc-common.inc |
2 | 2 | ||
3 | PR = "r19" | 3 | PR = "r20" |
4 | 4 | ||
5 | # Third digit in PV should be incremented after a minor release | 5 | # Third digit in PV should be incremented after a minor release |
6 | # happens from this branch on gcc e.g. currently its 4.6.0 | 6 | # happens from this branch on gcc e.g. currently its 4.6.0 |
@@ -62,7 +62,6 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \ | |||
62 | file://64bithack.patch \ | 62 | file://64bithack.patch \ |
63 | file://optional_libstdc.patch \ | 63 | file://optional_libstdc.patch \ |
64 | file://disable_relax_pic_calls_flag.patch \ | 64 | file://disable_relax_pic_calls_flag.patch \ |
65 | file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \ | ||
66 | file://COLLECT_GCC_OPTIONS.patch \ | 65 | file://COLLECT_GCC_OPTIONS.patch \ |
67 | file://volatile_access_backport.patch \ | 66 | file://volatile_access_backport.patch \ |
68 | file://use-defaults.h-and-t-oe-in-B.patch \ | 67 | file://use-defaults.h-and-t-oe-in-B.patch \ |
@@ -73,6 +72,7 @@ SRC_URI = "svn://gcc.gnu.org/svn/gcc/branches;module=${BRANCH};proto=http \ | |||
73 | file://pr32219.patch \ | 72 | file://pr32219.patch \ |
74 | file://pr47551.patch \ | 73 | file://pr47551.patch \ |
75 | file://gcc-arm-set-cost.patch \ | 74 | file://gcc-arm-set-cost.patch \ |
75 | file://GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch \ | ||
76 | " | 76 | " |
77 | 77 | ||
78 | SRC_URI_append_sh3 = " file://sh3-installfix-fixheaders.patch " | 78 | SRC_URI_append_sh3 = " file://sh3-installfix-fixheaders.patch " |
diff --git a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch index 05b2fa96c2..6ccbeea00d 100644 --- a/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch +++ b/meta/recipes-devtools/gcc/gcc-4.6/GPLUSPLUS_INCLUDE_DIR_with_sysroot.patch | |||
@@ -1,35 +1,186 @@ | |||
1 | Upstream-Status: Pending | 1 | source: http://patchwork.ozlabs.org/patch/129800/ |
2 | 2 | Upstream-Status: Submitted | |
3 | # by default c++ include directories are not relative to "--sysroot" | 3 | |
4 | # which brings one trouble when using the toolchain in an environment | 4 | ChangeLog |
5 | # where the build directory generating that toolchain doesn't exist, | 5 | * Makefile.in (gcc_gxx_include_dir_add_sysroot): New. |
6 | # e.g. in sstate, machine specific sysroot and relocatable SDK | 6 | (PREPROCESSOR_DEFINES): Define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT. |
7 | # toolchain. This patch now enables c++ include paths under sysroot. | 7 | |
8 | # This way it's enough as long as "--sysroot" is correctly enabled | 8 | * cppdefault.c (cpp_include_defaults): replace hard coded "1" with |
9 | # in the new environment. | 9 | GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT for "add_sysroot" field. |
10 | # | 10 | |
11 | # Signed-off-by Kevin Tian <kevin.tian@intel.com>, 2010-12-30 | 11 | * configure.ac (AC_SUBST): Add gcc_gxx_include_dir_add_sysroot to |
12 | 12 | control whether sysroot should be prepended to gxx include dir. | |
13 | Index: gcc-4.6.0/gcc/cppdefault.c | 13 | |
14 | * configure: Regenerate. | ||
15 | |||
16 | Hi, this is a follow up for issue "http://codereview.appspot.com/4641076". | ||
17 | |||
18 | The rationale for the patch copied from previous thread: | ||
19 | ======================================= | ||
20 | The setup: | ||
21 | |||
22 | Configuring a toolchain targeting x86-64 GNU Linux (Ubuntu Lucid), as a | ||
23 | cross-compiler. Using a sysroot to provide the Lucid headers+libraries, | ||
24 | with the sysroot path being within the GCC install tree. Want to use the | ||
25 | Lucid system libstdc++ and headers, which means that I'm not | ||
26 | building/installing libstdc++-v3. | ||
27 | |||
28 | So, configuring with: | ||
29 | --with-sysroot="$SYSROOT" | ||
30 | --disable-libstdc++-v3 \ | ||
31 | --with-gxx-include-dir="$SYSROOT/usr/include/c++/4.4" \ | ||
32 | (among other options). | ||
33 | |||
34 | Hoping to support two usage models with this configuration, w.r.t. use of | ||
35 | the sysroot: | ||
36 | |||
37 | (1) somebody installs the sysroot in the normal location relative to the | ||
38 | GCC install, and relocates the whole bundle (sysroot+GCC). This works | ||
39 | great AFAICT, GCC finds its includes (including the C++ includes) thanks | ||
40 | to the add_standard_paths iprefix handling. | ||
41 | |||
42 | (2) somebody installs the sysroot in a non-standard location, and uses | ||
43 | --sysroot to try to access it. This works fine for the C headers, but | ||
44 | doesn't work. | ||
45 | |||
46 | For the C headers, add_standard_paths prepends the sysroot location to | ||
47 | the /usr/include path (since that's what's specified in cppdefault.c for | ||
48 | that path). It doesn't do the same for the C++ include path, though | ||
49 | (again, as specified in cppdefault.c). | ||
50 | |||
51 | add_standard_paths doesn't attempt to relocate built-in include paths that | ||
52 | start with the compiled-in sysroot location (e.g., the g++ include dir, in | ||
53 | this case). This isn't surprising really: normally you either prepend the | ||
54 | sysroot location or you don't (as specified by cppdefault.c); none of the | ||
55 | built-in paths normally *start* with the sysroot location and need to be | ||
56 | relocated. However, in this odd-ball case of trying to use the C++ headers | ||
57 | from the sysroot, one of the paths *does* need to be relocated in this way. | ||
58 | =========================== | ||
59 | Index: gcc-4_6-branch/gcc/Makefile.in | ||
60 | =================================================================== | ||
61 | --- gcc-4_6-branch.orig/gcc/Makefile.in 2011-12-13 22:52:15.000000000 -0800 | ||
62 | +++ gcc-4_6-branch/gcc/Makefile.in 2011-12-13 22:52:21.933635767 -0800 | ||
63 | @@ -587,6 +587,7 @@ | ||
64 | build_tooldir = $(exec_prefix)/$(target_noncanonical) | ||
65 | # Directory in which the compiler finds target-independent g++ includes. | ||
66 | gcc_gxx_include_dir = @gcc_gxx_include_dir@ | ||
67 | +gcc_gxx_include_dir_add_sysroot = @gcc_gxx_include_dir_add_sysroot@ | ||
68 | # Directory to search for site-specific includes. | ||
69 | local_includedir = $(local_prefix)/include | ||
70 | includedir = $(prefix)/include | ||
71 | @@ -3964,6 +3965,7 @@ | ||
72 | -DGCC_INCLUDE_DIR=\"$(libsubdir)/include\" \ | ||
73 | -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \ | ||
74 | -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \ | ||
75 | + -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \ | ||
76 | -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \ | ||
77 | -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \ | ||
78 | -DLOCAL_INCLUDE_DIR=\"$(local_includedir)\" \ | ||
79 | Index: gcc-4_6-branch/gcc/configure.ac | ||
14 | =================================================================== | 80 | =================================================================== |
15 | --- gcc-4.6.0.orig/gcc/cppdefault.c | 81 | --- gcc-4_6-branch.orig/gcc/configure.ac 2011-12-13 22:52:15.000000000 -0800 |
16 | +++ gcc-4.6.0/gcc/cppdefault.c | 82 | +++ gcc-4_6-branch/gcc/configure.ac 2011-12-13 22:52:21.937635526 -0800 |
17 | @@ -48,15 +48,15 @@ const struct default_include cpp_include | 83 | @@ -144,6 +144,15 @@ |
84 | fi | ||
85 | fi | ||
86 | |||
87 | +gcc_gxx_include_dir_add_sysroot=0 | ||
88 | +if test "${with_sysroot+set}" = set; then : | ||
89 | + gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'` | ||
90 | + if test "${gcc_gxx_without_sysroot}"; then : | ||
91 | + gcc_gxx_include_dir="${gcc_gxx_without_sysroot}" | ||
92 | + gcc_gxx_include_dir_add_sysroot=1 | ||
93 | + fi | ||
94 | +fi | ||
95 | + | ||
96 | AC_ARG_WITH(cpp_install_dir, | ||
97 | [ --with-cpp-install-dir=DIR | ||
98 | install the user visible C preprocessor in DIR | ||
99 | @@ -4737,6 +4746,7 @@ | ||
100 | AC_SUBST(float_h_file) | ||
101 | AC_SUBST(gcc_config_arguments) | ||
102 | AC_SUBST(gcc_gxx_include_dir) | ||
103 | +AC_SUBST(gcc_gxx_include_dir_add_sysroot) | ||
104 | AC_SUBST(host_exeext) | ||
105 | AC_SUBST(host_xm_file_list) | ||
106 | AC_SUBST(host_xm_include_list) | ||
107 | Index: gcc-4_6-branch/gcc/cppdefault.c | ||
108 | =================================================================== | ||
109 | --- gcc-4_6-branch.orig/gcc/cppdefault.c 2011-12-13 22:51:28.000000000 -0800 | ||
110 | +++ gcc-4_6-branch/gcc/cppdefault.c 2011-12-13 22:52:21.937635526 -0800 | ||
111 | @@ -48,15 +48,18 @@ | ||
18 | = { | 112 | = { |
19 | #ifdef GPLUSPLUS_INCLUDE_DIR | 113 | #ifdef GPLUSPLUS_INCLUDE_DIR |
20 | /* Pick up GNU C++ generic include files. */ | 114 | /* Pick up GNU C++ generic include files. */ |
21 | - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, | 115 | - { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, |
22 | + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, | 116 | + { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1, |
117 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, | ||
23 | #endif | 118 | #endif |
24 | #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR | 119 | #ifdef GPLUSPLUS_TOOL_INCLUDE_DIR |
25 | /* Pick up GNU C++ target-dependent include files. */ | 120 | /* Pick up GNU C++ target-dependent include files. */ |
26 | - { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 }, | 121 | - { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 0, 1 }, |
27 | + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, 1, 1 }, | 122 | + { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1, |
123 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 }, | ||
28 | #endif | 124 | #endif |
29 | #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR | 125 | #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR |
30 | /* Pick up GNU C++ backward and deprecated include files. */ | 126 | /* Pick up GNU C++ backward and deprecated include files. */ |
31 | - { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, | 127 | - { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 0, 0 }, |
32 | + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, 1, 0 }, | 128 | + { GPLUSPLUS_BACKWARD_INCLUDE_DIR, "G++", 1, 1, |
129 | + GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, | ||
33 | #endif | 130 | #endif |
34 | #ifdef GCC_INCLUDE_DIR | 131 | #ifdef GCC_INCLUDE_DIR |
35 | /* This is the dir for gcc's private headers. */ | 132 | /* This is the dir for gcc's private headers. */ |
133 | Index: gcc-4_6-branch/gcc/configure | ||
134 | =================================================================== | ||
135 | --- gcc-4_6-branch.orig/gcc/configure 2011-12-13 22:52:15.000000000 -0800 | ||
136 | +++ gcc-4_6-branch/gcc/configure 2011-12-13 22:52:33.185690436 -0800 | ||
137 | @@ -636,6 +636,7 @@ | ||
138 | host_xm_include_list | ||
139 | host_xm_file_list | ||
140 | host_exeext | ||
141 | +gcc_gxx_include_dir_add_sysroot | ||
142 | gcc_gxx_include_dir | ||
143 | gcc_config_arguments | ||
144 | float_h_file | ||
145 | @@ -3313,6 +3314,15 @@ | ||
146 | fi | ||
147 | fi | ||
148 | |||
149 | +gcc_gxx_include_dir_add_sysroot=0 | ||
150 | +if test "${with_sysroot+set}" = set; then : | ||
151 | + gcc_gxx_without_sysroot=`expr "${gcc_gxx_include_dir}" : "${with_sysroot}"'\(.*\)'` | ||
152 | + if test "${gcc_gxx_without_sysroot}"; then : | ||
153 | + gcc_gxx_include_dir="${gcc_gxx_without_sysroot}" | ||
154 | + gcc_gxx_include_dir_add_sysroot=1 | ||
155 | + fi | ||
156 | +fi | ||
157 | + | ||
158 | |||
159 | # Check whether --with-cpp_install_dir was given. | ||
160 | if test "${with_cpp_install_dir+set}" = set; then : | ||
161 | @@ -17514,7 +17524,7 @@ | ||
162 | lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 | ||
163 | lt_status=$lt_dlunknown | ||
164 | cat > conftest.$ac_ext <<_LT_EOF | ||
165 | -#line 17517 "configure" | ||
166 | +#line 17527 "configure" | ||
167 | #include "confdefs.h" | ||
168 | |||
169 | #if HAVE_DLFCN_H | ||
170 | @@ -17620,7 +17630,7 @@ | ||
171 | lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 | ||
172 | lt_status=$lt_dlunknown | ||
173 | cat > conftest.$ac_ext <<_LT_EOF | ||
174 | -#line 17623 "configure" | ||
175 | +#line 17633 "configure" | ||
176 | #include "confdefs.h" | ||
177 | |||
178 | #if HAVE_DLFCN_H | ||
179 | @@ -26151,6 +26161,7 @@ | ||
180 | |||
181 | |||
182 | |||
183 | + | ||
184 | |||
185 | |||
186 | |||
diff --git a/meta/recipes-devtools/gcc/gcc-configure-cross.inc b/meta/recipes-devtools/gcc/gcc-configure-cross.inc index 3e3742349d..774dadb89f 100644 --- a/meta/recipes-devtools/gcc/gcc-configure-cross.inc +++ b/meta/recipes-devtools/gcc/gcc-configure-cross.inc | |||
@@ -9,7 +9,7 @@ EXTRA_OECONF += " --enable-poison-system-directories \ | |||
9 | INHIBIT_DEFAULT_DEPS = "1" | 9 | INHIBIT_DEFAULT_DEPS = "1" |
10 | 10 | ||
11 | EXTRA_OECONF_PATHS = "--with-local-prefix=${STAGING_DIR_TARGET}${target_exec_prefix} \ | 11 | EXTRA_OECONF_PATHS = "--with-local-prefix=${STAGING_DIR_TARGET}${target_exec_prefix} \ |
12 | --with-gxx-include-dir=${target_includedir}/c++ \ | 12 | --with-gxx-include-dir=${STAGING_DIR_TARGET}${target_includedir}/c++ \ |
13 | --with-sysroot=${STAGING_DIR_TARGET} \ | 13 | --with-sysroot=${STAGING_DIR_TARGET} \ |
14 | --with-build-sysroot=${STAGING_DIR_TARGET}" | 14 | --with-build-sysroot=${STAGING_DIR_TARGET}" |
15 | 15 | ||
diff --git a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc index f130b4757b..eb6757cdc8 100644 --- a/meta/recipes-devtools/gcc/gcc-configure-sdk.inc +++ b/meta/recipes-devtools/gcc/gcc-configure-sdk.inc | |||
@@ -5,7 +5,7 @@ USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibc", "no", "", d )}' | |||
5 | USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibceabi", "no", "", d )}' | 5 | USE_NLS = '${@base_conditional( "TARGET_OS", "linux-uclibceabi", "no", "", d )}' |
6 | 6 | ||
7 | EXTRA_OECONF_PATHS = "--with-local-prefix=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_exec_prefix} \ | 7 | EXTRA_OECONF_PATHS = "--with-local-prefix=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_exec_prefix} \ |
8 | --with-gxx-include-dir=${target_includedir}/c++ \ | 8 | --with-gxx-include-dir=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS}${target_includedir}/c++ \ |
9 | --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \ | 9 | --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \ |
10 | --with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \ | 10 | --with-sysroot=${SDKPATH}/sysroots/${TUNE_PKGARCH}${TARGET_VENDOR}-${TARGET_OS} \ |
11 | --with-build-sysroot=${STAGING_DIR_TARGET}" | 11 | --with-build-sysroot=${STAGING_DIR_TARGET}" |