clang++ and libc++
Ryan Schmidt
ryandesign at macports.org
Wed Mar 3 10:43:18 UTC 2021
On Mar 3, 2021, at 03:59, Paul Floyd wrote:
> Hi
>
> A slightly off topic question. I have two macbooks, and the old one I use for testing the build of Valgrind when I'm wearing my opensource hat.
>
> The Mac is running 10.7.5. XCode for this platform is too old to build the current Valgrind source, so I'm using clang 9.0.1 from macports.
>
> This mostly works, at least for building the code, but there is an issue with C++ code. There are some regression tests that use 'modern C++' (my fault!). These use automake configure tests to check that the compiler supports these features. This works OK, but when it comes to linking there is a failure.
>
> For instance, one test covers C++14 sized deallocation.
>
>
> The configure test is
>
> AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
> return 0;
> ]])], [
> FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
> ac_have_sized_deallocation=yes
> AC_MSG_RESULT([yes])
> ], [
> FLAG_FSIZED_DEALLOCATION=""
> ac_have_sized_deallocation=no
> AC_MSG_RESULT([no])
> ])
>
> and the link error is
>
> /opt/local/bin/clang++-mp-9.0 -Winline -Wall -Wshadow -Wno-long-long -g -fno-stack-protector -Wno-unused-private-field -arch x86_64 -fsized-deallocation -o sized_delete sized_delete-sized_delete.o
> Undefined symbols for architecture x86_64:
> "operator delete[](void*, unsigned long)", referenced from:
> _main in sized_delete-sized_delete.o
> "operator delete(void*, unsigned long)", referenced from:
> _main in sized_delete-sized_delete.o
> ld: symbol(s) not found for architecture x86_64
>
>
> So my question, is there a way to get such code to link with clang++ on such an old platform? Or does in only use /usr/lib/libc++.1.dylib and so is limited to the C++ library features present in that library?
If you're trying to create software that will work on other people's Mac OS X 10.7 systems too, then you're limited to the C++ features present in /usr/lib/libc++.1.dylib.
If you don't care about compatibility with other people's systems and only need it to work on your system, you can install the libcxx port with the +replacemnt_libcxx variant. (See "port variants libcxx".) This will replace /usr/lib/libc++.1.dylib with a newer version from MacPorts. MacPorts will not preserve a backup copy of your old /usr/lib/libc++.1.dylib so you should make a copy in a safe place in case you want to revert to it later.
More information about the macports-users
mailing list