build: fix external module symbol collection if build_dir is a symlink
authorRoman Yeryomin <roman@advem.lv>
Fri, 12 Apr 2019 15:26:03 +0000 (18:26 +0300)
committerJonas Gorski <jonas.gorski@gmail.com>
Thu, 6 Jun 2019 10:05:51 +0000 (12:05 +0200)
e26ffb31dfa30d498b963a86d231835e3af7d3df fixed only embedded modules
symbol collection. If we are building external modules, like broadcom-wl
or lantiq dsl stuff then modules which do EXPORT_SYMBOL have unresolved
paths in Module.symvers and external module which depend on other
external modules will have empty dependencies, leading to broken
module loading.
This was discussed on IRC with Jonas some time ago.
Fix this by handling both resolved and unresolved paths.

Fixes: e26ffb31dfa3 ("build: fix module symbol collection if build_dir is a symlink")
Signed-off-by: Roman Yeryomin <roman@advem.lv>
[jonas.gorski@gmail.com: add appropriate fixes tag]
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
include/kernel.mk

index 3195090a0a79795bd4f629fae963c251c6c18a4b..8dfe903bccbb6857d36feda25bf90f80e346acf1 100644 (file)
@@ -141,7 +141,10 @@ endef
 
 define collect_module_symvers
        for subdir in $(PKG_EXTMOD_SUBDIRS); do \
-               grep -F $$$$(readlink -f $(PKG_BUILD_DIR)) $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
+               realdir=$$$$(readlink -f $(PKG_BUILD_DIR)); \
+               grep -F $(PKG_BUILD_DIR) $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
+               [ "$(PKG_BUILD_DIR)" = "$$$$realdir" ] || \
+                       grep -F $$$$realdir $(PKG_BUILD_DIR)/$$$$subdir/Module.symvers >> $(PKG_BUILD_DIR)/Module.symvers.tmp; \
        done; \
        sort -u $(PKG_BUILD_DIR)/Module.symvers.tmp > $(PKG_BUILD_DIR)/Module.symvers; \
        mv $(PKG_BUILD_DIR)/Module.symvers $(PKG_INFO_DIR)/$(PKG_NAME).symvers