Github messages for voidlinux
 help / color / mirror / Atom feed
From: voidlinux-github@inbox.vuxu.org
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [wip] cross-arm-none-eabi*: update to 9.2, rework to include libgcc.a and libstdc++, newlib: build nano
Date: Sat, 28 Dec 2019 17:28:58 +0100	[thread overview]
Message-ID: <20191228162858.kdxylYR0QbsIMAvdcq1Qs8jrZsAMnA61tzr0zelDPR8@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-17827@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 1223 bytes --]

There is an updated pull request by q66 against master on the void-packages repository

https://github.com/q66/void-packages arm-none-eabi
https://github.com/void-linux/void-packages/pull/17827

[wip] cross-arm-none-eabi*: update to 9.2, rework to include libgcc.a and libstdc++, newlib: build nano
For `cross-arm-none-eabi-gcc`:

I've reworked this to make it possible to include `libgcc.a`, rather than just the compiler itself. However, as `libstdc++` requires `newlib` to be built and present (which requires the gcc to build), skip building `libstdc++` at this stage. Instead, move it into a separate package.

I figured out the necessary changes mostly by reading the Arch pkgbuild.

For `cross-arm-none-eabi-libstdc++`:

As the gcc cannot include libstdc++ because of its newlib requirement, build it as a separate package. This is achieved by taking the gcc source tree, installing our previously built gcc as well as newlib (which was already packaged) and building libstdc++ on its own. I've successfully compiled things with this.

For `cross-arm-none-eabi-newlib`:

We now build a nano variant.

@sirikid 

A patch file from https://github.com/void-linux/void-packages/pull/17827.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-arm-none-eabi-17827.patch --]
[-- Type: text/x-diff, Size: 12567 bytes --]

From 9cd50cb0f9dac27c8c03e3eb85e6470d8fd28ed5 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 27 Dec 2019 23:40:18 +0100
Subject: [PATCH 1/4] cross-arm-none-eabi-gcc: update to 9.2.0 + build libgcc

This does other reworking, such as building in a separate directory
like is recommended by the project.

By importing some changes from Arch, I managed to fix building of
libgcc, which further enables building the rest of the toolchain.

However, building libstdc++ is skipped, as that requires newlib
to build, which itself is not available at this point. Newlib on
the other hand requires a built toolchain to compile. We solve
this by building gcc (complete but without libstdc++) first,
followed by building newlib, followed by building just libstdc++
on its own.
---
 srcpkgs/cross-arm-none-eabi-gcc/template | 118 +++++++++++++----------
 1 file changed, 68 insertions(+), 50 deletions(-)

diff --git a/srcpkgs/cross-arm-none-eabi-gcc/template b/srcpkgs/cross-arm-none-eabi-gcc/template
index 0e636b75773..f082fdcb39c 100644
--- a/srcpkgs/cross-arm-none-eabi-gcc/template
+++ b/srcpkgs/cross-arm-none-eabi-gcc/template
@@ -1,55 +1,13 @@
-# Template file for 'cross-${_triplet}-${_pkgname}'
+# Template file for 'cross-${_triplet}-gcc'
 _triplet=arm-none-eabi
 _pkgname=gcc
-pkgname=cross-${_triplet}-${_pkgname}
-version=9.1.0
+pkgname=cross-${_triplet}-gcc
+version=9.2.0
 revision=1
-wrksrc="${_pkgname}-${version}"
+wrksrc="gcc-${version}"
+build_wrksrc=build
 build_style=gnu-configure
-configure_args="
- --disable-decimal-float
- --disable-libffi
- --disable-libgomp
- --disable-libmudflap
- --disable-libquadmath
- --disable-libssp
- --disable-libstdcxx-pch
- --disable-nls
- --disable-shared
- --disable-threads
- --disable-tls
- --disable-werror
- --enable-__cxa_atexit
- --enable-c99
- --enable-gnu-indirect-function
- --enable-interwork
- --enable-languages=c,c++
- --enable-long-long
- --enable-multilib
- --enable-plugins
- --host=${XBPS_CROSS_TRIPLET}
- --libdir=/usr/lib
- --libexecdir=/usr/lib
- --prefix=/usr
- --target=${_triplet}
- --with-gmp
- --with-gnu-as
- --with-gnu-ld
- --with-headers=/usr/${_triplet}/include
- --with-host-libstdcxx='-static-libgcc'
- --with-isl
- --with-libelf
- --with-mpc
- --with-mpfr
- --with-multilib-list=rmprofile
- --with-native-system-header-dir=/include
- --with-newlib
- --with-python-dir=share/${_pkgname}-${_triplet}
- --with-sysroot=/usr/${_triplet}
- --with-system-zlib
-"
-make_build_target="all-gcc"
-make_install_target="install-gcc"
+make_build_args="INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'"
 hostmakedepends="autoconf automake cross-arm-none-eabi-binutils bison flex perl"
 makedepends="gmp-devel isl15-devel libmpc-devel mpfr-devel zlib-devel"
 depends="cross-arm-none-eabi-binutils"
