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