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

Make configure use -lc++ for clang #170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jfowkes
Copy link
Contributor

@jfowkes jfowkes commented Oct 30, 2023

Resolves #165

@barracuda156 please test.

@jfowkes jfowkes linked an issue Oct 30, 2023 that may be closed by this pull request
@barracuda156
Copy link

@jfowkes Let me try and update you soon.

The title is a bit inaccurate: clang is not specific to macOS (recent releases of FreeBSD use clang as a default compiler, AFAIK), and macOS may be using gcc (no clangs on macOS prior to 10.6, and gcc can be used on any modern macOS, just not being a default).

@jfowkes jfowkes changed the title Make configure use -lc++ on macOS Make configure use -lc++ for clang Oct 30, 2023
@jfowkes jfowkes force-pushed the 165-c++-runtime-should-not-be-hardcoded-in-configure branch from 6ce2ee7 to b63b292 Compare October 30, 2023 14:20
@barracuda156
Copy link

barracuda156 commented Oct 30, 2023

@jfowkes Something does not work still. The build is fine with gcc13, but broken with clang16, as the correct flag is not passed:

ar cru libspral.a src/blas_iface.o src/core_analyse.o src/compat.o  src/cuda/cuda_nocuda.o src/hw_topology/hw_topology.o src/hw_topology/guess_topology.o src/lapack_iface.o src/lsmr.o interfaces/C/lsmr.o src/match_order.o src/matrix_util.o interfaces/C/matrix_util.o src/metis5_wrapper.o src/omp.o src/pgm.o src/rutherford_boeing.o interfaces/C/rutherford_boeing.o src/scaling.o interfaces/C/scaling.o src/timer.o src/random.o interfaces/C/random.o src/random_matrix.o interfaces/C/random_matrix.o  src/ssids/gpu/subtree_no_cuda.o src/ssids/akeep.o src/ssids/anal.o src/ssids/contrib.o src/ssids/contrib_free.o src/ssids/datatypes.o src/ssids/fkeep.o src/ssids/inform.o src/ssids/profile.o src/ssids/profile_iface.o src/ssids/ssids.o src/ssids/subtree.o src/ssids/cpu/cpu_iface.o src/ssids/cpu/NumericSubtree.o src/ssids/cpu/subtree.o src/ssids/cpu/SymbolicSubtree.o src/ssids/cpu/ThreadStats.o src/ssids/cpu/kernels/cholesky.o src/ssids/cpu/kernels/ldlt_app.o src/ssids/cpu/kernels/ldlt_nopiv.o src/ssids/cpu/kernels/ldlt_tpp.o src/ssids/cpu/kernels/wrappers.o interfaces/C/ssids.o src/ssmfe/ssmfe.o src/ssmfe/core.o src/ssmfe/expert.o interfaces/C/ssmfe.o interfaces/C/ssmfe_core.o interfaces/C/ssmfe_expert.o 
ranlib libspral.a
/opt/local/bin/gfortran-mp-13 -fopenmp -pipe -Os -m64 -c -o driver/cuda_helper_nogpu.o driver/cuda_helper_nogpu.f90
/opt/local/bin/gfortran-mp-13 -DHAVE_CONFIG_H -I.   -I/opt/local/include -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -fopenmp -pipe -Os -m64 -c -o driver/spral_ssids.o driver/spral_ssids.F90
/opt/local/bin/gfortran-mp-13 -fopenmp -pipe -Os -m64  -L/opt/local/lib -Wl,-headerpad_max_install_names -L/opt/local/lib/libomp -lomp -Wl,-rpath,/opt/local/lib/libgcc -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -arch arm64 -o spral_ssids driver/spral_ssids.o  driver/cuda_helper_nogpu.o -L. -lspral -lmetis -llapack -lblas  -L/opt/local/lib -lhwloc -lm -lxml2 -lpthread -lxml2 -lz -llzma -liconv -licui18n -licuuc -licudata -L/opt/local/lib -L/opt/local/lib/libomp -L/opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0 -L/opt/local/lib/gcc13/gcc/arm64-apple-darwin23/13.2.0/../../.. -lomp -lgfortran -lemutls_w -lquadmath -lstdc++ 
ld: warning: duplicate -rpath '/opt/local/lib/libgcc' ignored
Undefined symbols for architecture arm64:
  "__ZNSt20bad_array_new_lengthC1Ev", referenced from:
      __ZSt28__throw_bad_array_new_lengthB7v160006v in libspral.a(guess_topology.o)
      __ZSt28__throw_bad_array_new_lengthB7v160006v in libspral.a(NumericSubtree.o)
      __ZSt28__throw_bad_array_new_lengthB7v160006v in libspral.a(SymbolicSubtree.o)
      __ZSt28__throw_bad_array_new_lengthB7v160006v in libspral.a(ldlt_app.o)
  "__ZNSt3__119__shared_weak_count14__release_weakEv", referenced from:
      __ZN5spral5ssids3cpu12assemble_preIdNS1_11AppendAllocIdEENS1_14BuddyAllocatorIdNSt3__19allocatorIdEEEEEEvbiRKNS1_12SymbolicNodeEPPvRNS1_11NumericNodeIT_T1_EERT0_RSH_RNS6_6vectorINS1_9WorkspaceENS7_ISO_EEEEPKSG_ST_ in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu13assemble_postIdNS1_14BuddyAllocatorIdNSt3__19allocatorIdEEEEEEviRKNS1_12SymbolicNodeEPPvRNS1_11NumericNodeIT_T0_EERSF_RNS4_6vectorINS1_9WorkspaceENS5_ISK_EEEE in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu23SmallLeafNumericSubtreeILb1EdNS1_11AppendAllocIdEENS1_14BuddyAllocatorIdNSt3__19allocatorIdEEEEE8assembleEiRKNS1_12SymbolicNodeEPNS1_11NumericNodeIdS9_EERS4_RS9_PiPKdSL_ in libspral.a(NumericSubtree.o)
      __ZNSt3__110shared_ptrIN5spral5ssids3cpu21append_alloc_internal4PoolEED2B7v160006Ev in libspral.a(NumericSubtree.o)
      __ZNSt3__110shared_ptrIN5spral5ssids3cpu20buddy_alloc_internal5TableINS_9allocatorIcEEEEED2B7v160006Ev in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu23SmallLeafNumericSubtreeILb0EdNS1_11AppendAllocIdEENS1_14BuddyAllocatorIdNSt3__19allocatorIdEEEEE12assemble_preERKNS1_12SymbolicNodeERNS1_11NumericNodeIdS9_EERS4_RS9_PiPKdSL_ in libspral.a(NumericSubtree.o)
      __ZNSt3__110shared_ptrIiED2B7v160006Ev in libspral.a(SymbolicSubtree.o)
      ...
  "__ZNSt3__119__shared_weak_countD2Ev", referenced from:
      __ZNSt3__120__shared_ptr_pointerIPN5spral5ssids3cpu21append_alloc_internal4PoolENS_10shared_ptrIS5_E27__shared_ptr_default_deleteIS5_S5_EENS_9allocatorIS5_EEED1Ev in libspral.a(NumericSubtree.o)
      __ZNSt3__120__shared_ptr_pointerIPN5spral5ssids3cpu21append_alloc_internal4PoolENS_10shared_ptrIS5_E27__shared_ptr_default_deleteIS5_S5_EENS_9allocatorIS5_EEED0Ev in libspral.a(NumericSubtree.o)
      __ZNSt3__120__shared_ptr_pointerIPN5spral5ssids3cpu20buddy_alloc_internal5TableINS_9allocatorIcEEEENS_10shared_ptrIS8_E27__shared_ptr_default_deleteIS8_S8_EENS6_IS8_EEED1Ev in libspral.a(NumericSubtree.o)
      __ZNSt3__120__shared_ptr_pointerIPN5spral5ssids3cpu20buddy_alloc_internal5TableINS_9allocatorIcEEEENS_10shared_ptrIS8_E27__shared_ptr_default_deleteIS8_S8_EENS6_IS8_EEED0Ev in libspral.a(NumericSubtree.o)
      __ZNSt3__120__shared_ptr_pointerIPiNS_14default_deleteIA_iEENS_9allocatorIiEEED1Ev in libspral.a(SymbolicSubtree.o)
      __ZNSt3__120__shared_ptr_pointerIPiNS_14default_deleteIA_iEENS_9allocatorIiEEED0Ev in libspral.a(SymbolicSubtree.o)
  "__ZNSt3__15alignEmmRPvRm", referenced from:
      __ZN5spral5ssids3cpu20buddy_alloc_internal4PageINSt3__19allocatorIcEEEC2EmRKS6_ in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu9Workspace15alloc_and_alignEm in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu21append_alloc_internal4Pool8allocateEm in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu20buddy_alloc_internal4PageINSt3__19allocatorIcEEEC2EmRKS6_ in libspral.a(ldlt_app.o)
      __ZN5spral5ssids3cpu9Workspace15alloc_and_alignEm in libspral.a(ldlt_app.o)
  "__ZNSt9bad_allocC1Ev", referenced from:
      __ZN5spral5ssids3cpu21append_alloc_internal4PageC2EmPS3_ in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu9Workspace15alloc_and_alignEm in libspral.a(NumericSubtree.o)
      __ZN5spral5ssids3cpu9Workspace15alloc_and_alignEm in libspral.a(ldlt_app.o)
  "__ZTINSt3__119__shared_weak_countE", referenced from:
      __ZTINSt3__120__shared_ptr_pointerIPN5spral5ssids3cpu21append_alloc_internal4PoolENS_10shared_ptrIS5_E27__shared_ptr_default_deleteIS5_S5_EENS_9allocatorIS5_EEEE in libspral.a(NumericSubtree.o)
      __ZTINSt3__120__shared_ptr_pointerIPN5spral5ssids3cpu20buddy_alloc_internal5TableINS_9allocatorIcEEEENS_10shared_ptrIS8_E27__shared_ptr_default_deleteIS8_S8_EENS6_IS8_EEEE in libspral.a(NumericSubtree.o)
      __ZTINSt3__120__shared_ptr_pointerIPiNS_14default_deleteIA_iEENS_9allocatorIiEEEE in libspral.a(SymbolicSubtree.o)
