build: turn on -fno-strict-aliasing
Turn on `-fno-strict-aliasing` in libuv and add a note in the README for downstream projects. Fixes: https://github.com/libuv/libuv/issues/1230 PR-URL: https://github.com/libuv/libuv/pull/2588 Reviewed-By: Jameson Nash <vtjnash@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
parent
48cf8c8286
commit
cbcd0cfc82
@ -102,6 +102,9 @@ list(APPEND uv_cflags ${lint-no-conditional-assignment-msvc})
|
||||
list(APPEND uv_cflags ${lint-no-unsafe-msvc})
|
||||
list(APPEND uv_cflags ${lint-utf8-msvc} )
|
||||
|
||||
check_c_compiler_flag(-fno-strict-aliasing UV_F_STRICT_ALIASING)
|
||||
list(APPEND uv_cflags $<$<BOOL:${UV_F_STRICT_ALIASING}>:-fno-strict-aliasing>)
|
||||
|
||||
set(uv_sources
|
||||
src/fs-poll.c
|
||||
src/idna.c
|
||||
@ -325,7 +328,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
|
||||
src/unix/bsd-ifaddrs.c
|
||||
src/unix/no-proctitle.c
|
||||
src/unix/no-fsevents.c)
|
||||
list(APPEND uv_cflags -fno-strict-aliasing)
|
||||
list(APPEND uv_libraries socket)
|
||||
endif()
|
||||
|
||||
|
||||
10
README.md
10
README.md
@ -286,6 +286,16 @@ listed in `test/benchmark-list.h`.
|
||||
|
||||
Check the [SUPPORTED_PLATFORMS file](SUPPORTED_PLATFORMS.md).
|
||||
|
||||
### `-fno-strict-aliasing`
|
||||
|
||||
It is recommended to turn on the `-fno-strict-aliasing` compiler flag in
|
||||
projects that use libuv. The use of ad hoc "inheritance" in the libuv API
|
||||
may not be safe in the presence of compiler optimizations that depend on
|
||||
strict aliasing.
|
||||
|
||||
MSVC does not have an equivalent flag but it also does not appear to need it
|
||||
at the time of writing (December 2019.)
|
||||
|
||||
### AIX Notes
|
||||
|
||||
AIX compilation using IBM XL C/C++ requires version 12.1 or greater.
|
||||
|
||||
@ -25,6 +25,7 @@ AC_ENABLE_STATIC
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
CC_FLAG_VISIBILITY #[-fvisibility=hidden]
|
||||
CC_CHECK_CFLAGS_APPEND([-fno-strict-aliasing])
|
||||
CC_CHECK_CFLAGS_APPEND([-g])
|
||||
CC_CHECK_CFLAGS_APPEND([-std=gnu89])
|
||||
CC_CHECK_CFLAGS_APPEND([-Wall])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user