DPDK patches and discussions
 help / color / Atom feed
* [dpdk-dev] [PATCH] mk: add EXTRA_CFLAGS to link step for shared library
@ 2019-11-05  1:56 Stephen Hemminger
  2019-11-25 22:56 ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2019-11-05  1:56 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

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.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 mk/rte.shared.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mk/rte.shared.mk b/mk/rte.shared.mk
index 2b501ddb8480..a0620a3eb233 100644
--- a/mk/rte.shared.mk
+++ b/mk/rte.shared.mk
@@ -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) \
-- 
2.20.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] mk: add EXTRA_CFLAGS to link step for shared library
  2019-11-05  1:56 [dpdk-dev] [PATCH] mk: add EXTRA_CFLAGS to link step for shared library Stephen Hemminger
@ 2019-11-25 22:56 ` Thomas Monjalon
  2019-11-26  1:44   ` Stephen Hemminger
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Monjalon @ 2019-11-25 22:56 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev

05/11/2019 02:56, Stephen Hemminger:
> 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.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> --- a/mk/rte.shared.mk
> +++ b/mk/rte.shared.mk
> -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.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] mk: add EXTRA_CFLAGS to link step for shared library
  2019-11-25 22:56 ` Thomas Monjalon
@ 2019-11-26  1:44   ` Stephen Hemminger
  0 siblings, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2019-11-26  1:44 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Mon, 25 Nov 2019 23:56:00 +0100
Thomas Monjalon <thomas@monjalon.net> wrote:

> 05/11/2019 02:56, Stephen Hemminger:
> > 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.
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> > --- a/mk/rte.shared.mk
> > +++ b/mk/rte.shared.mk
> > -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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-05  1:56 [dpdk-dev] [PATCH] mk: add EXTRA_CFLAGS to link step for shared library Stephen Hemminger
2019-11-25 22:56 ` Thomas Monjalon
2019-11-26  1:44   ` Stephen Hemminger

DPDK patches and discussions

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ http://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox