llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Maksim Levental (makslevental) <details> <summary>Changes</summary> On Mac M1, if you load something that transitively loads `#include <new>`, it will fail because ``` In file included from <<< inputs >>>:1: In file included from input_line_22:1: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/memory:671: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/__functional_base:23: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include/c++/v1/new:214:70: error: 'internal_linkage' attribute does not appear on the first declaration 214 | _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} | ^ input_line_0:3:11: note: previous declaration is here 3 | void* operator new(__SIZE_TYPE__, void* __p) noexcept; | ^ Assertion failed: (Ptr && "dereferencing end() iterator"), function operator*, file DeclBase.h, line 1315. ``` This is because `MacOSX12.3.sdk/usr/include/c++/v1/__config` sets `_LIBCPP_INLINE_VISIBILITY` to be `__attribute__((__visibility__("hidden"))) __attribute__((internal_linkage))`, which makes the `new` in `<new>` incompatible with the hardcoded decl `void* operator new(__SIZE_TYPE__, void* __p) noexcept;` in `clang/lib/Interpreter/Interpreter::Runtimes`. I believe the correct thing to do is replace that decl with `#include <new>` (as I've done here). --- Full diff: https://github.com/llvm/llvm-project/pull/69072.diff 2 Files Affected: - (modified) clang/lib/Interpreter/Interpreter.cpp (+1-1) - (modified) clang/test/Interpreter/execute.cpp (+2) ``````````diff diff --git a/clang/lib/Interpreter/Interpreter.cpp b/clang/lib/Interpreter/Interpreter.cpp index 7968c62cbd3e7b3..ddfbc9ac01c6743 100644 --- a/clang/lib/Interpreter/Interpreter.cpp +++ b/clang/lib/Interpreter/Interpreter.cpp @@ -248,7 +248,7 @@ Interpreter::~Interpreter() { // can't find the precise resource directory in unittests so we have to hard // code them. const char *const Runtimes = R"( - void* operator new(__SIZE_TYPE__, void* __p) noexcept; + #include <new> void *__clang_Interpreter_SetValueWithAlloc(void*, void*, void*); void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*); void __clang_Interpreter_SetValueNoAlloc(void*, void*, void*, void*); diff --git a/clang/test/Interpreter/execute.cpp b/clang/test/Interpreter/execute.cpp index 6e73ed3927e8155..d54ab99749c1bac 100644 --- a/clang/test/Interpreter/execute.cpp +++ b/clang/test/Interpreter/execute.cpp @@ -20,4 +20,6 @@ auto r2 = printf("S[f=%f, m=0x%llx]\n", s.f, reinterpret_cast<unsigned long long inline int foo() { return 42; } int r3 = foo(); +#include <memory> + %quit `````````` </details> https://github.com/llvm/llvm-project/pull/69072 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits