From: Rutherther via Guix-patches via <guix-patches@gnu.org>
To: 73118@debbugs.gnu.org
Cc: Rutherther <rutherther@protonmail.com>
Subject: [bug#73118] [PATCH v2 3/5] gnu: make-libstdc++-arm-none-eabi: add nano variant
Date: Fri, 13 Sep 2024 11:42:12 +0000 [thread overview]
Message-ID: <1b301413ec52ea11d7e2cc603b506966abd63b72.1726227323.git.rutherther@protonmail.com> (raw)
In-Reply-To: <cover.1726227323.git.rutherther@protonmail.com>
The arm-none-eabi nano toolchain had same libstdc++ as the non-nano variant.
The libstdc++ should be compiled with -fno-exceptions to make a nano
toolchain.
Additionally, since the "_nano.a" variants were not present, it was impossible
to compile C++ programs with libstdc++ using --specs=nano.specs,
since libstdc++_nano.a was not found.
The `--with-target-subdir="."` flag is a preparation for gcc-12 introduction
since the libstdc++ doesn't build without that, failing on GCC_NO_EXECUTABLES
error in configure stage. I have not been able to find out another workaround.
* gnu/packages/embedded.scm (make-libstdc++-arm-none-eabi):
[arguments]<#:make-flags>: Add CFLAGS and CXXFLAGS.
[arguments]<#:configure-flags>: Add --with-target-subdir.
* gnu/packages/embedded.scm (make-libstdc++-nano-arm-none-eabi): Add variable.
Change-Id: I06a507fef07352a4ec80d84e4d97065343fc2295
---
gnu/packages/embedded.scm | 74 +++++++++++++++++++++++++++++++++------
1 file changed, 63 insertions(+), 11 deletions(-)
diff --git a/gnu/packages/embedded.scm b/gnu/packages/embedded.scm
index 2a482f7e52..847eb8059c 100644
--- a/gnu/packages/embedded.scm
+++ b/gnu/packages/embedded.scm
@@ -483,8 +483,17 @@ (define make-libstdc++-arm-none-eabi
(name "libstdc++-arm-none-eabi")
(arguments
(substitute-keyword-arguments (package-arguments libstdc++)
+ ((#:make-flags flags #f)
+ #~(cons* "CFLAGS=-g -O2 -fdata-sections -ffunction-sections"
+ "CXXFLAGS=-g -O2 -fdata-sections -ffunction-sections"
+ (or #$flags '())))
((#:configure-flags _)
- ``("--target=arm-none-eabi"
+ ``(; This is more of a hack. This option doesn't really seem
+ ; to change what subdir is used eventually, but without it there is
+ ; error: Link tests are not allowed after GCC_NO_EXECUTABLES with
+ ; The 12.3 toolchain
+ "--with-target-subdir=\".\""
+ "--target=arm-none-eabi"
"--host=arm-none-eabi"
"--disable-libstdcxx-pch"
"--enable-multilib"
@@ -506,21 +515,64 @@ (define make-libstdc++-arm-none-eabi
("xgcc" ,xgcc)
,@(package-native-inputs libstdc++)))))))
+(define make-libstdc++-nano-arm-none-eabi
+ (mlambda (xgcc newlib-nano)
+ (let ((base (make-libstdc++-arm-none-eabi xgcc newlib-nano)))
+ (package
+ (inherit base)
+ (name "libstdc++-nano-arm-none-eabi")
+ (arguments (substitute-keyword-arguments (package-arguments base)
+ ((#:make-flags flags)
+ #~(map (lambda (flag)
+ (if (or (string-prefix? "CFLAGS=" flag)
+ (string-prefix? "CXXFLAGS=" flag))
+ (string-append flag " -fno-exceptions")
+ flag))
+ #$flags))
+ ((#:phases phases)
+ #~(modify-phases #$phases
+ (add-after 'install 'hardlink-libstdc++
+ ;; XXX: Most arm toolchains offer both *.a and *_nano.a as
+ ;; newlib and newlib-nano respectively. The headers are
+ ;; usually arm-none-eabi/include/newlib.h for newlib and
+ ;; arm-none-eabi/include/newlib-nano/newlib.h for newlib-nano.
+ ;; We have two different toolchain packages for each which
+ ;; works but is a little strange.
+ (lambda* (#:key outputs #:allow-other-keys)
+ (let ((out (assoc-ref outputs "out")))
+ ;; The nano.specs file says that newlib-nano files should
+ ;; end in "_nano.a" instead of just ".a". Note that this
+ ;; applies to all the multilib folders too.
+ (for-each
+ (lambda (file)
+ (link file
+ (string-append
+ ;; Strip ".a" off the end
+ (substring file 0 (- (string-length file) 2))
+ ;; Add "_nano.a" onto the end
+ "_nano.a")))
+ (find-files
+ out "^(libstdc\\+\\+.a|libsupc\\+\\+.a)$")))))))))))))
+
(define make-arm-none-eabi-toolchain
(mlambda (xgcc newlib)
"Produce a cross-compiler toolchain package with the compiler XGCC and the
C library variant NEWLIB."
- (let ((newlib-with-xgcc
- (package
- (inherit newlib)
- (native-inputs
- (alist-replace "xgcc" (list xgcc)
- (package-native-inputs newlib))))))
+ (let* ((nano? (string=? (package-name newlib)
+ "newlib-nano"))
+ (newlib-with-xgcc
+ (package
+ (inherit newlib)
+ (native-inputs
+ (alist-replace "xgcc" (list xgcc)
+ (package-native-inputs newlib)))))
+ (libstdc++
+ (if nano?
+ (make-libstdc++-nano-arm-none-eabi xgcc newlib-with-xgcc)
+ (make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))))
(package
(name (string-append "arm-none-eabi"
- (if (string=? (package-name newlib-with-xgcc)
- "newlib-nano")
- "-nano" "")
+ (if nano? "-nano" "")
"-toolchain"))
(version (package-version xgcc))
(source #f)
@@ -537,7 +589,7 @@ (define make-arm-none-eabi-toolchain
directories))))))
(propagated-inputs
`(("binutils" ,(cross-binutils "arm-none-eabi"))
- ("libstdc++" ,(make-libstdc++-arm-none-eabi xgcc newlib-with-xgcc))
+ ("libstdc++" ,libstdc++)
("gcc" ,xgcc)
("newlib" ,newlib-with-xgcc)))
(synopsis "Complete GCC tool chain for ARM bare metal development")
--
2.46.0
next prev parent reply other threads:[~2024-09-13 11:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-08 7:42 [bug#73118] [PATCH 0/5] Fix arm-none-eabi toolchains and introduce a newer version 12.3.rel1 Rutherther via Guix-patches via
2024-09-08 7:48 ` [bug#73118] [PATCH 1/5] Fix native-search-paths of arm-none-eabi toolchains Rutherther via Guix-patches via
2024-09-08 7:49 ` [bug#73118] [PATCH 2/5] Fix lib directory of arm-none-eabi libstdc++ Rutherther via Guix-patches via
2024-09-08 7:49 ` [bug#73118] [PATCH 3/5] Add libstdc++-nano for arm-none-eabi Rutherther via Guix-patches via
2024-09-08 7:49 ` [bug#73118] [PATCH 4/5] Fix arm-none-eabi 7 newlib nano variant Rutherther via Guix-patches via
2024-09-08 7:49 ` [bug#73118] [PATCH 5/5] Introduce arm-none-eabi 12.3.rel1 toolchain Rutherther via Guix-patches via
2024-09-13 11:41 ` [bug#73118] [PATCH v2 0/5] Fix arm-none-eabi toolchains and introduce a newer version 12.3.rel1 Rutherther via Guix-patches via
2024-09-13 11:41 ` [bug#73118] [PATCH v2 1/5] gnu: make-gcc-arm-none-eabi: reorder C++ native search paths Rutherther via Guix-patches via
2024-09-13 11:42 ` [bug#73118] [PATCH v2 2/5] gnu: make-libstdc++-arm-none-eabi: output libstdc++ to arm-none-eabi Rutherther via Guix-patches via
2024-09-13 11:42 ` Rutherther via Guix-patches via [this message]
2024-09-13 11:42 ` [bug#73118] [PATCH v2 4/5] gnu: newlib arm-none-eabi-7-2018-q2-update: Add proper newlib-nano variant Rutherther via Guix-patches via
2024-09-13 11:42 ` [bug#73118] [PATCH v2 5/5] gnu: arm-none-eabi toolchain 12.3.rel1 Rutherther via Guix-patches via
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1b301413ec52ea11d7e2cc603b506966abd63b72.1726227323.git.rutherther@protonmail.com \
--to=guix-patches@gnu.org \
--cc=73118@debbugs.gnu.org \
--cc=rutherther@protonmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).