blob: 89b19684befcafd340bc2039722e56c39bacd9f3 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001inherit cross
2
3INHIBIT_DEFAULT_DEPS = "1"
4EXTRADEPENDS = ""
5DEPENDS = "virtual/${TARGET_PREFIX}binutils virtual/${TARGET_PREFIX}libc-for-gcc ${EXTRADEPENDS} ${NATIVEDEPS}"
6PROVIDES = "virtual/${TARGET_PREFIX}gcc virtual/${TARGET_PREFIX}g++"
7python () {
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008 if d.getVar("TARGET_OS").startswith("linux"):
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009 d.setVar("EXTRADEPENDS", "linux-libc-headers")
10}
11
12PN = "gcc-cross-${TARGET_ARCH}"
13
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014# Ignore how TARGET_ARCH is computed.
15TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}"
16
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017require gcc-configure-common.inc
18
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019# While we want the 'gnu' hash style, we explicitly set it to sysv here to
20# ensure that any recipe which doesn't obey our LDFLAGS (which also set it to
21# gnu) will hit a QA failure.
22LINKER_HASH_STYLE ?= "sysv"
23
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024EXTRA_OECONF += "--enable-poison-system-directories"
25EXTRA_OECONF_append_sh4 = " \
26 --with-multilib-list= \
27 --enable-incomplete-targets \
28"
29
30EXTRA_OECONF += "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 --with-system-zlib \
32"
33
34DEPENDS_remove_libc-baremetal := "virtual/${TARGET_PREFIX}libc-for-gcc"
35EXTRA_OECONF_append_libc-baremetal = " --without-headers"
36EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080037EXTRA_OECONF_remove_libc-newlib = "--enable-threads=posix"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050038
39EXTRA_OECONF_PATHS = "\
40 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
41 --with-sysroot=/not/exist \
42 --with-build-sysroot=${STAGING_DIR_TARGET} \
43"
44
45ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
46
47do_compile () {
48 export CC="${BUILD_CC}"
49 export AR_FOR_TARGET="${TARGET_SYS}-ar"
50 export RANLIB_FOR_TARGET="${TARGET_SYS}-ranlib"
51 export LD_FOR_TARGET="${TARGET_SYS}-ld"
52 export NM_FOR_TARGET="${TARGET_SYS}-nm"
53 export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc"
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
59 oe_runmake all-host configure-target-libgcc
Brad Bishopd7bf8c12018-02-25 22:55:05 -050060 (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 -050061 # now generate script to drive testing
62 echo "#!/usr/bin/env sh" >${B}/${TARGET_PREFIX}testgcc
63 set >> ${B}/${TARGET_PREFIX}testgcc
64 # prune out the unneeded vars
65 sed -i -e "/^BASH/d" ${B}/${TARGET_PREFIX}testgcc
66 sed -i -e "/^USER/d" ${B}/${TARGET_PREFIX}testgcc
67 sed -i -e "/^OPT/d" ${B}/${TARGET_PREFIX}testgcc
68 sed -i -e "/^DIRSTACK/d" ${B}/${TARGET_PREFIX}testgcc
69 sed -i -e "/^EUID/d" ${B}/${TARGET_PREFIX}testgcc
70 sed -i -e "/^FUNCNAME/d" ${B}/${TARGET_PREFIX}testgcc
71 sed -i -e "/^GROUPS/d" ${B}/${TARGET_PREFIX}testgcc
72 sed -i -e "/^HOST/d" ${B}/${TARGET_PREFIX}testgcc
73 sed -i -e "/^HOME/d" ${B}/${TARGET_PREFIX}testgcc
74 sed -i -e "/^IFS/d" ${B}/${TARGET_PREFIX}testgcc
75 sed -i -e "/^LC_ALL/d" ${B}/${TARGET_PREFIX}testgcc
76 sed -i -e "/^LOGNAME/d" ${B}/${TARGET_PREFIX}testgcc
77 sed -i -e "/^MACHTYPE/d" ${B}/${TARGET_PREFIX}testgcc
78 sed -i -e "/^OSTYPE/d" ${B}/${TARGET_PREFIX}testgcc
79 sed -i -e "/^PIPE/d" ${B}/${TARGET_PREFIX}testgcc
80 sed -i -e "/^SHELL/d" ${B}/${TARGET_PREFIX}testgcc
81 sed -i -e "/^'/d" ${B}/${TARGET_PREFIX}testgcc
82 sed -i -e "/^UID/d" ${B}/${TARGET_PREFIX}testgcc
83 sed -i -e "/^TERM/d" ${B}/${TARGET_PREFIX}testgcc
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 sed -i -e "/^PKG_/d" ${B}/${TARGET_PREFIX}testgcc
85 sed -i -e "/^POSIXLY_/d" ${B}/${TARGET_PREFIX}testgcc
86 sed -i -e "/^PPID/d" ${B}/${TARGET_PREFIX}testgcc
87 sed -i -e "/^PS4/d" ${B}/${TARGET_PREFIX}testgcc
88 sed -i -e "/^Q/d" ${B}/${TARGET_PREFIX}testgcc
89 sed -i -e "/^SHLVL/d" ${B}/${TARGET_PREFIX}testgcc
90 sed -i -e "/^STAGING/d" ${B}/${TARGET_PREFIX}testgcc
91 sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${TARGET_PREFIX}testgcc
92 sed -i -e "/^PSEUDO/d" ${B}/${TARGET_PREFIX}testgcc
93
94 # append execution part of the script
95cat >> ${B}/${TARGET_PREFIX}testgcc << STOP
96target="\$1"
97usage () {
98 echo "Usage:"
99 echo "\$0 user@target 'extra options to dejagnu'"
100 echo "\$0 target 'extra options to dejagnu'"
101 echo "\$0 target"
102 echo "e.g. \$0 192.168.7.2 ' dg.exp=visibility-d.c'"
103 echo "will only run visibility-d.c test case"
104 echo "e.g. \$0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'"
105 echo "will only run visibility-d.c test case in thumb mode"
106 echo "You need to have dejagnu autogen expect installed"
107 echo "on the build host"
108 }
109if [ "x\$target" = "x" ]
110then
111 echo "Please specify the target machine and remote user in form of user@target\n"
112 usage
113 exit 1;
114fi
115
116shift
117
118echo "\$target" | grep "@" 2>&1 > /dev/null
119if [ "x\$?" = "x0" ]
120then
121 user=\$(echo \$target | cut -d '@' -f 1)
122 target=\$(echo \$target | cut -d '@' -f 2)
123else
124 user=\$USER
125fi
126ssh \$user@\$target date 2>&1 > /dev/null
127if [ "x\$?" != "x0" ]
128then
129 echo "Failed connecting to \$user@\$target it could be because"
130 echo "you don't have passwordless ssh setup to access \$target"
131 echo "or sometimes host key has been changed"
132 echo "in such case do something like below on build host"
133 echo "ssh-keygen -f "~/.ssh/known_hosts" -R \$target"
134 echo "and then try ssh \$user@\$target"
135
136 usage
137 exit 1
138fi
139 echo "lappend boards_dir [pwd]/../../.." > ${B}/site.exp
140 echo "load_generic_config \"unix\"" > ${B}/${PACKAGE_ARCH}.exp
141 echo "set_board_info username \$user" >> ${B}/${PACKAGE_ARCH}.exp
142 echo "set_board_info rsh_prog ssh" >> ${B}/${PACKAGE_ARCH}.exp
143 echo "set_board_info rcp_prog scp" >> ${B}/${PACKAGE_ARCH}.exp
144 echo "set_board_info hostname \$target" >> ${B}/${PACKAGE_ARCH}.exp
145 DEJAGNU=${B}/site.exp make -k check RUNTESTFLAGS="--target_board=${PACKAGE_ARCH}\$@"
146
147STOP
148
149 chmod +x ${B}/${TARGET_PREFIX}testgcc
150
151}
152
153INHIBIT_PACKAGE_STRIP = "1"
154
155# Compute how to get from libexecdir to bindir in python (easier than shell)
156BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
157
158do_install () {
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500159 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h-forbuild install-unwind_h )
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500160 oe_runmake 'DESTDIR=${D}' install-host
161
162 install -d ${D}${target_base_libdir}
163 install -d ${D}${target_libdir}
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500164
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500165 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
166 # gfortran is fully backwards compatible. This is a safe and practical solution.
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500167 if [ -n "${@d.getVar('FORTRAN')}" ]; then
168 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
169 fortsymlinks="g77 gfortran"
170 fi
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
173 # found. These need to be relative paths so they work in different locations.
174 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
175 install -d $dest
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500176 for t in ar as ld ld.bfd ld.gold nm objcopy objdump ranlib strip gcc cpp $fortsymlinks; do
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
178 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
179 done
180
181 # Remove things we don't need but keep share/java
182 for d in info man share/doc share/locale share/man share/info; do
183 rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d
184 done
185
186 # libquadmath headers need to be available in the gcc libexec dir
187 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
188 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
189 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
190
191 # We use libiberty from binutils
192 find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f
193 find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195
196do_package[noexec] = "1"
197do_packagedata[noexec] = "1"
198do_package_write_ipk[noexec] = "1"
199do_package_write_rpm[noexec] = "1"
200do_package_write_deb[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500201
202BUILDDIRSTASH = "${WORKDIR}/stashed-builddir"
203do_gcc_stash_builddir[dirs] = "${B}"
204do_gcc_stash_builddir[cleandirs] = "${BUILDDIRSTASH}"
205do_gcc_stash_builddir () {
206 dest=${BUILDDIRSTASH}
207 hardlinkdir . $dest
208}
209addtask do_gcc_stash_builddir after do_compile before do_install
210SSTATETASKS += "do_gcc_stash_builddir"
211do_gcc_stash_builddir[sstate-inputdirs] = "${BUILDDIRSTASH}"
212do_gcc_stash_builddir[sstate-outputdirs] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir${COMPILERINITIAL}-${TARGET_SYS}"
213do_gcc_stash_builddir[sstate-fixmedir] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir${COMPILERINITIAL}-${TARGET_SYS}"
214
215python do_gcc_stash_builddir_setscene () {
216 sstate_setscene(d)
217}
218addtask do_gcc_stash_builddir_setscene