projects/aports·blob master · refs

29 lines · 952 B

1From 0a876ce2825f1e54bec7059a387e43a2e0386665 Mon Sep 17 00:00:00 2001
2From: Daniel Kolesa <[email protected]>
3Date: Sun, 23 Oct 2022 01:02:35 +0200
4Subject: [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
11diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp
12index 20bfbf144..9095c0f2f 100644
13--- a/lib/Frontend/InitPreprocessor.cpp
14+++ b/lib/Frontend/InitPreprocessor.cpp
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--
282.38.0
29