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

Duplicate symbol isinf and isnan on macOS using Intel OneAPI #2132

Closed
kgerheiser opened this issue Oct 28, 2021 · 9 comments · Fixed by #2559
Closed

Duplicate symbol isinf and isnan on macOS using Intel OneAPI #2132

kgerheiser opened this issue Oct 28, 2021 · 9 comments · Fixed by #2559

Comments

@kgerheiser
Copy link

kgerheiser commented Oct 28, 2021

I'm building NetCDF 4.8.1 and I'm getting duplicate symbol on macOS (11.6.0, XCode 13.0) using Intel OneAPI 2021.2.0.

duplicate symbol '_isinf' in:
    ../libdispatch/.libs/libdispatch.a(libdispatch_la-dutil.o)
    /opt/intel/oneapi/compiler/2021.2.0/mac/bin/intel64/../../compiler/lib/libimf.a(isinf.o)
duplicate symbol '_isnan' in:
    ../libdispatch/.libs/libdispatch.a(libdispatch_la-dutil.o)
    /opt/intel/oneapi/compiler/2021.2.0/mac/bin/intel64/../../compiler/lib/libimf.a(isnan.o)
ld: 2 duplicate symbols for architecture x86_64

Intel declares isnan and isInf in libimf, and NetCDF declares it here (for __APPLE__ only):

#ifdef __APPLE__

Not sure why that's necessary in the first place, but if it's required maybe it should check if __APPLE__ and also not __INTEL_COMPILER .

@DennisHeimbigner
Copy link
Collaborator

Probably historical. At some point, it is possible that OSX did not define isinf and isnan.
If you remove those apple specific decls, does everything work?
If so, then I will just remove them.

@kgerheiser
Copy link
Author

Interestingly, it was added pretty recently with this commit:

31dee0c

I was able to build using NetCDF-4.7.4 which doesn't contain that change. I'm pretty sure Intel will compile, but maybe it's an issue with Clang or GCC?

Maybe @WardF has some insight?

@DennisHeimbigner
Copy link
Collaborator

BTW is __INTEL_COMPILER the actual preprocessor macro for the intel compiler?
Do you know what C/C++ compiler is standard on osx?

@kgerheiser
Copy link
Author

Yes, __INTEL_COMPILER is the macro. Clang is the default compiler.

@DennisHeimbigner
Copy link
Collaborator

Then your solution is the best, I think.

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
@DennisHeimbigner
Copy link
Collaborator

Fixed by #2138

@MicroTed
Copy link

I almost opened a new issue, but found this one....

When compiling 4.9.0 on macos (big sur) with FC=ifort CC=clang (13.0), configure sets HAVE_DECL_ISINF=1. The logic in dutil.c around the isinf/isnan functions does not use this flag, but instead has

#if ! defined __INTEL_COMPILER 
#if defined __APPLE__ 

which causes the isinf/isnan code to be included and can result in a link error for duplicate definition. (It works correctly if CC=icc instead of clang). I recompiled after inserting an additional condition on HAVE_DECL_ISINF into dutil.c, and it seems to work fine.

Obviously netcdf-c doesn't use the fortran compiler, but I set FC out of habit and it probably has no effect. Is there a reason not to use the HAVE_DECL_ISINF flag in dutil.c?

It is also possible that there is still something screwy in my system (just updated to Big Sur), but excluding those functions fixed a duplicate symbol error I got when compiling WRF.

@WardF
Copy link
Member

WardF commented Nov 16, 2022

I'm working on getting v4.9.1-rc2 out the door right now, this seems like a straightforward fix, and I'm working on MacOS so it should be easy to test. Thanks!

@MicroTed
Copy link

I should add one detail that I was compiling with --disable-shared, which may or may not make any difference in linking error. Also 'make check' was happy in either case (before/after change to dutil.c), so I don't really know.

I think I just used the conditional in include/isnan.h:

#if ! (defined(isinf) || HAVE_DECL_ISINF)

clrpackages pushed a commit to clearlinux-pkgs/netcdf that referenced this issue Feb 9, 2023
DWesl (26):
      DEV: Add autools-generated files to .gitignore.
      CI: Add Cygwin CI run.
      CI, TST: Check that test plugins don't get installed with DESTDIR
      BLD: Get netCDF4 build working on Windows.
      DEV, TST: Move test plugins to check_LTLIBRARIES instead of tmp_LTLIBRARIES.
      BLD: Try fixing the export-symbols problem on MinGW
      CI, DBG: Upload MinGW test logs on failure.
      TST: Add code for MinGW to findplugin.sh.
      TST: Mark tst_filter.sh XFAIL on MinGW
      CI: Try to skip failing NCZarr Plugin tests on MinGW
      TST: Mark NCZarr plugins XFAIL on MinGW
      TST: tst_h_strbug and tst_h_refs pass on Cygwin now
      BLD: Use host platform instead of build platform for platform-specific checks.
      CI: Prep Cygwin CI run for adding CMake build.
      BLD: Get CMake build compiling on Cygwin.
      BUG: Robustify nulldup definition.
      TST: Mark nczarr s3 cleanup test XFAIL on Cygwin instead of skipping.
      CI: Disable CMake tests on Cygwin and MinGW.
      CI: Revert Windows CI run on push.
      BLD: Fix syntax in configure.ac.
      BLD: Avoid specifying -version-info and -avoid-version
      BLD: Specify -avoid-version on MinGW and Cygwin; -version-info otherwise
      STY: Move nulldup backup definition from cp_win32.c to ncconfigure.h
      FIX: ifndef requires no parentheses.
      BLD: Declare nulldup backup definition static not extern
      CI: Change autotools CI build to out-of-tree build.

