-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
cfitsio: add Darwin support #41254
Conversation
# 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}" |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- 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}" |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
Thanks |
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
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)