ld: symbol(s) not found for architecture arm64
collect2: error: ld returned 1 exit status
make[1]: *** [spral_ssids] Error 1
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_spral/spral/work/spral-2023.09.07'
make: *** [all] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_spral/spral/work/spral-2023.09.07'
Command failed:  cd "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_math_spral/spral/work/spral-2023.09.07" && /usr/bin/make -j1 -w all 
Exit code: 2

@barracuda156
Copy link

@amontoison
Copy link
Member

amontoison commented Oct 31, 2023

We should also modify the Meson build system.
I suggest to test if we are on Mac or FreeBSD and if the C++ compiler is clang++, we link with -lc++ here.

@jfowkes
Copy link
Contributor Author

jfowkes commented Oct 31, 2023

Apologies, it should test CXX for clang++ (not clang which is the C compiler). @barracuda156 could you re-test?

@jfowkes
Copy link
Contributor Author

jfowkes commented Oct 31, 2023

We should also modify the Meson build system. I suggest to test if we are on Mac or FreeBSD and if the C++ compiler is clang++, we link with -lc++ here.

@amontoison can Meson not autodetect the C++ runtime? See the discussion in #165. Otherwise I guess we'll have to go with your suggestion as a best effort attempt.

@amontoison
Copy link
Member

autodetect the C++ runtime

It can if we use the C++ compiler as linker but we prefer to use the Fortran compiler for linking.

@jfowkes
Copy link
Contributor Author

jfowkes commented Feb 20, 2024

@barracuda156 this is the fix for autotools, please test and we can merge it.

@barracuda156
Copy link

@jfowkes I will try, thank you.

@amontoison By the way, it may be worth offering a configure option to choose the desired C++ runtime (and have reasonable defaults, if it is not passed explicitly). Since, for example, it is certainly possible to use gcc with libc++ (at least on macOS), though it is not a standard combo, or, maybe, even clang with libstdc++.

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.

C++ runtime should not be hardcoded in configure
3 participants