Skip to content

Commit 2644b84

Browse files
Merge branch 'arc-dev' into arc-staging
2 parents 9954fef + 435a199 commit 2644b84

File tree

16 files changed

+196
-53
lines changed

16 files changed

+196
-53
lines changed

Makefile.release

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ $O/.stamp_elf_le_windows_built: $O/.stamp_checked_out $O/.stamp_elf_le_built
219219
PATH=$(shell readlink -e $O/$(TOOLS_ELFLE_DIR_LINUX)/bin):$$PATH \
220220
./build-all.sh $(BUILDALLFLAGS) \
221221
--install-dir $O/$(TOOLS_ELFLE_DIR_WIN) --no-uclibc --no-sim \
222-
--release-name $(RELEASE) --host i686-w64-mingw32
222+
--release-name $(RELEASE) --host i686-w64-mingw32 --no-system-expat
223223
touch $@
224224

225225
$O/.stamp_elf_be_windows_built: $O/.stamp_checked_out $O/.stamp_elf_be_built
226226
# Install toolchain in the same dir as little endian
227227
PATH=$(shell readlink -e $O/$(TOOLS_ELFBE_DIR_LINUX))/bin:$$PATH \
228228
./build-all.sh $(BUILDALLFLAGS) \
229229
--install-dir $O/$(TOOLS_ELFBE_DIR_WIN) --no-uclibc --big-endian --no-sim \
230-
--release-name $(RELEASE) --host i686-w64-mingw32
230+
--release-name $(RELEASE) --host i686-w64-mingw32 --no-system-expat
231231
touch $@
232232

233233
$O/.stamp_elf_le_windows_tarball: $O/.stamp_elf_le_windows_built

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ consumed and time to clone the repository.
128128
By default `toolchain` repository will be checked out to the current
129129
development branch `arc-dev`.
130130

131+
If current working directory is not a "toolchain" directory, then change to it:
132+
133+
$ cd toolchain
134+
131135
Following command will check out repository to the latest release:
132136

133137
$ git checkout arc-releases
@@ -257,20 +261,24 @@ officially supported and not recommended by Synopsys, due to severe performance
257261
penalty of those environments on build time and possible compatibility issue.
258262

259263
Some limitation apply:
260-
* CGEN simulator is not support on Windows hosts, thus should be disabled with
261-
`--no-sim` option.
262-
* Only bare metal (elf32) tool chain can be built this way.
263-
* It is required to have tool chain for Linux hosts in the `PATH` for Canadian
264+
- CGEN simulator is not supported on Windows hosts, thus should be disabled
265+
with `--no-sim` option.
266+
- Only bare metal (elf32) tool chain can be built this way.
267+
- It is required to have tool chain for Linux hosts in the `PATH` for Canadian
264268
cross-build to succeed - it will be used to compile standard library of tool
265269
chain.
270+
- Expat library is required for GDB to parse XML target description files. This
271+
library might be not available in some Mingw setup. Easiest solution is to
272+
let `build-all.sh` script to build Expat by passing option
273+
`--no-system-expat`.
266274

267-
To cross-compile tool chain on Linux, mingw tool chain should be installed. On
275+
To cross-compile tool chain on Linux, Mingw tool chain should be installed. On
268276
Ubuntu that can be done with `mingw-w64` package:
269277

270278
# apt-get install mingw-w64
271279

272-
RHEL 6 has a very antique mingw (4.4-something), so it is recommended to first
273-
add EPEL repository, then install mingw from it. In CentOS:
280+
RHEL 6 has a very antique Mingw (4.4-something), so it is recommended to first
281+
add EPEL repository, then install Mingw from it. In CentOS:
274282

275283
# yum install epel-release
276284
# yum install mingw-binutils-generic mingw-filesystem-base \
@@ -283,7 +291,8 @@ For instruction how to install EPEL on RHEL, see
283291

284292
After prerequisites are installed and Linux tools are in the `PATH`, do:
285293

