Skip to contentSkip to conversation

rules: filter out irrelevant files

PATCH In review Michael S. Tsirkin 2 participants 3 messages Feb 17, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rules: filter out irrelevant files

It's often handy to make executables depend on each other, e.g. make a test depend on a helper. This doesn't work now, as linker will attempt to use the helper as an object.
To fix, filter only relevant file types before linking an executable.

---
 rules.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rules.mak +1 -1
index fc5ee41..d1ff311 100644
@@ -102,7 +102,7 @@ LD_REL := $(CC) -nostdlib -Wl,-r
 modules:
 
 %$(EXESUF): %.o
-	$(call LINK,$^)
+	$(call LINK,$(filter %.o %.a %.mo, $^))
 
 %.a:
 	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
Signature · 1 line
MST
#1 lore raw
Quoted 4 lines · Michael S. Tsirkin

It's often handy to make executables depend on each other, e.g. make a test depend on a helper. This doesn't work now, as linker will attempt to use the helper as an object.
To fix, filter only relevant file types before linking an executable.

Can you provide an example of what you're trying to do?

Paolo

Quoted 19 lines
---
 rules.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rules.mak +1 -1
index fc5ee41..d1ff311 100644
@@ -102,7 +102,7 @@ LD_REL := $(CC) -nostdlib -Wl,-r
 modules:
 
 %$(EXESUF): %.o
-	$(call LINK,$^)
+	$(call LINK,$(filter %.o %.a %.mo, $^))
 
 %.a:
 	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")
#2 lore raw
Quoted 11 lines · Paolo Bonzini
Quoted 4 lines · Michael S. Tsirkin

It's often handy to make executables depend on each other, e.g. make a test depend on a helper. This doesn't work now, as linker will attempt to use the helper as an object.
To fix, filter only relevant file types before linking an executable.

Can you provide an example of what you're trying to do?

Paolo

Write a test that uses vhost-user to talk to a background process helper (e.g. vhost-user-bridge).
This has to depend on the helper being built.

Quoted 19 lines
Quoted 19 lines
---
 rules.mak | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
rules.mak +1 -1
index fc5ee41..d1ff311 100644
@@ -102,7 +102,7 @@ LD_REL := $(CC) -nostdlib -Wl,-r
 modules:
 
 %$(EXESUF): %.o
-	$(call LINK,$^)
+	$(call LINK,$(filter %.o %.a %.mo, $^))
 
 %.a:
 	$(call quiet-command,rm -f $@ && $(AR) rcs $@ $^,"  AR    $(TARGET_DIR)$@")