Unidata / UDUNITS-2

API and utility for arithmetic manipulation of units of physical quantities
http://www.unidata.ucar.edu/software/udunits
Other
59 stars 36 forks source link

udunits fails to build with clang under xcode 12 #97

Open aerorahul opened 3 years ago

aerorahul commented 3 years ago
../configure --prefix=/Users/runner/work/hpc-stack/hpc-stack/install-clang-mpich --disable-shared --enable-static
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ../build-aux/install-sh -c -d
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 for gcc... clang
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 clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of clang... gcc3
checking whether clang and cc understand -c and -o together... yes
checking how to run the C preprocessor... clang -E
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking for bison... bison -y
checking for flex... flex
checking lex output file root... lex.yy
checking lex library... -ll
checking whether yytext is a pointer... yes
checking whether we are using the GNU Fortran compiler... yes
checking whether gfortran-9 accepts -g... yes
checking for library containing dirname... none required
checking for library containing log10... none required
checking for library containing XML_StopParser... -lexpat
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -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 float.h usability... yes
checking float.h presence... yes
checking for float.h... yes
checking for inttypes.h... (cached) yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
configure: Checking for the CUNIT unit-testing package.
checking CUnit/CUnit.h usability... no
checking CUnit/CUnit.h presence... no
checking for CUnit/CUnit.h... no
configure: CUNIT not found.  Disabling unit-tests.
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for floor... yes
checking for memmove... yes
checking for memset... yes
checking for modf... yes
checking for pow... yes
checking for strcasecmp... yes
checking for strdup... yes
checking for strpbrk... yes
checking build system type... x86_64-apple-darwin19.6.0
checking host system type... x86_64-apple-darwin19.6.0
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by clang... /Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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... 196608
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-apple-darwin19.6.0 file names to x86_64-apple-darwin19.6.0 format... func_convert_file_noop
checking how to convert x86_64-apple-darwin19.6.0 file names to toolchain format... func_convert_file_noop
checking for /Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/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 clang object... ok
checking for sysroot... no
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 for dlfcn.h... yes
checking for objdir... .libs
checking if clang supports -fno-rtti -fno-exceptions... yes
checking for clang option to produce PIC... -fno-common -DPIC
checking if clang PIC flag -fno-common -DPIC works... yes
checking if clang static flag -static works... no
checking if clang supports -c -o file.o... yes
checking if clang supports -c -o file.o... (cached) yes
checking whether the clang linker (/Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin19.6.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... no
checking whether to build static libraries... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes
checking for gfortran-9 option to produce PIC... -fno-common
checking if gfortran-9 PIC flag -fno-common works... yes
checking if gfortran-9 static flag -static works... no
checking if gfortran-9 supports -c -o file.o... yes
checking if gfortran-9 supports -c -o file.o... (cached) yes
checking whether the gfortran-9 linker (/Applications/Xcode_12.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin19.6.0 dyld
checking how to hardcode library paths into programs... immediate
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating lib/Makefile
config.status: creating lib/xmlFailures/Makefile
config.status: creating lib/xmlSuccesses/Makefile
config.status: creating prog/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
+ make -j4
/Applications/Xcode_12.app/Contents/Developer/usr/bin/make  all-recursive
Making all in lib
/Applications/Xcode_12.app/Contents/Developer/usr/bin/make  all-recursive
Making all in xmlFailures
make[4]: Nothing to be done for `all'.
Making all in xmlSuccesses
make[4]: Nothing to be done for `all'.
depbase=`echo unitcore.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
    /bin/sh ../libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I../../lib -I..   -DNDEBUG  -fPIC -MT unitcore.lo -MD -MP -MF $depbase.Tpo -c -o unitcore.lo ../../lib/unitcore.c &&\
    mv -f $depbase.Tpo $depbase.Plo
depbase=`echo converter.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
    /bin/sh ../libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I../../lib -I..   -DNDEBUG  -fPIC -MT converter.lo -MD -MP -MF $depbase.Tpo -c -o converter.lo ../../lib/converter.c &&\
    mv -f $depbase.Tpo $depbase.Plo
depbase=`echo formatter.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
    /bin/sh ../libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I../../lib -I..   -DNDEBUG  -fPIC -MT formatter.lo -MD -MP -MF $depbase.Tpo -c -o formatter.lo ../../lib/formatter.c &&\
    mv -f $depbase.Tpo $depbase.Plo
depbase=`echo idToUnitMap.lo | sed 's|[^/]*$|.deps/&|;s|\.lo$||'`;\
    /bin/sh ../libtool  --tag=CC   --mode=compile clang -DHAVE_CONFIG_H -I. -I../../lib -I..   -DNDEBUG  -fPIC -MT idToUnitMap.lo -MD -MP -MF $depbase.Tpo -c -o idToUnitMap.lo ../../lib/idToUnitMap.c &&\
    mv -f $depbase.Tpo $depbase.Plo
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I../../lib -I.. -DNDEBUG -fPIC -MT converter.lo -MD -MP -MF .deps/converter.Tpo -c ../../lib/converter.c -o converter.o
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I../../lib -I.. -DNDEBUG -fPIC -MT unitcore.lo -MD -MP -MF .deps/unitcore.Tpo -c ../../lib/unitcore.c -o unitcore.o
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I../../lib -I.. -DNDEBUG -fPIC -MT formatter.lo -MD -MP -MF .deps/formatter.Tpo -c ../../lib/formatter.c -o formatter.o
libtool: compile:  clang -DHAVE_CONFIG_H -I. -I../../lib -I.. -DNDEBUG -fPIC -MT idToUnitMap.lo -MD -MP -MF .deps/idToUnitMap.Tpo -c ../../lib/idToUnitMap.c -o idToUnitMap.o
../../lib/converter.c:187:12: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Werror,-Wimplicit-function-declaration]
    return snprintf(buf, max, "%s", variable);
           ^
../../lib/converter.c:187:12: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
1 error generated.
../../lib/unitcore.c:415:19: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
    int n = (int)(abs(numer)/denom);
                  ^
../../lib/unitcore.c:415:19: note: use function 'fabs' instead
    int n = (int)(abs(numer)/denom);
                  ^~~
                  fabs
../../lib/formatter.c:234:8: error: implicitly declaring library function 'snprintf' with type 'int (char *, unsigned long, const char *, ...)' [-Werror,-Wimplicit-function-declaration]
            : snprintf(buf, size, "%s", id);
              ^
../../lib/formatter.c:234:8: note: include the header <stdio.h> or explicitly provide a declaration for 'snprintf'
make[4]: *** [converter.lo] Error 1
make[4]: *** Waiting for unfinished jobs....
1 error generated.
make[4]: *** [formatter.lo] Error 1
1 warning generated.
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
semmerson commented 3 years ago

Working on it.

tenomoto commented 3 years ago

I maintain udunits on MacPorts. To circumvent the problem, I initially used -Wno-error=implicit-function-declaration, but it is not the right way because it will break on Apple Silicon. The solution was to properly declare a prototype. See https://github.com/macports/macports-ports/commit/19abd99be97c0193ebb4b86d008be1114c5eaac8