Bogleheads:Sandbox

Roth IRA considerations
If you use the FEIE, you cannot use any of the excluded income to contribute to an IRA. You can contribute if you have earned income above the FEIE limit, and below the IRA contribution cutoff. You can also contribute using earned income that it not excludable (for example, wages earned during a business trip to the US, which are considered US-source income even if paid by a non-US employer).

It is not mandatory to use the FEIE, but if one does use the FEIE, one has to use all of it, and exclude all income that is excludable up to the exclusion limit. It is NOT possible to partially exclude eligible earned income and leave some un-excluded for IRA contributions.