diff mbox series

lib: Fix compilation when USE_STATIC_LIB

Message ID 1511909897-18600-1-git-send-email-angelo@amarulasolutions.com
State Superseded
Headers show
Series lib: Fix compilation when USE_STATIC_LIB | expand

Commit Message

Angelo Compagnucci Nov. 28, 2017, 10:58 p.m. UTC
This patch removes the mandatory compiling of the shared library
when USE_STATIC_LIB is used.

Signed-off-by: Angelo Compagnucci <angelo@amarulasolutions.com>
---
 lib/Module.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Jean Delvare Nov. 29, 2017, 10:08 a.m. UTC | #1
Hi Angelo,

On Tue, 28 Nov 2017 23:58:17 +0100, Angelo Compagnucci wrote:
> This patch removes the mandatory compiling of the shared library
> when USE_STATIC_LIB is used.

No, thanks. The current behavior is as desired: always build the
dynamic library, and optionally build the static library. It was never
the intent to allow only building the static library. Static libraries
are evil.
Angelo Compagnucci Nov. 29, 2017, 11:04 a.m. UTC | #2
Hi Jean,

On Wed, Nov 29, 2017 at 11:08 AM, Jean Delvare <jdelvare@suse.de> wrote:
>
> Hi Angelo,
>
> On Tue, 28 Nov 2017 23:58:17 +0100, Angelo Compagnucci wrote:
> > This patch removes the mandatory compiling of the shared library
> > when USE_STATIC_LIB is used.
>
> No, thanks. The current behavior is as desired: always build the
> dynamic library, and optionally build the static library. It was never
> the intent to allow only building the static library. Static libraries
> are evil.


In Buildroot we have the need to support also static only libraries
cause we have targets that doesn't support dynamic libraries (like
cortex M4 for which I'm fixing this bug).
The option for static only is also present for various other
architectures as a build option.

So, if this cannot be fixed upstream, I'll push a patch only on the
Buildroot side.

Sincerely, Angelo.


>
>
> --
> Jean Delvare
> SUSE L3 Support
Jean Delvare Nov. 29, 2017, 12:05 p.m. UTC | #3
On Wed, 29 Nov 2017 12:04:06 +0100, Angelo Compagnucci wrote:
> On Wed, Nov 29, 2017 at 11:08 AM, Jean Delvare <jdelvare@suse.de> wrote:
> > On Tue, 28 Nov 2017 23:58:17 +0100, Angelo Compagnucci wrote:  
> > > This patch removes the mandatory compiling of the shared library
> > > when USE_STATIC_LIB is used.  
> >
> > No, thanks. The current behavior is as desired: always build the
> > dynamic library, and optionally build the static library. It was never
> > the intent to allow only building the static library. Static libraries
> > are evil.  
> 
> In Buildroot we have the need to support also static only libraries
> cause we have targets that doesn't support dynamic libraries (like
> cortex M4 for which I'm fixing this bug).

That's a frightening platform :(

> The option for static only is also present for various other
> architectures as a build option.
> 
> So, if this cannot be fixed upstream, I'll push a patch only on the
> Buildroot side.

Maybe it can be fixed upstream, but not the way you proposed because it
causes a regression (by default the dynamic lib would no longer be
built.)

I suppose that introducing BUILD_DYNAMIC_LIB, which would default to 1
and would only control whether the dynamic library is built or not,
would be acceptable. But you'll have to make sure that at least one
flavor of the library is being built, and that the tools themselves are
linked to the right library (dynamic if available, else fallback to
static, see USE_STATIC_LIB.)

By default we want all library flavors built, and the tools linked
dynamically.
diff mbox series

Patch

diff --git a/lib/Module.mk b/lib/Module.mk
index 432a051..bdcb19d 100644
--- a/lib/Module.mk
+++ b/lib/Module.mk
@@ -27,12 +27,13 @@  LIB_SHSONAME	:= $(LIB_SHBASENAME).$(LIB_MAINVER)
 LIB_SHLIBNAME	:= $(LIB_SHBASENAME).$(LIB_VER)
 LIB_STLIBNAME	:= libi2c.a
 
-LIB_TARGETS	:= $(LIB_SHLIBNAME)
 LIB_LINKS	:= $(LIB_SHSONAME) $(LIB_SHBASENAME)
 LIB_OBJECTS	:= smbus.o
 ifeq ($(BUILD_STATIC_LIB),1)
-LIB_TARGETS	+= $(LIB_STLIBNAME)
+LIB_TARGETS	:= $(LIB_STLIBNAME)
 LIB_OBJECTS	+= smbus.ao
+else
+LIB_TARGETS	:= $(LIB_SHLIBNAME)
 endif
 
 #