diff mbox series

[v2,14/28] bluez: Disable invalid-pp-token warning with clang

Message ID 20250520-clang-toolchain-v2-14-db97c2eb3756@gmail.com
State New
Headers show
Series clang: Add clang C/C++ toolchain | expand

Commit Message

Khem Raj May 21, 2025, 6:19 a.m. UTC
We add FIRMWARE_DIR via CFLAGS using escapes for string and clang
option parser flags it

<command line>:4:23: warning: missing terminating '"' character [-Winvalid-pp-token]
    4 | #define FIRMWARE_DIR \"/usr/lib/firmware\"
      |                       ^

emitting this warning during configure means some tests fail wrongly. e.g.
test for enable -fPIC -DPIC, which results in textrels in libbbluetooth.so

This warning can be disabled, the string is correctly passed to sources in
the end, so its spurious

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 meta/recipes-connectivity/bluez5/bluez5.inc | 1 +
 1 file changed, 1 insertion(+)

Comments

Ross Burton May 29, 2025, 9:28 a.m. UTC | #1
> On 21 May 2025, at 07:19, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
> 
> We add FIRMWARE_DIR via CFLAGS using escapes for string and clang
> option parser flags it
> 
> <command line>:4:23: warning: missing terminating '"' character [-Winvalid-pp-token]
>    4 | #define FIRMWARE_DIR \"/usr/lib/firmware\"
>      |                       ^
> 
> emitting this warning during configure means some tests fail wrongly. e.g.
> test for enable -fPIC -DPIC, which results in textrels in libbbluetooth.so
> 
> This warning can be disabled, the string is correctly passed to sources in
> the end, so its spurious
> 
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> meta/recipes-connectivity/bluez5/bluez5.inc | 1 +
> 1 file changed, 1 insertion(+)
> 
> diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc b/meta/recipes-connectivity/bluez5/bluez5.inc
> index 7bae968094f2a272c4deff7416dbd1208549e6ce..5835662f7a63a23915ec4af94597ec4a614a4640 100644
> --- a/meta/recipes-connectivity/bluez5/bluez5.inc
> +++ b/meta/recipes-connectivity/bluez5/bluez5.inc
> @@ -84,6 +84,7 @@ EXTRA_OECONF = "\
> "
> 
> CFLAGS += "-DFIRMWARE_DIR=\\"${nonarch_base_libdir}/firmware\\""
> +CFLAGS:append:toolchain-clang = " -Wno-invalid-pp-token”

Wouldn’t it be neater to change the line above to:

CFLAGS += "-DFIRMWARE_DIR="${nonarch_base_libdir}/firmware”"

Bitbake’s parser is crazy and stuff like that works.

Ross
Khem Raj May 29, 2025, 4:21 p.m. UTC | #2
On 5/29/25 2:28 AM, Ross Burton wrote:
> 
> 
>> On 21 May 2025, at 07:19, Khem Raj via lists.openembedded.org <raj.khem=gmail.com@lists.openembedded.org> wrote:
>>
>> We add FIRMWARE_DIR via CFLAGS using escapes for string and clang
>> option parser flags it
>>
>> <command line>:4:23: warning: missing terminating '"' character [-Winvalid-pp-token]
>>     4 | #define FIRMWARE_DIR \"/usr/lib/firmware\"
>>       |                       ^
>>
>> emitting this warning during configure means some tests fail wrongly. e.g.
>> test for enable -fPIC -DPIC, which results in textrels in libbbluetooth.so
>>
>> This warning can be disabled, the string is correctly passed to sources in
>> the end, so its spurious
>>
>> Signed-off-by: Khem Raj <raj.khem@gmail.com>
>> ---
>> meta/recipes-connectivity/bluez5/bluez5.inc | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc b/meta/recipes-connectivity/bluez5/bluez5.inc
>> index 7bae968094f2a272c4deff7416dbd1208549e6ce..5835662f7a63a23915ec4af94597ec4a614a4640 100644
>> --- a/meta/recipes-connectivity/bluez5/bluez5.inc
>> +++ b/meta/recipes-connectivity/bluez5/bluez5.inc
>> @@ -84,6 +84,7 @@ EXTRA_OECONF = "\
>> "
>>
>> CFLAGS += "-DFIRMWARE_DIR=\\"${nonarch_base_libdir}/firmware\\""
>> +CFLAGS:append:toolchain-clang = " -Wno-invalid-pp-token”
> 
> Wouldn’t it be neater to change the line above to:
> 
> CFLAGS += "-DFIRMWARE_DIR="${nonarch_base_libdir}/firmware”"
> 
> Bitbake’s parser is crazy and stuff like that works.

I have tried several ways to pass it, what you suggest was in fact first 
thing I tried and it passes -DFIRMWARE_DIR="/usr/lib/firmware” as seen 
in bitbake preprocessing output but emits following into an implicit 
header file that compiler sees

#define FIRMWARE_DIR /usr/lib/firmware

which is not right string syntax in C. what we need is

#define FIRMWARE_DIR "/usr/lib/firmware"

on compiler commandline it should look like

-DFIRMWARE_DIR=\"/usr/lib/firmware\"

So how can we teach bitbake to do this ?

> 
> Ross
diff mbox series

Patch

diff --git a/meta/recipes-connectivity/bluez5/bluez5.inc b/meta/recipes-connectivity/bluez5/bluez5.inc
index 7bae968094f2a272c4deff7416dbd1208549e6ce..5835662f7a63a23915ec4af94597ec4a614a4640 100644
--- a/meta/recipes-connectivity/bluez5/bluez5.inc
+++ b/meta/recipes-connectivity/bluez5/bluez5.inc
@@ -84,6 +84,7 @@  EXTRA_OECONF = "\
 "
 
 CFLAGS += "-DFIRMWARE_DIR=\\"${nonarch_base_libdir}/firmware\\""
+CFLAGS:append:toolchain-clang = " -Wno-invalid-pp-token"
 
 # bluez5 builds a large number of useful utilities but does not
 # install them.  Specify which ones we want put into ${PN}-noinst-tools.