Skip to contentSkip to conversation

include: sbi: Don't use #pragma when preprocessing device tree sources

PATCH Applied Jessica Clarke 4 participants 4 messages Jul 9, 2025 – Jul 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 include: sbi: Don't use #pragma when preprocessing device tree sources

Since this persists in the preprocessed output (so that it can affect the subsequent compilation), it ends up in the input to dtc and is a syntax error, breaking the k210 build. Ideally we wouldn't add the -include flag to DTSCPPFLAGS in the first place as this header is wholly pointless there, but that's a more invasive build system change compared to just making this header safe to include there.

Fixes 86c01a73ff9d ("lib: sbi: Avoid GOT indirection for global symbol references")
---
 include/sbi/sbi_visibility.h | 2 ++
 1 file changed, 2 insertions(+)
include/sbi/sbi_visibility.h +2 -0
index e9c401c..f900c44 100644
@@ -7,10 +7,12 @@
 #ifndef __SBI_VISIBILITY_H__
 #define __SBI_VISIBILITY_H__
 
+#ifndef __DTS__
 /*
  * Declare all global objects with hidden visibility so access is PC-relative
  * instead of going through the GOT.
  */
 #pragma GCC visibility push(hidden)
+#endif
 
 #endif
Signature · 7 lines
2.34.1


-- 
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · 在 2025-07-10四的 00:28 +0100,Jessica Clarke写道:

Since this persists in the preprocessed output (so that it can affect the subsequent compilation), it ends up in the input to dtc and is a syntax error, breaking the k210 build. Ideally we wouldn't add the -include flag to DTSCPPFLAGS in the first place as this header is wholly pointless there, but that's a more invasive build system change compared to just making this header safe to include there.

Fixes 86c01a73ff9d ("lib: sbi: Avoid GOT indirection for global symbol references")

This error will reappear when PLATFORM=kendryte/k210 LLVM=1. No problem under gcc.

Quoted 24 lines

---
 include/sbi/sbi_visibility.h | 2 ++

 1 file changed, 2 insertions(+)
include/sbi/sbi_visibility.h +0 -0
index e9c401c..f900c44 100644
@@ -7,10 +7,12 @@
  #ifndef __SBI_VISIBILITY_H__
  #define __SBI_VISIBILITY_H__


+#ifndef __DTS__
 /*
  * Declare all global objects with hidden visibility so access is PC-relative
  * instead of going through the GOT.
  */
 #pragma GCC visibility push(hidden)
+#endif

 #endif

Signature · 1 line
2.34.1
Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Reviewed-by on v1 1/1
#2 lore raw
In reply to Jessica Clarke
Quoted 20 lines · Jessica Clarke

Since this persists in the preprocessed output (so that it can affect the subsequent compilation), it ends up in the input to dtc and is a syntax error, breaking the k210 build. Ideally we wouldn't add the -include flag to DTSCPPFLAGS in the first place as this header is wholly pointless there, but that's a more invasive build system change compared to just making this header safe to include there.

Fixes 86c01a73ff9d ("lib: sbi: Avoid GOT indirection for global symbol references")
---
 include/sbi/sbi_visibility.h | 2 ++
 1 file changed, 2 insertions(+)
include/sbi/sbi_visibility.h +0 -0
index e9c401c..f900c44 100644
@@ -7,10 +7,12 @@
 #ifndef __SBI_VISIBILITY_H__
 #define __SBI_VISIBILITY_H__

include/sbi/sbi_visibility.h line 18

Quoted 10 lines
include/sbi/sbi_visibility.h +2 -0
 
+#ifndef __DTS__
 /*
  * Declare all global objects with hidden visibility so access is PC-relative
  * instead of going through the GOT.
  */
 #pragma GCC visibility push(hidden)
+#endif
 
 #endif

Thanks for the fix!

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi
Applied
#3 lore raw
In reply to Jessica Clarke
Quoted 10 lines · Jessica Clarke

Since this persists in the preprocessed output (so that it can affect the subsequent compilation), it ends up in the input to dtc and is a syntax error, breaking the k210 build. Ideally we wouldn't add the -include flag to DTSCPPFLAGS in the first place as this header is wholly pointless there, but that's a more invasive build system change compared to just making this header safe to include there.

Fixes 86c01a73ff9d ("lib: sbi: Avoid GOT indirection for global symbol references")

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 29 lines
---
 include/sbi/sbi_visibility.h | 2 ++
 1 file changed, 2 insertions(+)
include/sbi/sbi_visibility.h +2 -1
index e9c401c..f900c44 100644
@@ -7,10 +7,12 @@
 #ifndef __SBI_VISIBILITY_H__
 #define __SBI_VISIBILITY_H__
 
+#ifndef __DTS__
 /*
  * Declare all global objects with hidden visibility so access is PC-relative
  * instead of going through the GOT.
  */
 #pragma GCC visibility push(hidden)
+#endif
 
 #endif
--

2.34.1

--
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi

Signature · 3 lines
opensbi mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/opensbi