Skip to content

Commit

Permalink
Fix building shared libraries on macOS with --enable-libtorch (#1123)
Browse files Browse the repository at this point in the history
  • Loading branch information
Luthaf authored Oct 10, 2024
1 parent 6d443b0 commit d72cc4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 31 deletions.
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

1 comment on commit d72cc4d

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

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

Found broken examples in automatic/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.