Patrick Williams | 864cc43 | 2023-02-09 14:54:44 -0600 | [diff] [blame^] | 1 | From abaac31d1cb4d0ba0e8e9ef7f344e62de3b150de Mon Sep 17 00:00:00 2001 |
| 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Sat, 4 Feb 2023 16:50:46 -0800 |
| 4 | Subject: [PATCH] minicoredumper_demo: Use 'optnone' attribute with clang |
| 5 | |
| 6 | clang does not support optimize("On") yet, therefore use optnone which |
| 7 | should give intended results with clang compiler |
| 8 | |
| 9 | Upstream-Status: Submitted [https://github.com/diamon/minicoredumper/pull/7] |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | --- |
| 12 | src/minicoredumper_demo/main.c | 9 +++++++-- |
| 13 | 1 file changed, 7 insertions(+), 2 deletions(-) |
| 14 | |
| 15 | diff --git a/src/minicoredumper_demo/main.c b/src/minicoredumper_demo/main.c |
| 16 | index 65aac46..e60eb82 100644 |
| 17 | --- a/src/minicoredumper_demo/main.c |
| 18 | +++ b/src/minicoredumper_demo/main.c |
| 19 | @@ -11,8 +11,13 @@ |
| 20 | #include <sys/types.h> |
| 21 | |
| 22 | #include "minicoredumper.h" |
| 23 | - |
| 24 | -int __attribute__((optimize("O0"))) main(int argc, char *argv[]) |
| 25 | +int |
| 26 | +#ifdef __clang__ |
| 27 | +__attribute__((optnone)) |
| 28 | +#else |
| 29 | +__attribute__((optimize("O0"))) |
| 30 | +#endif |
| 31 | +main(int argc, char *argv[]) |
| 32 | { |
| 33 | char *str1 = "This is string 1."; |
| 34 | unsigned long val1 = 0x1abc123f; |
| 35 | -- |
| 36 | 2.39.1 |
| 37 | |