[llvm] r192864 - Expose install_fatal_error_handler() through the C API.

Alp Toker alp at nuanti.com
Tue Oct 22 05:37:47 PDT 2013


I've gone ahead fixed the build using the LLVM_EXTENSION attribute in
r193160.

We've been using this patch internally to build clang selfhost for the
last week or so since it broke.

Should keep things moving until Filip Pizlo gets back.

Alp.


On 22/10/2013 13:07, Evgeniy Stepanov wrote:
> LLVM_ENABLE_WERROR=ON build has been broken on Linux for 5 days now.
> Please do something.
>
>
> On Tue, Oct 22, 2013 at 12:17 PM, Kostya Serebryany <kcc at google.com> wrote:
>> Filip,
>>   ping.
>>
>>
>> On Mon, Oct 21, 2013 at 1:03 PM, Kostya Serebryany <kcc at google.com> wrote:
>>> This seems to be still unfixed.
>>>
>>> --kcc
>>>
>>>
>>> On Thu, Oct 17, 2013 at 11:50 AM, Kai Nacke <kai.nacke at redstar.de> wrote:
>>>> Yes - I see it with clang 3.4 on Linux.
>>>>
>>>> Regards
>>>> Kai
>>>>
>>>>
>>>> On 17.10.2013 09:41, Kostya Serebryany wrote:
>>>>> This is causing build errors for me:
>>>>>
>>>>> /home/kcc/llvm/lib/Support/ErrorHandling.cpp:110:5: error: cast between
>>>>> pointer-to-function and pointer-to-object is an extension
>>>>> [-Werror,-Wpedantic]
>>>>>      reinterpret_cast<LLVMFatalErrorHandler>(user_data);
>>>>>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>> /home/kcc/llvm/lib/Support/ErrorHandling.cpp:116:27: error: cast between
>>>>> pointer-to-function and pointer-to-object is an extension
>>>>> [-Werror,-Wpedantic]
>>>>>      bindingsErrorHandler, reinterpret_cast<void*>(Handler));
>>>>>                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>>>
>>>>> Does anyone else see these?
>>>>>
>>>>> My build config is:
>>>>> cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON \
>>>>>   -DCMAKE_C_COMPILER=/home/kcc/host_clang/bin/clang \
>>>>>   -DCMAKE_CXX_COMPILER=/home/kcc/host_clang/bin/clang++ \
>>>>>   -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
>>>>>   -DLLVM_ENABLE_WERROR=ON
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Oct 17, 2013 at 5:38 AM, Filip Pizlo <fpizlo at apple.com
>>>>> <mailto:fpizlo at apple.com>> wrote:
>>>>>
>>>>>     Author: fpizlo
>>>>>     Date: Wed Oct 16 20:38:28 2013
>>>>>     New Revision: 192864
>>>>>
>>>>>     URL: http://llvm.org/viewvc/llvm-project?rev=192864&view=rev
>>>>>     Log:
>>>>>     Expose install_fatal_error_handler() through the C API.
>>>>>
>>>>>     I expose the API with some caveats:
>>>>>
>>>>>     - The C++ API involves a traditional void* opaque pointer for the
>>>>> fatal
>>>>>     error callback.  The C API doesn’t do this.  I don’t think that the
>>>>>     void*
>>>>>     opaque pointer makes any sense since this is a global callback -
>>>>>     there will
>>>>>     only be one of them.  So if you need to pass some data to your
>>>>> callback,
>>>>>     just put it in a global variable.
>>>>>
>>>>>     - The bindings will ignore the gen_crash_diag boolean.  I ignore it
>>>>>     because
>>>>>     (1) I don’t know what it does, (2) it’s not documented AFAIK, and
>>>>> (3) I
>>>>>     couldn’t imagine any use for it.  I made the gut call that it
>>>>> probably
>>>>>     wasn’t important enough to expose through the C API.
>>>>>
>>>>>
>>>>>     Modified:
>>>>>          llvm/trunk/include/llvm-c/Core.h
>>>>>          llvm/trunk/lib/Support/ErrorHandling.cpp
>>>>>
>>>>>     Modified: llvm/trunk/include/llvm-c/Core.h
>>>>>     URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=192864&r1=192863&r2=192864&view=diff
>>>>>
>>>>> ==============================================================================
>>>>>     --- llvm/trunk/include/llvm-c/Core.h (original)
>>>>>     +++ llvm/trunk/include/llvm-c/Core.h Wed Oct 16 20:38:28 2013
>>>>>     @@ -416,6 +416,22 @@ void LLVMShutdown();
>>>>>       char *LLVMCreateMessage(const char *Message);
>>>>>       void LLVMDisposeMessage(char *Message);
>>>>>
>>>>>     +typedef void (*LLVMFatalErrorHandler)(const char *Reason);
>>>>>     +
>>>>>     +/**
>>>>>     + * Install a fatal error handler. By default, if LLVM detects a
>>>>>     fatal error, it
>>>>>     + * will call exit(1). This may not be appropriate in many contexts.
>>>>>     For example,
>>>>>     + * doing exit(1) will bypass many crash reporting/tracing system
>>>>>     tools. This
>>>>>     + * function allows you to install a callback that will be invoked
>>>>>     prior to the
>>>>>     + * call to exit(1).
>>>>>     + */
>>>>>     +void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
>>>>>     +
>>>>>     +/**
>>>>>     + * Reset the fatal error handler. This resets LLVM's fatal error
>>>>>     handling
>>>>>     + * behavior to the default.
>>>>>     + */
>>>>>     +void LLVMResetFatalErrorHandler(void);
>>>>>
>>>>>       /**
>>>>>        * @defgroup LLVMCCoreContext Contexts
>>>>>
>>>>>     Modified: llvm/trunk/lib/Support/ErrorHandling.cpp
>>>>>     URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=192864&r1=192863&r2=192864&view=diff
>>>>>
>>>>> ==============================================================================
>>>>>     --- llvm/trunk/lib/Support/ErrorHandling.cpp (original)
>>>>>     +++ llvm/trunk/lib/Support/ErrorHandling.cpp Wed Oct 16 20:38:28
>>>>> 2013
>>>>>     @@ -20,6 +20,7 @@
>>>>>       #include "llvm/Support/Signals.h"
>>>>>       #include "llvm/Support/Threading.h"
>>>>>       #include "llvm/Support/raw_ostream.h"
>>>>>     +#include "llvm-c/Core.h"
>>>>>       #include <cassert>
>>>>>       #include <cstdlib>
>>>>>
>>>>>     @@ -102,3 +103,19 @@ void llvm::llvm_unreachable_internal(con
>>>>>         LLVM_BUILTIN_UNREACHABLE;
>>>>>       #endif
>>>>>       }
>>>>>     +
>>>>>     +static void bindingsErrorHandler(void *user_data, const
>>>>>     std::string& reason,
>>>>>     +                                 bool gen_crash_diag) {
>>>>>     +  LLVMFatalErrorHandler handler =
>>>>>     +    reinterpret_cast<LLVMFatalErrorHandler>(user_data);
>>>>>     +  handler(reason.c_str());
>>>>>     +}
>>>>>     +
>>>>>     +void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) {
>>>>>     +  install_fatal_error_handler(
>>>>>     +    bindingsErrorHandler, reinterpret_cast<void*>(Handler));
>>>>>     +}
>>>>>     +
>>>>>     +void LLVMResetFatalErrorHandler() {
>>>>>     +  remove_fatal_error_handler();
>>>>>     +}
>>>>>
>>>>>
>>>>>     _______________________________________________
>>>>>     llvm-commits mailing list
>>>>>     llvm-commits at cs.uiuc.edu <mailto:llvm-commits at cs.uiuc.edu>
>>>>>     http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> llvm-commits mailing list
>>>>> llvm-commits at cs.uiuc.edu
>>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>>>
>>>> _______________________________________________
>>>> llvm-commits mailing list
>>>> llvm-commits at cs.uiuc.edu
>>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-- 
http://www.nuanti.com
the browser experts




More information about the llvm-commits mailing list