blob: 1872faee1b08cf252721f4d30e127824f553d41e [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit cross-canadian
2
3SUMMARY = "GNU cc and gcc C compilers (cross-canadian for ${TARGET_ARCH} target)"
4PN = "gcc-cross-canadian-${TRANSLATED_TARGET_ARCH}"
5
Brad Bishop19323692019-04-05 15:28:33 -04006DEPENDS = "virtual/${TARGET_PREFIX}gcc virtual/${HOST_PREFIX}gcc-crosssdk virtual/${HOST_PREFIX}binutils-crosssdk virtual/nativesdk-libc nativesdk-gettext flex-native virtual/libc"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007
8GCCMULTILIB = "--enable-multilib"
9
10require gcc-configure-common.inc
11
12EXTRA_OECONF_PATHS = "\
13 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
14 --with-build-time-tools=${STAGING_DIR_NATIVE}${prefix_native}/${TARGET_SYS}/bin \
15 --with-sysroot=/not/exist \
16 --with-build-sysroot=${STAGING_DIR_TARGET} \
17"
18# We have to point gcc at a sysroot but we don't need to rebuild if this changes
19# e.g. we switch between different machines with different tunes.
20EXTRA_OECONF_PATHS[vardepsexclude] = "TUNE_PKGARCH"
21TARGET_ARCH[vardepsexclude] = "TUNE_ARCH"
22get_gcc_float_setting[vardepvalue] = ""
23
24#
25# gcc-cross looks and finds these in ${exec_prefix} but we're not so lucky
26# for the sdk. Hardcoding the paths ensures the build doesn't go canadian or worse.
27#
28export AR_FOR_TARGET = "${TARGET_PREFIX}ar"
29export AS_FOR_TARGET = "${TARGET_PREFIX}as"
30export DLLTOOL_FOR_TARGET = "${TARGET_PREFIX}dlltool"
31export CC_FOR_TARGET = "${TARGET_PREFIX}gcc"
32export CXX_FOR_TARGET = "${TARGET_PREFIX}g++"
33export GCC_FOR_TARGET = "${TARGET_PREFIX}gcc"
34export LD_FOR_TARGET = "${TARGET_PREFIX}ld"
35export LIPO_FOR_TARGET = "${TARGET_PREFIX}lipo"
36export NM_FOR_TARGET = "${TARGET_PREFIX}nm"
37export OBJDUMP_FOR_TARGET = "${TARGET_PREFIX}objdump"
38export RANLIB_FOR_TARGET = "${TARGET_PREFIX}ranlib"
39export STRIP_FOR_TARGET = "${TARGET_PREFIX}strip"
40export WINDRES_FOR_TARGET = "${TARGET_PREFIX}windres"
41
42#
43# We need to override this and make sure the compiler can find staging
44#
45export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET}"
46
47do_configure () {
48 export CC_FOR_BUILD="${BUILD_CC}"
49 export CXX_FOR_BUILD="${BUILD_CXX}"
50 export CFLAGS_FOR_BUILD="${BUILD_CFLAGS}"
51 export CPPFLAGS_FOR_BUILD="${BUILD_CPPFLAGS}"
52 export CXXFLAGS_FOR_BUILD="${BUILD_CXXFLAGS}"
53 export LDFLAGS_FOR_BUILD="${BUILD_LDFLAGS}"
54 export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
55 export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
56 export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
57 export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
58 oe_runconf
59}
60
61do_compile () {
62 oe_runmake all-host configure-target-libgcc
Brad Bishopd7bf8c12018-02-25 22:55:05 -050063 (cd ${B}/${TARGET_SYS}/libgcc; oe_runmake enable-execute-stack.c unwind.h md-unwind-support.h sfp-machine.h gthr-default.h)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050064}
65
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066PACKAGES = "${PN}-dbg ${PN} ${PN}-doc"
67
68FILES_${PN} = "\
69 ${exec_prefix}/bin/* \
70 ${libexecdir}/gcc/${TARGET_SYS}/${BINV}/* \
71 ${gcclibdir}/${TARGET_SYS}/${BINV}/*.o \
72 ${gcclibdir}/${TARGET_SYS}/${BINV}/specs \
73 ${gcclibdir}/${TARGET_SYS}/${BINV}/lib* \
74 ${gcclibdir}/${TARGET_SYS}/${BINV}/include \
75 ${gcclibdir}/${TARGET_SYS}/${BINV}/include-fixed \
76 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/include/ \
77 ${gcclibdir}/${TARGET_SYS}/${BINV}/plugin/gtype.* \
Andrew Geisslerc926e172021-05-07 16:11:35 -050078 ${libdir}/bfd-plugins/*.so \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079 ${includedir}/c++/${BINV} \
80 ${prefix}/${TARGET_SYS}/bin/* \
81 ${prefix}/${TARGET_SYS}/lib/* \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050082 ${prefix}/${TARGET_SYS}${target_includedir}/* \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083"
84INSANE_SKIP_${PN} += "dev-so"
85
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086FILES_${PN}-doc = "\
87 ${infodir} \
88 ${mandir} \
89 ${gcclibdir}/${TARGET_SYS}/${BINV}/include/README \
90"
91
92EXEEXT = ""
93
94# Compute how to get from libexecdir to bindir in python (easier than shell)
95BINRELPATH = "${@os.path.relpath(d.expand("${bindir}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
Andrew Geisslerc926e172021-05-07 16:11:35 -050096# linker plugin path
97LIBRELPATH = "${@os.path.relpath(d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"), d.expand("${libdir}/bfd-plugins"))}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098
99do_install () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500100 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101 oe_runmake 'DESTDIR=${D}' install-host
102
103 # Cleanup some of the ${libdir}{,exec}/gcc stuff ...
104 rm -r ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
105 rm -r ${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/install-tools
106 rm -rf ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/finclude
107
108 # We care about g++ not c++
109 rm -f ${D}${bindir}/*c++
110
111 # We don't care about the gcc-<version> copies
Andrew Geissler635e0e42020-08-21 15:58:33 -0500112 rm -f ${D}${bindir}/*gcc-${BINV}*
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114 # Cleanup empty directories which are not shipped
115 # we use rmdir instead of 'rm -f' to ensure the non empty directories are not deleted
116 # ${D}${libdir}/../lib only seems to appear with SDKMACHINE=i686
117 local empty_dirs="${D}${libdir}/../lib ${D}${prefix}/${TARGET_SYS}/lib ${D}${prefix}/${TARGET_SYS} ${D}${includedir}"
118 for i in $empty_dirs; do
119 [ -d $i ] && rmdir --ignore-fail-on-non-empty $i
120 done
121
122 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
123 # found.
124 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
125 install -d $dest
126 suffix=${EXEEXT}
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700127 for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500128 if [ "$t" = "g77" -o "$t" = "gfortran" ] && [ ! -e ${D}${bindir}/${TARGET_PREFIX}$t$suffix ]; then
129 continue
130 fi
131
132 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t$suffix $dest$t$suffix
133 done
134 t=real-ld
135 ln -sf ${BINRELPATH}/${TARGET_PREFIX}ld$suffix $dest$t$suffix
136
137 # libquadmath headers need to be available in the gcc libexec dir
138 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
139 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
140 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
141
Andrew Geisslerc926e172021-05-07 16:11:35 -0500142 # install LTO linker plugins where binutils tools can find it
143 install -d ${D}${libdir}/bfd-plugins
144 ln -sf ${LIBRELPATH}/liblto_plugin.so ${D}${libdir}/bfd-plugins/liblto_plugin.so
145
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500146 chown -R root:root ${D}
Andrew Geisslerc926e172021-05-07 16:11:35 -0500147
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500148 cross_canadian_bindirlinks
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500149
150 for i in linux ${CANADIANEXTRAOS}
151 do
152 for v in ${CANADIANEXTRAVENDOR}
153 do
154 d=${D}${bindir}/../${TARGET_ARCH}$v-$i
155 install -d $d
156 for j in ${TARGET_PREFIX}gcc${EXEEXT} ${TARGET_PREFIX}g++${EXEEXT}
157 do
158 p=${TARGET_ARCH}$v-$i-`echo $j | sed -e s,${TARGET_PREFIX},,`
159 case $i in
160 *musl*)
161 rm -rf $d/$p
162 echo "#!/usr/bin/env sh" > $d/$p
163 echo "exec \`dirname \$0\`/../${TARGET_SYS}/$j -mmusl \$@" >> $d/$p
164 chmod 0755 $d/$p
165 ;;
166 *)
167 ;;
168 esac
169 done
170 done
171 done
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172}
173
174ELFUTILS = "nativesdk-elfutils"
175DEPENDS += "nativesdk-gmp nativesdk-mpfr nativesdk-libmpc ${ELFUTILS} nativesdk-zlib"
176RDEPENDS_${PN} += "nativesdk-mpfr nativesdk-libmpc ${ELFUTILS}"
177
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500178SYSTEMHEADERS = "${target_includedir}/"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179SYSTEMLIBS = "${target_base_libdir}/"
180SYSTEMLIBS1 = "${target_libdir}/"
181
182EXTRA_OECONF += "--enable-poison-system-directories"
Brad Bishopc342db32019-05-15 21:57:59 -0400183EXTRA_OECONF_remove_elf = "--with-sysroot=/not/exist"
184EXTRA_OECONF_remove_eabi = "--with-sysroot=/not/exist"
Andrew Geissler82c905d2020-04-13 13:39:40 -0500185EXTRA_OECONF_append_elf = " --without-headers --with-newlib"
186EXTRA_OECONF_append_eabi = " --without-headers --with-newlib"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500187# gcc 4.7 needs -isystem
188export ARCH_FLAGS_FOR_TARGET = "--sysroot=${STAGING_DIR_TARGET} -isystem=${target_includedir}"