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

cfitsio: add Darwin support #41254

Merged
merged 3 commits into from Jun 1, 2018
Merged

cfitsio: add Darwin support #41254

merged 3 commits into from Jun 1, 2018

Conversation

smaret
Copy link
Member

@smaret smaret commented May 30, 2018

Motivation for this change

This PR adds support for the cfitsio library on Darwin. A couple of changes have been made in the configure script:

1 - The detection of /usr/bin/curl-config on Darwin has been turned off. As a result, the library does not support HTTPS, but I believe it is not supported on Linux either.
2 - The flags to build a universal library have been removed because they cause a link error (missing i386 symbols).

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

# Build 'Universal' binaries (i386 & x86_64 architectures) and
# use rpath token on Darwin 10.x or newer:
- SHLIB_LD="$CC -dynamiclib $C_UNIV_SWITCH -headerpad_max_install_names -install_name @rpath/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
+ SHLIB_LD="$CC -dynamiclib -headerpad_max_install_names -install_name @rpath/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use rpaths on darwin, using @rpath/libcfitsio.5.dylib as the install_name will result in broken binaries/libraries since the stdenv expects us to be using absolute references to libraries instead.

If a package doesn't do this correctly we generally either patch the build or use install_name_tool to fixup the references at the end of the build. eg.

{
  postPatch = ''
    substituteInPlace cfitsio-universal/configure \
        --replace "-install_name @rpath/lib" "-install_name $out/lib"
  '';
}

# Shared-only build
buildFlags = "shared";
patchPhase = '' sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@smaret
Copy link
Member Author

smaret commented May 31, 2018

Thanks for the review @LnL7. I've fixed the rpath issue in d629dae.

- SHLIB_LD="$CC -dynamiclib $C_UNIV_SWITCH -headerpad_max_install_names -install_name @rpath/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
- ;;
- esac
+ SHLIB_LD="$CC -dynamiclib -install_name ${out}/lib\${PACKAGE}.\${CFITSIO_SONAME}\${SHLIB_SUFFIX} -compatibility_version \${CFITSIO_SONAME} -current_version \${CFITSIO_SONAME}.\${CFITSIO_MAJOR}.\${CFITSIO_MINOR}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${out}/lib/ is missing a trailing slash.

You can check the install name like this:

$ otool -D result/lib/libcfitsio.5.dylib
result/lib/libcfitsio.5.dylib:
/nix/store/iv4p3lnqck320m29c0nd4xz2abfc2f2p-cfitsio-3.430/libcfitsio.5.dylib
$ file /nix/store/iv4p3lnqck320m29c0nd4xz2abfc2f2p-cfitsio-3.430/libcfitsio.5.dylib
/nix/store/iv4p3lnqck320m29c0nd4xz2abfc2f2p-cfitsio-3.430/libcfitsio.5.dylib: cannot open `/nix/store/iv4p3lnqck320m29c0nd4xz2abfc2f2p-cfitsio-3.430/libcfitsio.5.dylib' (No such file or directory)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, thanks for noticing. Fixed with 73bc473.

@LnL7 LnL7 merged commit e126a8c into NixOS:master Jun 1, 2018
@LnL7
Copy link
Member

LnL7 commented Jun 1, 2018

Thanks

@smaret smaret deleted the cfitsio branch June 13, 2018 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants