From cbb1d7ec3727aba2ae4cc77400f4c99cbe8446aa Mon Sep 17 00:00:00 2001 From: vasilito Date: Sun, 12 Jul 2026 22:46:27 +0300 Subject: [PATCH] fix: ncurses/ncursesw need -fPIC for static linking into PIE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --with-pic alone doesn't generate PIC code in newer ncurses (6.6+). The static archive produced non-PIC objects using R_X86_64_PC32 relocations, which can't be linked into PIE executables. Forced PIC via: - Switched DYNAMIC_INIT → DYNAMIC_STATIC_INIT (builds both shared AND static) - Added CFLAGS+=+=-fPIC CXXFLAGS+=+=-fPIC export (forces PIC at compile) redbear-netctl-console now links successfully against libncursesw.a. --- recipes/libs/ncurses/recipe.toml | 4 +++- recipes/libs/ncursesw/recipe.toml | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/recipes/libs/ncurses/recipe.toml b/recipes/libs/ncurses/recipe.toml index ad0affd889..3927d5e6c9 100644 --- a/recipes/libs/ncurses/recipe.toml +++ b/recipes/libs/ncurses/recipe.toml @@ -8,7 +8,7 @@ patches = [ [build] template = "custom" script = """ -DYNAMIC_INIT +DYNAMIC_STATIC_INIT COOKBOOK_CONFIGURE_FLAGS+=( --disable-db-install --disable-stripping @@ -26,6 +26,8 @@ if [ "${COOKBOOK_DYNAMIC}" == "1" ] then COOKBOOK_CONFIGURE_FLAGS+=(--with-shared) fi +export CFLAGS="${CFLAGS} -fPIC" +export CXXFLAGS="${CXXFLAGS} -fPIC" cookbook_configure """ diff --git a/recipes/libs/ncursesw/recipe.toml b/recipes/libs/ncursesw/recipe.toml index 355d9d127a..cd65db1ddc 100644 --- a/recipes/libs/ncursesw/recipe.toml +++ b/recipes/libs/ncursesw/recipe.toml @@ -8,7 +8,7 @@ same_as = "../ncurses" [build] template = "custom" script = """ -DYNAMIC_INIT +DYNAMIC_STATIC_INIT COOKBOOK_CONFIGURE_FLAGS+=( --disable-db-install --disable-ext-colors @@ -24,6 +24,9 @@ COOKBOOK_CONFIGURE_FLAGS+=( cf_cv_func_mkstemp=yes cf_cv_wint_t=yes ) +# Force PIC compilation - --with-pic alone doesn't always work for static libs +export CFLAGS="${CFLAGS} -fPIC" +export CXXFLAGS="${CXXFLAGS} -fPIC" cookbook_configure """