@@ -90,13 +90,34 @@ option(
90
90
default = phc_default ,
91
91
when = "--enable-jemalloc" ,
92
92
help = "{Enable|Disable} PHC (Probabilistic Memory Checker). "
93
- "Also enables frame pointers" ,
93
+ "Also enables frame pointers when needed " ,
94
94
)
95
- imply_option ("--enable-frame-pointers" , True , when = "--enable-phc" )
96
-
97
95
98
96
set_config ("MOZ_PHC" , True , when = "--enable-phc" )
99
97
98
+
99
+ # PHC parses stacks using frame pointers on these systems.
100
+ @depends ("--enable-phc" , target , have_unwind , when = "--enable-jemalloc" )
101
+ def phc_implies_frame_pointers (phc , target , have_unwind ):
102
+ if not phc :
103
+ return False
104
+
105
+ # This should be kept in sync with the ifdefs in memory/build/PHC.cpp
106
+ # that control stack walking.
107
+ # This is true for the first two options in PHC.cpp
108
+ if (target .os == "WINNT" and target .cpu == "x86" ) or target .kernel == "Darwin" :
109
+ return True
110
+
111
+ # This should match the #defines in mozglue/misc/StackWalk.cpp
112
+ if (target .cpu in ("x86" , "ppc" )) and (target .kernel in ("Darwin" , "Linux" )):
113
+ return not have_unwind
114
+
115
+ return False
116
+
117
+
118
+ imply_option ("--enable-frame-pointers" , True , when = phc_implies_frame_pointers )
119
+
120
+
100
121
with only_when (depends (target .os )(lambda os : os != "WINNT" )):
101
122
set_define ("HAVE_STRNDUP" , check_symbol ("strndup" ))
102
123
set_define ("HAVE_POSIX_MEMALIGN" , check_symbol ("posix_memalign" ))
0 commit comments