Skip to content

GCC 14 leads to compile errors in WRF/WPS compilation #2047

@SettRaziel

Description

@SettRaziel

Hej there.
I am maintaining a project to provide wrf/wps binaries for deployment in an ArchLinux environment.

Describe the bug
With the update to gcc 14 several new changes regarding compile flags were done.
These lead to a more restrict error handling since several flags that would only lead to warnings now lead to compile errors:

Looking on the changes with gcc 14 it seems they have change the flag: GCC 14

Implicit function declarations (-Werror=implicit-function-declaration)
It is no longer possible to call a function that has not been declared. In general, the solution is to include a header file with an appropriate function prototype. Note that GCC will perform further type checks based on the function prototype, which can reveal further type errors that require additional changes.

For well-known functions declared in standard headers, GCC provides fix-it hints with the appropriate #include directives:

error: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
    5 |   return strlen (s);
      |          ^~~~~~
note: include ‘<string.h>’ or provide a declaration of ‘strlen’
  +++ |+#include <string.h>
    1 |

When compiling the wrf model now these new restriction lead to these compile errors, e.g.

gcc  -I. -w -O3 -c   -DDM_PARALLEL -DLANDREAD_STUB=1 -DMAX_HISTORY=25 -DNMM_CORE=0   -c get_region_center.c
get_region_center.c: In function ‘get_region_center_’:
get_region_center.c:40:3: error: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration]
   40 |   memcpy(MemoryOrder,MemoryOrderIn,strlen1);
      |   ^~~~~~

To Reproduce
Steps to reproduce the behavior:
Testing environment is an ArchLinux VM with Linux Kernel 6.8.9.
Compiler is gcc/gfortran with version 14.1.1.
Current compile flags: Env. Variables
Additional parameter for compilation: 35 gfortran dm+sm
Precondition: Successful compilation of netcdf, netcdf-fortran, mpich, hdf5
Running my compile routines lead to a reproducible number of around 140 of these implicit compile errors.

Workaround
Adding to the compile flags: -Wimplicit-function-declaration (issue tracked in: wrf_archlinux)

Expected behavior
No implicit functions declaration throughout the code resolving the workaround to address these issues as warnings and not as errors with the flag which might lead to other side effects during the code compilation.

Additional context
Up to gcc/gfortran 13.2.2 these implicit declarations only lead to warnings, so up to that point the compilation runs successfully.
Are there plans to refactor the code base?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions