fixed for #7977, there are 2 solutions, one is like this checkin, annother is change all the places through replace ALL_CFLAGS with FO_LDFLAGS in the testing. if you think the 2nd one is better, please tell me.