| 1 | From 0a876ce2825f1e54bec7059a387e43a2e0386665 Mon Sep 17 00:00:00 2001
|
| 2 | From: Daniel Kolesa <[email protected]>
|
| 3 | Date: Sun, 23 Oct 2022 01:02:35 +0200
|
| 4 | Subject: [PATCH 2/4] clang: enable fortify by default on optimizing musl
|
| 5 | targets
|
| 6 |
|
| 7 | ---
|
| 8 | lib/Frontend/InitPreprocessor.cpp | 5 +++++
|
| 9 | 1 file changed, 5 insertions(+)
|
| 10 |
|
| 11 | diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
|
| 12 | index 20bfbf144..9095c0f2f 100644
|
| 13 | |
| 14 | |
| 15 | @@ -1508,6 +1508,11 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
|
| 16 | #undef TARGET_OS
|
| 17 | }
|
| 18 |
|
| 19 | + // Enable fortify by default on musl when optimizing, but not with asan
|
| 20 | + if (TI.getTriple().isMusl() && LangOpts.Optimize &&
|
| 21 | + !LangOpts.Sanitize.has(SanitizerKind::Address))
|
| 22 | + Builder.defineMacro("_FORTIFY_SOURCE", "2");
|
| 23 | +
|
| 24 | // Get other target #defines.
|
| 25 | TI.getTargetDefines(LangOpts, Builder);
|
| 26 | }
|
| 27 | --
|
| 28 | 2.38.0
|
| 29 |
|