NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Building NetBSD 11 Release from Source Fails on Linux/MacOS



I continued my experiments to narrow down the source of the issue.
In short, my results are:

a) The problem is not that `nbm4` cannot find the included m4 files.
b) Likely, nothing is wrong with the `nbm4` binary that gets build when building the tools.
c) The m4 files are not corrupted during clone or during conversion from CVS to Git.
d) The C compiler I am using is likely not too new.
e) I have enough space on the disk where build is conducted.
f) Likely, environment variables do not disturb the build.
g) I cannot build a release from the same sources on Linux and MacOS, but I can build one on FreeBSD 14-RELEASE.

Therefore, my gut feeling is that there is something wrong with the cross-build setup and likely not with my host.

In the following, I detail each of these points and what I did about it.
Unfortunately, it became a bit of text :) 


## `nbm4` cannot find the included m4 files?

My original hypothesis from two days ago was that the preprocessor fails since it cannot find `config.m4``.
Now, I realize that this is not the issue.
From the build logs, the first command on which building libgmp fails, is the following:

```
/home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-x86_64/bin/nbm4 \
    -DCONFIG_TOP_SRCDIR=/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp/dummy \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/ \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp \
    -DPIC \
    -DOPERATION_sqr_diag_addlsh1 \
    /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm
```

When I execute this command in isolation, it produces this error message:

```
nbm4: unexpected end of input, unclosed parenthesis:
   /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm at line 116
```

To see if the `config.m4` file is found by the preprocessor, I run the command again with `-dV` to get verbose information on what is processed in which way:

```
/home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-x86_64/bin/nbm4 \
    -dV \
    -DCONFIG_TOP_SRCDIR=/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp/dummy \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/ \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp \
    -DPIC \
    -DOPERATION_sqr_diag_addlsh1 \
    /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm
```

I log the output (ca. 7MB) to a file.
It shows that all the required macro files are included and can be opened for processing.


## Something wrong with the `nbm4` binary?

My next hypothesis was that something is wrong with the `nbm4` binary that is produced when building the tools.
However, on my Linux host, I cannot find a sign for that:

a) The logs from building the tools do not show an error for building `nbm4`.
b) `nbm4` is invoked in building the tools. There, it just seems to work, no errors are shown when it is invoked (at least I do not find any).
c) `file /home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-x86_64/bin/nbm4` suggests that it is an executable: `ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=5fb00af99d59a4bd53de867c462d8eab30b9554d, for GNU/Linux 3.2.0, not stripped`
c) `/home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-x86_64/bin/nbm4 --version` show an output: `nbm4 version 20150116`.
d) `nbm4` runs and produces an error message that looks reasonable in case something is wrong with the input files.
e) `nbm4` can process contents that are provided to it, e.g., 
   ```
   $ /home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-x86_64/bin/nbm4 <<'EOF'
   eval(1==1 && 1-0==0)
   EOF
   0
   ```

To see if perhaps GNU m4 from my Linux host can preprocess the file, I run it with the same arguments:

```
m4 \
    -DCONFIG_TOP_SRCDIR=/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp/dummy \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/ \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp \
    -DPIC \
    -DOPERATION_sqr_diag_addlsh1 \
    /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm
```

The interesting thing is that it also produces an error, though a different one: 
`m4:/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm:116: ERROR: end of file in argument list`


## m4 files are corrupted during clone or during conversion from CVS to Git?

Since I am trying to build the sources from the Git mirror on GitHub, which is not described in the documentation, 
I thought that perhaps some of the m4 files get corrupted either while cloning of the Git repository or when the Git mirror is created from the CVS repository.

To rule that out, I fetch the sources for NetBSD 11 from FTP and CVS as documented (https://www.netbsd.org/docs/guide/en/chap-fetch.html) and I download the 
source sets that RVP pointed to (https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-11/latest/source/sets/)
I build the tools and release with the same build commands (`./build.sh -U -u -j11 -m amd64 -a x86_64 -O [...] release`), with a separate obj directory for each (abbreviated by [...]).
To ensure that builds are isolated.

However, file corruption does not seem to be the problem.
On my Linux host, in all cases, i.e., building from CVS checkout, building from the FTP sources, and building from the source sets, produces the same issue when nbm4 tries to preprocess libgmp's ASM files.

Additionally, I do what RVP suggests and diff the respective files from the most current source sets with those from my Git clone.
I do the following:

```
wget https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-11/20261102163432Z/source/sets/src.tgz
wget https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-11/20261102163432Z/source/sets/gnusrc.tgz
wget https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-11/20261102163432Z/source/sets/sharesrc.tgz
wget https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-11/20261102163432Z/source/sets/syssrc.tgz
for file in *.tgz; do tar -xzf $file -C ./; done
cd ./usr/src

