diff mbox

[1/1] depmod: pass -P $CONFIG_SYMBOL_PREFIX

Message ID 1359625303-11842-1-git-send-email-james.hogan@imgtec.com (mailing list archive)
State New, archived
Headers show

Commit Message

James Hogan Jan. 31, 2013, 9:41 a.m. UTC
On architectures which have symbol prefixes, depmod emits lots of false
warnings like this:

WARNING: $module.ko needs unknown symbol $symbol

This is because depmod isn't being passed the -P <symbol_prefix>
arguments to specify the symbol prefix to ignore. This option is
included since the 3.13 release of module-init-tools.

Update scripts/depmod.sh to take extra arguments which are passed
through directly to depmod, and update the main Makefile to pass
-P $(CONFIG_SYMBOL_PREFIX to scripts/depmod.sh, but only if
CONFIG_SYMBOL_PREFIX is set and non-empty.

scripts/depmod.sh also drops the -P arguments if depmod --version
reports module-init-tools with a version number < 3.13.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: linux-kbuild@vger.kernel.org
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: uclinux-dist-devel@blackfin.uclinux.org
---
My shell-fu isn't great, so all comments for improvements appreciated.

 Makefile          |    6 +++++-
 scripts/depmod.sh |   27 +++++++++++++++++++++++----
 2 files changed, 28 insertions(+), 5 deletions(-)

Comments

Michal Marek Jan. 31, 2013, 10:37 a.m. UTC | #1
On 31.1.2013 10:41, James Hogan wrote:
> On architectures which have symbol prefixes, depmod emits lots of false
> warnings like this:
> 
> WARNING: $module.ko needs unknown symbol $symbol
> 
> This is because depmod isn't being passed the -P <symbol_prefix>
> arguments to specify the symbol prefix to ignore. This option is
> included since the 3.13 release of module-init-tools.
> 
> Update scripts/depmod.sh to take extra arguments which are passed
> through directly to depmod, and update the main Makefile to pass
> -P $(CONFIG_SYMBOL_PREFIX to scripts/depmod.sh, but only if
> CONFIG_SYMBOL_PREFIX is set and non-empty.

OK.


> scripts/depmod.sh also drops the -P arguments if depmod --version
> reports module-init-tools with a version number < 3.13.

You can replace the test with a simple

"$DEPMOD" -P _ --help 2>/dev/null >/dev/null

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
James Hogan Jan. 31, 2013, 10:50 a.m. UTC | #2
Hi Michal,

On 31/01/13 10:37, Michal Marek wrote:
> On 31.1.2013 10:41, James Hogan wrote:
>> On architectures which have symbol prefixes, depmod emits lots of false
>> warnings like this:
>>
>> WARNING: $module.ko needs unknown symbol $symbol
>>
>> This is because depmod isn't being passed the -P <symbol_prefix>
>> arguments to specify the symbol prefix to ignore. This option is
>> included since the 3.13 release of module-init-tools.
>>
>> Update scripts/depmod.sh to take extra arguments which are passed
>> through directly to depmod, and update the main Makefile to pass
>> -P $(CONFIG_SYMBOL_PREFIX to scripts/depmod.sh, but only if
>> CONFIG_SYMBOL_PREFIX is set and non-empty.
> 
> OK.
> 
> 
>> scripts/depmod.sh also drops the -P arguments if depmod --version
>> reports module-init-tools with a version number < 3.13.
> 
> You can replace the test with a simple
> 
> "$DEPMOD" -P _ --help 2>/dev/null >/dev/null

Thanks for the suggestion. It would be much cleaner, but unfortunately I
tried this on module-init-tools 3.3-pre2 and module-init-tools 3.9 and
both still return success.

Cheers
James

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Marek Jan. 31, 2013, 11:11 a.m. UTC | #3
On 31.1.2013 11:50, James Hogan wrote:
> Hi Michal,
> 
> On 31/01/13 10:37, Michal Marek wrote:
>> On 31.1.2013 10:41, James Hogan wrote:
>>> On architectures which have symbol prefixes, depmod emits lots of false
>>> warnings like this:
>>>
>>> WARNING: $module.ko needs unknown symbol $symbol
>>>
>>> This is because depmod isn't being passed the -P <symbol_prefix>
>>> arguments to specify the symbol prefix to ignore. This option is
>>> included since the 3.13 release of module-init-tools.
>>>
>>> Update scripts/depmod.sh to take extra arguments which are passed
>>> through directly to depmod, and update the main Makefile to pass
>>> -P $(CONFIG_SYMBOL_PREFIX to scripts/depmod.sh, but only if
>>> CONFIG_SYMBOL_PREFIX is set and non-empty.
>>
>> OK.
>>
>>
>>> scripts/depmod.sh also drops the -P arguments if depmod --version
>>> reports module-init-tools with a version number < 3.13.
>>
>> You can replace the test with a simple
>>
>> "$DEPMOD" -P _ --help 2>/dev/null >/dev/null
> 
> Thanks for the suggestion. It would be much cleaner, but unfortunately I
> tried this on module-init-tools 3.3-pre2 and module-init-tools 3.9 and
> both still return success.

Indeed, depmod had the modutils fallback, so it did not fail on unknown
options immediately. So the version parsing is inevitable. Thanks for
checking.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mike Frysinger Feb. 3, 2013, 6:17 a.m. UTC | #4
On Thursday 31 January 2013 04:41:43 James Hogan wrote:
> --- a/Makefile
> +++ b/Makefile
> 
> +ifneq ($(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)),)
> +  depmod_args = -P $(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
> +endif
> ...
>  # Run depmod only if we have System.map and depmod is executable
>  quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
>        cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
> -                   $(KERNELRELEASE)
> +                   $(KERNELRELEASE) $(depmod_args)

scripts/Makefile.lib just does:
	ifdef CONFIG_SYMBOL_PREFIX
so you should do the same

that said, cmd_depmod is just a shell command.  and you're running another 
script helper (depmod.sh).  how about passing it unconditionally ?
	cmd_depmod = ... -P "$(CONFIG_SYMBOL_PREFIX)"

since the default will be "no prefix", using -P "" is the same thing.

> --- a/scripts/depmod.sh
> +++ b/scripts/depmod.sh
> 
>  DEPMOD=$1
> -KERNELRELEASE=$2
> +shift
> +KERNELRELEASE=$1
> +shift

you can do:
	DEPMOD=$1
	KERNELRELEASE=$2
	shift 2

> +# older versions of depmod don't support -P <symbol-prefix>
> +# support was added in module-init-tools 3.13
> +if test "$1" = "-P"; then
> +	release=$("$DEPMOD" --version)
> +	package=$(echo "$release" | cut -d' ' -f 1)
> +	if test "$package" = "module-init-tools"; then
> +		version=$(echo "$release" | cut -d' ' -f 2)
> +		later=$({ echo "$version"; echo "3.13"; } | sort -V | tail -n 1)

you could do instead:
	later=$(printf '%s\n' "$version" "3.13" | sort -V | tail -n 1)

> +		if test "$later" != "$version"; then
> +			# module-init-tools < 3.13, drop the next 2 args
> +			shift
> +			shift
> +		fi

shift 2
-mike
James Hogan Feb. 5, 2013, 10:33 a.m. UTC | #5
Hi Mike,

On 03/02/13 06:17, Mike Frysinger wrote:
> On Thursday 31 January 2013 04:41:43 James Hogan wrote:
>> --- a/Makefile
>> +++ b/Makefile
>>
>> +ifneq ($(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)),)
>> +  depmod_args = -P $(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
>> +endif
>> ...
>>  # Run depmod only if we have System.map and depmod is executable
>>  quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
>>        cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
>> -                   $(KERNELRELEASE)
>> +                   $(KERNELRELEASE) $(depmod_args)
> 
> scripts/Makefile.lib just does:
> 	ifdef CONFIG_SYMBOL_PREFIX
> so you should do the same

arch/openrisc/Kconfig now defines SYMBOL_PREFIX as "", so this isn't
sufficient (arguably it probably shouldn't be defined empty like that?)

> 
> that said, cmd_depmod is just a shell command.  and you're running another 
> script helper (depmod.sh).  how about passing it unconditionally ?
> 	cmd_depmod = ... -P "$(CONFIG_SYMBOL_PREFIX)"
> 
> since the default will be "no prefix", using -P "" is the same thing.

Yep, I could do this, but depmod.sh would need modifying to drop it if
the prefix is empty, otherwise you get the following from depmod:
FATAL: -P only takes a single char

I don't mind adding that, but what do you think?

> 
>> --- a/scripts/depmod.sh
>> +++ b/scripts/depmod.sh
>>
>>  DEPMOD=$1
>> -KERNELRELEASE=$2
>> +shift
>> +KERNELRELEASE=$1
>> +shift
> 
> you can do:
> 	DEPMOD=$1
> 	KERNELRELEASE=$2
> 	shift 2

neat, thanks

> 
>> +# older versions of depmod don't support -P <symbol-prefix>
>> +# support was added in module-init-tools 3.13
>> +if test "$1" = "-P"; then
>> +	release=$("$DEPMOD" --version)
>> +	package=$(echo "$release" | cut -d' ' -f 1)
>> +	if test "$package" = "module-init-tools"; then
>> +		version=$(echo "$release" | cut -d' ' -f 2)
>> +		later=$({ echo "$version"; echo "3.13"; } | sort -V | tail -n 1)
> 
> you could do instead:
> 	later=$(printf '%s\n' "$version" "3.13" | sort -V | tail -n 1)

yep, definitely better, thanks

> 
>> +		if test "$later" != "$version"; then
>> +			# module-init-tools < 3.13, drop the next 2 args
>> +			shift
>> +			shift
>> +		fi
> 
> shift 2

ok

Thanks for the suggestions

Cheers
James
Mike Frysinger Feb. 5, 2013, 11:18 p.m. UTC | #6
On Tuesday 05 February 2013 05:33:19 James Hogan wrote:
> On 03/02/13 06:17, Mike Frysinger wrote:
> > On Thursday 31 January 2013 04:41:43 James Hogan wrote:
> >> --- a/Makefile
> >> +++ b/Makefile
> >> 
> >> +ifneq ($(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)),)
> >> +  depmod_args = -P $(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
> >> +endif
> >> ...
> >>  # Run depmod only if we have System.map and depmod is executable
> >>  quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
> >>        cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh
> >>        $(DEPMOD) \
> >> -                   $(KERNELRELEASE)
> >> +                   $(KERNELRELEASE) $(depmod_args)
> > 
> > scripts/Makefile.lib just does:
> > 	ifdef CONFIG_SYMBOL_PREFIX
> > 
> > so you should do the same
> 
> arch/openrisc/Kconfig now defines SYMBOL_PREFIX as "", so this isn't
> sufficient (arguably it probably shouldn't be defined empty like that?)

yes, that should simply be deleted

> > that said, cmd_depmod is just a shell command.  and you're running
> > another script helper (depmod.sh).  how about passing it unconditionally
> > ?
> > 
> > 	cmd_depmod = ... -P "$(CONFIG_SYMBOL_PREFIX)"
> > 
> > since the default will be "no prefix", using -P "" is the same thing.
> 
> Yep, I could do this, but depmod.sh would need modifying to drop it if
> the prefix is empty, otherwise you get the following from depmod:
> FATAL: -P only takes a single char
> 
> I don't mind adding that, but what do you think?

i mean depmod.sh should only pass -P to depmod if the arg is non-empty
-mike
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 2d3c92c..89e41d4 100644
--- a/Makefile
+++ b/Makefile
@@ -1394,10 +1394,14 @@  quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN   $(wildcard $(rm-dirs)))
 quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
       cmd_rmfiles = rm -f $(rm-files)
 
+ifneq ($(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX)),)
+  depmod_args = -P $(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
+endif
+
 # Run depmod only if we have System.map and depmod is executable
 quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
       cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
-                   $(KERNELRELEASE)
+                   $(KERNELRELEASE) $(depmod_args)
 
 # Create temporary dir for module support files
 # clean it up only when building all modules
diff --git a/scripts/depmod.sh b/scripts/depmod.sh
index 2ae4817..4f3747f 100755
--- a/scripts/depmod.sh
+++ b/scripts/depmod.sh
@@ -2,16 +2,35 @@ 
 #
 # A depmod wrapper used by the toplevel Makefile
 
-if test $# -ne 2; then
-	echo "Usage: $0 /sbin/depmod <kernelrelease>" >&2
+if test $# -lt 2; then
+	echo "Usage: $0 /sbin/depmod <kernelrelease> [args]" >&2
 	exit 1
 fi
 DEPMOD=$1
-KERNELRELEASE=$2
+shift
+KERNELRELEASE=$1
+shift
 
 if ! test -r System.map -a -x "$DEPMOD"; then
 	exit 0
 fi
+
+# older versions of depmod don't support -P <symbol-prefix>
+# support was added in module-init-tools 3.13
+if test "$1" = "-P"; then
+	release=$("$DEPMOD" --version)
+	package=$(echo "$release" | cut -d' ' -f 1)
+	if test "$package" = "module-init-tools"; then
+		version=$(echo "$release" | cut -d' ' -f 2)
+		later=$({ echo "$version"; echo "3.13"; } | sort -V | tail -n 1)
+		if test "$later" != "$version"; then
+			# module-init-tools < 3.13, drop the next 2 args
+			shift
+			shift
+		fi
+	fi
+fi
+
 # older versions of depmod require the version string to start with three
 # numbers, so we cheat with a symlink here
 depmod_hack_needed=true
@@ -30,7 +49,7 @@  if $depmod_hack_needed; then
 	KERNELRELEASE=99.98.$KERNELRELEASE
 fi
 
-set -- -ae -F System.map
+set -- -ae -F System.map "$@"
 if test -n "$INSTALL_MOD_PATH"; then
 	set -- "$@" -b "$INSTALL_MOD_PATH"
 fi