Thread (6 messages) 6 messages, 2 authors, 2021-01-29

Re: '-D' 'KBUILD_MODSYM=main - like KBUILD_MODNAME, without the quotes ?

From: jim.cromie@gmail.com
Date: 2021-01-29 00:16:47

On Thu, Jan 28, 2021 at 4:57 PM Valdis Klētnieks [off-list ref]
wrote:
On Thu, 28 Jan 2021 12:11:54 -0700, jim.cromie@gmail.com said:
quoted
In my hacking, Im finding this useful.
it adds a version of KBUILD_MODNAME without the quotes
OK, I'll bite.  When and how is this useful?
heres my use

#define DEFINE_DYNAMIC_DEBUG_TABLE_(_sym_,_mod_)       \
weak struct _ddebug \
__used __aligned(8) \
__section(".gnu.linkonce." _mod_ ".dyndbg") \
_sym_##_dyndbg_base = { \
.site = &_sym_##_dyndbg_site, \
.format = _mod_, \
.lineno = 0 \
}

#pragma message "OK<" KBUILD_MODNAME ">[" __stringify(KBUILD_MODSYM) "]
adding DYNDBG_TABLE"

#define DEFINE_DYNAMIC_DEBUG_TABLE() \
DEFINE_DYNAMIC_DEBUG_TABLE_(KBUILD_MODSYM, KBUILD_MODNAME);

that pragma does:

                 from /home/jimc/projects/lx/wk-next/init/version.c:14:
/home/jimc/projects/lx/wk-next/include/linux/dynamic_debug.h:172:9: note:
‘#pragma message: OK<version>[version] adding DYNDBG_TABLE’
  172 | #pragma message "OK<" KBUILD_MODNAME ">["
__stringify(KBUILD_MODSYM) "] adding DYNDBG_TABLE"
      |         ^~~~~~~
  CC      init/do_mounts.o

IOW the _sym_ works better for ## token-joining

KBUILD_MODNAME has the quotes for a reason;

Hint:  do a "git grep KBUILD_MODNAME", look at how it's used, and
think about how invasive a patch to change it would be...
(And pay heed to the comment in arch/sparc/include/asm/vio.h -
it means that there's second-order effects to deal with as well...)
I have no intention of changing KBUILD_MODNAME.
I created a near-synonym to avoid exactly that.


quoted
Afterall, __stringify() could add the quotes for cases where it was
needed.Afterall, __stringify() could add the quotes for cases where it was
needed.

How would it know?
It would not.
you would add it to create the quoted version, as I used in the pragma.
obviously theres no need, since KBUILD_MODNAME already exists.

So question reduces to:

is there anything brittle with the Makefile -DKBUILD_MODSYM=$modname
addition ?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help