Dan Ibanez (1):
      Rename variable to avoid function name conflict

Dennis Heimbigner (65):
      Fix nc_def_var_fletcher32 operation
      Update release notes
      Use env variable USERPROFILE instead of HOME for windows and mingw.
      Update release notes
      restart github
      Make public a limited API for programmatic access to internal .rc tables
      Update Release Notes
      Fix errors:
      Use env variable USERPROFILE instead of HOME for windows and mingw.
      Cleanup szip handling some more
      Update release notes
      fix RELEASENOTES
      undebug
      Minimal changes to RELEASENOTES to get a working patch
      force rebuild
      Fix way CMake handle -DPLUGIN_INSTALL_DIR
      Update Release notes
      debug1
      Ensure that netcdf_json.h does not interfere with ncjson.
      Update RELEASENOTES.md
      Fix bad cmake install location
      Fix some bugs in the blosc filter wrapper
      Update release notes
      Update blosc testing
      Provide a default enum const when fill value does not match any enum const.
      Update release notes
      debug1
      Fix support for reading arrays of HDF5 fixed size strings
      Windows specific blosc fixed
      debug1
      nodebug
      Add option to control accessing external servers
      Add support for Zarr string type to NCZarr
      Update release notes"
      update release notes
      Fix LGTM alert: too few args
      Update nczarr documentation
      update file permission
      Fix some problems with PR Unidata/netcdf-c#2492
      Update release notes
      Update Release Notes
      Fix missing files
      Catch Xarray dimension inconsistencies
      Fix some addtional errors in NCZarr
      Update release notes
      update file permission
      Cleanup built test sources in nczarr_test
      restore
      Move construction of VERSION file to end of the build
      Turn off extraneous debug output
      test
      test
      test2
      merged
      Fix race condition in ncdump (and other) tests.
      Update RELEASE notes
      test3
      Restore DAP4 functionality and testing
      test4
      ckp
      Suppress nczarr_test/tst_unknown filter test (and its nczarr_test equivalen)
      Update Release Notes
      retry
      Fix infinite loop in file inferencing
      Fix Memory Leak

Dženan Zukić (1):
      Fix AWS SDK linking errors

Edward Hartnett (37):
      checking doxygen version
      updated Doxyfile.in
      turned on WARN_AS_ERROR and added documentation build to CI
      fixed case of --enable-doxygen but doxygen not found
      installing doxygen in CI when needed
      installing doxygen in CI when needed
      installing doxygen in CI when needed
      installing doxygen in CI when needed
      installing doxygen in CI when needed
      change to trigger CI
      updated release notes
      change to rerun CI
      change to trigger CI
      change to trigger CI
      fixed RELEASE_NOTES.md
      fixed missing quote
      fixed missing quote
      changed backslash to and
      change to trigger CI
      change to trigger CI
      moved quantize error documentation
      fix and test quantize mode for NC_CLASSIC_MODEL
      documentation
      code and documentation cleanup
      code and documentation cleanup
      adding pre-processor constant NC_MAX_FILENAME to nc_tests.h
      more quantize testing
      more quantize testing
      more quantize testing
      more quantize testing
      more testing of quantize
      more testing of quantize
      more testing of quantize
      more testing of quantize
      more testing of quantize
      more testing of quantize
      more testing of quantize

Greg Sjaardema (2):
      Minor update to doxygen function documentation
      For loop initial declarations are only allowed in C99 mode

James Edwards (1):
      make UDF0 not require NC_NETCDF4

Jim Edwards (3):
      add udf2 fix magic
      remove whitespace changes
      fix syntax error

Magnus Ulimoen (3):
      Prevent cmake writing to source dir
      fix musl build
      Use int64_t instead of __int64

Stephen Herbener (3):
      Added an ncdump -t calendars test using variable length string
      Modifications to enable the use of variable length string attributes for both
      Moved the new ncdump_tst_calendars_nc4 test to the "USE_HDF5" section.

