blob: 45985c3847966e177667f90b6336e2d7c9c5944d [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 += "\
31 --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} \
32 --with-system-zlib \
33"
34
35DEPENDS_remove_libc-baremetal := "virtual/${TARGET_PREFIX}libc-for-gcc"
36EXTRA_OECONF_append_libc-baremetal = " --without-headers"
37EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix"
38
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
60 # now generate script to drive testing
61 echo "#!/usr/bin/env sh" >${B}/${TARGET_PREFIX}testgcc
62 set >> ${B}/${TARGET_PREFIX}testgcc
63 # prune out the unneeded vars
64 sed -i -e "/^BASH/d" ${B}/${TARGET_PREFIX}testgcc
65 sed -i -e "/^USER/d" ${B}/${TARGET_PREFIX}testgcc
66 sed -i -e "/^OPT/d" ${B}/${TARGET_PREFIX}testgcc
67 sed -i -e "/^DIRSTACK/d" ${B}/${TARGET_PREFIX}testgcc
68 sed -i -e "/^EUID/d" ${B}/${TARGET_PREFIX}testgcc
69 sed -i -e "/^FUNCNAME/d" ${B}/${TARGET_PREFIX}testgcc
70 sed -i -e "/^GROUPS/d" ${B}/${TARGET_PREFIX}testgcc
71 sed -i -e "/^HOST/d" ${B}/${TARGET_PREFIX}testgcc
72 sed -i -e "/^HOME/d" ${B}/${TARGET_PREFIX}testgcc
73 sed -i -e "/^IFS/d" ${B}/${TARGET_PREFIX}testgcc
74 sed -i -e "/^LC_ALL/d" ${B}/${TARGET_PREFIX}testgcc
75 sed -i -e "/^LOGNAME/d" ${B}/${TARGET_PREFIX}testgcc
76 sed -i -e "/^MACHTYPE/d" ${B}/${TARGET_PREFIX}testgcc
77 sed -i -e "/^OSTYPE/d" ${B}/${TARGET_PREFIX}testgcc
78 sed -i -e "/^PIPE/d" ${B}/${TARGET_PREFIX}testgcc
79 sed -i -e "/^SHELL/d" ${B}/${TARGET_PREFIX}testgcc
80 sed -i -e "/^'/d" ${B}/${TARGET_PREFIX}testgcc
81 sed -i -e "/^UID/d" ${B}/${TARGET_PREFIX}testgcc
82 sed -i -e "/^TERM/d" ${B}/${TARGET_PREFIX}testgcc
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083 sed -i -e "/^PKG_/d" ${B}/${TARGET_PREFIX}testgcc
84 sed -i -e "/^POSIXLY_/d" ${B}/${TARGET_PREFIX}testgcc
85 sed -i -e "/^PPID/d" ${B}/${TARGET_PREFIX}testgcc
86 sed -i -e "/^PS4/d" ${B}/${TARGET_PREFIX}testgcc
87 sed -i -e "/^Q/d" ${B}/${TARGET_PREFIX}testgcc
88 sed -i -e "/^SHLVL/d" ${B}/${TARGET_PREFIX}testgcc
89 sed -i -e "/^STAGING/d" ${B}/${TARGET_PREFIX}testgcc
90 sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${TARGET_PREFIX}testgcc
91 sed -i -e "/^PSEUDO/d" ${B}/${TARGET_PREFIX}testgcc
92
93 # append execution part of the script
94cat >> ${B}/${TARGET_PREFIX}testgcc << STOP
95target="\$1"
96usage () {
97 echo "Usage:"
98 echo "\$0 user@target 'extra options to dejagnu'"
99 echo "\$0 target 'extra options to dejagnu'"
100 echo "\$0 target"
101 echo "e.g. \$0 192.168.7.2 ' dg.exp=visibility-d.c'"
102 echo "will only run visibility-d.c test case"
103 echo "e.g. \$0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'"
104 echo "will only run visibility-d.c test case in thumb mode"
105 echo "You need to have dejagnu autogen expect installed"
106 echo "on the build host"
107 }
108if [ "x\$target" = "x" ]
109then
110 echo "Please specify the target machine and remote user in form of user@target\n"
111 usage
112 exit 1;
113fi
114
115shift
116
117echo "\$target" | grep "@" 2>&1 > /dev/null
118if [ "x\$?" = "x0" ]
119then
120 user=\$(echo \$target | cut -d '@' -f 1)
121 target=\$(echo \$target | cut -d '@' -f 2)
122else
123 user=\$USER
124fi
125ssh \$user@\$target date 2>&1 > /dev/null
126if [ "x\$?" != "x0" ]
127then
128 echo "Failed connecting to \$user@\$target it could be because"
129 echo "you don't have passwordless ssh setup to access \$target"
130 echo "or sometimes host key has been changed"
131 echo "in such case do something like below on build host"
132 echo "ssh-keygen -f "~/.ssh/known_hosts" -R \$target"
133 echo "and then try ssh \$user@\$target"
134
135 usage
136 exit 1
137fi
138 echo "lappend boards_dir [pwd]/../../.." > ${B}/site.exp
139 echo "load_generic_config \"unix\"" > ${B}/${PACKAGE_ARCH}.exp
140 echo "set_board_info username \$user" >> ${B}/${PACKAGE_ARCH}.exp
141 echo "set_board_info rsh_prog ssh" >> ${B}/${PACKAGE_ARCH}.exp
142 echo "set_board_info rcp_prog scp" >> ${B}/${PACKAGE_ARCH}.exp
143 echo "set_board_info hostname \$target" >> ${B}/${PACKAGE_ARCH}.exp
144 DEJAGNU=${B}/site.exp make -k check RUNTESTFLAGS="--target_board=${PACKAGE_ARCH}\$@"
145
146STOP
147
148 chmod +x ${B}/${TARGET_PREFIX}testgcc
149
150}
151
152INHIBIT_PACKAGE_STRIP = "1"
153
154# Compute how to get from libexecdir to bindir in python (easier than shell)
155BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
156
157do_install () {
158 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h )
159 oe_runmake 'DESTDIR=${D}' install-host
160
161 install -d ${D}${target_base_libdir}
162 install -d ${D}${target_libdir}
163
164 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
165 # gfortran is fully backwards compatible. This is a safe and practical solution.
166 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
167
168
169 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
170 # found. These need to be relative paths so they work in different locations.
171 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
172 install -d $dest
173 for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
174 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
175 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
176 done
177
178 # Remove things we don't need but keep share/java
179 for d in info man share/doc share/locale share/man share/info; do
180 rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d
181 done
182
183 # libquadmath headers need to be available in the gcc libexec dir
184 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
185 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
186 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
187
188 # We use libiberty from binutils
189 find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f
190 find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192
193do_package[noexec] = "1"
194do_packagedata[noexec] = "1"
195do_package_write_ipk[noexec] = "1"
196do_package_write_rpm[noexec] = "1"
197do_package_write_deb[noexec] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500198
199BUILDDIRSTASH = "${WORKDIR}/stashed-builddir"
200do_gcc_stash_builddir[dirs] = "${B}"
201do_gcc_stash_builddir[cleandirs] = "${BUILDDIRSTASH}"
202do_gcc_stash_builddir () {
203 dest=${BUILDDIRSTASH}
204 hardlinkdir . $dest
205}
206addtask do_gcc_stash_builddir after do_compile before do_install
207SSTATETASKS += "do_gcc_stash_builddir"
208do_gcc_stash_builddir[sstate-inputdirs] = "${BUILDDIRSTASH}"
209do_gcc_stash_builddir[sstate-outputdirs] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir${COMPILERINITIAL}-${TARGET_SYS}"
210do_gcc_stash_builddir[sstate-fixmedir] = "${COMPONENTS_DIR}/${BUILD_ARCH}/gcc-stashed-builddir${COMPILERINITIAL}-${TARGET_SYS}"
211
212python do_gcc_stash_builddir_setscene () {
213 sstate_setscene(d)
214}
215addtask do_gcc_stash_builddir_setscene