Context. Cosmic ray ion irradiation affects the chemical composition of and triggers physical changes in interstellar ice mantles in space. One of the primary structural changes induced is the loss of porosity, and the mantles evolve toward a more compact amorphous state. Previously, ice compaction was monitored at low to moderate ion energies. The existence of a compaction threshold in stopping power has been suggested. Aims. In this article we experimentally study the effect of heavy ion irradiation at energies closer to true cosmic rays. This minimises extrapolation and allows a regime where electronic interaction always dominates to be explored, providing the ice compaction cross section over a wide range of electronic stopping power. Methods. High-energy ion irradiations provided by the GANIL accelerator, from the MeV up to the GeV range, are combined with in-situ infrared spectroscopy monitoring of ice mantles. We follow the IR spectral evolution of the ice as a function of increasing fluence (induced compaction of the initial microporous amorphous ice into a more compact amorphous phase). We use the number of OH dangling bonds of the water molecule, i.e. pending OH bonds not engaged in a hydrogen bond in the initially porous ice structure as a probe of the phase transition. These high-energy experiments are combined with lower energy experiments using light ions (H, He) from other facilities in Catania, Italy, and Washington, USA. Results. We evaluated the cross section for the disappearance of OH dangling bonds as a function of electronic stopping power. A cross-section law in a large energy range that includes data from different ice deposition setups is established. The relevant phase structuring time scale for the ice network is compared to interstellar chemical time scales using an astrophysical model. Conclusions. The presence of a threshold in compaction at low stopping power suggested in some previous works seems not to be confirmed for the high-energy cosmic rays encountered in interstellar space. Ice mantle porosity or pending bonds monitored by the OH dangling bonds is removed efficiently by cosmic rays. As a consequence, this considerably reduces the specific surface area available for surface chemical reactions.