Skip to content
  • matthewbauer's avatar
    Only pass -pie, -no-pie when linking · af653b5f
    matthewbauer authored and Marge Bot's avatar Marge Bot committed
    Previously, these flags were passed when both compiling and linking
    code. However, `-pie` and `-no-pie` are link-time-only options. Usually,
    this does not cause issues, but when using Clang with `-Werror` set
    results in errors:
    
        clang: error: argument unused during compilation: '-nopie' [-Werror,-Wunused-command-line-argument]
    
    This is unused by Clang because this flag has no effect at compile time
    (it’s called `-nopie` internally by Clang but called `-no-pie` in GHC
    for compatibility with GCC). Just passing these flags at linking time
    resolves this.
    
    Additionally, update #15319 hack to look for `-pgml` instead.
    
    Because of the main change, the value of `-pgmc` does not matter when
    checking for the workaround of #15319. However, `-pgml` *does* still
    matter as not all `-pgml` values support `-no-pie`.
    
    To cover all potential values, we assume that no custom `-pgml` values
    support `-no-pie`. This means that we run the risk of not using
    `-no-pie` when it is otherwise necessary for in auto-hardened
    toolchains! This could be a problem at some point, but this workaround
    was already introduced in 8d008b71 and we might as well continue
    supporting it.
    
    Likewise, mark `-pgmc-supports-no-pie` as deprecated and create a new
    `-pgml-supports-no-pie`.
    af653b5f