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

Fix building shared libraries on macOS with --enable-libtorch #1123

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 7 additions & 28 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu


# PLUMED_CHECK_LDFLAGS(flag)
# use it to check if a flag is available on this compiler
# use it to check if a flag is available for linking


# PLUMED_SEARCH_LIBS(function,search-libs[,action-if-found][,action-if-not-found][,other-libraries])
Expand Down Expand Up @@ -9664,26 +9664,13 @@ fi
if test $libtorch = true ; then
# disable as-needed in linking libraries (both static and shared)

save_CXXFLAGS="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS -Wl,--no-as-needed"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -Wl,--no-as-needed" >&5
$as_echo_n "checking whether $CXX accepts -Wl,--no-as-needed... " >&6; }
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--no-as-needed"
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether LDFLAGS can contain -Wl,--no-as-needed" >&5
$as_echo_n "checking whether LDFLAGS can contain -Wl,--no-as-needed... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{
Expand All @@ -9696,20 +9683,12 @@ if ac_fn_cxx_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not linking" >&5
$as_echo "not linking" >&6; }; CXXFLAGS="$save_CXXFLAGS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }; LDFLAGS="$save_LDFLAGS"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext

else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }; CXXFLAGS="$save_CXXFLAGS"

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

LDSHARED="$LDSHARED -Wl,--no-as-needed "

# CUDA and CPU libtorch libs have different libraries
# first test CUDA program
Expand Down
5 changes: 2 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ AC_DEFUN([PLUMED_CHECK_CFLAG], [
])

# PLUMED_CHECK_LDFLAGS(flag)
# use it to check if a flag is available on this compiler
# use it to check if a flag is available for linking
AC_DEFUN([PLUMED_CHECK_LDFLAGS], [
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $1"
Expand Down Expand Up @@ -935,8 +935,7 @@ fi
#added by luigibonati
if test $libtorch = true ; then
# disable as-needed in linking libraries (both static and shared)
PLUMED_CHECK_CXXFLAG([-Wl,--no-as-needed])
LDSHARED="$LDSHARED -Wl,--no-as-needed "
PLUMED_CHECK_LDFLAGS([-Wl,--no-as-needed])

# CUDA and CPU libtorch libs have different libraries
# first test CUDA program
Expand Down
Loading