286-
$ ./build-all.sh --no-uclibc --no-sim --host i686-w64-mingw32
294+
$ ./build-all.sh --no-uclibc --no-sim --host i686-w64-mingw32 \
295+
--no-system-expat
287296

288297
Note that value of host triplet depends on what mingw tool chain is being used.
289298
Triplet `i686-w64-mingw32` is valid for mingw tool chain currently used in
@@ -304,7 +313,7 @@ been added to the PATH:
304313

305314
Build application:
306315

307-
$ arc-elf32-gcc hello_world.c -marc700
316+
$ arc-elf32-gcc hello_world.c -marc700 -g
308317

309318
To run it on CGEN-based simulator without debugger:
310319

arc-clone-all.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ parse_args () {
9696

9797
# -----------------------------------------------------------------------------
9898
# Function to clone a tool and (optionally) its upstream. The ARC branches of
99-
# the tool will be from a remote called "arc", the upstream branches from a
100-
# remote called "upstream".
99+
# the tool will be from a remote with default name ("origin"), the upstream
100+
# branches from a remote called "upstream".
101101

102102
# With the creation of the binutils-gdb combined repo, the name of the repo
103103
# and the name of the tool are no longer the same, so we need a third argument.
@@ -130,9 +130,9 @@ clone_tool () {
130130

131131
# Clone the ARC repo
132132
if [ ${is_dev} = "false" ] \
133-
|| ! git clone -q -o arc ${ssh_repo} ${tool} >> ${logfile} 2>&1
133+
|| ! git clone -q ${ssh_repo} ${tool} >> ${logfile} 2>&1
134134
then
135-
if ! git clone -q -o arc ${http_repo} ${tool} >> ${logfile} 2>&1
135+
if ! git clone -q ${http_repo} ${tool} >> ${logfile} 2>&1
136136
then
137137
echo "Warning: Failed to clone ${http_repo}" | tee -a ${logfile}
138138
return 1

arc-init.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ temp_file_in_dir () {
174174
PATTERN=$2
175175
FILE=$(cd ${DIR} && mktemp "${PATTERN}")
176176
STATUS=$?
177-
if [ ${STATUS} == 0 ]
177+
if [ ${STATUS} = 0 ]
178178
then
179179
echo ${DIR}/${FILE}
180180
else
@@ -315,7 +315,14 @@ configure_elf32() {
315315
local src=$tool
316316
fi
317317
echo " configuring..."
318-
config_path="$(calcConfigPath "$ARC_GNU/$src")"
318+
# If there is / in srcdir - that this is already a path. Otherwise
319+
# construct path from a directory name.
320+
if echo "$src" | grep -q -e /
321+
then
322+
config_path="$(calcConfigPath $src)"
323+
else
324+
config_path="$(calcConfigPath "$ARC_GNU/$src")"
325+
fi
319326

320327
if [ "$TOOLCHAIN_HOST" ]; then
321328
host_opt="--host=$TOOLCHAIN_HOST"
@@ -408,7 +415,14 @@ configure_uclibc_stage2() {
408415
local src=$tool
409416
fi
410417
echo " configuring..."
411-
config_path="$(calcConfigPath "$ARC_GNU/$src")"
418+
# If there is / in srcdir - that this is already a path. Otherwise
419+
# construct path from a directory name.
420+
if echo "$src" | grep -q -e /
421+
then
422+
config_path="$(calcConfigPath $src)"
423+
else
424+
config_path="$(calcConfigPath "$ARC_GNU/$src")"
425+
fi
412426
if ! "$config_path/configure" \
413427
--target=$triplet \
414428
--with-cpu=${ISA_CPU} \
@@ -446,6 +460,14 @@ configure_for_arc() {
446460

447461
local srcdir=$1
448462
local triplet=$2
463+
464+
# Cannto do a simple "CFLAGS=$CFLAGS_FOR_TARGET, because if latter is empty
465+
# that would reset CFLAGS unnecessarily.
466+
local cflags=
467+
if [ "$CFLAGS_FOR_TARGET" ]
468+
then
469+
cflags="CFLAGS=$CFLAGS_FOR_TARGET"
470+
fi
449471
shift 2
450472

451473
# --prefix must correspond to prefix on *target* system, not where it will
@@ -457,7 +479,7 @@ configure_for_arc() {
457479
if ! $srcdir/configure --prefix=/usr --host=$triplet \
458480
--with-pkgversion="$UCLIBC_TOOLS_VERSION"\
459481
--with-bugurl="$ARC_COMMON_BUGURL" \
460-
CFLAGS="$CFLAGS_FOR_TARGET" $* \
482+
$cflags $* \
461483
>> "$logfile" 2>&1
462484
then
463485
echo "ERROR: failed while configuring."

arc-versions.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,14 @@ do
136136
if [ "x${autopull}" = "x--auto-pull" ]
137137
then
138138
# Fetch any new tags and branches.
139+
# Note the usage of --all. Without this option and without explicit
140+
# remote name `git fetch` will succeed only if there is remote named
141+
# "origin", and it will fetch only it (which might be really not what
142+
# is desired). And if there is no remote named "origin" then `git
143+
# fetch` will fail even if there is only a single remote in git
144+
# configuration.
139145
echo " fetching tags"
140-
if ! git fetch --tags
146+
if ! git fetch --tags --all
141147
then
142148
exit 1
143149
fi

build-all.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
# [--checkout-config <config>]
5252
# [--host <triplet>]
5353
# [--native-gdb | --no-native-gdb]
54+
# [--system-expat | --no-system-expat]
5455

5556
# This script is a convenience wrapper to build the ARC GNU 4.4 tool
5657
# chains. It utilizes Joern Rennecke's build-elf32.sh script and Bendan
@@ -289,6 +290,15 @@
289290
# manually with your ncurses. Buildroot handles this nicely.
290291
# - Due to a bug ncurses has to be built without C++ bindings.
291292

293+
# --system-expat | --no-system-expat
294+
295+
# Whether to use expat library installed into system or build it in this
296+
# script. expat is used by GDB to parse XML, therefore is needed to work
297+
# with XML Target descriptions. Usually using system expat is sufficient,
298+
# however it may cause issues if system doesn't have expat or it is of wrong
299+
# version. Notable use case for --no-system-expat is mingw32 build, if mingw
300+
# installation lacks expat. Default value is to use system expat.
301+
292302
# Where directories are specified as arguments, they are relative to the
293303
# current directory, unless specified as absolute names.
294304

@@ -364,6 +374,7 @@ is_tarball=
364374
NPTL_SUPPORT="yes"
365375
CHECKOUT_CONFIG=
366376
TOOLCHAIN_HOST=
377+
SYSTEM_EXPAT=yes
367378

368379
# Default multilib usage and conversion for toolchain building
369380
case "x${DISABLE_MULTILIB}" in
@@ -578,6 +589,14 @@ case ${opt} in
578589
DO_NATIVE_GDB=no
579590
;;
580591

592+
--system-expat)
593+
SYSTEM_EXPAT=yes
594+
;;
595+
596+
--no-system-expat)
597+
SYSTEM_EXPAT=no
598+
;;
599+
581600
?*)
582601
echo "Unknown argument $1"
583602
echo
@@ -612,6 +631,7 @@ case ${opt} in
612631
echo " [--checkout-config <config>]"
613632
echo " [--host <triplet>]"
614633
echo " [--native-gdb | --no-native-gdb]"
634+
echo " [--system-expat | --no-system-expat]"
615635
exit 1
616636
;;
617637

@@ -796,6 +816,7 @@ export CHECKOUT_CONFIG
796816
# Used by configure funcs in arc-init.sh
797817
export TOOLCHAIN_HOST
798818
export UCLIBC_TOOLS_VERSION
819+
export SYSTEM_EXPAT
799820

800821
# Set up a logfile
801822
logfile="${LOGDIR}/all-build-$(date -u +%F-%H%M).log"
@@ -896,7 +917,7 @@ fi
896917
# Patch RPATHs so they are relative
897918
if [ "x${rel_rpaths}" = "x--rel-rpaths" ]
898919
then
899-
if ! "${ARC_GNU}"/toolchain/rel-rpaths.sh >> "${logfile}" 2>&1
920+
if ! "${ARC_GNU}"/toolchain/rel-rpaths.sh ${INSTALLDIR} >> "${logfile}" 2>&1
900921
then
901922
echo "ERROR: Unable to make RPATHs relative. Is patchelf installed?"
902923
exit 1

build-elf32.sh

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ echo "START ELF32: $(date)" | tee -a "$logfile"
120120

121121
# Initialize common variables and functions.
122122
. "${ARC_GNU}"/toolchain/arc-init.sh
123+
toolchain_build_dir=$PWD/toolchain
123124

124125
# variables to control whether the simulator is build. Note that we actively
125126
# edit in the requirement for a simulator library in case it has been left
@@ -128,7 +129,7 @@ if [ "x${DO_SIM}" = "x--sim" ]
128129
then
129130
sim_config="--enable-sim --enable-sim-endian=no"
130131
sim_build=all-sim
131-
# CGEN doesn't have install-strip target.
132+
# NB: CGEN doesn't have install-strip target.
132133
sim_install=install-sim
133134
${SED} -i "${ARC_GNU}"/gdb/gdb/configure.tgt \
134135
-e 's!# gdb_sim=../sim/arc/libsim.a!gdb_sim=../sim/arc/libsim.a!'
@@ -176,7 +177,8 @@ make_target building all-binutils all-gas all-ld
176177
# is required that binutils is installed before ld and gas. That order
177178
# denedency showed up only with Linux toolchain so far, but for safety same
178179
# patch is applied to baremetal toolchain.
179-
make_target_ordered installing install-binutils install-ld install-gas
180+
make_target_ordered installing ${HOST_INSTALL}-binutils ${HOST_INSTALL}-ld \
181+
${HOST_INSTALL}-gas
180182
if [ "$DO_PDF" = "--pdf" ]
181183
then
182184
make_target "generating PDF documentation" install-pdf-binutils \
@@ -257,11 +259,29 @@ make_target installing install-target-libstdc++-v3
257259
# Don't build libstdc++ documentation because it requires additional software
258260
# on build host.
259261

262+
# Expat if requested
263+
if [ "$SYSTEM_EXPAT" = no ]
264+
then
265+
mkdir -p $toolchain_build_dir/_download_tmp
266+
expat_version=2.1.0
267+
expat_tar=expat-${expat_version}.tar.gz
268+
if [ ! -s $toolchain_build_dir/_download_tmp/$expat_tar ]; then
269+
wget -nv -O $toolchain_build_dir/_download_tmp/$expat_tar \
270+
http://sourceforge.net/projects/expat/files/expat/$expat_version/$expat_tar/download
271+
fi
272+
273+
build_dir_init expat
274+
tar xzf $toolchain_build_dir/_download_tmp/$expat_tar --strip-components=1
275+
configure_elf32 expat $PWD
276+
make_target building all
277+
make_target installing install
278+
fi
279+
260280
# GDB and CGEN simulator (maybe)
261281
build_dir_init gdb
262282
configure_elf32 gdb
263283
make_target building all-gdb ${sim_build}
264-
make_target installing ${sim_install} install-gdb
284+
make_target installing ${sim_install} ${HOST_INSTALL}-gdb
265285
if [ "$DO_PDF" = "--pdf" ]
266286
then
267287
make_target "generating PDF documentation" install-pdf-gdb

0 commit comments

Comments
 (0)