Sun
The Sun's chemical composition was got from the interstellar medium. The hydrogen and most of the helium in the Sun would have been produced by Big Bang nucleosynthesis in the first 20 minutes of the universe. The heavier elements were produced by stars that died before the Sun was formed. The heavier elements were released into the interstellar medium when stars exploded as supernovae.