compiler: fix checkNonStdWay for targets that require dynamic libraries
This commit fixes checkNonStdWay to ensure that for targets whose RTS
linker can only load dynamic code, the dynamic way of object is
selected.
(cherry picked from commit 94ef949e)
(cherry picked from commit 38474be0)