Detecting phase difference between a clean and a noisy signal
Here is how I would do it:

1) Find the frequency of the clean signal, this should be trivial in the time domain for a clean square wave.

2) Heavily smooth the noisy signal with a symmetric filter.  (IIR or FIR)  

3) Calculate a single DFT bin for each signal using the length of a whole number of cycles for your frame.  This will make the harmonics leakless, and make your fundamental measurement more accurate.  The bin number you calculate should be the number of periods in your frame.

4) Calculate the phase for each signal relative to the frame at the fundamental frequency.  (Straight from the DFT bin value)

5) Take the difference in the two phases and translate if from an angle to a time using the frequency.

This is going to be way more efficient than some cross-correlation type calculation.