Ward Fisher (103):
      Add manual GitHub actions triggers for the tests.
      Added a check for xml2-config as a test for the libxml2-dev header files.
      Add libxml2 install to mingw GitHub actions.
      Generate nc_test/run_pnetcdf_tests.sh when using cmake, in support of Unidata/netcdf-c#2435
      Fixing cmake-based run_pnetcdf_tests.sh
      Building test programs invoked by run_pnetcdf_tests.sh
      Fix cache check.
      Run one-off tests first.
      Fix a typo.
      Fix a typo.
      Make pnetcdf tests run in serial fashion when using cmake
      Work in a one-line change as originally suggested in Unidata/netcdf-c#2426.
      Updated CMakeLists to avoid the error described in Unidata/netcdf-c#2271
      configure.ac logic for disabling quantize.
      Update release notes.
      Guard _declspec(dllexport) in support of Unidata/netcdf-c#2446
      Changed attribute case in documentation in support of Unidata/netcdf-c#2481
      Address jump-misses-init issue.
      Remove stray conflict markers that made their way into the branch.
      Adding all-error-codes.md back in to distribution documentation.
      Remove obsolete tags from Doxyfile.
      Updating doxygen files.
      Doxygen update, reorganizing.
      Update hdf5 version in github actions.
      Added an additional check for zstd.h in configure.ac
      Clean up (on linux) an issue with uintptr_t
      Add a check for stdint.h in order to fix a weird issue where libzstd-dev, when present, was masking a missing data type declaration.
      Adding additional flags to nc-config to indicate presence of newer functionality, and plugin directory location.
      Added plugin directory to nc-config
      Add various newer options to nc-config
      Updated release notes.
      Updated release notes.
      Adding NC_HAS_BLOSC and NC_HAS_BZ2 to netcdf_meta.h in support of Unidata/netcdf-c#2511
      Update cmakelists.txt in support of Unidata/netcdf-c#2511
      Updated release notes.
      Updated test logic in nc-config.in file.
      Corrected an error.
      Correct nccopy4 dependency on tst_fillbug.
      Added a dependency to tst_nans to nccopy4
      Added additional dependencies.
      Add LDFLAGS for two plugins, nczstdfilters and nczhdf5filters, in support of Unidata/netcdf-c#2478
      Add prepreqs to ncdump/tst_nccopy4, revising some race condition related errors.
      Add blank filter quickstart guide file.
      Updated release notes.
      Working towards writing the quick start for plugins and integrating it into doxygen.
      Roughed in initial quickstart
      Working on filter quickstart document.
      Continuing to flesh out the quick-start guide.
      Further editing.
      Updated SO version.
      Updated for next release cycle.
      Manually bump version in diff-compare to get RC1 out the door, this will need to be automatically excluded from the test at some point otherwise we will see this test fail every time the VERSION string changes.
      Copy zmap reference files for cmake-based tests.
      Update release notes.
      Add generated files to distclean.
      Correct an issue with 'make distcheck' where out-of-source tests were failing.
      Working on another make distcheck failure.
      Correct an issue observed in out-of-source builds.
      Updated RELEASE_NOTES
      Updated the relees notes.
      Correct a typo in support of Unidata/netcdf-c#2534
      Make dap4 reference dap instead of hard-wired to be disabled.
      Add a check for HAVE_DECL_ISINF and HAVE_DECL_ISNAN in support of Unidata/netcdf-c#2132
      Fix mismatched arguments warning in CMakeLists.txt
      Restore release date for 4.9.1 RC1 in release notes.
      Added target release date for RC2.
      Supported headers for hdf4 are not installed in actions, and there does not appear (currently) to be an easy way to reinstall these.
      Update release date.
      DAP4 is back on for cmake-based builds.
      Add an old static file.
      Added another old static html page in preparation for updating.
      Fix a logic error re: DAP4 tests, when DAP4 is specified, but hdf5/netcdf4 support is disabled.
      Added S3 status to libnetcdf.settings, turned byterange on by default.
      Cleaning up NCZARR_S3 summary, turning on byterange by default.
      Add libcurl-dev to cygwin github actions
      Correct libcurl development package.
      Add libiconv-devel to cygwin CI
      Correct version string change that should not have ended up in this branch.
      Correct logic for running DAP4 tests when HDF5 is not enabled.
      Update whitespace.
      Correct lingering merge issue.
      Merging Unidata/netcdf-c#2583 manually into the v4.9.1 wellspring branch.
      Fix a doxygen warning-treated-as-error
      Add new test, tst_calendars_nc4.sh, to automake-based builds.
      Fix an issue I introduced with make distcheck
      Remove internal flag from byterange documentation.
      Update additional documentation infrastructure.
      Update github action configuration scripts.
      Small tweak.
      Updating filter documentation with a quickstart guide.
      Remove dangling file.
      A bit of doxygen cleanup.
      re-added quickstart filters document.
      Clean up some garbled output from Doxygen.
      Change in support of Unidata/netcdf-c#2599
      Update release notes with v4.9.1 release date.
      Updating for v4.9.1 release.
      Updating in preparation for 4.9.1
      Updating in prep for the v4.9.1 release.
      Updated .gitignore.
      Added autoconf generated files for a stand-alone release.
      Added generated manfile for a stand-alone release.
      Update Release Notes with proper release date.

Yuriy Chernyshov (1):
      Fix typo in CMakeLists.txt

wkliao (3):
      use malloc to increase read chunk size from 1 KB to 4 MB
      typo fix
      replace 4194304 with READ_BLOCK_SIZE
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

Successfully merging a pull request may close this issue.

4 participants