Skip to content

configure.ac: fix the mmap check with autoconf 2.70 and later - #62

Merged
guillerodriguez merged 1 commit into
ingelabs:masterfrom
duncanmcqueen:fix-configure-mmap
Oct 14, 2026
Merged

guillerodriguez merged 1 commit into
ingelabs:masterfrom
duncanmcqueen:fix-configure-mmap

Conversation

@duncanmcqueen

Copy link
Copy Markdown
Contributor

Split from #59.

Problem and fix

In the AC_CHECK_FUNCS list in configure.ac, the line statvfs \ has two spaces after the backslash. Thus the backslash quotes a space, not the newline.

With autoconf 2.72 and later, configure checks for a function with the name " mmap" (with a space), not "mmap". The check fails, and HAVE_MMAP is not defined. Then FileChannel.map() throws IOException: memory-mapped files not implemented. Also, OpenTypeFontPeer cannot load fonts, because it maps the font files.

The CI uses Ubuntu 24.04, which has autoconf 2.71. Thus the CI does not show the problem.

This change removes the two spaces.

How to reproduce

./autogen.sh        # autoconf 2.72 or later
./configure ...
grep -n 'checking for  *mmap' config.log
grep -n HAVE_MMAP include/config.h

Then run this test:

javac MapFile.java
java MapFile
MapFile.java
import java.io.*;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;

/**
 * FileChannel.map() must work. It fails when configure did not define
 * HAVE_MMAP.
 */
public class MapFile
{
  public static void main(String[] args) throws IOException
  {
    File f = File.createTempFile("mapfile", ".bin");
    f.deleteOnExit();
    FileOutputStream out = new FileOutputStream(f);
    out.write(new byte[] { 1, 2, 3, 42 });
    out.close();
    FileInputStream in = new FileInputStream(f);
    try
      {
        MappedByteBuffer b = in.getChannel().map(FileChannel.MapMode.READ_ONLY,
                                                 0, 4);
        boolean ok = b.get(3) == 42;
        System.out.println((ok ? "PASS" : "FAIL") + ": mapped byte 3 = "
                           + b.get(3));
        System.exit(ok ? 0 : 1);
      }
    catch (IOException e)
      {
        System.out.println("FAIL: " + e);
        System.exit(1);
      }
  }
}

Results

Linux x86_64, ingelabs/classpath master (0406074), JamVM master, javac from JDK 8, autoconf 2.73, automake 1.19, the configure options of the CI Linux job, out-of-tree build. "Before" is master. "After" is master with this commit.

Before:
configure:22046: checking for  mmap
/* #undef HAVE_MMAP */
FAIL: java.io.IOException: memory-mapped files not implemented

After:
configure:22288: checking for mmap
#define HAVE_MMAP 1
PASS: mapped byte 3 = 42

Platforms

Not specific to Haiku. The problem occurs on all systems with autoconf 2.72 or later. I reproduced it on Linux.

AI assistance

An AI model (Claude Code, by Anthropic) wrote this change, the test and this text. The repository owner directed the work and checked the results. Please review it as you review other contributions.

🤖 Generated with Claude Code

In the AC_CHECK_FUNCS list, 'statvfs \' was followed by two spaces,
so the backslash quoted a space instead of the newline. Autoconf 2.72
and later then check for ' mmap' instead of 'mmap', HAVE_MMAP is not
defined, and FileChannel.map() fails (OpenTypeFontPeer maps its font
files this way).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: duncanmcqueen <206344294+duncanmcqueen@users.noreply.github.com>
@guillerodriguez

Copy link
Copy Markdown
Contributor

Thank you for the fix!

One correction: the issue seems to be present since autoconf 2.70, not 2.72. And in fact it is visible in CI: both the Ubuntu job (autoconf 2.71) and the macOS job (autoconf 2.73) show it. I just checked the logs from recent builds:

configure.ac:446: warning: AC_CHECK_FUNCS(\): you should use literals
[...]
checking for  mmap... no
checking for munmap... yes

The build completes and all tests pass, but only because the current test suite never exercises map(). I’m adding a Malva test based on your MapFile reproducer to fix that.

I’ll update the PR title to mention autoconf 2.70 instead of 2.72, and will also amend the commit message when merging.

@guillerodriguez guillerodriguez changed the title configure.ac: fix the mmap check with autoconf 2.72 and later configure.ac: fix the mmap check with autoconf 2.70 and later Oct 14, 2026
@guillerodriguez
guillerodriguez self-requested a review October 14, 2026 22:08
@guillerodriguez
guillerodriguez marked this pull request as ready for review October 14, 2026 22:08
@guillerodriguez
guillerodriguez merged commit c4eb665 into ingelabs:master Oct 14, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants