Skip to content

Locale mechanism for numeric parsing not supported on GCC11

The following attempt to compile LHAPDF 6.4.0 FTBFS @ x86_64-apple-darwin20.5.0 with GCC 11 from homebrew

#!/bin/sh -l
set -x
export CXX=g++-11
export CC=gcc-11
wget  https://www.hepforge.org/archive/lhapdf/LHAPDF-6.4.0.tar.gz
rm -rf LHAPDF-6.4.0
tar zxvf LHAPDF-6.4.0.tar.gz
cd LHAPDF-6.4.0
./configure
make -j 4

fails

user@host ~ % sh do.sh 
+ export CXX=g++-11
+ CXX=g++-11
+ export CC=gcc-11
+ CC=gcc-11
+ wget https://www.hepforge.org/archive/lhapdf/LHAPDF-6.4.0.tar.gz
..........SKIP............
+ cd LHAPDF-6.4.0
+ ./configure
checking for a BSD-compatible install... /usr/local/bin/ginstall -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/local/bin/gmkdir -p
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking for sw_vers... sw_vers
checking for style of include used by make... GNU
checking whether to compile using MPI... no
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++-11 accepts -g... yes
checking dependency style of g++-11... gcc3
checking whether g++-11 supports C++11 features by default... yes
checking for gcc... gcc-11
checking whether we are using the GNU C compiler... yes
checking whether gcc-11 accepts -g... yes
checking for gcc-11 option to accept ISO C89... none needed
checking whether gcc-11 understands -c and -o together... yes
checking dependency style of gcc-11... gcc3
checking whether ln -s works... yes
checking build system type... x86_64-apple-darwin20.5.0
checking host system type... x86_64-apple-darwin20.5.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/local/bin/gsed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc-11... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 786432
checking how to convert x86_64-apple-darwin20.5.0 file names to x86_64-apple-darwin20.5.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin20.5.0 file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... no
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc-11 object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for lipo... lipo
checking for otool... otool
checking for otool64... no
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking for -force_load linker flag... yes
checking how to run the C preprocessor... gcc-11 -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc-11 supports -fno-rtti -fno-exceptions... no
checking for gcc-11 option to produce PIC... -fno-common -DPIC
checking if gcc-11 PIC flag -fno-common -DPIC works... yes
checking if gcc-11 static flag -static works... no
checking if gcc-11 supports -c -o file.o... yes
checking if gcc-11 supports -c -o file.o... (cached) yes
checking whether the gcc-11 linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.5.0 dyld
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++-11 -E
checking for ld used by g++-11... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... no
checking whether the g++-11 linker (/usr/bin/ld) supports shared libraries... yes
checking for g++-11 option to produce PIC... -fno-common -DPIC
checking if g++-11 PIC flag -fno-common -DPIC works... yes
checking if g++-11 static flag -static works... no
checking if g++-11 supports -c -o file.o... yes
checking if g++-11 supports -c -o file.o... (cached) yes
checking whether the g++-11 linker (/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin20.5.0 dyld
checking how to hardcode library paths into programs... immediate
configure: Building LHAGLUE Fortran wrappers
configure: Building LHAGLUE C++ wrappers
checking for pdflatex... /Library/TeX/texbin/pdflatex
checking for doxygen... no
checking for python... /usr/bin/python
checking for python version... 2.7
checking for python platform... darwin
checking for python script directory... ${prefix}/lib/python2.7/site-packages
checking for python extension module directory... ${exec_prefix}/lib/python2.7/site-packages
checking for Cython >= 0.19... no
checking if the g++-11 compiler accepts the -pedantic flag... yes
checking if the g++-11 compiler accepts the -Wall flag... yes
checking if the g++-11 compiler accepts the -Wno-long-long flag... yes
checking if the g++-11 compiler accepts the -Qunused-arguments flag... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating src/yamlcpp/Makefile
config.status: creating include/Makefile
config.status: creating include/LHAPDF/Makefile
config.status: creating bin/Makefile
config.status: creating bin/lhapdf-config
config.status: creating examples/Makefile
config.status: creating tests/Makefile
config.status: creating doc/Makefile
config.status: creating doc/Doxyfile
config.status: creating lhapdf.pc
config.status: creating wrappers/Makefile
config.status: creating wrappers/python/Makefile
config.status: creating wrappers/python/setup.py
config.status: creating config/config.h
config.status: creating include/LHAPDF/Version.h
config.status: include/LHAPDF/Version.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands

****************************************************************
IMPORTANT INFORMATION ABOUT PDF SETS

LHAPDF no longer bundles PDF set data in the package tarball.
The sets are instead all stored online at
  http://lhapdfsets.web.cern.ch/lhapdfsets/current/
and you should install those that you wish to use into
  /usr/local/share/LHAPDF

The downloadable PDF sets are packaged as tarballs, which
must be expanded to be used. The simplest way to do this is with
the 'lhapdf' script, e.g. to install the CT10nlo PDF set:
  lhapdf install CT10nlo
The same effect can be achieved manually with, e.g.:
  wget http://lhapdfsets.web.cern.ch/lhapdfsets/current/CT10nlo.tar.gz -O- | tar xz -C /usr/local/share/LHAPDF

****************************************************************

+ make -j 4
Making all in src
...... SKIP ....
  CXX      GridPDF.lo
GridPDF.cc:170:7: error: 'locale_t' does not name a type
  170 |       locale_t _locale_set, _locale_prev;
      |       ^~~~~~~~
GridPDF.cc: In member function 'void LHAPDF::{anonymous}::NumParser::_set_locale()':
GridPDF.cc:152:9: error: '_locale_set' was not declared in this scope
  152 |         _locale_set = newlocale(LC_NUMERIC_MASK, "C", NULL);
      |         ^~~~~~~~~~~
GridPDF.cc:152:33: error: 'LC_NUMERIC_MASK' was not declared in this scope; did you mean 'LC_NUMERIC'?
  152 |         _locale_set = newlocale(LC_NUMERIC_MASK, "C", NULL);
      |                                 ^~~~~~~~~~~~~~~
      |                                 LC_NUMERIC
GridPDF.cc:152:23: error: 'newlocale' was not declared in this scope; did you mean 'setlocale'?
  152 |         _locale_set = newlocale(LC_NUMERIC_MASK, "C", NULL);
      |                       ^~~~~~~~~
      |                       setlocale
GridPDF.cc:153:9: error: '_locale_prev' was not declared in this scope
  153 |         _locale_prev = uselocale(_locale_set);
      |         ^~~~~~~~~~~~
GridPDF.cc:153:24: error: 'uselocale' was not declared in this scope; did you mean 'setlocale'?
  153 |         _locale_prev = uselocale(_locale_set);
      |                        ^~~~~~~~~
      |                        setlocale
GridPDF.cc: In member function 'void LHAPDF::{anonymous}::NumParser::_reset_locale()':
GridPDF.cc:160:24: error: '_locale_prev' was not declared in this scope
  160 |         if (!uselocale(_locale_prev)) {
      |                        ^~~~~~~~~~~~
GridPDF.cc:160:14: error: 'uselocale' was not declared in this scope; did you mean 'setlocale'?
  160 |         if (!uselocale(_locale_prev)) {
      |              ^~~~~~~~~
      |              setlocale
GridPDF.cc:163:20: error: '_locale_set' was not declared in this scope
  163 |         freelocale(_locale_set);
      |                    ^~~~~~~~~~~
GridPDF.cc:163:9: error: 'freelocale' was not declared in this scope; did you mean 'setlocale'?
  163 |         freelocale(_locale_set);
      |         ^~~~~~~~~~
      |         setlocale
make[2]: *** [GridPDF.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all-recursive] Error 1

It seems that sometimes one needs extra headers to be included for locale_t.

g++-11 --version reports

g++-11 (Homebrew GCC 11.2.0) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Best regards,

Andrii

Edited by Andy Buckley