diff external/lgpl3/gmp/dist/mpn/x86_64/sqr_diag_addlsh1.asm /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/dist/mpn/x86_64/sqr_diag_addlsh1.asm
diff external/lgpl3/gmp/lib/libgmp/arch/x86_64/config.m4 /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/arch/x86_64/config.m4 
diff external/lgpl3/gmp/dist/mpn/asm-defs.m4 /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/dist/mpn/asm-defs.m4 
diff external/lgpl3/gmp/dist/mpn/x86_64/x86_64-defs.m4 /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/dist/mpn/x86_64/x86_64-defs.m4 
```

For none of the four files, `diff` shows anything.
Consequently, I am quite certain that nothing is wrong with these files.


## The C compiler I am using is too new. Likely not.

On Pop!_OS 22.04 LTS, which is Ubuntu 22.04 LTS, he GNU C compiler is (`gcc --version`) "gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0".
On MacOS Sequoia, my C compiler is "Apple clang version 17.0.0 (clang-1700.0.13.5)"


## Are environment variables set to something?

To check that none of the env. variables $CC, $CFLAGS, $CXXFLAGS, $LDFLAGS contain values that could influence the build, I echo their values in the terminal in which I start the build.
None of the environment variables is set to anything.
I also do not set them in any of my dot files. 


## Is there space enough for the build?

On my Linux host, I have 63GB of free space and on MacOS there are more than 600GB free.
I believe in both cases this should be enough of free space for the build to succeed. 


## Is it a problem with my Linux host?

I was wondering if the issue is only appearing on my Linux host.
To rule that out, I try to build a NetBSD 11 release from sources from the Git mirror also on MacOS Sequoia, and FreeBSD 14-RELEASE.
On each OS, I do the following:

```
git clone --depth 1 https://github.com/NetBSD/src.git -b netbsd-11 netbsd-11-src
cd netbsd-11-src
./build.sh -U -u -j12 -m amd64 -a x86_64 -O /home/user/workspace/netbsd-11-obj release > release.log 2>&1
```

The, to me surprising, results are:

- Pop!_OS/Ubuntu 22.04 LTS: Build fails with nbm4 not being able to preprocess ASM files when building libgmp.
- MacOS Sequoia:            Build fails with nbm4 not being able to preprocess ASM files when building libgmp.
- FreeBSD 14-RELEASE :      I can build a release!


## What does nbm4 on FreeBSD say compared to my Linux host?

Since the build on FreeBSD succeeds, I inspect if the verbose output of nbm4 shows less errors or other errors than those produced on my Linux host.
I run:

```
/home/user/workspace/netbsd-11-obj/tooldir.FreeBSD-14.0-RELEASE-amd64/bin/nbm4 \
    -dV \
    -DCONFIG_TOP_SRCDIR=/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp/dummy \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/ \
    -I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn \
    -I/home/user/workspace/netbsd-11-obj/external/lgpl3/gmp/lib/libgmp \
    -DPIC \
    -DOPERATION_sqr_diag_addlsh1 \
    /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm > nbm4.log 2>&1
