A person who cooks gid hanasheh should be cupable for all five averious, because there is no NEED at all to do it on yom tov. So why does Hillel not prohibit him also for cooking and carrying,. Hillel would not permit a person to carry a stone for no reason at all on yom tov, why would he let him cook for no reason at all?
alan, Israel Ramat Beit Shemesh
Tosfos (12b DH Hacha) asks this question and says that since the person cooking the Gid intended to eat it, we consider the cooking a Tzorech. In other words, Tosfos holds that the definition of Tzorech depends on whether the Melachah was done for a need, not on whether there is in fact a benefit from the Melachah.
Rashi (12a DH Ela, see also Tosfos 12a DH Hachi Garsinan) holds that Min ha'Torah even if there is no Tzorech at all the Melachah is permitted. If so, we cannot give him Malkos even if there is no Tzorech.
Dov Freedman