@@ -57,12 +15,72 @@ short_desc="GNU Compiler Collection"
 maintainer="Ivan Sokolov <ivan-p-sokolov@ya.ru>"
 license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
 homepage="https://gcc.gnu.org"
-distfiles="${GNU_SITE}/${_pkgname}/${_pkgname}-${version}/${_pkgname}-${version}.tar.xz"
-checksum=79a66834e96a6050d8fe78db2c3b32fb285b230b855d0a66288235bc04b327a0
+distfiles="${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz"
+checksum=ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206
 alternatives="arm-none-eabi:/usr/bin/arm-none-eabi-cc:/usr/bin/arm-none-eabi-gcc"
 nocross=yes
 nopie=yes
+nostrip_files="libgcc.a libgcov.a"
+
+post_extract() {
+	mkdir -p build
+}
+
+pre_configure() {
+	export CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections"
+	export CXXFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections"
+}
+
+do_configure() {
+	../configure \
+		--disable-decimal-float \
+		--disable-libffi \
+		--disable-libgomp \
+		--disable-libmudflap \
+		--disable-libquadmath \
+		--disable-libssp \
+		--disable-libstdcxx-pch \
+		--disable-libstdc__-v3 \
+		--disable-nls \
+		--disable-shared \
+		--disable-threads \
+		--disable-tls \
+		--disable-werror \
+		--enable-__cxa_atexit \
+		--enable-c99 \
+		--enable-gnu-indirect-function \
+		--enable-interwork \
+		--enable-languages=c,c++ \
+		--enable-long-long \
+		--enable-multilib \
+		--enable-plugins \
+		--host=${XBPS_CROSS_TRIPLET} \
+		--libdir=/usr/lib \
+		--libexecdir=/usr/lib \
+		--prefix=/usr \
+		--target=${_triplet} \
+		--with-gmp \
+		--with-gnu-as \
+		--with-gnu-ld \
+		--with-headers=/usr/${_triplet}/include \
+		--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
+		--with-isl \
+		--with-libelf \
+		--with-mpc \
+		--with-mpfr \
+		--with-multilib-list=rmprofile \
+		--with-native-system-header-dir=/include \
+		--with-newlib \
+		--with-python-dir=share/gcc-${_triplet} \
+		--with-sysroot=/usr/${_triplet} \
+		--with-system-zlib
+}
+
+pre_build() {
+	pre_configure
+}
 
 post_install() {
 	rm -fr ${DESTDIR}/usr/share/{info,man/man7}
+	rm -fr ${DESTDIR}/usr/lib/libcc1.*
 }

From 8a88885c54062f303d5c29c7aadf27d8851923d5 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sat, 28 Dec 2019 02:18:41 +0100
Subject: [PATCH 2/4] cross-arm-none-eabi-newlib: build a nano variant

---
 srcpkgs/cross-arm-none-eabi-newlib/template | 73 +++++++++++++++++----
 1 file changed, 61 insertions(+), 12 deletions(-)

diff --git a/srcpkgs/cross-arm-none-eabi-newlib/template b/srcpkgs/cross-arm-none-eabi-newlib/template
index 076c52c93f3..a5c27a2ce79 100644
--- a/srcpkgs/cross-arm-none-eabi-newlib/template
+++ b/srcpkgs/cross-arm-none-eabi-newlib/template
@@ -3,21 +3,14 @@ _triplet=arm-none-eabi
 _pkgname=newlib
 pkgname=cross-${_triplet}-${_pkgname}
 version=3.1.0.20181231
-revision=1
+revision=2
 wrksrc="${_pkgname}-${version}"
 build_style=gnu-configure
 configure_args="
- --disable-newlib-supplied-syscalls
- --disable-nls
- --enable-interwork
- --enable-newlib-io-long-long
- --enable-newlib-register-fini
- --host=${XBPS_CROSS_TRIPLET}
- --prefix=/usr
- --target=${_triplet}
- --with-gnu-as
- --with-gnu-ld
-"
+ --prefix=/usr --target=${_triplet} --host=${XBPS_CROSS_TRIPLET}
+ --with-gnu-as --with-gnu-ld --disable-nls
+ --disable-newlib-supplied-syscalls --enable-newlib-retargetable-locking
+ --enable-interwork"
 hostmakedepends="cross-arm-none-eabi-binutils cross-arm-none-eabi-gcc"
 short_desc="C library intended for use on embedded systems"
 maintainer="Ivan Sokolov <ivan-p-sokolov@ya.ru>"
