]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
toolchain: fix libgloss/adros build errors
authorTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 20:41:52 +0000 (17:41 -0300)
committerTulio A M Mendes <[email protected]>
Sun, 19 Apr 2026 20:41:52 +0000 (17:41 -0300)
- Add sys/uio.h compat header (struct iovec + readv/writev declarations)
  needed by posix_stubs.c which was missing from sysroot_headers
- Remove duplicate fcntl() definition in posix_stubs.c (line 541 was
  identical to line 256, causing redefinition error with newlib headers)
- Move libgloss/adros source sync outside patch_newlib() marker guard
  so edits to stubs are always picked up on rebuild (cp -f instead of
  cp -u); keep mkdir -p inside patch_newlib() for autoconf file creation

newlib/libgloss/adros/posix_stubs.c
newlib/sysroot_headers/sys/uio.h [new file with mode: 0644]
toolchain/build.sh

index 4952bfd8f98198a415fd505f1d9d787c7f472c30..ea391696d35f2c57eba6eb4af50a1b7a80d7fbbe 100644 (file)
@@ -537,14 +537,6 @@ int gethostname(char *name, size_t len) {
  * Additional POSIX wrappers (previously missing)
  * ================================================================ */
 
-int fcntl(int fd, int cmd, ...) {
-    va_list ap;
-    va_start(ap, cmd);
-    int arg = va_arg(ap, int);
-    va_end(ap);
-    return _check(_sc3(SYS_FCNTL, fd, cmd, arg));
-}
-
 int rename(const char *oldpath, const char *newpath) {
     return _check(_sc2(SYS_RENAME, (int)oldpath, (int)newpath));
 }
diff --git a/newlib/sysroot_headers/sys/uio.h b/newlib/sysroot_headers/sys/uio.h
new file mode 100644 (file)
index 0000000..157c35a
--- /dev/null
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: BSD-3-Clause
+/*
+ * Copyright (c) 2018, Tulio A. M. Mendes <[email protected]>
+ * All rights reserved.
+ * See LICENSE for details.
+ *
+ * Source: https://github.com/tadryanom/AdrOS
+ */
+
+/* sys/uio.h — Scatter/gather I/O (POSIX compat header for AdrOS/newlib) */
+
+#ifndef _SYS_UIO_H
+#define _SYS_UIO_H
+
+#include <stddef.h>
+
+struct iovec {
+    void  *iov_base;
+    size_t iov_len;
+};
+
+ssize_t readv(int fd, const struct iovec *iov, int iovcnt);
+ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
+
+#endif
index 4c95ec7351bc24e46d94d855d664413e1fed5902..117d3c053c54ab32200bb3ebaedfe817434f7280 100755 (executable)
@@ -390,12 +390,8 @@ EOF
         step "Patched libgloss/configure.ac"
     fi
 
-    # Copy/sync our libgloss/adros stubs into the Newlib source tree
+    # Create libgloss/adros directory and autoconf files if not present
     mkdir -p "$d/libgloss/adros"
-    cp -u "$ADROS_ROOT/newlib/libgloss/adros/"*.c "$ADROS_ROOT/newlib/libgloss/adros/"*.S "$d/libgloss/adros/" 2>/dev/null || true
-    step "Synced libgloss/adros/ stubs"
-
-    # Create libgloss/adros autoconf files if not present
     if [[ ! -f "$d/libgloss/adros/configure.in" ]]; then
         cat > "$d/libgloss/adros/configure.in" <<'EOF'
 dnl AdrOS libgloss configure
@@ -490,6 +486,13 @@ patch_gcc
 patch_newlib
 patch_bash
 
+# Always sync libgloss/adros source files (even if patches are already applied)
+# so that edits to our stubs are picked up on rebuild.
+_gloss_dir="$SRC_DIR/newlib-${NEWLIB_VER}/libgloss/adros"
+mkdir -p "$_gloss_dir"
+cp -f "$ADROS_ROOT/newlib/libgloss/adros/"*.c "$ADROS_ROOT/newlib/libgloss/adros/"*.S "$_gloss_dir/" 2>/dev/null || true
+step "Synced libgloss/adros/ stubs (forced)"
+
 # ==================================================================
 # STEP 1: Build Binutils
 # ==================================================================