blob: 1e25dad86bfc487dd5b629c6676b4424d9e32023 [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 \
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 () {
Andrew Geissler82c905d2020-04-13 13:39:40 -0500142 # Prevent full target sysroot path from being used in configargs.h header,
143 # as it will be rewritten when used by other sysroots preventing support
144 # for gcc plugins. Additionally the path is embeddeded into the output
145 # binary, this prevents building a reproducible binary.
146 oe_runmake configure-gcc
147 sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/configargs.h
148 sed -i 's@${STAGING_DIR_HOST}@/@g' ${B}/gcc/configargs.h
149
150 # Prevent sysroot/workdir paths from being used in checksum-options.
151 # checksum-options is used to generate a checksum which is embedded into
152 # the output binary.
153 oe_runmake TARGET-gcc=checksum-options all-gcc
154 sed -i 's@${DEBUG_PREFIX_MAP}@@g' ${B}/gcc/checksum-options
155 sed -i 's@${STAGING_DIR_TARGET}@/@g' ${B}/gcc/checksum-options
156
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157 oe_runmake all-host
158}
159
160do_install () {
161 oe_runmake 'DESTDIR=${D}' install-host
162
163 # Add unwind.h, it comes from libgcc which we don't want to build again
164 install ${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/gcc/${TARGET_SYS}/${BINV}/include/unwind.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
165
166 # Info dir listing isn't interesting at this point so remove it if it exists.
167 if [ -e "${D}${infodir}/dir" ]; then
168 rm -f ${D}${infodir}/dir
169 fi
170
171 # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
172 rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
173 rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
174 rm -rf ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/*.la
175 rmdir ${D}${includedir}
176 rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
177
178 # Hack around specs file assumptions
179 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
180
181 # Cleanup manpages..
182 rm -rf ${D}${mandir}/man7
183
Andrew Geissler82c905d2020-04-13 13:39:40 -0500184 # Don't package details about the build host
185 rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/auto-build.h
186 rm -f ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/plugin/include/bconfig.h
187
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188 cd ${D}${bindir}
189
190 # We care about g++ not c++
Patrick Williamsf1e5d692016-03-30 15:21:19 -0500191 rm -f *c++*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192
193 # We don't care about the gcc-<version> ones for this
194 rm -f *gcc-?.?*
195
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500196 # Not sure why we end up with these but we don't want them...
197 rm -f ${TARGET_PREFIX}${TARGET_PREFIX}*
198
199 # Symlinks so we can use these trivially on the target
200 if [ -e ${TARGET_PREFIX}g77 ]; then
201 ln -sf ${TARGET_PREFIX}g77 g77 || true
202 ln -sf g77 f77 || true
203 fi
204 if [ -e ${TARGET_PREFIX}gfortran ]; then
205 ln -sf ${TARGET_PREFIX}gfortran gfortran || true
206 ln -sf gfortran f95 || true
207 fi
208 ln -sf ${TARGET_PREFIX}g++ g++
209 ln -sf ${TARGET_PREFIX}gcc gcc
210 ln -sf ${TARGET_PREFIX}cpp cpp
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500211 ln -sf ${TARGET_PREFIX}gcov gcov
212 ln -sf ${TARGET_PREFIX}gcov-tool gcov-tool
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500213 install -d ${D}${base_libdir}
214 ln -sf ${bindir}/${TARGET_PREFIX}cpp ${D}${base_libdir}/cpp
215 ln -sf g++ c++
216 ln -sf gcc cc
217
218 chown -R root:root ${D}
219}
220
221do_install_append () {
222 #
223 # Thefixinc.sh script, run on the gcc's compile phase, looks into sysroot header
224 # files and places the modified files into
225 # {D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed folder. This makes the
226 # build not deterministic. The following code prunes all those headers
227 # except those under include-fixed/linux, *limits.h and README, yielding
228 # the same include-fixed folders no matter what sysroot
229
230 include_fixed="${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include-fixed"
231 for f in $(find ${include_fixed} -type f); do
232 case $f in
233 */include-fixed/linux/*)
234 continue
235 ;;
236 */include-fixed/*limits.h)
237 continue
238 ;;
239 */include-fixed/README)
240 continue
241 ;;
242 *)
243 # remove file and directory if empty
244 bbdebug 2 "Pruning $f"
245 rm $f
246 find $(dirname $f) -maxdepth 0 -empty -exec rmdir {} \;
247 ;;
248 esac
249 done
250}
251
252# Installing /usr/lib/gcc/* means we'd have two copies, one from gcc-cross
253# and one from here. These can confuse gcc cross where includes use #include_next
254# and builds track file dependencies (e.g. perl and its makedepends code).
255# For determinism we don't install this ever and rely on the copy from gcc-cross.
256# [YOCTO #7287]
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600257SYSROOT_DIRS_BLACKLIST += "${libdir}/gcc"