driver: add necessary compile-time flags for wasm PIC mode
This commit adds necessary compile-time flags when compiling for wasm
PIC mode, see added comment for detailed explanation.
(cherry picked from commit f6abaf13)
(cherry picked from commit 9834ac3b)