Skip to content

driver: properly handle command line flag order for external tools

Cheng Shao requested to merge type-dance/ghc:fix-c-compiler-arg-order into master

When parsing command line flags for external tools (e.g. -optc for the C compiler), we used to prepend the parsed flags to the list of flags loaded from settings file, then reverse the entire list via getOpts to ensure user-specified flags appear later and override the system-wide default flags. However, simply reversing the flag order can cause unexpected errors when the flags are not commutative, see #24133 (closed) for such an example.

This patch removes getOpts completely and ensures user-specified flags override system-wide default flags by appending them to the flag list, instead of prepending.

Edited by Cheng Shao

Merge request reports