@@ -26,3 +19,59 @@ homepage="https://www.sourceware.org/${_pkgname}/"
 distfiles="ftp://sources.redhat.com/pub/${_pkgname}/${_pkgname}-${version}.tar.gz"
 checksum=9e12fea7297648b114434033ed4458755afe7b9b6c7d58123389e82bd37681c0
 nostrip=yes
+
+post_extract() {
+	mkdir -p build-{newlib,nano}
+}
+
+do_configure() {
+	pushd build-newlib
+	export CFLAGS_FOR_TARGET="-g -O2 -ffunction-sections -fdata-sections"
+	../configure ${configure_args} \
+		--enable-newlib-io-long-long \
+		--enable-newlib-register-fini
+	popd
+
+	pushd build-nano
+	export CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections"
+	../configure ${configure_args} \
+		--enable-newlib-reent-small \
+		--disable-newlib-fvwrite-in-streamio \
+		--disable-newlib-fseek-optimization \
+		--disable-newlib-wide-orient \
+		--enable-newlib-nano-malloc \
+		--disable-newlib-unbuf-stream-opt \
+		--enable-lite-exit \
+		--enable-newlib-global-atexit \
+		--enable-newlib-nano-formatted-io
+	popd
+}
+
+do_build() {
+	pushd build-newlib
+	make ${makejobs}
+	popd
+
+	pushd build-nano
+	make ${makejobs}
+	popd
+}
+
+do_install() {
+	pushd build-nano
+	make DESTDIR=${DESTDIR} install
+	find ${DESTDIR} -regex ".*/lib\(c\|g\|rdimon\)\.a" \
+		-exec rename .a _nano.a '{}' \;
+	install -d ${DESTDIR}/usr/${_triplet}/include/newlib-nano
+	install -m644 -t ${DESTDIR}/usr/${_triplet}/include/newlib-nano \
+		${DESTDIR}/usr/${_triplet}/include/newlib.h
+	popd
+
+	pushd build-newlib
+	make DESTDIR=${DESTDIR} install
+	popd
+}
+
+post_install() {
+	vlicense COPYING
+}

From 54d343b25d4cf19d88613a38c5a13080a8f8f6dc Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 27 Dec 2019 23:42:08 +0100
Subject: [PATCH 3/4] New package: cross-arm-none-eabi-libstdc++

This completes the basic bare metal C/C++ toolchain by adding
libstdc++. As this requires newlib to build, we need to make it
into a separate package in order to avoid a dependency cycle.

Two variants are added, a full one and a nano one (-Os, no
exceptions).
---
 .../cross-arm-none-eabi-libstdc++/template    | 85 +++++++++++++++++++
 1 file changed, 85 insertions(+)
 create mode 100644 srcpkgs/cross-arm-none-eabi-libstdc++/template

