<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/122687>122687</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Add support for -fhardened
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:driver
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          nikic
      </td>
    </tr>
</table>

<pre>
    GCC supports an `-fhardened` flag that enables a number of hardening options with one flag. Quoting from https://gcc.gnu.org/onlinedocs/gcc/Instrumentation-Options.html.

> Enable a set of flags for C and C++ that improve the security of the generated code without affecting its ABI. The precise flags enabled may change between major releases of GCC, but are currently:

>     -D_FORTIFY_SOURCE=3
>     -D_GLIBCXX_ASSERTIONS
>     -ftrivial-auto-var-init=zero
>     -fPIE  -pie  -Wl,-z,relro,-z,now
>     -fstack-protector-strong
>     -fstack-clash-protection
>     -fcf-protection=full (x86 GNU/Linux only)

> The list of options enabled by -fhardened can be generated using the --help=hardened option.

> When the system glibc is older than 2.35, -D_FORTIFY_SOURCE=2 is used instead.

> This option is intended to be used in production builds, not merely in debug builds.

> Currently, -fhardened is only supported on GNU/Linux targets.

> -fhardened only enables a particular option if it wasn’t already specified anywhere on the command line. For instance, -fhardened -fstack-protector will only enable -fstack-protector, but not -fstack-protector-strong.

It would be nice if Clang also accepted the flag.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx0Vc1u2zoTfRp6M5BgU5ZjLbRwZDswUDTf16Ro7yqgyJHEliIF_thVn_6Csp3Eaa9hQBB4ZubMmeERc062GrEk-T3JtzMWfGdsqeVPyWe1EWP5UFXgwjAY6x0wDWQ1T5qOWYEaBVnNoVGsBd8xD6hZrdABAx36Gi2YBs5IqVswg5dGOzhJ34HROAWm8P9gfDxurOmh835wJNsQuid033KetjqkxraE7o1WUqMw3J2PCN0ftPM29Kg9i7mTx3OJtPO9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