The first thing that removes build-up from clothes is baking soda. For a difficult job, saturate the water with baking soda. Let sit 24 hours. If the water is smelly or gross, I continue to do this another time until it is not. NEVER let a very dirty item sit in this water for two days. This causes the smelly water, which has absorbed out the bad things and build-up amd added water to proliferate the bacteria, to then reabsorb back into the fabric, causing the treatment to now take up to 5 cycles to get rid of the "icky water smell". Instead, use the baking soda soak for only 24 hours.
Vinegar removes all smells by neutralizing their molecules. However, spraying vinegar on a fabric does not work completely for types of smells such as body smells. Presumably, the vinegar does not penetrate to the inside of the fabric. That is why baking soda will be the most important step for a fabric that has never been naturally treated before and which is very gross and dirty. Vinegar, however, does ensure that all of the laundry detergent is removed, instead of it's normal behavior of sticking to the fabric, thus attracting other things to stick to it as well as wearing out the clothes sooner. Add at least one cup of vinegar to all clothing while the washing machine is filling up the water to rinse out the detergent with. However, if you have a smell on your clothing already you can try also using some vinegar to soak with beforehand.
The most efficient bacteria killer for this kind of situation is peroxide. Hydrogen peroxide, at the grocery store concentration of 3%, is often used in laundry and as a water disinfectent. Since the issue of clothing is bacteria, soaking it the way I usually soak my washcloths, which ttpically obtain the stale water smell after a couple of weeks during weather that does not dry them quickly, can also be a useful idea. Ttpical advice is to use a tablespoon in a small container. However, hydrogen peroxide is a form of bleach, so be careful if the clothing is one who's color you are extremely opposed to changing. Since it is soaking in a solution, the color change should be uniform. However, you may prefer to spray peroxide just on smelly parts. In that case, do not allow sun exposure to that part unless you wish to bleach it to white or nearly white. If you do allow sun exposure, do not use a very heavy spray, which may cause holes. If bleaching is your goal, then spray a light amount of moderate, and ensure sun exposure, wait 24-48 hours with sun exposure. For the smell, hydrogen peroxide generally kills bacteria but it is very likely that using the two previous methods will work, and those methods also they work faster, so the peroxide method can be saved as the last method.