Although we hear a lot about how the Sun is made of hydrogen and helium, it also contains trace quantities of all the other elements too, but at levels of less than 1 percent of its mass. Still, 1 percent is a lot of matter. The original gas cloud that formed our solar system had a chemical composition similar to the Sun's, with the elements heavier than helium provided by earlier generations of massive stars that went supernova. These stars converted some of their hydrogen and helium into elements like carbon, oxygen, nitrogen, silicon, iron etc, and the detonation of these stars over the course of billions of years, enriched the gases in interstellar space. In some ancient cloud, the Sun and the solar system formed 4.6 billion years ago. The Sun got the bulk of the mass with its original chemical abundances locked-in. The various planets underwent chemical evolution appropriate to their distances from the infant Sun, and what we now see is the end product of this secondary chemical evolution.