Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails on FreeBSD due to handling of fileno() #2043

Open
BarrySmith opened this issue Aug 3, 2021 · 7 comments
Open

Build fails on FreeBSD due to handling of fileno() #2043

BarrySmith opened this issue Aug 3, 2021 · 7 comments

Comments

@BarrySmith
Copy link

Machine platform:
uname_result(system='FreeBSD', node='petsc-fbsd02', release='12.1-RELEASE-p1', version='FreeBSD 12.1-RELEASE-p1 GENERIC', machine='amd64', processor='amd64')
Python version:
3.6.9 (default, Dec 10 2019, 01:10:29)
[GCC 4.2.1 Compatible FreeBSD Clang 6.0.1 (tags/RELEASE_601/final 335540)]

Error while building

             from ../config.h:612,
             from ncgen.y:13:

ncgen.y:22:12: error: expected identifier or '(' before '!' token
22 | extern int fileno(FILE*);
| ^~~~~~
ncgen.l:28:12: error: expected identifier or '(' before '!' token
28 | extern int fileno(FILE*);

The problem comes from netcdf include files prototyping fileno() while the Freebsd includes provide fileno() as a macro under some conditions.

Attached is the entire configure and build process.
netcdf.log

@DennisHeimbigner
Copy link
Collaborator

Try removing it from ncgen3/ncgeny.c (the actual parser).
Tell me if it works.

@BarrySmith
Copy link
Author

Sorry I missed this message earlier.

If I remove the fileno declarations from the four files ncgen3/ncgen.l ncgen.y and ncgen/ncgen.l ncgen.y and run make makeparse in those two directories then the code can be compiled.

But I don't know how to modify the netcdf build systems to do this.

@DennisHeimbigner
Copy link
Collaborator

Ok, try changing the files ncgen3/ncgen
try surrounding the fileno def in ncgen.l and ncgen.y
with

#ifndef fileno
...
#endif
and see if that fixes the problem.

@BarrySmith
Copy link
Author

Protecting just the fileno in ncgen.l and ncgen.y does not work because the build with configure; make does not actually regenerate the .c files (which for some unclear reason are in the repository even though they seem to be generated files). If I remove all the fileno() extern from all the files including the .c then netcdf builds fine.

I don't understand enough about the configure; make system to figure out why the .c files are not generated with the new values at configure; make time. BTW: I am building from a git clone but I don't think that should matter.

@DennisHeimbigner
Copy link
Collaborator

They are not regenerated so that users without bison/flex installed and still use the library.
The files that need fixing are, as you note, ncgen.y and ncgen.l.
However whenever we modify those we invoke the rebuild procedure
defined in Makefile.am
The question is if removing the externs altogether will build with OSX, Windows, etc.

@BarrySmith
Copy link
Author

Will this issue be fixed in the next point release of netcdf? This is preventing us from upgrading PETSc to use the latest NetCDF release and we don't want to be several releases behind.

@DennisHeimbigner
Copy link
Collaborator

I thought I put it in one of the PR, but let me check and create a separate PR for it.

DennisHeimbigner added a commit to DennisHeimbigner/netcdf-c that referenced this issue Nov 3, 2021
1. Issue Unidata#2043
   * FreeBSD build fails because of conflicts in defining the fileno() function. So removed all extern declarations of fileno.

2. Issue Unidata#2124
   * There were a couple of problems here.
     * I was conflating msys with mingw and they need separate handling of paths. So treat mingw like windows.
     * memio.c was not always writing the full content of the memory to file. Untested fix by properly accounting for zero size writes.
     * Fix bug when skipping white space in tst_xcache.c

3. Issue Unidata#2105
   * On MINGW, bash and other POSIX utilities use a mounted root directory,
     but executables compiled for Windows do not recognise the mount point.
     Ensure that Windows paths are used in tests of Windows executables.

4. Issue Unidata#2132
   * Apparently the Intel C compiler on OSX defines isnan etc.
     So disable declaration in dutil.c under that condition.

5. Fix and re-enable test_rcmerge.sh by allowing override of where to
   look for .rc files

6. CMakeLists.txt suppresses certain ncdump directory tests because of differences in printing floats/doubles.
   * Extend the list to include those that also fail under mingw.
   * Suppress the mingw tests in ncdump/Makefile.am
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

No branches or pull requests

2 participants