This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][crt] make test case nontrivial in check_cxx_section_exists
ClosedPublic

Authored by jcai19 on Sep 16 2019, 10:52 AM.

Details

Summary

.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. This change prevents .init_array section to be optimized away
even with -O2 or higher optimization level.

Diff Detail

Repository
rL LLVM

Event Timeline

jcai19 created this revision.Sep 16 2019, 10:52 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 16 2019, 10:52 AM
Herald added subscribers: llvm-commits, Restricted Project, mgorny, dberris. · View Herald Transcript
jcai19 added reviewers: echristo, MaskRay.
jcai19 added subscribers: manojgupta, llozano.

Could we make the function non-trivial e.g. __attribute__((constructor)) void f() { asm volatile ("nop"::); } to ensure that it's not optimized out even at -O2?

Can you declare a volatile variable and set that from f instead?

jcai19 updated this revision to Diff 220382.Sep 16 2019, 1:21 PM

Thanks for the comments. I have update my change accordinlgy.

jcai19 retitled this revision from [compiler-rt][crt] pass -O0 in check_cxx_section_exists to [compiler-rt][crt] make test case nontrivial in check_cxx_section_exists.Sep 16 2019, 1:22 PM
jcai19 edited the summary of this revision. (Show Details)
jcai19 updated this revision to Diff 220383.Sep 16 2019, 1:23 PM

Remove uncessary new line character.

Harbormaster completed remote builds in B38176: Diff 220383.
joerg accepted this revision.Sep 16 2019, 1:44 PM

LGTM

This revision is now accepted and ready to land.Sep 16 2019, 1:44 PM
This revision was automatically updated to reflect the committed changes.