I asked my late father (an electrical engineer) this very question years ago and he said that essentially, the entire cost of a solar panel is the cost of the energy to make it. You dig dirt out of the ground and apply energy to turn that into metal, glass, etc, then you use energy to ship parts around and to assemble them into a panel and ship the panel, etc. The cost of the true raw material is very low indeed and the cost of the factory is again the cost of the energy to make the factory, and so on down the line. The possible exception may be a retail markup and a labour cost when you finally acquire and install it.
Now, consider that solar panels "pay for themselves" in the end. You pay $X for a panel and after some number of years, you have saved $X in energy bills. It therefore follows that it has generated at least as much energy as it cost to make it. This logic would only fail if you pay a wildly different cost for energy than everyone before you in the chain. Aluminum smelters do locate near dams to get cheap power, but I don't think you'll find that cheap means "1/10th the price" or even "1/2 the price" so the logic holds. Any panel that is economically worthwhile has produced more power than it took to smelt and refine its materials and to make it, as measured in dollars.