This probably works in a lot of default cases, but not generally. For example, our compiler (portable_cc_toolchain) uses a sysroot that requires the flags --sysroot=path/to/sysroot --gcc-toolchain=path/to/gcc among a few other required linker flags. I think the correct implementation would use something like get_memory_inefficient_command_line for both compile and link actions, and add those flags via -Xcompiler and -Xlinker.