```

I count the m4_errors in the log file: `grep "m4_error" nbm4.log | sort | uniq | wc -l`.
On FreeBSD, I get 1126 compared to 1088 on Linux, even though it works in the former but not in the latter.

Since the original error in nbm4 preprocessing is about an unclosed parenthesis and since there are some m4_errors are about brackets, I search for respective errors.
Both on Linux and FreeBSD, I find the same messages in the logs:

```
`m4_error(`dont use a deflit as $1() because it loses the brackets (see deflit in asm-defs.m4 for more information)
`m4_error(`dont use a deflit as mpn_sqr_diag_addlsh1() because it loses the brackets (see deflit in asm-defs.m4 for more information)
```

Now, I do not know what else to do or search for :)
The only difference that I can find between the nbm4 binary on Linux, MacOS, and FreeBSD is the libraries against which it is dynamically linked...


## Conclusion for now...

I tested building NetBSD 11 from source on a Linux (Ubuntu 22.04 LTS), MacOS (Sequoia), and FreeBSD (14-RELEASE)
On FreeBSD 14-RELEASE, I can build a release of NetBSD 11 from source.
On Linux and MacOS, I cannot build a release from source.
On Linux and MacOS, the build fails when nbm4 tries to preprocess libgmp's ASM files. 

Therefore, I believe there is something wrong with the cross-build chain, I guess I stumbled on a bug.
My questions are:

a) Is there somebody on the mailing list who can build NetBSD 11 from source on a host OS that is not NetBSD or FreeBSD?
b) What am i supposed to do now? 
   - Shall I send a bug report?
   - If yes, to where shall I send it?
   - If yes, what of the above information shall I include in it? 


Thank you in advance!






On Tue, 2026-11-03 at 11:01 +0000, RVP wrote:
> [You don't often get email from rvp%sdf.org@localhost. Learn why this is important at
> https://aka.ms/LearnAboutSenderIdentification ;]
> 
> On Tue, 3 Nov 2026, Helge Pfeiffer wrote:
> 
> > /home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-
> > x86_64/bin/nbm4 -
> > DCONFIG_TOP_SRCDIR=/home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist -
> > I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp -
> > I/home/user/workspace/netbsd-11-
> > obj/external/lgpl3/gmp/lib/libgmp/dummy -I/home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/ -
> > I/home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn  -
> > I/home/user/workspace/netbsd-11-
> > obj/external/lgpl3/gmp/lib/libgmp  -DPIC   -DOPERATION_sqr_diag_addlsh1
> > /home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm
> > > sqr_diag_addlsh1.s
> > nbm4: unexpected end of input, unclosed parenthesis:
> >   /home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm
> > at line
> > 116
> > 
> 
> The error is `unexpected end of input, unclosed parenthesis'. Which means all
> the files (incl. the included files) were found, but, there's something wrong
> with parsing them.
> 
> Compare these 2 files, and whatever they include, against the sources which
> surely build[1]:
> 
> /home/user/workspace/netbsd-11-
> src/external/lgpl3/gmp/dist/mpn/x86_64/sqr_diag_addlsh1.asm
> /home/user/workspace/netbsd-11-
> src/external/lgpl3/gmp/lib/libgmp/arch/x86_64/config.m4
> 
> (I think these are the only 2 included files.)
> /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/dist/mpn/asm-defs.m4
> /home/user/workspace/netbsd-11-src/external/lgpl3/gmp/dist/mpn/x86_64/x86_64-
> defs.m4
> 
> If all 4 files compare OK, you can run this command again, as a test:
> 
> > /home/user/workspace/netbsd-11-obj/tooldir.Linux-5.19.0-76051900-generic-
> > x86_64/bin/nbm4 -
> > DCONFIG_TOP_SRCDIR=/home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist -
> > I/home/user/workspace/netbsd-11-src/external/lgpl3/gmp/lib/libgmp -
> > I/home/user/workspace/netbsd-11-
> > obj/external/lgpl3/gmp/lib/libgmp/dummy -I/home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/ -
> > I/home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn  -
> > I/home/user/workspace/netbsd-11-
> > obj/external/lgpl3/gmp/lib/libgmp  -DPIC   -DOPERATION_sqr_diag_addlsh1
> > /home/user/workspace/netbsd-11-
> > src/external/lgpl3/gmp/lib/libgmp/../../dist/mpn/x86_64/sqr_diag_addlsh1.asm
> > > sqr_diag_addlsh1.s
> > *** [sqr_diag_addlsh1.s] Error code 1
> > ```
> 
> 1. Is there enough space for the build? Not running out of disk space, right?
> 
> 2. You shouldn't set any custom $CC, $CFLAGS, $CXXFLAGS, $LDFLAGS etc.
>     These have a tendency to screw up the build in mysterious ways.
> 
> -RVP
> 
> [1]: https://nycdn.netbsd.org/pub/NetBSD-daily/netbsd-11/latest/source/sets/



Home | Main Index | Thread Index | Old Index