blob: 627005964446c34f9ae1028c125739d26140e346 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001GCCMULTILIB = "--enable-multilib"
2require gcc-configure-common.inc
3
4EXTRA_OECONF_PATHS = "\
5 --with-sysroot=/ \
6 --with-build-sysroot=${STAGING_DIR_TARGET} \
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007 --with-gxx-include-dir=${includedir}/c++/${BINV} \
8"
9
10EXTRA_OECONF_append_linuxstdbase = " --enable-clocale=gnu"
11
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012# Configure gcc running on the target to default to an architecture which will
13# be compatible with that of gcc-runtime (which is cross compiled to be target
14# specific). For example, for ARM, ARMv6+ adds atomic instructions that may
15# affect the ABI in the gcc-runtime libs. Since we can't rely on gcc on the
16# target to always be passed -march etc, its built-in default needs to be safe.
17
18ARMFPARCHEXT ?= ""
19
20EXTRA_OECONF_append_armv6 = " --with-arch=armv6${ARMFPARCHEXT}"
21EXTRA_OECONF_append_armv7a = " --with-arch=armv7-a${ARMFPARCHEXT}"
22EXTRA_OECONF_append_armv7ve = " --with-arch=armv7ve${ARMFPARCHEXT}"
Brad Bishop19323692019-04-05 15:28:33 -040023EXTRA_OECONF_append_arc = " --with-cpu=${TUNE_PKGARCH}"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050024
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025# libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is
26# set in subdir gcc, so subdir libcc1 can't use it, export it here to
27# fix the problem.
28export gcc_cv_objdump = "${TARGET_PREFIX}objdump"
29
30EXTRA_OECONF_GCC_FLOAT = "${@get_gcc_float_setting(bb, d)}"
31
32PACKAGES = "\
33 ${PN} ${PN}-plugins ${PN}-symlinks \
34 g++ g++-symlinks \
35 cpp cpp-symlinks \
36 g77 g77-symlinks \
37 gfortran gfortran-symlinks \
38 gcov gcov-symlinks \
39 ${PN}-doc \
40 ${PN}-dev \
41 ${PN}-dbg \
42"
43
44FILES_${PN} = "\
45 ${bindir}/${TARGET_PREFIX}gcc* \
Patrick Williamsf1e5d692016-03-30 15:21:19 -050046 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/collect2* \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \
49 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
50 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \
51 ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
52 ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
53 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
54 ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
55 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
56"
57INSANE_SKIP_${PN} += "dev-so"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060058RRECOMMENDS_${PN} += "\
59 libssp \
60 libssp-dev \
61"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062RDEPENDS_${PN} += "cpp"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064FILES_${PN}-dev = "\
65 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
66 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
67 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
68 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \
69 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \
70"
71FILES_${PN}-symlinks = "\
72 ${bindir}/cc \
73 ${bindir}/gcc \
74 ${bindir}/gccbug \
75"
76
77FILES_${PN}-plugins = "\
78 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \
79"
80ALLOW_EMPTY_${PN}-plugins = "1"
81
82FILES_g77 = "\
83 ${bindir}/${TARGET_PREFIX}g77 \
84 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \
85"
86FILES_g77-symlinks = "\
87 ${bindir}/g77 \
88 ${bindir}/f77 \
89"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060090RRECOMMENDS_g77 = "\
91 libg2c \
92 libg2c-dev \
93"
94
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095FILES_gfortran = "\
96 ${bindir}/${TARGET_PREFIX}gfortran \
97 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \
98"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060099RRECOMMENDS_gfortran = "\
100 libquadmath \
101 libquadmath-dev \
102"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103FILES_gfortran-symlinks = "\
104 ${bindir}/gfortran \
105 ${bindir}/f95"
106
107FILES_cpp = "\
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500108 ${bindir}/${TARGET_PREFIX}cpp* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500109 ${base_libdir}/cpp \
110 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1"
111FILES_cpp-symlinks = "${bindir}/cpp"
112
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500113FILES_gcov = "${bindir}/${TARGET_PREFIX}gcov* \
114 ${bindir}/${TARGET_PREFIX}gcov-tool* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115"
116FILES_gcov-symlinks = "${bindir}/gcov \
117 ${bindir}/gcov-tool \
118"
119
120FILES_g++ = "\
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500121 ${bindir}/${TARGET_PREFIX}g++* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \
123"
124FILES_g++-symlinks = "\
125 ${bindir}/c++ \
126 ${bindir}/g++ \
127"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600128RRECOMMENDS_g++ = "\
129 libstdc++ \
130 libstdc++-dev \
131 libatomic \
132 libatomic-dev \
133"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500134
135FILES_${PN}-doc = "\
136 ${infodir} \
137 ${mandir} \
138 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
139"
140
141do_compile () {
142 oe_runmake all-host
143}
144
145do_install () {
146 oe_runmake 'DESTDIR=${D}' install-host
147
148 # Add unwind.h, it comes from libgcc which we don't want to build again
149 install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
150
151 # Info dir listing isn't interesting at this point so remove it if it exists.
152 if [ -e "${D}${infodir}/dir" ]; then
153 rm -f ${D}${infodir}/dir
154 fi
155
156 # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
157 rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
158 rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
159 rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la
160 rmdir ${D}${includedir}
161 rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
162
163 # Hack around specs file assumptions
164 test -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/specs && sed -i -e '/^*cross_compile:$/ { n; s/1/0/; }' ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/specs
165
166 # Cleanup manpages..
167 rm -rf ${D}${mandir}/man7
168
169 cd ${D}${bindir}
170
171 # We care about g++ not c++
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500172 rm -f *c++*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173
174 # We don't care about the gcc-<version> ones for this
175 rm -f *gcc-?.?*
176
177 # We use libiberty from binutils
178 find ${D}${libdir} -name libiberty.a | xargs rm -f
179 find ${D}${libdir} -name libiberty.h | xargs rm -f
180
181 # Not sure why we end up with these but we don't want them...
182 rm -f ${TARGET_PREFIX}${TARGET_PREFIX}*
183
184 # Symlinks so we can use these trivially on the target
185 if [ -e ${TARGET_PREFIX}g77 ]; then
186 ln -sf ${TARGET_PREFIX}g77 g77 || true
187 ln -sf g77 f77 || true
188 fi
189 if [ -e ${TARGET_PREFIX}gfortran ]; then
190 ln -sf ${TARGET_PREFIX}gfortran gfortran || true
191 ln -sf gfortran f95 || true
192 fi
193 ln -sf ${TARGET_PREFIX}g++ g++
194 ln -sf ${TARGET_PREFIX}gcc gcc
195 ln -sf ${TARGET_PREFIX}cpp cpp
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196 ln -sf ${TARGET_PREFIX}gcov gcov
197 ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198 install -d ${D}${base_libdir}
199 ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp
200 ln -sf g++ c++
201 ln -sf gcc cc
202
203 chown -R root:root ${D}
204}
205
206do_install_append () {
207 #
208 # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header
209 # files and places the modified files into
210 # {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the
211 # build not deterministic. The following code prunes all those headers
212 # except those under include-fixed/linux, *limits.h and README, yielding
213 # the same include-fixed folders no matter what sysroot
214
215 include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed"
216 for f in $(find ${include_fixed} -type f); do
217 case $f in
218 */include-fixed/linux/*)
219 continue
220 ;;
221 */include-fixed/*limits.h)
222 continue
223 ;;
224 */include-fixed/README)
225 continue
226 ;;
227 *)
228 # remove file and directory if empty
229 bbdebug 2 "Pruning $f"
230 rm $f
231 find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \;
232 ;;
233 esac
234 done
235}
236
237# Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross
238# and one from here. These can confuse gcc cross where includes use #include_next
239# and builds track file dependencies (e.g. perl and its makedepends code).
240# For determinism we don't install this ever and rely on the copy from gcc-cross.
241# [YOCTO #7287]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600242SYSROOT_DIRS_BLACKLIST += "${libdir}/gcc"