From cfb1c798b9bbf4dbe875cfc63babfd677d7cddde Mon Sep 17 00:00:00 2001 From: Jouke Witteveen Date: Wed, 13 Mar 2024 16:03:21 +0100 Subject: [PATCH] Don't set the rpath when linking statically (#4125) --- bin/h5cc.in | 42 +++++++++++++++++++++--------------------- c++/src/h5c++.in | 42 +++++++++++++++++++++--------------------- fortran/src/h5fc.in | 28 ++++++++++++++-------------- 3 files changed, 56 insertions(+), 56 deletions(-) diff --git a/bin/h5cc.in b/bin/h5cc.in index e4d43684e3c..bb290df7aa4 100644 --- a/bin/h5cc.in +++ b/bin/h5cc.in @@ -327,27 +327,27 @@ if test "x$do_link" = "xyes"; then fi link_args="$link_args -L${libdir}" - case "$kind" in - gcc|linux*) - # MacOS X doesn't support the "-Wl,-rpath -Wl," style of linker flags. - # It appears to want none of them specified. - case "$host_os" in - darwin*) flag="" ;; - *) flag="-Wl,-rpath -Wl," ;; - esac - ;; - hpux*) flag="-Wl,+b -Wl," ;; - freebsd*|solaris*) flag="-R" ;; - rs6000*|aix*) flag="-L" ;; - sgi) flag="-rpath " ;; - *) flag="" ;; - esac - - if test -n "$flag"; then - shared_link="${flag}${libdir}" - fi - - if test "x$USE_SHARED_LIB" != "xyes"; then + if test "x$USE_SHARED_LIB" = "xyes"; then + case "$kind" in + gcc|linux*) + # MacOS X doesn't support the "-Wl,-rpath -Wl," style of linker flags. + # It appears to want none of them specified. + case "$host_os" in + darwin*) flag="" ;; + *) flag="-Wl,-rpath -Wl," ;; + esac + ;; + hpux*) flag="-Wl,+b -Wl," ;; + freebsd*|solaris*) flag="-R" ;; + rs6000*|aix*) flag="-L" ;; + sgi) flag="-rpath " ;; + *) flag="" ;; + esac + + if test -n "$flag"; then + shared_link="${flag}${libdir}" + fi + else # The "-lhdf5" & "-lhdf5_hl" flags are in here already...This is a static # compile though, so change it to the static version (.a) of the library. new_libraries="" diff --git a/c++/src/h5c++.in b/c++/src/h5c++.in index e666ba96b92..a5c584c8465 100644 --- a/c++/src/h5c++.in +++ b/c++/src/h5c++.in @@ -314,27 +314,27 @@ if test "x$do_link" = "xyes"; then fi link_args="$link_args -L${libdir}" - case "$kind" in - gcc|linux*) - # MacOS X doesn't support the "-Wl,-rpath -Wl," style of linker flags. - # It appears to want none of them specified. - case "$host_os" in - darwin*) flag="" ;; - *) flag="-Wl,-rpath -Wl," ;; - esac - ;; - hpux*) flag="-Wl,+b -Wl," ;; - freebsd*|solaris*) flag="-R" ;; - rs6000*|aix*) flag="-L" ;; - sgi) flag="-rpath " ;; - *) flag="" ;; - esac - - if test -n "$flag"; then - shared_link="${flag}${libdir}" - fi - - if test "x$USE_SHARED_LIB" != "xyes"; then + if test "x$USE_SHARED_LIB" = "xyes"; then + case "$kind" in + gcc|linux*) + # MacOS X doesn't support the "-Wl,-rpath -Wl," style of linker flags. + # It appears to want none of them specified. + case "$host_os" in + darwin*) flag="" ;; + *) flag="-Wl,-rpath -Wl," ;; + esac + ;; + hpux*) flag="-Wl,+b -Wl," ;; + freebsd*|solaris*) flag="-R" ;; + rs6000*|aix*) flag="-L" ;; + sgi) flag="-rpath " ;; + *) flag="" ;; + esac + + if test -n "$flag"; then + shared_link="${flag}${libdir}" + fi + else # The "-lhdf5" & "-lhdf5_hl" flags are in here already...This is a static # compile though, so change it to the static version (.a) of the library. new_libraries="" diff --git a/fortran/src/h5fc.in b/fortran/src/h5fc.in index 6d7329a183a..f92c523aaff 100644 --- a/fortran/src/h5fc.in +++ b/fortran/src/h5fc.in @@ -308,20 +308,20 @@ if test "x$do_link" = "xyes"; then fi link_args="$link_args -L${libdir}" - case "$host_os" in - linux*) flag="@fortran_linux_linker_option@-rpath -Wl," ;; - hpux*) flag="-Wl,+b -Wl," ;; - freebsd*|solaris*) flag="-R" ;; - rs6000*|aix*) flag="-L" ;; - sgi) flag="-rpath " ;; - *) flag="" ;; - esac - - if test -n "$flag"; then - shared_link="${flag}${libdir}" - fi - - if test "x$USE_SHARED_LIB" != "xyes"; then + if test "x$USE_SHARED_LIB" = "xyes"; then + case "$host_os" in + linux*) flag="@fortran_linux_linker_option@-rpath -Wl," ;; + hpux*) flag="-Wl,+b -Wl," ;; + freebsd*|solaris*) flag="-R" ;; + rs6000*|aix*) flag="-L" ;; + sgi) flag="-rpath " ;; + *) flag="" ;; + esac + + if test -n "$flag"; then + shared_link="${flag}${libdir}" + fi + else # The hdf5 library "-l" flags are in here already. This is a static # compile though, so change it to the static versions (.a) of the libraries. new_libraries=""