devkitPro / newlib

fork from sourceware git://sourceware.org / newlib-cygwin.git
https://devkitpro.org
GNU General Public License v2.0
22 stars 16 forks source link

devkitA64: Build posix into libc (for fnmatch) #11

Closed compomega closed 5 years ago

compomega commented 5 years ago

I have at least two libraries I'm trying to build that are trying to use fnmatch. One is configure based and the other is CMake based. The CMake based one is assuming the feature is there and not checking it (which sucks). For both it finds fnmatch.h but gets a linker error later. I can build it into my library (which is a bad idea) or hack the configure script output to not define HAVE_FNMATCH_H like so:

sed -i -e 's/#define HAVE_FNMATCH_H 1//' aarch64-none-elf/config.h

That is not ideal though. Is there a downside to building the posix implementation into libc? I see that opendir is still in libsysbase (hence the HAVE_OPENDIR define) after I make this change and half the posix files can be disabled or don't build anyway.

diff --git a/newlib/configure.host b/newlib/configure.host
index d536e0d..5c971a1 100644
--- a/newlib/configure.host
+++ b/newlib/configure.host
@@ -409,6 +409,9 @@ case "${host}" in
        sys_dir=a29khif
        signal_dir=
        ;;
+  aarch64*-*-*)
+    posix_dir=posix
+    ;;
   arm*-*-*)
        sys_dir=arm
        if [ "x${newlib_may_supply_syscalls}" = "xno" ] ; then
@@ -627,7 +630,7 @@ newlib_cflags="${newlib_cflags} -DCLOCK_PROVIDED -DMALLOC_PROVIDED -DEXIT_PROVID
        default_newlib_io_c99_formats="yes"
        default_newlib_io_long_long="yes"
        default_newlib_io_pos_args="yes"
-       newlib_cflags="${newlib_cflags} -D__DYNAMIC_REENT__ -DREENTRANT_SYSCALLS_PROVIDED -D__DEFAULT_UTF8__"
+       newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -D__DYNAMIC_REENT__ -DREENTRANT_SYSCALLS_PROVIDED -D__DEFAULT_UTF8__"
        newlib_cflags="${newlib_cflags} -ffunction-sections -fdata-sections"
        syscall_dir=syscalls
        ;;
WinterMute commented 5 years ago

despite the dates in this repository our libsysbase layer predates the posix dir by a few years. It serves much the same purpose but has a different approach in that we wanted to be able to have stuff configure without dependencies on the target libraries that provide the low level functionality. Trying to use the posix dir is "crossing the streams" so to speak.

We can look at providing fnmatch with libsysbase if it makes sense, we already provide scandir there. https://github.com/devkitPro/newlib/tree/devkitA64/libgloss/libsysbase.

compomega commented 5 years ago

Either way is fine with me.

WinterMute commented 5 years ago

Either way is fine with me.

Not an either way thing ... enabling that posix dir will break the toolchain ...

compomega commented 5 years ago

I mean I don't care which way it's fixed.