[PATCH] D67628: [compiler-rt][crt] pass -O0 in check_cxx_section_exists

Jian Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 10:54:37 PDT 2019


jcai19 created this revision.
Herald added subscribers: llvm-commits, Sanitizers, mgorny, dberris.
Herald added projects: Sanitizers, LLVM.
jcai19 added a reviewer: phosek.
jcai19 added subscribers: manojgupta, llozano.
jcai19 added reviewers: echristo, MaskRay.

.init_array gets optimized away when building with -O2 and as a result,
check_cxx_section_exists failed to pass -DCOMPILER_RT_HAS_INITFINI_ARRAY
when building crtbegin.o and crtend.o, which causes binaries linked with
them encounter segmentation fault. See https://crbug.com/855759 for
details.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67628

Files:
  compiler-rt/lib/crt/CMakeLists.txt


Index: compiler-rt/lib/crt/CMakeLists.txt
===================================================================
--- compiler-rt/lib/crt/CMakeLists.txt
+++ compiler-rt/lib/crt/CMakeLists.txt
@@ -70,7 +70,9 @@
 endfunction()
 
 check_cxx_section_exists(".init_array" COMPILER_RT_HAS_INITFINI_ARRAY
-  SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n")
+  SOURCE "__attribute__((constructor)) void f() {}\nint main() { return 0; }\n"
+  FLAGS "-O0"
+)
 
 append_list_if(COMPILER_RT_HAS_STD_C11_FLAG -std=c11 CRT_CFLAGS)
 append_list_if(COMPILER_RT_HAS_INITFINI_ARRAY -DCRT_HAS_INITFINI_ARRAY CRT_CFLAGS)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67628.220361.patch
Type: text/x-patch
Size: 627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190916/f2dd93d2/attachment-0001.bin>


More information about the llvm-commits mailing list