Molecular oxygen has been detected in the coma of comet 67P/Churyumov-Gerasimenko with abundances in the 1%-10% range by the Rosetta Orbiter Spectrometer for Ion and Neutral Analysis-Double Focusing Mass Spectrometer instrument on board the Rosetta spacecraft. Here we find that the radiolysis of icy grains in low-density environments such as the presolar cloud may induce the production of large amounts of molecular oxygen. We also show that molecular oxygen can be efficiently trapped in clathrates formed in the protosolar nebula (PSN), and that its incorporation as crystalline ice is highly implausible, because this would imply much larger abundances of Ar and N-2 than those observed in the coma. Assuming that radiolysis has been the only O...