@@ -172,7 +172,7 @@ char MPIR_attach_fifo[MPIR_MAX_PATH_LENGTH] = {0};
172172int MPIR_force_to_main = 0 ;
173173static void orte_debugger_init_before_spawn (orte_job_t * jdata );
174174
175- ORTE_DECLSPEC void * __opal_attribute_optnone__ MPIR_Breakpoint (void );
175+ ORTE_DECLSPEC void __opal_attribute_optnone__ MPIR_Breakpoint (void );
176176
177177/*
178178 * Attempt to prevent the compiler from optimizing out
@@ -190,14 +190,26 @@ ORTE_DECLSPEC void* __opal_attribute_optnone__ MPIR_Breakpoint(void);
190190 * See the following git issue for more discussion:
191191 * https://github.com/open-mpi/ompi/issues/5501
192192 */
193- static volatile void * volatile noop_mpir_breakpoint_ptr = NULL ;
193+ volatile void * volatile orte_noop_mpir_breakpoint_ptr = NULL ;
194194
195195/*
196196 * Breakpoint function for parallel debuggers
197197 */
198- void * MPIR_Breakpoint (void )
198+ void MPIR_Breakpoint (void )
199199{
200- return noop_mpir_breakpoint_ptr ;
200+ /*
201+ * Actually do something with this pointer to make
202+ * sure the compiler does not optimize out this function.
203+ * The compiler should be forced to keep this
204+ * function around due to the volatile void* type.
205+ *
206+ * This pointer doesn't actually do anything other than
207+ * prevent unwanted optimization, and
208+ * *should not* be used anywhere else in the code.
209+ * So pointing this to the weeds should be OK.
210+ */
211+ orte_noop_mpir_breakpoint_ptr = (volatile void * ) 0x42 ;
212+ return ;
201213}
202214
203215/* local objects */
0 commit comments