Skip to content

Commit b91e1c6

Browse files
author
ARC GNU Verification
committed
Merge branch 'arc-dev' into arc-staging
2 parents 456d831 + 7f6f62d commit b91e1c6

File tree

7 files changed

+90
-22
lines changed

7 files changed

+90
-22
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ New Features and Enhancements
2020

2121
* Toolchain Build Scripts
2222
* Removed obsolete unsupported scripts.
23+
* macOS support.
2324

2425
[[TBD]]
2526

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,37 @@ instead versions of those libraries installed on the build host will be used.
7474
In most cases this is not required.
7575

7676

77+
### macOS Prerequisites
78+
79+
By default HFS on macOS is configured to be case-insensitive, which is known to
80+
cause issues with Linux sources (there are files which differ only in character
81+
case). As a result to build uClibc toolchain for ARC it is required to use
82+
partition that is configured to be case sensitive (use Disk Utility to create a
83+
new partition, at least 16 GiB are needed to build uClibc toolchain, 32 GiB are
84+
needed to build a complete baremetal toolchain. With baremetal (elf) toolchain
85+
there are no such problems.
86+
87+
To build toolchain on macOS it is required to install several prerequisites
88+
which are either not installed by default or non-GNU-compatible versions are
89+
installed by default. This easily can be done with Homebrew:
90+
91+
# Install homebrew itself (https://brew.sh/)
92+
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
93+
94+
# Install wget
95+
$ brew install wget
96+
97+
# Install GNU sed
98+
$ brew install gnu-sed
99+
100+
To build PDF documentation for toolchain TeX must be installed:
101+
102+
$ brew cask install mactex
103+
104+
If PDF documentation is not needed, pass option `--no-pdf` to build-all.sh to
105+
disable its build, then mactex is not required.
106+
107+
77108
Getting sources
78109
---------------
79110

@@ -90,7 +121,7 @@ versions >= 3.9 are supported. Linux sources should be located in the directory
90121
named `linux` that is the sibling of this `toolchain` directory. For example:
91122

92123
$ wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.8.2.tar.xz
93-
$ tar xaf linux-4.8.2.tar.xz --transform=s/linux-4.8.2/linux/
124+
$ tar xf linux-4.8.2.tar.xz --transform=s/linux-4.8.2/linux/
94125

95126
### Using Git repositories
96127

arc-external.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ for url in ${urls} ; do
4141
if [ ! -f "${filename}" ]; then
4242
$WGET "${url}"
4343
fi
44-
tar xaf "${filename}"
44+
tar xf "${filename}"
4545
fi
4646
mv "${dirname}" "${toolname}"
4747
fi

build-all.sh

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,11 @@ esac
448448

449449
if [ x`uname -s` = "xDarwin" ]
450450
then
451+
IS_MAC_OS=yes
451452
#You can install gsed with 'brew install gnu-sed'
452453
SED=gsed
454+
else
455+
IS_MAC_OS=no
453456
fi
454457

455458
# Parse options
@@ -835,9 +838,13 @@ then
835838
fi
836839
fi
837840

838-
# Default parallellism
839-
make_load="`(echo processor; cat /proc/cpuinfo 2>/dev/null echo processor) \
840-
| grep -c processor`"
841+
# Default parallellism (number of cores + 1).
842+
if [ "$IS_MAC_OS" != yes ]; then
843+
make_load="$( (echo processor; cat /proc/cpuinfo 2>/dev/null) \
844+
| grep -c processor )"
845+
else
846+
make_load="$(( $(sysctl -n hw.ncpu) + 1))"
847+
fi
841848

842849
if [ "x${jobs}" = "x" ]
843850
then
@@ -908,18 +915,23 @@ if [ $DO_PDF = --pdf ]; then
908915
# Texi is a major source of toolchain build errors -- PDF regularly do not
909916
# work with particular versions of texinfo, but work with others. To
910917
# workaround those issues build scripts should be aware of texi version.
911-
export TEXINFO_VERSION_MAJOR=$(texi2pdf --version | grep -Po '(?<=Texinfo )[0-9]+')
912-
# Grep perl look-behind expressions must have a fixed length, so to future
913-
# proof for texinfo versions 10+, we have to read variable, because that
914-
# wouldn't work: (?<=Texinfo [0-9]+\.)
915-
export TEXINFO_VERSION_MINOR=$(texi2pdf --version |
916-
grep -Po "(?<=Texinfo $TEXINFO_VERSION_MAJOR\.)[0-9]+")
918+
export TEXINFO_VERSION_MAJOR=$(texi2pdf --version | \
919+
perl -ne 'print $1 if /Texinfo ([0-9]+)/')
920+
export TEXINFO_VERSION_MINOR=$(texi2pdf --version | \
921+
perl -ne 'print $2 if /Texinfo ([0-9]+)\.([0-9]+)/')
917922

918923
# There are issues with Texinfo v4 and non-C locales.
919924
# See http://lists.gnu.org/archive/html/bug-texinfo/2010-03/msg00031.html
920-
if [ 4 = $TEXINFO_VERSION_MAJOR ]; then
925+
if [ 4 = "$TEXINFO_VERSION_MAJOR" ]; then
921926
export LC_ALL=C
922927
fi
928+
929+
# On macOS TeX binary might not be in the PATH even when texi2pdf is.
930+
if [ $IS_MAC_OS = yes ]; then
931+
if ! which tex &>/dev/null ; then
932+
export PATH=/Library/TeX/texbin:$PATH
933+
fi
934+
fi
923935
fi
924936

925937
# Standard setup
@@ -958,6 +970,7 @@ export BUILD_OPTSIZE_NEWLIB
958970
export BUILD_OPTSIZE_LIBSTDCXX
959971
export DO_STRIP_TARGET_LIBRARIES
960972
export IS_CROSS_COMPILING
973+
export IS_MAC_OS
961974
export IS_NATIVE
962975
export UCLIBC_IN_SRC_TREE
963976

build-uclibc.sh

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,24 @@ DEFCFG_DIR=$ARC_GNU/uClibc/extra/Configs/defconfigs/arc/
245245
rm -rf "$build_dir"
246246
mkdir -p "$build_dir"
247247

248+
# -----------------------------------------------------------------------------
249+
# Black magic for macOS. The problem is that default sed on macOS is not
250+
# compatible with GNU, while some scripts use GNU-specific extensions. GNU sed
251+
# can be installed with Homebrew, but by default it will have a name `gsed`, so
252+
# scripts should be modified to use it. While this can be done in ARC scripts,
253+
# we don't have full control over other projects, Linux in particular, which
254+
# also require GNU sed. Therefore in followind lines a new directory is
255+
# created, a link named `sed` is created and is pointed to `gsed` and directory
256+
# is added to the PATH, so GNU sed will be used by Linux. Alternative solution
257+
# would be to install GNU sed as `sed` in Homebrew, however that might have
258+
# some negative effect on other applications, so I don't think it is wise to
259+
# require this from the user.
260+
if [ "$IS_MAC_OS" = yes ]; then
261+
mkdir $build_dir/macos_aliases
262+
ln -s $(which gsed) $build_dir/macos_aliases/sed
263+
export PATH=$build_dir/macos_aliases:$PATH
264+
fi
265+
248266
# -----------------------------------------------------------------------------
249267
# Install the Linux headers
250268

@@ -593,7 +611,7 @@ if [ $DO_NATIVE_GDB = yes ]; then
593611
fi
594612

595613
build_dir_init ncurses
596-
tar xaf $toolchain_build_dir/_download_tmp/$ncurses_tar --strip-components=1
614+
tar xf $toolchain_build_dir/_download_tmp/$ncurses_tar --strip-components=1
597615

598616
# GCC 5 introduced some changes to the preprocessor output, that causes a
599617
# compilation error in files generated by ncurses. See GCC commit:

doc/linux/kernel-build.rst

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ single question "How to confirm, that I can build Linux kernel with *that*
1010
toolchain?"
1111

1212
To learn how to configure Linux, debug kernel itself and build extra software
13-
please see `<https://github.com/foss-for-synopsys-dwc-arc-processors/linux/wiki>`.
13+
please see `https://github.com/foss-for-synopsys-dwc-arc-processors/linux/wiki`.
1414

1515

1616
Prerequisites
@@ -58,7 +58,7 @@ Synopsys will be used.
5858
Configuring
5959
-----------
6060

61-
Check `Buildroot downloads page <http://buildroot.org/download.html>` for
61+
Check `Buildroot downloads page <http://buildroot.org/download.html>`_ for
6262
latest release. This guide further assumes latest snapshot. Get Buildroot
6363
sources::
6464

@@ -81,6 +81,7 @@ Contents of this file should be following::
8181
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
8282
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_8=y
8383
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
84+
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
8485
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
8586
BR2_TOOLCHAIN_EXTERNAL_CXX=y
8687
BR2_LINUX_KERNEL=y
@@ -115,10 +116,13 @@ Building
115116
To build Linux kernel image using that defconfig::
116117

117118
$ cd buildroot
118-
$ make O=../output_hs defconfig DEFCONFIG=../hs_defconfig
119+
$ make O=`readlink -e ../output_hs` defconfig DEFCONFIG=`readlink -e ../hs_defconfig`
119120
$ cd ../output_hs
120121
$ make
121122

123+
It's necessary to pass an absolute path to Buildroot, because there is the issue
124+
with a relative path.
125+
122126
After that there will be Linux kernel image file
123127
``arc-2017.03-linux-guide/output/images/vmlinux``.
124128

@@ -234,6 +238,7 @@ With those changes Buildroot defconfig for ARC HS VDK is::
234238
BR2_TOOLCHAIN_EXTERNAL_GCC_6=y
235239
BR2_TOOLCHAIN_EXTERNAL_HEADERS_4_8=y
236240
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
241+
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
237242
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=y
238243
BR2_TOOLCHAIN_EXTERNAL_CXX=y
239244
BR2_LINUX_KERNEL=y
@@ -249,7 +254,7 @@ Save this defconfig to some file (for example ``vdk_defconfig``). Then use same
249254
process as in :ref:`linux-building-label` section.::
250255

251256
$ cd buildroot
252-
$ make O=../output_vdk defconfig DEFCONFIG=<path-to-VDK-defconfig-file>
257+
$ make O=`readlink -e ../output_vdk` defconfig DEFCONFIG=<path-to-VDK-defconfig-file>
253258
$ cd ../output_vdk
254259
$ make
255260

@@ -335,5 +340,5 @@ defconfig is::
335340

336341
This defconfig will create a uImage file instead of vmlinux. Please refer to
337342
`ARC Linux wiki
338-
<https://github.com/foss-for-synopsys-dwc-arc-processors/linux/wiki/Getting-Started-with-Linux-on-ARC-AXS103-Software-Development-Platform-(SDP)>`
343+
<https://github.com/foss-for-synopsys-dwc-arc-processors/linux/wiki/Getting-Started-with-Linux-on-ARC-AXS103-Software-Development-Platform-(SDP)>`_
339344
for more details on using u-boot with AXS103.

release.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ $O/$(ECLIPSE_VANILLA_ZIP_WIN):
711711
# in sync.
712712
$O/.stamp_ide_linux_eclipse: $O/$(ECLIPSE_VANILLA_TGZ_LINUX) $O/$(IDE_PLUGINS_ZIP)
713713
mkdir -m775 -p $O/$(IDE_INSTALL_LINUX)
714-
tar xaf $< -C $O/$(IDE_INSTALL_LINUX)
714+
tar xf $< -C $O/$(IDE_INSTALL_LINUX)
715715
$O/$(IDE_INSTALL_LINUX)/eclipse/eclipse \
716716
-application org.eclipse.equinox.p2.director \
717717
-noSplash \
@@ -733,7 +733,7 @@ $O/.stamp_ide_linux_tar: \
733733
cp -al $O/$(TOOLS_LINUXLE_HS_DIR_LINUX)/* $O/$(IDE_INSTALL_LINUX)
734734
cp -al $O/$(TOOLS_LINUXBE_HS_DIR_LINUX)/* $O/$(IDE_INSTALL_LINUX)
735735
mkdir -m775 $O/$(IDE_INSTALL_LINUX)/eclipse/jre
736-
tar xaf $O/$(JRE_TGZ_LINUX) -C $O/$(IDE_INSTALL_LINUX)/eclipse/jre \
736+
tar xf $O/$(JRE_TGZ_LINUX) -C $O/$(IDE_INSTALL_LINUX)/eclipse/jre \
737737
--strip-components=1
738738
cp -al $O/$(OOCD_DIR_LINUX)/* $O/$(IDE_INSTALL_LINUX)
739739
tar caf $O/$(IDE_TGZ_LINUX) -C $O $(IDE_INSTALL_LINUX)
@@ -818,7 +818,7 @@ $(BUILD_DIR)/libusb-$(LIBUSB_VERSION).tar.bz2:
818818

819819

820820
$(BUILD_DIR)/libusb_linux_src: $(BUILD_DIR)/libusb-$(LIBUSB_VERSION).tar.bz2
821-
tar -C $(BUILD_DIR) -xaf $< --transform='s/libusb-$(LIBUSB_VERSION)/libusb_linux_src/'
821+
tar -C $(BUILD_DIR) -xf $< --transform='s/libusb-$(LIBUSB_VERSION)/libusb_linux_src/'
822822

823823

824824
.PHONY: libusb-linux-install
@@ -832,7 +832,7 @@ $(BUILD_DIR)/libusb_linux_install/lib/libusb-1.0.a: $(BUILD_DIR)/libusb_linux_sr
832832

833833

834834
$(BUILD_DIR)/libusb_win_src: $(BUILD_DIR)/libusb-$(LIBUSB_VERSION).tar.bz2
835-
tar -C $(BUILD_DIR) -xaf $< --transform='s/libusb-$(LIBUSB_VERSION)/libusb_win_src/'
835+
tar -C $(BUILD_DIR) -xf $< --transform='s/libusb-$(LIBUSB_VERSION)/libusb_win_src/'
836836

837837

838838
# It looks like that libusb Makefile is not parallel-friendly, it fails with error

0 commit comments

Comments
 (0)