diff --git a/srcpkgs/cross-arm-none-eabi-libstdc++/template b/srcpkgs/cross-arm-none-eabi-libstdc++/template
new file mode 100644
index 00000000000..d1e1936a545
--- /dev/null
+++ b/srcpkgs/cross-arm-none-eabi-libstdc++/template
@@ -0,0 +1,85 @@
+# Template file for 'cross-${_triplet}-libstdc++'
+_triplet=arm-none-eabi
+pkgname=cross-${_triplet}-libstdc++
+version=9.2.0
+revision=1
+wrksrc="gcc-${version}"
+# gnu-configure implicitly passes stuff we don't want
+build_style=configure
+configure_args="
+ --disable-libstdcxx-pch --disable-libstdcxx-threads
+ --disable-nls --disable-shared --disable-tls --disable-werror
+ --enable-multilib --host=${_triplet} --target=${_triplet}
+ --libdir=/usr/${_triplet}/lib --prefix=/usr/${_triplet}
+ --with-gnu-ld --with-gxx-include-dir=/usr/${_triplet}/include/${version}
+ --with-newlib --with-python-dir=share/gcc-${_triplet}"
+make_build_args="INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'"
+hostmakedepends="autoconf automake cross-arm-none-eabi-binutils
+ cross-arm-none-eabi-gcc cross-arm-none-eabi-newlib bison flex perl"
+makedepends="gmp-devel isl15-devel libmpc-devel mpfr-devel zlib-devel"
+depends="cross-arm-none-eabi-gcc"
+short_desc="GNU Compiler Collection - Standard C++ Library"
+maintainer="q66 <daniel@octaforge.org>"
+license="GPL-3.0-or-later"
+homepage="https://gcc.gnu.org"
+distfiles="${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz"
+checksum=ea6ef08f121239da5695f76c9b33637a118dcf63e24164422231917fa61fb206
+nocross=yes
+nopie=yes
+nostrip=yes
+
+post_extract() {
+	mkdir -p build-{regular,nano}
+}
+
+do_configure() {
+	export CC=arm-none-eabi-gcc
+	export CXX=arm-none-eabi-g++
+	export CPP=arm-none-eabi-cpp
+	export AR=arm-none-eabi-ar
+	export AS=arm-none-eabi-as
+
+	pushd build-regular
+	export CFLAGS="-g -O2 -ffunction-sections -fdata-sections"
+	export CXXFLAGS="-g -O2 -ffunction-sections -fdata-sections"
+	../libstdc++-v3/configure ${configure_args}
+	popd
+
+	pushd build-nano
+	export CFLAGS="-g -Os -ffunction-sections -fdata-sections -fno-exceptions"
+	export CXXFLAGS="-g -Os -ffunction-sections -fdata-sections -fno-exceptions"
+	../libstdc++-v3/configure ${configure_args}
+	popd
+}
+
+do_build() {
+	unset CC CXX CPP AR AS CFLAGS CXXFLAGS
+
+	pushd build-regular
+	make ${makejobs} ${make_build_args}
+	popd
+
+	pushd build-nano
+	make ${makejobs} ${make_build_args}
+	popd
+}
+
+do_install() {
+	pushd build-regular
+	make DESTDIR=${DESTDIR} install
+	popd
+
+	pushd build-nano
+	mkdir -p dest-nano
+	make DESTDIR=$(pwd)/dest-nano install
+	# only install the static libs for nano, no headers
+	local multilibs=( $(${_triplet}-gcc -print-multi-lib 2>/dev/null) )
+	for multilib in "${multilibs[@]}"; do
+		local dir="${multilib%%;*}"
+		local from_dir=dest-nano/usr/${_triplet}/lib/${dir}
+		local to_dir=${DESTDIR}/usr/${_triplet}/lib/${dir}
+		cp -f ${from_dir}/libstdc++.a ${to_dir}/libstdc++_nano.a
+		cp -f ${from_dir}/libsupc++.a ${to_dir}/libsupc++_nano.a
+	done
+	popd
+}

From bb96b551b52e3eb8f6c6a21a57f4a31437a246b2 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Fri, 27 Dec 2019 23:43:03 +0100
Subject: [PATCH 4/4] cross-arm-none-eabi: add libstdc++ dependency

[ci skip]
---
 srcpkgs/cross-arm-none-eabi/template | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/srcpkgs/cross-arm-none-eabi/template b/srcpkgs/cross-arm-none-eabi/template
index 4cae46f9b08..8a6b7573ebe 100644
--- a/srcpkgs/cross-arm-none-eabi/template
+++ b/srcpkgs/cross-arm-none-eabi/template
@@ -1,10 +1,11 @@
 # Template file for 'cross-arm-none-eabi'
 _triplet=arm-none-eabi
 pkgname=cross-arm-none-eabi
-version=0.4
+version=0.5
 revision=1
 build_style=meta
-depends="cross-arm-none-eabi-binutils cross-arm-none-eabi-gcc cross-arm-none-eabi-newlib"
+depends="cross-arm-none-eabi-binutils cross-arm-none-eabi-gcc
+ cross-arm-none-eabi-libstdc++ cross-arm-none-eabi-newlib"
 short_desc="GNU cross bare metal toolchain"
 maintainer="Ivan Sokolov <ivan-p-sokolov@ya.ru>"
 license="metapackage"

  parent reply	other threads:[~2019-12-28 16:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-27 22:56 [PR PATCH] cross-arm-none-eabi*: update to 9.2, rework to include libgcc.a and libstdc++ voidlinux-github
2019-12-28  1:19 ` [PR PATCH] [Updated] " voidlinux-github
2019-12-28  1:22 ` voidlinux-github
2019-12-28 15:24 ` [PR PATCH] [Updated] [wip] " voidlinux-github
2019-12-28 16:28 ` voidlinux-github [this message]
2019-12-28 16:39 ` [wip] cross-arm-none-eabi*: update to 9.2, rework to include libgcc.a and libstdc++, newlib: build nano voidlinux-github
2019-12-28 16:39 ` voidlinux-github
2019-12-28 20:51 ` voidlinux-github
2019-12-28 21:55 ` voidlinux-github
2019-12-28 22:02 ` voidlinux-github
2019-12-28 23:49 ` voidlinux-github
2020-01-04  1:21 ` [PR PATCH] [Merged]: " voidlinux-github

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191228162858.kdxylYR0QbsIMAvdcq1Qs8jrZsAMnA61tzr0zelDPR8@z \
    --to=voidlinux-github@inbox.vuxu.org \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).