Answer :

By the nuclear fusion.
Well,

The sun's energy is produced mainly in the core, which has sufficient temperature to initiate nuclear fusion.

Hydrogen --> Deuterium --> Tritium --> Helium --> Beryllium? --> Carbon --> ? --> Silicon --> Iron/Nickel = Most massive stars