[PATCH] Kbuild: provide a __UNIQUE_ID for clang

Subsystems: clang/llvm build support, the rest

STALE3827d

3 messages, 2 authors, 2016-02-09 · open the first message on its own page

[PATCH] Kbuild: provide a __UNIQUE_ID for clang

From: Arnd Bergmann <arnd@arndb.de>
Date: 2016-02-08 14:39:12

The default __UNIQUE_ID macro in compiler.h fails to work for some drivers:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:615:1: error: redefinition of
      '__UNIQUE_ID_firmware615'
BRCMF_FW_NVRAM_DEF(4354, "brcmfmac4354-sdio.bin", "brcmfmac4354-sdio.txt");

This adds a copy of the version we use for gcc-4.3 and higher, as the same
one works with all versions of clang that I could find in svn (2.6 and higher).

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 include/linux/compiler-clang.h | 5 +++++
 1 file changed, 5 insertions(+)
diff --git a/include/linux/compiler-clang.h b/include/linux/compiler-clang.h
index d1e49d52b640..de179993e039 100644
--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -10,3 +10,8 @@
 #undef uninitialized_var
 #define uninitialized_var(x) x = *(&(x))
 #endif
+
+/* same as gcc, this was present in clang-2.6 so we can assume it works
+ * with any version that can compile the kernel
+ */
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
-- 
2.7.0

Re: [PATCH] Kbuild: provide a __UNIQUE_ID for clang

From: Michal Marek <hidden>
Date: 2016-02-08 18:13:29

On Mon, Feb 08, 2016 at 03:38:32PM +0100, Arnd Bergmann wrote:
The default __UNIQUE_ID macro in compiler.h fails to work for some drivers:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:615:1: error: redefinition of
      '__UNIQUE_ID_firmware615'
BRCMF_FW_NVRAM_DEF(4354, "brcmfmac4354-sdio.bin", "brcmfmac4354-sdio.txt");
I applied the patch to kbuild.git#kbuild, but can you tell me with which
commit and config you get such failure. I only see a single
MODULE_FIRMWARE() call in the expansion of BRCMF_FW_NVRAM_DEF(), which
should work with line numbers as well. And I can't reproduce it with
today's linux-next. If there is some issue with code not yet in
linux-next, it needs to be worked around, because older GCCs did not
have __COUNTER__.

Michal

Re: [PATCH] Kbuild: provide a __UNIQUE_ID for clang

From: Arnd Bergmann <arnd@arndb.de>
Date: 2016-02-09 14:55:08

On Monday 08 February 2016 19:13:26 Michal Marek wrote:
On Mon, Feb 08, 2016 at 03:38:32PM +0100, Arnd Bergmann wrote:
quoted
The default __UNIQUE_ID macro in compiler.h fails to work for some drivers:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c:615:1: error: redefinition of
      '__UNIQUE_ID_firmware615'
BRCMF_FW_NVRAM_DEF(4354, "brcmfmac4354-sdio.bin", "brcmfmac4354-sdio.txt");
I applied the patch to kbuild.git#kbuild, but can you tell me with which
commit and config you get such failure. I only see a single
MODULE_FIRMWARE() call in the expansion of BRCMF_FW_NVRAM_DEF(), which
should work with line numbers as well. And I can't reproduce it with
today's linux-next. If there is some issue with code not yet in
linux-next, it needs to be worked around, because older GCCs did not
have __COUNTER__.
I wrote this patch in early January before Arend van Spriel changed the
code with the patch below. I wasn't aware of his change, but that explains
why you don't see the problem any more.

	Arnd

commit 23195ec00503c6c29daea5b6c780787c0b5f1bf3
Author: Arend van Spriel [off-list ref]
Date:   Sat Jan 16 16:39:13 2016 +0100

    brcmfmac: fix BRCMF_FW_NVRAM_DEF macro for older gcc compilers
    
    With gcc < 4.3 __UNIQUE_ID does not create unique ids with the macro
    BRCMF_FW_NVRAM_DEF. Fix this by removing the MODULE_FIRMWARE instance
    for the nvram file. This file is not in linux-firmware repo so it may
    not be needed anyway. Otherwise consider this as a temporary fix.
    
    Reported-by: Geert Uytterhoeven [off-list ref]
    Signed-off-by: Arend van Spriel [off-list ref]
    Acked-by: Kalle Valo [off-list ref]
    Tested-by: Geert Uytterhoeven [off-list ref]
    Signed-off-by: David S. Miller [off-list ref]
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
index ef06f57a7a0e..d3c9f0d52ae3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.h
@@ -47,8 +47,7 @@ static const char BRCM_ ## fw_nvram_name ## _FIRMWARE_NAME[] = \
 	BRCMF_FW_DEFAULT_PATH fw; \
 static const char BRCM_ ## fw_nvram_name ## _NVRAM_NAME[] = \
 	BRCMF_FW_DEFAULT_PATH nvram; \
-MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw); \
-MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH nvram)
+MODULE_FIRMWARE(BRCMF_FW_DEFAULT_PATH fw);
 
 #define BRCMF_FW_DEF(fw_name, fw) \
 static const char BRCM_ ## fw_name ## _FIRMWARE_NAME[] = \
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help