[Buildroot] [PATCH 1/1] package/mtd: build with -fPIC when shared libraries are enabled
[email protected] Sun, 2 Aug 2026 01:29:45 +0300
| Newsgroups | net.busybox.buildroot |
|---|---|
| Message-ID | <[email protected]> |
From: Konstantin Menyaev <[email protected]> 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 <[email protected]> --- 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 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot