Skip to contentSkip to conversation

Makefile: Fix cross building

PATCH In review Patrick Waterlander 2 participants 2 messages Apr 21, 2021 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Fix cross building

The native pkg-config is always called which may result in incorrect flags and paths being passed to the cross compiler. Implement $(CROSS_COMPILE)pkg-config to avoid this issue.

---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +2 -1
index bc19584fee59..9aa2073f68d6 100644
@@ -462,6 +462,7 @@ LZMA		= lzma
 LZ4		= lz4c
 XZ		= xz
 ZSTD		= zstd
+PKG_CONFIG     ?= $(CROSS_COMPILE)pkg-config
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
 		  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)
@@ -1089,7 +1090,7 @@ mod_sign_cmd = true
 endif
 export mod_sign_cmd
 
-HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
+HOST_LIBELF_LIBS = $(shell $(PKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)
 
 has_libelf = $(call try-run,\
                echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
Signature · 1 line
2.17.1
#1 lore raw
Quoted 23 lines · Patrick Waterlander

The native pkg-config is always called which may result in incorrect flags and paths being passed to the cross compiler. Implement $(CROSS_COMPILE)pkg-config to avoid this issue.

---
 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Makefile +1 -0
index bc19584fee59..9aa2073f68d6 100644
@@ -462,6 +462,7 @@ LZMA                = lzma
 LZ4            = lz4c
 XZ             = xz
 ZSTD           = zstd
+PKG_CONFIG     ?= $(CROSS_COMPILE)pkg-config
 
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                  -Wbitwise -Wno-return-void -Wno-unknown-attribute $(CF)

Makefile mod_sign_cmd = true · line 1093

Quoted 5 lines
Makefile +1 -1
@@ -1089,7 +1090,7 @@ mod_sign_cmd = true
 endif
 export mod_sign_cmd
 
-HOST_LIBELF_LIBS = $(shell pkg-config libelf --libs 2>/dev/null || echo -lelf)
+HOST_LIBELF_LIBS = $(shell $(PKG_CONFIG) libelf --libs 2>/dev/null || echo -lelf)

libelf will be linked to host programs.

This is clear from HOST_LIBELF_LIBS.

                   ^^^^

pkg-config should be OK.

Quoted 6 lines
Makefile +0 -1
 has_libelf = $(call try-run,\
                echo "int main() {}" | $(HOSTCC) -xc -o /dev/null $(HOST_LIBELF_LIBS) -,1,0)
--

2.17.1

Signature · 2 lines
Best Regards
Masahiro Yamada