scripts: fix symbol overriding in configuration files
PATCH 1/1 scripts: fix symbol overriding in configuration files
When redefining the same symbol in configuration (basically after an inclusion), we need to undefine the previous symbol to avoid "redefined" errors.
--- scripts/gen-config-h.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
scripts/gen-config-h.sh +6 -6
@@ -33,11 +33,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" -grep CONFIG_ $1 \ -| grep -v '^[ \t]*#' \ -| sed 's,CONFIG_\(.*\)=y.*$,#define \1 1,' \ -| sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' \ -| sed 's,CONFIG_\(.*\)=\(.*\)$,#define \1 \2,' \ -| sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' +grep CONFIG_ $1 | +grep -v '^[ \t]*#' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"
Signature · 1 line
1.7.10.4
A message that is not in the archive (sent off-list or not yet received): 1417087745-9004-1-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Quoted 4 lines
When redefining the same symbol in configuration (basically after an inclusion), we need to undefine the previous symbol to avoid "redefined" errors.
Signed-off-by David Marchand <[email protected]>
Applied
Thanks
Signature · 1 line
Thomas
Quoted 9 lines · Thomas Monjalon
Quoted 4 lines
When redefining the same symbol in configuration (basically after an inclusion), we need to undefine the previous symbol to avoid "redefined" errors.
Signed-off-by David Marchand <[email protected]>Acked-by Thomas Monjalon <[email protected]>Applied
This patch doesn't seem to work on FreeBSD. I'm still investigating how to fix it but right now compilation with gcc/clang on FreeBSD is broken due to the config.h file having lines like the below in it :-(
/usr/home/bruce/dpdk.org/x86_64-native-bsdapp-clang/include/rte_config.h:3:21: fatal error: extra tokens at end of #undef directive [-Wextra-tokens] #undef RTE_EXEC_ENVn#define RTE_EXEC_ENV "bsdapp"
I'll send on a fix as soon as I can.
Regards,
/Bruce
Hello Bruce,
Quoted 16 lines · Bruce Richardson
Quoted 1 line · Thomas Monjalon
Quoted 1 line
When redefining the same symbol in configuration (basically after an
inclusion),
Quoted 8 lines
Quoted 3 lines
we need to undefine the previous symbol to avoid "redefined" errors.
Signed-off-by David Marchand <[email protected]>Acked-by Thomas Monjalon <[email protected]>Applied
This patch doesn't seem to work on FreeBSD. I'm still investigating how to fix
it but right now compilation with gcc/clang on FreeBSD is broken due to theconfig.hfile having lines like the below in it :-(
Quoted 5 lines
/usr/home/bruce/dpdk.org/x86_64-native-bsdapp-clang/include/rte_config.h:3:21: fatal
error: extra tokens at end of #undef directive [-Wextra-tokens] #undef RTE_EXEC_ENVn#defineRTE_EXEC_ENV"bsdapp"
This is probably because of the \n in the sed.
Can you try something like this (I did not like this version of my patch at first because it is not that readable) ?
scripts/gen-config-h.sh +4 -2
@@ -35,9 +35,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" grep CONFIG_ $1 | grep -v '^[ \t]*#' | -sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\ +#define \1 1,' | sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | -sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\ +#define \1 \2,' | sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"
Signature · 1 line
David Marchand
A message that is not in the archive (sent off-list or not yet received): CALwxeUvRWYPmwSR4tuH9x8QYwR1AA6qnUarMu=wM-NrK+Aq-6w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 41 lines · David Marchand
Hello Bruce,
Quoted 16 lines · Bruce Richardson
Quoted 1 line · Thomas Monjalon
Quoted 1 line
When redefining the same symbol in configuration (basically after an
inclusion),
Quoted 8 lines
Quoted 3 lines
we need to undefine the previous symbol to avoid "redefined" errors.
Signed-off-by David Marchand <[email protected]>Acked-by Thomas Monjalon <[email protected]>Applied
This patch doesn't seem to work on FreeBSD. I'm still investigating how to fix
it but right now compilation with gcc/clang on FreeBSD is broken due to theconfig.hfile having lines like the below in it :-(Quoted 5 lines
/usr/home/bruce/dpdk.org/x86_64-native-bsdapp-clang/include/rte_config.h:3:21: fatal
error: extra tokens at end of #undef directive [-Wextra-tokens] #undef RTE_EXEC_ENVn#defineRTE_EXEC_ENV"bsdapp"This is probably because of the \n in the sed.
Can you try something like this (I did not like this version of my patch at first because it is not that readable) ?
scripts/gen-config-h.sh +0
-0@@ -35,9 +35,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" grep CONFIG_ $1 | grep -v '^[ \t]*#' |
scripts/gen-config-h.sh echo "#ifndef __RTE_CONFIG_H" · line 45
Quoted 10 lines
scripts/gen-config-h.sh +4
-2-sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\ +#define \1 1,' | sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | -sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\ +#define \1 \2,' | sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"
I tried a number of different things to get sed to introduce "\n" characters, but I missed trying that one. I've sent on an alternative fix now, which uses tr instead of sed to insert the "\n"'s. It's not a fix I'm terribly happy with, but having seen the above (but not tried it yet), it actually doesn't seem that bad in comparison :-)
/Bruce
Quoted 42 lines · David Marchand
Hello Bruce,
Quoted 16 lines · Bruce Richardson
Quoted 1 line · Thomas Monjalon
Quoted 1 line
When redefining the same symbol in configuration (basically after an
inclusion),
Quoted 8 lines
Quoted 3 lines
we need to undefine the previous symbol to avoid "redefined" errors.
Signed-off-by David Marchand <[email protected]>Acked-by Thomas Monjalon <[email protected]>Applied
This patch doesn't seem to work on FreeBSD. I'm still investigating how to fix
it but right now compilation with gcc/clang on FreeBSD is broken due to theconfig.hfile having lines like the below in it :-(Quoted 5 lines
/usr/home/bruce/dpdk.org/x86_64-native-bsdapp-clang/include/rte_config.h:3:21: fatal
error: extra tokens at end of #undef directive [-Wextra-tokens] #undef RTE_EXEC_ENVn#defineRTE_EXEC_ENV"bsdapp"This is probably because of the \n in the sed.
Can you try something like this (I did not like this version of my patch at first because it is not that readable) ?
scripts/gen-config-h.sh +0
-0@@ -35,9 +35,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" grep CONFIG_ $1 | grep -v '^[ \t]*#' |
scripts/gen-config-h.sh echo "#ifndef __RTE_CONFIG_H" · line 45
Quoted 10 lines
scripts/gen-config-h.sh +4
-2-sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\ +#define \1 1,' | sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | -sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\ +#define \1 \2,' | sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"
This proposed fix also works. I don't mind whether my patch proposal or this fix gets applied - gen-config-h.sh is not a commonly modified script anyway.
/Bruce
Quoted 5 lines · Bruce Richardson
This proposed fix also works. I don't mind whether my patch proposal or this
fix gets applied -gen-config-h.shis not a commonly modified script anyway.
I prefer my ugliness ;-)
But Thomas just proposed me something that could work. Trying ...
Signature · 1 line
David Marchand
A message that is not in the archive (sent off-list or not yet received): CALwxeUt+_0mnh1Z15ruBr5eB5UkAQSX_ZzWaoHnNgaMEt9NUkw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
Quoted 9 lines · David Marchand
Quoted 5 lines · Bruce Richardson
This proposed fix also works. I don't mind whether my patch proposal or this
fix gets applied -gen-config-h.shis not a commonly modified script anyway.
Quoted 4 lines
I prefer my ugliness ;-)
But Thomas just proposed me something that could work. Trying ...
Yes, it's ugly, but it's probably more resilient. I'm looking forward to getting an option C.
/Bruce
Quoted 4 lines · Bruce Richardson
Yes, it's ugly, but it's probably more resilient. I'm looking forward to getting
an option C.
Option C and D are ugly as well (using some bashism like $' ' or using an intermediate variable with a newline in it).
Our "posix" guy told me that he prefers the initial version of the patch. I will send a patch with this.
Thomas ?
Signature · 1 line
David Marchand
A message that is not in the archive (sent off-list or not yet received): CALwxeUuUJPUvKnyAxGtyebuQX24dJSZPm8q4cLi3ODEYUdwY-g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org
PATCH 1/1 scripts: fix newline character in sed expression
Use of \n in sed expression is not portable and triggered an invalid configuration on BSD (at least).
Replace with an explicit newline.
--- scripts/gen-config-h.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/gen-config-h.sh +4 -2
@@ -35,9 +35,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" grep CONFIG_ $1 | grep -v '^[ \t]*#' | -sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\ +#define \1 1,' | sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | -sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\ +#define \1 \2,' | sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"
Signature · 1 line
1.7.10.4
A message that is not in the archive (sent off-list or not yet received): 1417189364-23969-1-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org
Bruce Richardson
Acked-byRe: [PATCH] scripts: fix newline character in sed expression
Quoted 6 lines · David Marchand
Use of \n in sed expression is not portable and triggered an invalid configuration on BSD (at least).
Replace with an explicit newline.Reported-by Bruce Richardson <[email protected]>Signed-off-by David Marchand <[email protected]>
Quoted 25 lines
--- scripts/gen-config-h.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)scripts/gen-config-h.sh +4
-2@@ -35,9 +35,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" grep CONFIG_ $1 | grep -v '^[ \t]*#' | -sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\ +#define \1 1,' | sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | -sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\ +#define \1 \2,' | sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"Signature · 1 line
1.7.10.4
Thomas Monjalon
AppliedRe: [PATCH] scripts: fix newline character in sed expression
Quoted 8 lines
Quoted 6 lines
Use of \n in sed expression is not portable and triggered an invalid configuration on BSD (at least).
Replace with an explicit newline.Reported-by Bruce Richardson <[email protected]>Signed-off-by David Marchand <[email protected]>Acked-by Bruce Richardson <[email protected]>
Applied
Thanks
Signature · 1 line
Thomas
PATCH 1/1 scripts: fix merged lines on FreeBSD in config.h
In reply to Bruce RichardsonSince commit 0a91453d, "Fix symbol overriding in configuration", the rte_config.h can have two lines generated for a single directive to enable a feature - one line to undef the feature value, and a second to enable or set the new value. On FreeBSD, sed inserts an "n" char instead of the "\n" carriage return, leading to compiler errors. This patch fixes that by having sed insert a "$" character instead of attempting a "\n", and then using tr subsequently to turn "$" characters into real "\n" characters.
--- scripts/gen-config-h.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
scripts/gen-config-h.sh +4 -3
@@ -35,9 +35,10 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" grep CONFIG_ $1 | grep -v '^[ \t]*#' | -sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1$#define \1 1,' | sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | -sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | -sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1$#define \1 \2,' | +sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' | +tr '$' '\n' echo "#endif /* __RTE_CONFIG_H */"
Signature · 1 line
2.1.0
Quoted 4 lines · David Marchand
When redefining the same symbol in configuration (basically after an inclusion), we need to undefine the previous symbol to avoid "redefined" errors.
Signed-off-by David Marchand <[email protected]>
Though I see this patch is already replied, my comment on the below is that it may be best as two separate patches, since you are doing two things there that makes the actual change hard to see. One patch should move the "|" from the start of the next line to end of the previous, and the second patch should then add the undef statements. As it is, I had to stare at this for a while to work out why the grep lines were changing to undefine previously defined values. :-)
/Bruce
Quoted 29 lines
--- scripts/gen-config-h.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)scripts/gen-config-h.sh +6
-6@@ -33,11 +33,11 @@ echo "#ifndef __RTE_CONFIG_H" echo "#define __RTE_CONFIG_H" -grep CONFIG_ $1 \ -| grep -v '^[ \t]*#' \ -| sed 's,CONFIG_\(.*\)=y.*$,#define \1 1,' \ -| sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' \ -| sed 's,CONFIG_\(.*\)=\(.*\)$,#define \1 \2,' \ -| sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' +grep CONFIG_ $1 | +grep -v '^[ \t]*#' | +sed 's,CONFIG_\(.*\)=y.*$,#undef \1\n#define \1 1,' | +sed 's,CONFIG_\(.*\)=n.*$,#undef \1,' | +sed 's,CONFIG_\(.*\)=\(.*\)$,#undef \1\n#define \1 \2,' | +sed 's,\# CONFIG_\(.*\) is not set$,#undef \1,' echo "#endif /* __RTE_CONFIG_H */"Signature · 1 line
1.7.10.4