blob: cc465a2796295f22c0793cda6480e37b81fb97c8 [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 () {
8 if d.getVar("TARGET_OS", True).startswith("linux"):
9 d.setVar("EXTRADEPENDS", "linux-libc-headers")
10}
11
12PN = "gcc-cross-${TARGET_ARCH}"
13
14require gcc-configure-common.inc
15
Patrick Williamsc0f7c042017-02-23 20:41:17 -060016# While we want the 'gnu' hash style, we explicitly set it to sysv here to
17# ensure that any recipe which doesn't obey our LDFLAGS (which also set it to
18# gnu) will hit a QA failure.
19LINKER_HASH_STYLE ?= "sysv"
20
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021EXTRA_OECONF += "--enable-poison-system-directories"
22EXTRA_OECONF_append_sh4 = " \
23 --with-multilib-list= \
24 --enable-incomplete-targets \
25"
26
27EXTRA_OECONF += "\
28 --with-mpfr=${STAGING_DIR_NATIVE}${prefix_native} \
29 --with-system-zlib \
30"
31
32DEPENDS_remove_libc-baremetal := "virtual/${TARGET_PREFIX}libc-for-gcc"
33EXTRA_OECONF_append_libc-baremetal = " --without-headers"
34EXTRA_OECONF_remove_libc-baremetal = "--enable-threads=posix"
35
36EXTRA_OECONF_PATHS = "\
37 --with-gxx-include-dir=/not/exist${target_includedir}/c++/${BINV} \
38 --with-sysroot=/not/exist \
39 --with-build-sysroot=${STAGING_DIR_TARGET} \
40"
41
42ARCH_FLAGS_FOR_TARGET += "-isystem${STAGING_DIR_TARGET}${target_includedir}"
43
44do_compile () {
45 export CC="${BUILD_CC}"
46 export AR_FOR_TARGET="${TARGET_SYS}-ar"
47 export RANLIB_FOR_TARGET="${TARGET_SYS}-ranlib"
48 export LD_FOR_TARGET="${TARGET_SYS}-ld"
49 export NM_FOR_TARGET="${TARGET_SYS}-nm"
50 export CC_FOR_TARGET="${CCACHE} ${TARGET_SYS}-gcc"
51 export CFLAGS_FOR_TARGET="${TARGET_CFLAGS}"
52 export CPPFLAGS_FOR_TARGET="${TARGET_CPPFLAGS}"
53 export CXXFLAGS_FOR_TARGET="${TARGET_CXXFLAGS}"
54 export LDFLAGS_FOR_TARGET="${TARGET_LDFLAGS}"
55
56 oe_runmake all-host configure-target-libgcc
57 # now generate script to drive testing
58 echo "#!/usr/bin/env sh" >${B}/${TARGET_PREFIX}testgcc
59 set >> ${B}/${TARGET_PREFIX}testgcc
60 # prune out the unneeded vars
61 sed -i -e "/^BASH/d" ${B}/${TARGET_PREFIX}testgcc
62 sed -i -e "/^USER/d" ${B}/${TARGET_PREFIX}testgcc
63 sed -i -e "/^OPT/d" ${B}/${TARGET_PREFIX}testgcc
64 sed -i -e "/^DIRSTACK/d" ${B}/${TARGET_PREFIX}testgcc
65 sed -i -e "/^EUID/d" ${B}/${TARGET_PREFIX}testgcc
66 sed -i -e "/^FUNCNAME/d" ${B}/${TARGET_PREFIX}testgcc
67 sed -i -e "/^GROUPS/d" ${B}/${TARGET_PREFIX}testgcc
68 sed -i -e "/^HOST/d" ${B}/${TARGET_PREFIX}testgcc
69 sed -i -e "/^HOME/d" ${B}/${TARGET_PREFIX}testgcc
70 sed -i -e "/^IFS/d" ${B}/${TARGET_PREFIX}testgcc
71 sed -i -e "/^LC_ALL/d" ${B}/${TARGET_PREFIX}testgcc
72 sed -i -e "/^LOGNAME/d" ${B}/${TARGET_PREFIX}testgcc
73 sed -i -e "/^MACHTYPE/d" ${B}/${TARGET_PREFIX}testgcc
74 sed -i -e "/^OSTYPE/d" ${B}/${TARGET_PREFIX}testgcc
75 sed -i -e "/^PIPE/d" ${B}/${TARGET_PREFIX}testgcc
76 sed -i -e "/^SHELL/d" ${B}/${TARGET_PREFIX}testgcc
77 sed -i -e "/^'/d" ${B}/${TARGET_PREFIX}testgcc
78 sed -i -e "/^UID/d" ${B}/${TARGET_PREFIX}testgcc
79 sed -i -e "/^TERM/d" ${B}/${TARGET_PREFIX}testgcc
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 sed -i -e "/^PKG_/d" ${B}/${TARGET_PREFIX}testgcc
81 sed -i -e "/^POSIXLY_/d" ${B}/${TARGET_PREFIX}testgcc
82 sed -i -e "/^PPID/d" ${B}/${TARGET_PREFIX}testgcc
83 sed -i -e "/^PS4/d" ${B}/${TARGET_PREFIX}testgcc
84 sed -i -e "/^Q/d" ${B}/${TARGET_PREFIX}testgcc
85 sed -i -e "/^SHLVL/d" ${B}/${TARGET_PREFIX}testgcc
86 sed -i -e "/^STAGING/d" ${B}/${TARGET_PREFIX}testgcc
87 sed -i -e "/^LD_LIBRARY_PATH/d" ${B}/${TARGET_PREFIX}testgcc
88 sed -i -e "/^PSEUDO/d" ${B}/${TARGET_PREFIX}testgcc
89
90 # append execution part of the script
91cat >> ${B}/${TARGET_PREFIX}testgcc << STOP
92target="\$1"
93usage () {
94 echo "Usage:"
95 echo "\$0 user@target 'extra options to dejagnu'"
96 echo "\$0 target 'extra options to dejagnu'"
97 echo "\$0 target"
98 echo "e.g. \$0 192.168.7.2 ' dg.exp=visibility-d.c'"
99 echo "will only run visibility-d.c test case"
100 echo "e.g. \$0 192.168.7.2 '/-mthumb dg.exp=visibility-d.c'"
101 echo "will only run visibility-d.c test case in thumb mode"
102 echo "You need to have dejagnu autogen expect installed"
103 echo "on the build host"
104 }
105if [ "x\$target" = "x" ]
106then
107 echo "Please specify the target machine and remote user in form of user@target\n"
108 usage
109 exit 1;
110fi
111
112shift
113
114echo "\$target" | grep "@" 2>&1 > /dev/null
115if [ "x\$?" = "x0" ]
116then
117 user=\$(echo \$target | cut -d '@' -f 1)
118 target=\$(echo \$target | cut -d '@' -f 2)
119else
120 user=\$USER
121fi
122ssh \$user@\$target date 2>&1 > /dev/null
123if [ "x\$?" != "x0" ]
124then
125 echo "Failed connecting to \$user@\$target it could be because"
126 echo "you don't have passwordless ssh setup to access \$target"
127 echo "or sometimes host key has been changed"
128 echo "in such case do something like below on build host"
129 echo "ssh-keygen -f "~/.ssh/known_hosts" -R \$target"
130 echo "and then try ssh \$user@\$target"
131
132 usage
133 exit 1
134fi
135 echo "lappend boards_dir [pwd]/../../.." > ${B}/site.exp
136 echo "load_generic_config \"unix\"" > ${B}/${PACKAGE_ARCH}.exp
137 echo "set_board_info username \$user" >> ${B}/${PACKAGE_ARCH}.exp
138 echo "set_board_info rsh_prog ssh" >> ${B}/${PACKAGE_ARCH}.exp
139 echo "set_board_info rcp_prog scp" >> ${B}/${PACKAGE_ARCH}.exp
140 echo "set_board_info hostname \$target" >> ${B}/${PACKAGE_ARCH}.exp
141 DEJAGNU=${B}/site.exp make -k check RUNTESTFLAGS="--target_board=${PACKAGE_ARCH}\$@"
142
143STOP
144
145 chmod +x ${B}/${TARGET_PREFIX}testgcc
146
147}
148
149INHIBIT_PACKAGE_STRIP = "1"
150
151# Compute how to get from libexecdir to bindir in python (easier than shell)
152BINRELPATH = "${@os.path.relpath(d.expand("${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_SYS}"), d.expand("${libexecdir}/gcc/${TARGET_SYS}/${BINV}"))}"
153
154do_install () {
155 ( cd ${B}/${TARGET_SYS}/libgcc; oe_runmake 'DESTDIR=${D}' install-unwind_h )
156 oe_runmake 'DESTDIR=${D}' install-host
157
158 install -d ${D}${target_base_libdir}
159 install -d ${D}${target_libdir}
160
161 # Link gfortran to g77 to satisfy not-so-smart configure or hard coded g77
162 # gfortran is fully backwards compatible. This is a safe and practical solution.
163 ln -sf ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}gfortran ${STAGING_DIR_NATIVE}${prefix_native}/bin/${TARGET_PREFIX}g77 || true
164
165
166 # Insert symlinks into libexec so when tools without a prefix are searched for, the correct ones are
167 # found. These need to be relative paths so they work in different locations.
168 dest=${D}${libexecdir}/gcc/${TARGET_SYS}/${BINV}/
169 install -d $dest
170 for t in ar as ld nm objcopy objdump ranlib strip g77 gcc cpp gfortran; do
171 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t $dest$t
172 ln -sf ${BINRELPATH}/${TARGET_PREFIX}$t ${dest}${TARGET_PREFIX}$t
173 done
174
175 # Remove things we don't need but keep share/java
176 for d in info man share/doc share/locale share/man share/info; do
177 rm -rf ${D}${STAGING_DIR_NATIVE}${prefix_native}/$d
178 done
179
180 # libquadmath headers need to be available in the gcc libexec dir
181 install -d ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
182 cp ${S}/libquadmath/quadmath.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
183 cp ${S}/libquadmath/quadmath_weak.h ${D}${libdir}/gcc/${TARGET_SYS}/${BINV}/include/
184
185 # We use libiberty from binutils
186 find ${D}${exec_prefix}/lib -name libiberty.a | xargs rm -f
187 find ${D}${exec_prefix}/lib -name libiberty.h | xargs rm -f
188
189 # gcc-runtime installs libgcc into a special location in staging since it breaks doing a standalone build
190 case ${PN} in
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600191 *gcc-cross-${TARGET_ARCH}|*gcc-crosssdk-${SDK_SYS})
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192 dest=${D}/${includedir}/gcc-build-internal-${TARGET_SYS}
193 hardlinkdir . $dest
194 ;;
195 esac
196}
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600197# This is reflected in the recipe name and target gcc shouldn't depend
198# on SDK settings either
199do_install[vardepsexclude] += "SDK_SYS"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500200
201do_package[noexec] = "1"
202do_packagedata[noexec] = "1"
203do_package_write_ipk[noexec] = "1"
204do_package_write_rpm[noexec] = "1"
205do_package_write_deb[noexec] = "1"