aboutsummaryrefslogtreecommitdiffstats
path: root/src/build-data
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-31 11:59:27 -0500
committerJack Lloyd <[email protected]>2015-12-31 11:59:27 -0500
commitb269c8d1ce0cb5412712a8df963b2205364e17ae (patch)
tree8245489665f1f31c35626d4cf5275afbf0914276 /src/build-data
parent18d81936b55874ba76eca59b1d01e8028cc2bf9a (diff)
Use memcpy instead of misaligned pointer casts for reading words.
It works on x86, but C says it is undefined and it makes UBSan unhappy. Happily, this memcpy approach probably also works fine under processors which previously used the byte-at-a-time approach such as ARM. But for right now using memcpy here is still gated under the processor alignment flags. In my tests recent GCC and Clang seemed to produce basically identical code for either approach when using -O3; I imagine most compilers these days are very good at analyzing/inlining/unrolling memcpys. Also remove the manually unrolled versions of xor_buf, which caused problems with GCC and -O3 due to it vectorizing the loads into (aligned) SSE2 loads, which would fail when a misaligned pointer was passed. Which always seemed kind of bogus to me, but I guess that's what undefined behavior is for. Enable -O3 for GCC. With this change the test suite is clean under GCC ASan+UBSan and Clang ASan+UBSan, with the exception of one failure due to a bug in libstdc++ (GCC bug 60734) when compiled by Clang.
Diffstat (limited to 'src/build-data')
-rw-r--r--src/build-data/cc/gcc.txt8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/build-data/cc/gcc.txt b/src/build-data/cc/gcc.txt
index 2e6c0c364..79c9ba5f4 100644
--- a/src/build-data/cc/gcc.txt
+++ b/src/build-data/cc/gcc.txt
@@ -13,13 +13,17 @@ warning_flags "-Wall -Wextra -Wstrict-aliasing -Wstrict-overflow=5 -Wcast-align
compile_flags "-c"
debug_info_flags "-g"
-optimization_flags "-O2"
+optimization_flags "-O3"
shared_flags "-fPIC"
coverage_flags "--coverage"
-#sanitizer_flags "-D_GLIBCXX_DEBUG -fsanitize=address -fsanitize=undefined"
+
+# GCC 4.8
sanitizer_flags "-D_GLIBCXX_DEBUG -fsanitize=address"
+# GCC 4.9 and later
+#sanitizer_flags "-D_GLIBCXX_DEBUG -fsanitize=address,undefined -fno-sanitize-recover=undefined"
+
visibility_build_flags "-fvisibility=hidden"
visibility_attribute '__attribute__((visibility("default")))'