blob: 0ee3e83d42d2384ae1a5d1ebd44562ca99668ad8 [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
Andrew Geissler4b740dc2020-05-05 08:54:39 -050018EXTRA_OECONF_append_armv6_class-target = " --with-arch=armv6${ARMFPARCHEXT}"
19EXTRA_OECONF_append_armv7a_class-target = " --with-arch=armv7-a${ARMFPARCHEXT}"
20EXTRA_OECONF_append_armv7ve_class-target = " --with-arch=armv7ve${ARMFPARCHEXT}"
21EXTRA_OECONF_append_arc_class-target = " --with-cpu=${TUNE_PKGARCH}"
22EXTRA_OECONF_append_x86-64_class-target = " --with-arch=native"
Brad Bishopd7bf8c12018-02-25 22:55:05 -050023
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024# libcc1 requres gcc_cv_objdump when cross build, but gcc_cv_objdump is
25# set in subdir gcc, so subdir libcc1 can't use it, export it here to
26# fix the problem.
27export gcc_cv_objdump = "${TARGET_PREFIX}objdump"
28
29EXTRA_OECONF_GCC_FLOAT = "${@get_gcc_float_setting(bb, d)}"
30
31PACKAGES = "\
32 ${PN} ${PN}-plugins ${PN}-symlinks \
33 g++ g++-symlinks \
34 cpp cpp-symlinks \
35 g77 g77-symlinks \
36 gfortran gfortran-symlinks \
37 gcov gcov-symlinks \
38 ${PN}-doc \
39 ${PN}-dev \
40 ${PN}-dbg \
41"
42
43FILES_${PN} = "\
44 ${bindir}/${TARGET_PREFIX}gcc* \
Andrew Geisslerc182c622020-05-15 14:13:32 -050045 ${bindir}/${TARGET_PREFIX}lto* \
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 \
Andrew Geissler95ac1b82021-03-31 14:34:31 -050048 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/g++-mapper-server \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lto* \
50 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
51 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto*${SOLIBSDEV} \
52 ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
53 ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
54 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBS} \
55 ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
56 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
Andrew Geisslerc926e172021-05-07 16:11:35 -050057 ${libdir}/bfd-plugins/*.so \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058"
59INSANE_SKIP_${PN} += "dev-so"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060060RRECOMMENDS_${PN} += "\
61 libssp \
62 libssp-dev \
63"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064RDEPENDS_${PN} += "cpp"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050065
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066FILES_${PN}-dev = "\
67 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
68 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/lib*${SOLIBSDEV} \
69 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
70 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/plugin/gengtype \
71 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.state \
72"
73FILES_${PN}-symlinks = "\
74 ${bindir}/cc \
75 ${bindir}/gcc \
76 ${bindir}/gccbug \
77"
78
79FILES_${PN}-plugins = "\
80 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin \
81"
82ALLOW_EMPTY_${PN}-plugins = "1"
83
84FILES_g77 = "\
85 ${bindir}/${TARGET_PREFIX}g77 \
86 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f771 \
87"
88FILES_g77-symlinks = "\
89 ${bindir}/g77 \
90 ${bindir}/f77 \
91"
Patrick Williamsc0f7c042017-02-23 20:41:17 -060092RRECOMMENDS_g77 = "\
93 libg2c \
94 libg2c-dev \
95"
96
Patrick Williamsc124f4f2015-09-15 14:41:29 -050097FILES_gfortran = "\
98 ${bindir}/${TARGET_PREFIX}gfortran \
99 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/f951 \
100"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600101RRECOMMENDS_gfortran = "\
102 libquadmath \
103 libquadmath-dev \
104"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500105FILES_gfortran-symlinks = "\
106 ${bindir}/gfortran \
107 ${bindir}/f95"
108
109FILES_cpp = "\
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500110 ${bindir}/${TARGET_PREFIX}cpp* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111 ${base_libdir}/cpp \
112 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1"
113FILES_cpp-symlinks = "${bindir}/cpp"
114
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500115FILES_gcov = "${bindir}/${TARGET_PREFIX}gcov* \
116 ${bindir}/${TARGET_PREFIX}gcov-tool* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117"
118FILES_gcov-symlinks = "${bindir}/gcov \
119 ${bindir}/gcov-tool \
120"
121
122FILES_g++ = "\
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500123 ${bindir}/${TARGET_PREFIX}g++* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500124 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/cc1plus \
125"
126FILES_g++-symlinks = "\
127 ${bindir}/c++ \
128 ${bindir}/g++ \
129"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600130RRECOMMENDS_g++ = "\
131 libstdc++ \
132 libstdc++-dev \
133 libatomic \
134 libatomic-dev \
135"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136
137FILES_${PN}-doc = "\
138 ${infodir} \
139 ${mandir} \
140 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
141"
142
143do_compile () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500144 # Prevent full target sysroot path from being used in configargs.h header,
145 # as it will be rewritten when used by other sysroots preventing support
146 # for gcc plugins. Additionally the path is embeddeded into the output
147 # binary, this prevents building a reproducible binary.
148 oe_runmake configure-gcc
149 sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h
150 sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h
151
152 # Prevent sysroot/workdir paths from being used in checksum-options.
153 # checksum-options is used to generate a checksum which is embedded into
154 # the output binary.
155 oe_runmake TARGET-gcc=checksum-options all-gcc
156 sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options
157 sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/checksum-options
158
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500159 oe_runmake all-host
160}
161
162do_install () {
163 oe_runmake 'DESTDIR=${D}' install-host
164
165 # Add unwind.h, it comes from libgcc which we don't want to build again
166 install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
167
168 # Info dir listing isn't interesting at this point so remove it if it exists.
169 if [ -e "${D}${infodir}/dir" ]; then
170 rm -f ${D}${infodir}/dir
171 fi
172
173 # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
174 rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
175 rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
176 rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la
177 rmdir ${D}${includedir}
178 rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
179
180 # Hack around specs file assumptions
181 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
182
183 # Cleanup manpages..
184 rm -rf ${D}${mandir}/man7
185
Andrew Geissler82c905d2020-04-13 13:39:40 -0500186 # Don't package details about the build host
187 rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/auto-build.h
188 rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/bconfig.h
189
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190 cd ${D}${bindir}
191
192 # We care about g++ not c++
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500193 rm -f *c++*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194
195 # We don't care about the gcc-<version> ones for this
196 rm -f *gcc-?.?*
197
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198 # Not sure why we end up with these but we don't want them...
199 rm -f ${TARGET_PREFIX}${TARGET_PREFIX}*
200
201 # Symlinks so we can use these trivially on the target
202 if [ -e ${TARGET_PREFIX}g77 ]; then
203 ln -sf ${TARGET_PREFIX}g77 g77 || true
204 ln -sf g77 f77 || true
205 fi
206 if [ -e ${TARGET_PREFIX}gfortran ]; then
207 ln -sf ${TARGET_PREFIX}gfortran gfortran || true
208 ln -sf gfortran f95 || true
209 fi
210 ln -sf ${TARGET_PREFIX}g++ g++
211 ln -sf ${TARGET_PREFIX}gcc gcc
212 ln -sf ${TARGET_PREFIX}cpp cpp
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500213 ln -sf ${TARGET_PREFIX}gcov gcov
214 ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500215 install -d ${D}${base_libdir}
216 ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp
217 ln -sf g++ c++
218 ln -sf gcc cc
Andrew Geisslerc926e172021-05-07 16:11:35 -0500219 install -d ${D}${libdir}/bfd-plugins
220 ln -sf ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500221 chown -R root:root ${D}
222}
223
224do_install_append () {
225 #
226 # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header
227 # files and places the modified files into
228 # {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the
229 # build not deterministic. The following code prunes all those headers
230 # except those under include-fixed/linux, *limits.h and README, yielding
231 # the same include-fixed folders no matter what sysroot
232
233 include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed"
234 for f in $(find ${include_fixed} -type f); do
235 case $f in
236 */include-fixed/linux/*)
237 continue
238 ;;
239 */include-fixed/*limits.h)
240 continue
241 ;;
242 */include-fixed/README)
243 continue
244 ;;
245 *)
246 # remove file and directory if empty
247 bbdebug 2 "Pruning $f"
248 rm $f
249 find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \;
250 ;;
251 esac
252 done
253}
254
255# Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross
256# and one from here. These can confuse gcc cross where includes use #include_next
257# and builds track file dependencies (e.g. perl and its makedepends code).
258# For determinism we don't install this ever and rely on the copy from gcc-cross.
259# [YOCTO #7287]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600260SYSROOT_DIRS_BLACKLIST += "${libdir}/gcc"