[compiler-rt] r228384 - [UBSan] Enable -Wglobal-constructors.

Alexey Samsonov vonosmas at gmail.com
Wed Feb 11 12:01:13 PST 2015


On Wed, Feb 11, 2015 at 12:37 AM, Yury Gribov <y.gribov at samsung.com> wrote:

> On 02/11/2015 09:04 AM, Yury Gribov wrote:
>
>> On 02/11/2015 06:07 AM, Justin Bogner wrote:
>>
>>> Alexey Samsonov <vonosmas at gmail.com> writes:
>>>
>>>> Ah, right...
>>>> Feel free to revert this change. I have plans to deal with different
>>>> UBSan
>>>> initialization issues soon, and will see if I would be able to
>>>> reinstantiate
>>>> this warning on all platforms.
>>>>
>>>
>>> Reverted in r228795.
>>>
>>
>> Can't we just move initializer to separate file for which we then
>> disable this warning?
>>
>
> Does something like this make sense? It passes tests on Linux x64. I
> haven't verified OSX but I can see that -Wglobal-constructors is indeed
> disabled for ubsan_init.cc.


In fact, I wanted to split UBSan runtime into three parts: UBSan
(UBSAN_SOURCES without ubsan_init.cc), UBSanCXX (UBSAN_CXX_SOURCES) and
UBSanStandalone (~ubsan_init.cc).
Standalone UBSan would contain all three of them, while the first two would
also be embedded into ASan runtime. After we do this separation, it would
be easy
to specify -Wglobal-constructors just for UBSan and UBSanCXX.

-Y
>
>
> commit 991071e4b2c7a8d3fa247927adc5f3f256a91580
> Author: Yury Gribov <y.gribov at samsung.com>
> Date:   Wed Feb 4 16:30:22 2015 +0300
>
>     [UBSan] Re-enable -Wglobal-constructors portably.
>
> diff --git a/lib/ubsan/CMakeLists.txt b/lib/ubsan/CMakeLists.txt
> index 09c7a85..e321eb8 100644
> --- a/lib/ubsan/CMakeLists.txt
> +++ b/lib/ubsan/CMakeLists.txt
> @@ -19,6 +19,12 @@ set(UBSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
>  append_no_rtti_flag(UBSAN_CFLAGS)
>  set(UBSAN_CXXFLAGS ${SANITIZER_COMMON_CFLAGS})
>
> +if(COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG)
> +  list(APPEND UBSAN_CFLAGS -Wglobal-constructors)
> +  list(APPEND UBSAN_CXXFLAGS -Wglobal-constructors)
> +  set_source_files_properties(ubsan_init.cc PROPERTIES COMPILE_FLAGS
> -Wno-global-constructors)
> +endif()
> +
>  add_custom_target(ubsan)
>
>  if(APPLE)
>
>


-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150211/d86d55c6/attachment.html>


More information about the llvm-commits mailing list