URL:
  <https://savannah.gnu.org/bugs/?68146>

                 Summary: build.sh: segfault on macOS when $(wildcard) matches
files
                   Group: make
               Submitter: None
               Submitted: Wed 11 Mar 2026 11:22:16 PM UTC
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Unlocked
       Component Version: 4.4.1
        Operating System: None
           Fixed Release: None
           Triage Status: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Wed 11 Mar 2026 11:22:16 PM UTC By: Anonymous
  GNU Make 4.4.1 built via build.sh on macOS segfaults when a Makefile
  uses $(wildcard) and the pattern matches at least one file. Builds via
  ./configure && make are not affected. Versions 4.3 and 4.4 are not
  affected either.

  Steps to reproduce:
    1. Extract make-4.4.1.tar.gz on macOS
    2. ./configure --without-guile && ./build.sh
    3. mkdir /tmp/test && touch /tmp/test/foo.c /tmp/test/bar.c
    4. cat > /tmp/test/Makefile <<'EOF'
       SOURCES = $(wildcard *.c)
       all:
        @echo "$(SOURCES)"
       EOF
    5. ./make -C /tmp/test

  Expected: prints "bar.c foo.c"
  Actual: Segmentation fault

  Root cause:
  configure correctly detects that macOS lacks a compatible GNU glob and
  sets USE_SYSTEM_GLOB=no. GNU Make's own glob implementation is compiled
  into lib/libgnu.a. However, build.sh links with:

    $CC $CFLAGS $LDFLAGS -L"$OUTLIB" -o "$OUTDIR/makenew$EXEEXT" $objs -lgnu

  On macOS, libSystem.B.dylib is always implicitly linked and exports its
  own glob(). Since -lgnu is a static archive, the linker only pulls in
  symbols that are currently undefined. By the time it processes -lgnu,
  glob() is already resolved from libSystem. The system glob_t struct has
  a different layout than GNU glob_t, causing a segfault in glob_in_dir().

  Confirmed with nm:
    - Broken (build.sh 4.4.1):      U _glob  (from libSystem)
    - Working (build.sh 4.3/4.4):   T _glob  (internal)
    - Working (configure+make 4.4.1): T _glob  (internal)

  Patch attached. It uses -Wl,-force_load on macOS to ensure all symbols
  from libgnu.a are loaded, so GNU Make's internal glob() takes precedence.

  Environment:
    macOS 15.3 (Sequoia), Apple Clang 17, arm64






    _______________________________________________________
File Attachments:

Name: make-4.4.1-macos-glob.patch    Size: 2.4KiB

<https://file.savannah.gnu.org/file/make-4.4.1-macos-glob.patch?file_id=58345>



    AGPL NOTICE

These attachments are served by Savane. You can download the corresponding
source code of Savane at
https://savannah.gnu.org/source/savane-5479f0ac3e1f014845fd281c379bc3ccb7a72723.tar.gz

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68146>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/

Attachment: signature.asc
Description: PGP signature

Reply via email to