[MacPorts] #72064: clang-19 @19.1.7+analyzer: undefined symbol error when using std::make_exception_ptr
MacPorts
noreply at macports.org
Fri Feb 14 13:51:41 UTC 2025
#72064: clang-19 @19.1.7+analyzer: undefined symbol error when using
std::make_exception_ptr
------------------------+----------------------
Reporter: diegonehab | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: ports | Version: 2.10.5
Keywords: haspatch | Port: clang-19
------------------------+----------------------
There is an issue with clang-18 and clang-19 on macOS < 15.0.
It has been reported here
https://github.com/llvm/llvm-project/issues/77653
and a patch is available here
https://github.com/h-vetinari/llvm-
project/commit/95421fd66d41d1cad4eb8d427a038786a524e950
The problem can be tested with a simple program:
{{{
$ cat problem.cpp
#include <exception>
#include <iostream>
#include <stdexcept>
int main() {
try {
std::rethrow_exception(std::make_exception_ptr(std::bad_alloc{}));
} catch (std::exception &e) {
std::cout << "Caught exception: '" << e.what() << "'\n";
}
}
}}}
When compiling and running this program with clang-18 or clang-19, before
the patch, we get an unexpected missing symbol
{{{
clang++-mp-19 -o problem problem.cpp && ./problem
dyld[55759]: Symbol not found:
__ZNSt13exception_ptr31__from_native_exception_pointerEPv
Referenced from: <9E6BCC37-F397-30B0-BE47-0BAAFD863D63> problem
Expected in: <EC33CD83-7098-3AD6-82C8-BC03AC81E87B>
/usr/lib/libc++.1.dylib
Abort trap: 6
}}}
Whereas, after the patch, we get the expected behavior
{{{
$ clang++-mp-19 -o problem problem.cpp && ./problem
Caught exception: 'std::bad_alloc'
}}}
The patch provided is for clang-19, but the same modification can be made
to clang-18.
The only difference is that, for clang-18, instead of modifying file
`libcxx/include/__configuration/availability.h`, we should modify file
`libcxx/include/__availability` like so:
{{{
--- __availability 2025-02-14 13:48:16
+++ __availability.new 2025-02-14 13:48:42
@@ -103,7 +103,7 @@
// These macros controls the availability of __cxa_init_primary_exception
// in the built library, which std::make_exception_ptr might use
// (see libcxx/include/__exception/exception_ptr.h).
-# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 1
+# define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
// These macros control the availability of all parts of <filesystem>
that
}}}
--
Ticket URL: <https://trac.macports.org/ticket/72064>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list