Skip to content

Commit b98452c

Browse files
authored
Enable exceptions/rtti builds of libcxx with newlib (#36)
Also turn localization on to support iostream.
1 parent 401f001 commit b98452c

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

arm-software/embedded/arm-runtimes/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,12 +699,15 @@ if(ENABLE_CXX_LIBS)
699699
elseif(C_LIBRARY STREQUAL newlib)
700700
set(cxxlibs_extra_cmake_options
701701
-DLIBCXXABI_ENABLE_THREADS=OFF
702-
-DLIBCXX_ENABLE_THREADS=OFF
703702
-DLIBCXX_ENABLE_MONOTONIC_CLOCK=OFF
704703
-DLIBCXX_ENABLE_RANDOM_DEVICE=OFF
704+
-DLIBCXX_ENABLE_THREADS=OFF
705705
-DLIBCXX_ENABLE_WIDE_CHARACTERS=ON
706-
-DLIBCXX_ENABLE_LOCALIZATION=OFF
707706
-DLIBUNWIND_ENABLE_THREADS=OFF
707+
-DLIBCXXABI_ENABLE_EXCEPTIONS=${ENABLE_EXCEPTIONS}
708+
-DLIBCXXABI_ENABLE_STATIC_UNWINDER=${ENABLE_EXCEPTIONS}
709+
-DLIBCXX_ENABLE_EXCEPTIONS=${ENABLE_EXCEPTIONS}
710+
-DLIBCXX_ENABLE_RTTI=${ENABLE_RTTI}
708711
)
709712
endif()
710713

arm-software/embedded/patches/newlib/0001-Enable-newlib-build.patch

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 928f527624c6cbc1d897c5f36309981971f47873 Mon Sep 17 00:00:00 2001
1+
From 24fb12a2a1a46d759221b3d59b41502021cc877b Mon Sep 17 00:00:00 2001
22
From: Volodymyr Turanskyy <[email protected]>
33
Date: Thu, 2 Jan 2025 16:23:27 +0000
44
Subject: [PATCH] Update patch for newlib-4.5.0 tag
@@ -12,11 +12,12 @@ Change-Id: Iec24f4305ad35a3a6df1672bb14555bf81249130
1212
libgloss/arm/linux-crt0.c | 2 +-
1313
libgloss/arm/syscalls.c | 6 +-
1414
libgloss/arm/trap.S | 2 +-
15-
newlib/libc/include/sys/features.h | 2 +
15+
newlib/libc/include/sys/features.h | 3 +
1616
newlib/libc/machine/arm/setjmp.S | 4 +-
17+
newlib/libc/string/wcwidth.c | 2 +-
1718
newlib/libc/sys/arm/crt0.S | 2 +-
1819
newlib/libc/sys/arm/trap.S | 2 +-
19-
11 files changed, 73 insertions(+), 64 deletions(-)
20+
12 files changed, 75 insertions(+), 65 deletions(-)
2021

2122
diff --git a/libgloss/Makefile.in b/libgloss/Makefile.in
2223
index 54a00614d..be1450749 100644
@@ -398,14 +399,15 @@ index 845ad0173..2056c2adf 100644
398399
.global __rt_stkovf_split_small
399400

400401
diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h
401-
index 325acdf5f..12cb6465b 100644
402+
index 325acdf5f..dfaba8fe7 100644
402403
--- a/newlib/libc/include/sys/features.h
403404
+++ b/newlib/libc/include/sys/features.h
404-
@@ -27,6 +27,8 @@ extern "C" {
405+
@@ -27,6 +27,9 @@ extern "C" {
405406

406407
#include <_newlib_version.h>
407408

408409
+#define _DEFAULT_SOURCE
410+
+#define _GNU_SOURCE
409411
+
410412
/* Macro to test version of GCC. Returns 0 for non-GCC or too old GCC. */
411413
#ifndef __GNUC_PREREQ
@@ -427,6 +429,19 @@ index 0070f17cd..a53f7918e 100644
427429
.arch_extension mve
428430
# endif
429431
#endif
432+
diff --git a/newlib/libc/string/wcwidth.c b/newlib/libc/string/wcwidth.c
433+
index 8348eefe8..65604c061 100644
434+
--- a/newlib/libc/string/wcwidth.c
435+
+++ b/newlib/libc/string/wcwidth.c
436+
@@ -230,7 +230,7 @@ __wcwidth (const wint_t ucs)
437+
}
438+
439+
int
440+
-wcwidth (const wint_t wc)
441+
+wcwidth (const wchar_t wc)
442+
{
443+
wint_t wi = wc;
444+
430445
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
431446
index dae0f0465..51e86d549 100644
432447
--- a/newlib/libc/sys/arm/crt0.S

0 commit comments

Comments
 (0)