According to OED they're variant spellings of each other, in the meaning of wreck. But the only sense it gives for rack as a verb is to draw off sediment from a barrel. What meaning is the intended one for 'racking cough' anyway? It could feasibly be drawing off sediment from the lungs, or it could be a comparison with being put on the rack, or it could be the idea of your lungs being twisted inside out, in which case it would be wrack.
The OED is dragging its feet a bit. Chambers lists 5 senses for the verb:
verb (racked, racking)
1 to put something in a rack.
2 to move or adjust by rack and pinion.
3
historical to torture someone on a rack.
4 to stretch or move forcibly or excessively.
5 to cause pain or suffering to someone or something. racked or
(and usually regarded as an error) wracked adj tortured; tormented; distressed o be racked with guilt. Also in compounds o disease-racked.
on the rack
1 extremely anxious or distressed.
2 said of skill, etc: stretched to its limits.
rack one's brains to think as hard as one can, especially in order to remember something.
The cough would come under n° 5, causing pain and suffering. NB the bit I've underlined.
Agree re
wrack as alternative to wreck, but AFAIK the usage is archaic (other than among those who have recourse to the OED to paper over mistakes).
Ngram of wrack, wreck