public inbox for rulkc@linuxtesting.org
 help / color / mirror / Atom feed
* [rulkc] [PATCH 1/1] package/mtd: build with -fPIC when shared libraries are enabled
@ 2026-08-01 22:29 viper
  2026-08-09  8:26 ` Konstantin Menyaev
  0 siblings, 1 reply; 2+ messages in thread
From: viper @ 2026-08-01 22:29 UTC (permalink / raw)
  To: buildroot; +Cc: rulkc, Konstantin Menyaev

From: Konstantin Menyaev <viper@landau•one>

Historically, mtd-utils only provided static libraries, so they are
built without -fPIC.

This becomes an issue for configs with shared libraries,
where apps may need to link libmtd.a or libubi.a
into shared objects, resulting in relocation errors.

Build the MTD package with -fPIC when shared libraries are enabled,
while keeping static-only builds unchanged.

Signed-off-by: Konstantin Menyaev <viper@landau•one>
---
 package/mtd/mtd.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/mtd/mtd.mk b/package/mtd/mtd.mk
index 2a625fccce..d67770d5ba 100644
--- a/package/mtd/mtd.mk
+++ b/package/mtd/mtd.mk
@@ -14,8 +14,13 @@ MTD_CPE_ID_PRODUCT = mtd-utils
 MTD_INSTALL_STAGING = YES
 MTD_DEPENDENCIES = host-pkgconf
 
+MTD_CFLAGS = $(TARGET_CFLAGS)
 MTD_LDFLAGS = $(TARGET_LDFLAGS)
 
+ifeq ($(BR2_SHARED_LIBS)$(BR2_STATIC_SHARED_LIBS),y)
+MTD_CFLAGS += -fPIC
+endif
+
 ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
 MTD_DEPENDENCIES += libexecinfo
 MTD_LDFLAGS += -lexecinfo
@@ -35,7 +40,7 @@ else
 MTD_CONF_OPTS += --without-zlib
 endif
 
-MTD_CONF_ENV += LDFLAGS="$(MTD_LDFLAGS)"
+MTD_CONF_ENV += CFLAGS="$(MTD_CFLAGS)" LDFLAGS="$(MTD_LDFLAGS)"
 
 ifeq ($(BR2_PACKAGE_MTD_JFFS_UTILS),y)
 MTD_CONF_OPTS += --with-jffs
-- 
2.55.0


_______________________________________________
rulkc mailing list
rulkc@linuxtesting.org
http://linuxtesting.org/cgi-bin/mailman/listinfo/rulkc

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

* Re: [rulkc] [PATCH 1/1] package/mtd: build with -fPIC when shared libraries are enabled
  2026-08-01 22:29 [rulkc] [PATCH 1/1] package/mtd: build with -fPIC when shared libraries are enabled viper
@ 2026-08-09  8:26 ` Konstantin Menyaev
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Menyaev @ 2026-08-09  8:26 UTC (permalink / raw)
  To: buildroot; +Cc: rulkc

On 8/2/26 01:29, viper@landau•one wrote:
> From: Konstantin Menyaev <viper@landau•one>
> 
> Historically, mtd-utils only provided static libraries, so they are
> built without -fPIC.
> 
> This becomes an issue for configs with shared libraries,
> where apps may need to link libmtd.a or libubi.a
> into shared objects, resulting in relocation errors.
> 
> Build the MTD package with -fPIC when shared libraries are enabled,
> while keeping static-only builds unchanged.
> 
> Signed-off-by: Konstantin Menyaev <viper@landau•one>
> ---
>   package/mtd/mtd.mk | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/package/mtd/mtd.mk b/package/mtd/mtd.mk
> index 2a625fccce..d67770d5ba 100644
> --- a/package/mtd/mtd.mk
> +++ b/package/mtd/mtd.mk
> @@ -14,8 +14,13 @@ MTD_CPE_ID_PRODUCT = mtd-utils
>   MTD_INSTALL_STAGING = YES
>   MTD_DEPENDENCIES = host-pkgconf
>   
> +MTD_CFLAGS = $(TARGET_CFLAGS)
>   MTD_LDFLAGS = $(TARGET_LDFLAGS)
>   
> +ifeq ($(BR2_SHARED_LIBS)$(BR2_STATIC_SHARED_LIBS),y)
> +MTD_CFLAGS += -fPIC
> +endif
> +
>   ifeq ($(BR2_PACKAGE_LIBEXECINFO),y)
>   MTD_DEPENDENCIES += libexecinfo
>   MTD_LDFLAGS += -lexecinfo
> @@ -35,7 +40,7 @@ else
>   MTD_CONF_OPTS += --without-zlib
>   endif
>   
> -MTD_CONF_ENV += LDFLAGS="$(MTD_LDFLAGS)"
> +MTD_CONF_ENV += CFLAGS="$(MTD_CFLAGS)" LDFLAGS="$(MTD_LDFLAGS)"
>   
>   ifeq ($(BR2_PACKAGE_MTD_JFFS_UTILS),y)
>   MTD_CONF_OPTS += --with-jffs

kindly ping

_______________________________________________
rulkc mailing list
rulkc@linuxtesting.org
http://linuxtesting.org/cgi-bin/mailman/listinfo/rulkc

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

end of thread, other threads:[~2026-08-09  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-01 22:29 [rulkc] [PATCH 1/1] package/mtd: build with -fPIC when shared libraries are enabled viper
2026-08-09  8:26 ` Konstantin Menyaev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®