The GC is for future employment. You can be abroad doing nothing while your GC is processed or work in the US on a temporary visa, immigration law doesn't care.
Basically, you work for company A on H1b or L1. Company B files a labor cert with your name on it. Once it is approved, company B files an I140 and you can either file for adjustement of status at this time or for consular processing.
There is a point where you have to work for the sponsoring employer. And that point is the day you become a permanent resident.
So, if you work for company A, and company B sponsors you, you have to switch to company B right around the time that your I485 gets approved. At that point you have to show that you have the intent to work for company B 'permanently'. Permanent in the eyes of USCIS is anything over 3 months and you can't take any actions that make clear that you are planning to leave company B immediately (e.g. by just taking a leave of absence from company A, work for company B for 2-3 months while keeping your employment contract with company A).
In the case of consular processing, you have to start working for company B immediately after entering on your immigrant visa. And again, you have to stick with company B for a little while so you don't get your a## reamed at the citizenship interview 5 years later.