mk: add EXTRA_CFLAGS to link step for shared library
PATCH 1/1 mk: add EXTRA_CFLAGS to link step for shared library
When doing a cross compiling it is common to use EXTRA_CFLAGS with --sysroot option to point to alternate root filesystem. This already works as expected for objects and executables, it just doesn't work correctly for shared libraries.
When a shared library is linked using CC this flag needs to be passed in order for libraries to be found.
--- mk/rte.shared.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mk/rte.shared.mk +1 -1
@@ -31,7 +31,7 @@ exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1)))) ifeq ($(LINK_USING_CC),1) override EXTRA_LDFLAGS := $(call linkerprefix,$(EXTRA_LDFLAGS)) -O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \ +O_TO_SO = $(CC) $(EXTRA_CFLAGS) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \ -shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS)) else O_TO_SO = $(LD) $(LDFLAGS) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \
Signature · 1 line
2.20.1
05/11/2019 02:56, Stephen Hemminger:
Quoted 12 lines
When doing a cross compiling it is common to use
EXTRA_CFLAGSwith --sysroot option to point to alternate root filesystem. This already works as expected for objects and executables, it just doesn't work correctly for shared libraries.When a shared library is linked using CC this flag needs to be passed in order for libraries to be found.
Signed-off-by Stephen Hemminger <[email protected]>---
mk/rte.shared.mk exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1)))) · line 35
Quoted 3 lines
mk/rte.shared.mk +1
-1-O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \ +O_TO_SO = $(CC) $(EXTRA_CFLAGS) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \ -shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))
After several thoughts, I am afraid of the possible side effects of such a change.
I think only LDFLAGS should be used when linking.
If you need the same parameters at compilation and linking, you should pass the same parameters to CFLAGS and LDFLAGS.
Quoted 9 lines · On Mon, 25 Nov 2019 23:56:00 +0100 Thomas Monjalon <[email protected]> wrote:
05/11/2019 02:56, Stephen Hemminger:
Quoted 8 lines
When doing a cross compiling it is common to use
EXTRA_CFLAGSwith --sysroot option to point to alternate root filesystem. This already works as expected for objects and executables, it just doesn't work correctly for shared libraries.When a shared library is linked using CC this flag needs to be passed in order for libraries to be found.
Quoted 13 lines
mk/rte.shared.mk exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1)))) · line 35
Quoted 7 lines
Signed-off-by Stephen Hemminger <[email protected]>---
mk/rte.shared.mk +1
-1-O_TO_SO = $(CC) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \ +O_TO_SO = $(CC) $(EXTRA_CFLAGS) $(call linkerprefix,$(LDFLAGS)) $(LDFLAGS_$(@)) $(EXTRA_LDFLAGS) \ -shared -o $@ $(OBJS-y) $(call linkerprefix,$(LDLIBS))After several thoughts, I am afraid of the possible side effects of such a change.
I think only LDFLAGS should be used when linking.
If you need the same parameters at compilation and linking, you should pass the same parameters to CFLAGS and LDFLAGS.
Let me try same thing with EXTRA_LDFLAGS