Skip to contentSkip to conversation

package/ncftp: fix cross compilation detection

PATCH Superseded Yegor Yefremov via buildroot 2 participants 9 messages Sep 3 – Oct 30

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/ncftp: fix cross compilation detection

From: Yegor Yefremov <[email protected]>

ncftp still ships a configure script generated with autoconf 2.13, which determines whether it is cross compiling by simply trying to run a trivial program built with $CC, instead of looking at --host/--build. That heuristic breaks when the build machine is able to execute the binaries produced by the cross compiler, which is typically the case when building for x86/x86-64 on an x86-64 machine:

checking whether the C compiler (...) is a cross-compiler... no

configure then takes the AC_TRY_RUN path for the remaining tests. Those tests link against the target libraries but are executed on the build machine, so they fail as soon as more than the bare C library is involved. The most visible victim is the curses detection, which links the test program against the target libncurses and then runs it:

checking for curses library headers... checking for ncurses.h... yes checking for curses.h... yes
checking for curses library... no

With no curses library, ncftpbookmarks is silently dropped from the build and installation later fails with:

install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory

Other checks are mis-detected the same way, e.g. the 64-bit integral type checks, which end up breaking the build itself:

checking how to scan a 64-bit integral type... cannot scan io_get.c:763:96: error: expected ')' before 'PRINTF_LONG_LONG'

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Fixes:
https://autobuild.buildroot.org/results/ab25f98d7ab8b397e2aa4f87af9cf1d814f3d6cc/

---
 ...cross-compilation-from-host-and-buil.patch | 60 +++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch
package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch new file +60 -0
new file mode 100644
index 0000000000..c3ecd61d1f
@@ -0,0 +1,60 @@
+From: Yegor Yefremov <[email protected]>
+Date: Thu, 3 Sep 2026 10:00:00 +0200
+Subject: [PATCH] configure: detect cross compilation from --host and --build
+
+ncftp still ships a configure script generated with autoconf 2.13, which
+determines whether it is cross compiling by simply trying to run a
+trivial program built with $CC. That heuristic breaks when the build
+machine is able to execute the binaries produced by the cross compiler,
+which is typically the case when building for x86/x86-64 on an x86-64
+machine: configure then concludes it is not cross compiling and starts
+using AC_TRY_RUN based tests.
+
+Those tests link against the target libraries but are executed on the
+build machine, so they fail as soon as more than the bare C library is
+involved. The most visible victim is the curses detection, which links
+the test program against the target libncurses and then runs it:
+
+  checking for curses library headers... checking for ncurses.h... yes
+  checking for curses.h... yes
+  checking for curses library... no
+
+With no curses library, ncftpbookmarks is silently dropped from the
+build and installation later fails with:
+
+  install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory
+
+Follow what autoconf has been doing since 2.50 and consider the build
+cross compilation as soon as --host is given and differs from --build,
+regardless of whether the produced binaries happen to be runnable.
+
+Note: configure is not regenerated during the build, hence the generated
+script is patched directly.
+
+Upstream: N/A, patching a generated file (upstream has neither a public
+VCS nor a bug tracker)
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ configure | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index d955e20..2311c73 100755
+--- a/configure
++++ b/configure
+@@ -845,8 +845,13 @@ int main(void){return(0);}
+ EOF
+ if { (eval echo configure:847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   ac_cv_prog_cc_works=yes
++  # If --host was given and differs from --build, we are cross compiling,
++  # even when the build machine happens to be able to run the binaries
++  # produced by the cross compiler.
++  if test "$host" != NONE && test "$host" != "$build"; then
++    ac_cv_prog_cc_cross=yes
+   # If we can't run a trivial program, we are probably using a cross compiler.
+-  if (./conftest; exit) 2>/dev/null; then
++  elif (./conftest; exit) 2>/dev/null; then
+     ac_cv_prog_cc_cross=no
+   else
+     ac_cv_prog_cc_cross=yes
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello,

Quoted 4 lines · Yegor Yefremov via buildroot

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Instead of patching the generated configure script, have you tried using AUTORECONF = YES to fully regenerate the configure script from the configure.in? Or perhaps this is hopeless as the configure.in is ancient and any modern autoconf while not accept this ancient configure.in?

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hello Yegor,

Do you have some feedback on the below questions?

Thanks!

Thomas

Quoted 24 lines · Thomas Petazzoni via buildroot

Hello,

Quoted 4 lines · Yegor Yefremov via buildroot

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Instead of patching the generated configure script, have you tried using AUTORECONF = YES to fully regenerate the configure script from the configure.in? Or perhaps this is hopeless as the configure.in is ancient and any modern autoconf while not accept this ancient configure.in?

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#3 lore raw

From: Yegor Yefremov <[email protected]>

Hello Thomas,

Sorry for the late reply.

Quoted 5 lines · Thomas Petazzoni

Instead of patching the generated configure script, have you tried using AUTORECONF = YES to fully regenerate the configure script from the configure.in? Or perhaps this is hopeless as the configure.in is ancient and any modern autoconf while not accept this ancient configure.in?

Yes, it's the latter. We actually used to regenerate it (running autoconf -I autoconf_local in a pre-configure hook) until the 3.2.9 bump, where I had to drop it because it stopped working. With 3.3.0 it still fails:

configure.in:53: error: AC_LANG: unknown language:
autoconf_local/aclocal.m4:415: wi_TRY_RUN_NATIVE is expanded from...

The macros in autoconf_local/aclocal.m4 depend on autoconf 2.13 internals (AC_LANG used as a value, AC_FD_CC, __oline__, ...), and upstream even ships patches against autoconf 2.13 itself (acgeneral-2.13.m4.patch, acspecific-2.13.m4.patch), so their configure is produced by a patched 2.13. Making it work with autoconf 2.7x would mean porting all of those macros, which is far more invasive than this small fix to the generated script.

I've just sent a v2 that adds this explanation to the commit message and also drops the now unneeded host-autoconf dependency, which is a leftover from that time.

Best regards,
Yegor
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw

PATCH v2 1/1 package/ncftp: fix cross compilation detection

In reply to Yegor Yefremov via buildroot

From: Yegor Yefremov <[email protected]>

ncftp still ships a configure script generated with autoconf 2.13, which determines whether it is cross compiling by simply trying to run a trivial program built with $CC, instead of looking at --host/--build. That heuristic breaks when the build machine is able to execute the binaries produced by the cross compiler, which is typically the case when building for x86/x86-64 on an x86-64 machine:

checking whether the C compiler (...) is a cross-compiler... no

configure then takes the AC_TRY_RUN path for the remaining tests. Those tests link against the target libraries but are executed on the build machine, so they fail as soon as more than the bare C library is involved. The most visible victim is the curses detection, which links the test program against the target libncurses and then runs it:

checking for curses library headers... checking for ncurses.h... yes checking for curses.h... yes
checking for curses library... no

With no curses library, ncftpbookmarks is silently dropped from the build and installation later fails with:

install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory

Other checks are mis-detected the same way, e.g. the 64-bit integral type checks, which end up breaking the build itself:

checking how to scan a 64-bit integral type... cannot scan io_get.c:763:96: error: expected ')' before 'PRINTF_LONG_LONG'

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Regenerating configure instead is not an option: the macros in autoconf_local/aclocal.m4 rely on autoconf 2.13 internals (AC_LANG used as a value, AC_FD_CC, __oline__, ...) and upstream generates configure with a patched autoconf 2.13 (see autoconf_local/acgeneral-2.13.m4.patch and acspecific-2.13.m4.patch). A modern autoconf fails with:

configure.in:53: error: AC_LANG: unknown language:

This is also why running autoconf was dropped with the 3.2.9 bump in commit f8bc27111531e9607f79121414f61c0c2d5f83c0 (package/ncftp: bump to version 3.2.9). That commit left the host-autoconf dependency behind though, so drop it now.

Fixes:
https://autobuild.buildroot.org/results/ab25f98d7ab8b397e2aa4f87af9cf1d814f3d6cc/

Assisted-by Claude:claude-opus-5-5

---
Changes v1 -> v2:
- explain why configure is patched rather than regenerated (Thomas)
- drop the leftover host-autoconf dependency

 ...cross-compilation-from-host-and-buil.patch | 60 +++++++++++++++++++
 package/ncftp/ncftp.mk                        |  1 -
 2 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch
package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch new file +60 -0
new file mode 100644
index 0000000000..c3ecd61d1f
@@ -0,0 +1,60 @@
+From: Yegor Yefremov <[email protected]>
+Date: Thu, 3 Sep 2026 10:00:00 +0200
+Subject: [PATCH] configure: detect cross compilation from --host and --build
+
+ncftp still ships a configure script generated with autoconf 2.13, which
+determines whether it is cross compiling by simply trying to run a
+trivial program built with $CC. That heuristic breaks when the build
+machine is able to execute the binaries produced by the cross compiler,
+which is typically the case when building for x86/x86-64 on an x86-64
+machine: configure then concludes it is not cross compiling and starts
+using AC_TRY_RUN based tests.
+
+Those tests link against the target libraries but are executed on the
+build machine, so they fail as soon as more than the bare C library is
+involved. The most visible victim is the curses detection, which links
+the test program against the target libncurses and then runs it:
+
+  checking for curses library headers... checking for ncurses.h... yes
+  checking for curses.h... yes
+  checking for curses library... no
+
+With no curses library, ncftpbookmarks is silently dropped from the
+build and installation later fails with:
+
+  install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory
+
+Follow what autoconf has been doing since 2.50 and consider the build
+cross compilation as soon as --host is given and differs from --build,
+regardless of whether the produced binaries happen to be runnable.
+
+Note: configure is not regenerated during the build, hence the generated
+script is patched directly.
+
+Upstream: N/A, patching a generated file (upstream has neither a public
+VCS nor a bug tracker)
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ configure | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index d955e20..2311c73 100755
+--- a/configure
++++ b/configure
+@@ -845,8 +845,13 @@ int main(void){return(0);}
+ EOF
+ if { (eval echo configure:847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   ac_cv_prog_cc_works=yes
++  # If --host was given and differs from --build, we are cross compiling,
++  # even when the build machine happens to be able to run the binaries
++  # produced by the cross compiler.
++  if test "$host" != NONE && test "$host" != "$build"; then
++    ac_cv_prog_cc_cross=yes
+   # If we can't run a trivial program, we are probably using a cross compiler.
+-  if (./conftest; exit) 2>/dev/null; then
++  elif (./conftest; exit) 2>/dev/null; then
+     ac_cv_prog_cc_cross=no
+   else
+     ac_cv_prog_cc_cross=yes
package/ncftp/ncftp.mk +0 -1
index c56fc86848..4075449c53 100644
@@ -11,7 +11,6 @@ NCFTP_TARGET_BINS = ncftp
 NCFTP_LICENSE = ClArtistic
 NCFTP_LICENSE_FILES = doc/LICENSE.txt
 
-NCFTP_DEPENDENCIES = host-autoconf
 NCFTP_CONF_OPTS = --disable-ccdv
 
 ifeq ($(BR2_PACKAGE_NCFTP_GET),y)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Hello,

Quoted 10 lines · Yegor Yefremov via buildroot

From: Yegor Yefremov <[email protected]>

ncftp still ships a configure script generated with autoconf 2.13, which determines whether it is cross compiling by simply trying to run a trivial program built with $CC, instead of looking at --host/--build. That heuristic breaks when the build machine is able to execute the binaries produced by the cross compiler, which is typically the case when building for x86/x86-64 on an x86-64 machine:

checking whether the C compiler (...) is a cross-compiler... no

[...]

Thanks for the new iteration. But... which commit/change introduced the regression? If you're not able to trace back the origin of the regression, does it happen in 2025.02.x?

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#6 lore raw

PATCH v3 1/1 package/ncftp: fix cross compilation detection

In reply to Yegor Yefremov via buildroot

From: Yegor Yefremov <[email protected]>

ncftp still ships a configure script generated with autoconf 2.13, which determines whether it is cross compiling by simply trying to run a trivial program built with $CC, instead of looking at --host/--build. That heuristic breaks when the build machine is able to execute the binaries produced by the cross compiler, which is typically the case when building for x86/x86-64 on an x86-64 machine:

checking whether the C compiler (...) is a cross-compiler... no

configure then takes the AC_TRY_RUN path for the remaining tests. Those tests link against the target libraries but are executed on the build machine, so they fail as soon as more than the bare C library is involved. The most visible victim is the curses detection, which links the test program against the target libncurses and then runs it:

checking for curses library headers... checking for ncurses.h... yes checking for curses.h... yes
checking for curses library... no

With no curses library, ncftpbookmarks is silently dropped from the build and installation later fails with:

install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory

Other checks are mis-detected the same way, e.g. the 64-bit integral type checks, which end up breaking the build itself:

checking how to scan a 64-bit integral type... cannot scan io_get.c:763:96: error: expected ')' before 'PRINTF_LONG_LONG'

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Regenerating configure instead is not an option: the macros in autoconf_local/aclocal.m4 rely on autoconf 2.13 internals (AC_LANG used as a value, AC_FD_CC, __oline__, ...) and upstream generates configure with a patched autoconf 2.13 (see autoconf_local/acgeneral-2.13.m4.patch and acspecific-2.13.m4.patch). A modern autoconf fails with:

configure.in:53: error: AC_LANG: unknown language:

This regression was introduced by commit f8bc27111531e9607f79121414f61c0c2d5f83c0 ("package/ncftp: bump to version 3.2.9"). Before it, a pre-configure hook regenerated configure with autoconf precisely because the bundled script "doesn't detect cross-compilation correctly". With 3.2.9 that regeneration started to fail, so the hook was dropped, which brought the broken detection back. That commit left the host-autoconf dependency behind though, so drop it now.

The issue is present since 2025.05, and in 2025.02.x since 2025.02.1, where the 3.2.9 bump was backported as commit 6b0e4d82c31ee04e8a6abb48323252a7cd97c177.

Fixes:
https://autobuild.buildroot.org/results/ab25f98d7ab8b397e2aa4f87af9cf1d814f3d6cc/

Assisted-by Claude:claude-opus-5-5

---
Changes v2 -> v3:
- identify the commit that introduced the regression and the affected

    releases, including 2025.02.x (Thomas)

Changes v1 -> v2:
- explain why configure is patched rather than regenerated (Thomas)
- drop the leftover host-autoconf dependency

 ...cross-compilation-from-host-and-buil.patch | 60 +++++++++++++++++++
 package/ncftp/ncftp.mk                        |  1 -
 2 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch
package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch new file +60 -0
new file mode 100644
index 0000000000..c3ecd61d1f
@@ -0,0 +1,60 @@
+From: Yegor Yefremov <[email protected]>
+Date: Thu, 3 Sep 2026 10:00:00 +0200
+Subject: [PATCH] configure: detect cross compilation from --host and --build
+
+ncftp still ships a configure script generated with autoconf 2.13, which
+determines whether it is cross compiling by simply trying to run a
+trivial program built with $CC. That heuristic breaks when the build
+machine is able to execute the binaries produced by the cross compiler,
+which is typically the case when building for x86/x86-64 on an x86-64
+machine: configure then concludes it is not cross compiling and starts
+using AC_TRY_RUN based tests.
+
+Those tests link against the target libraries but are executed on the
+build machine, so they fail as soon as more than the bare C library is
+involved. The most visible victim is the curses detection, which links
+the test program against the target libncurses and then runs it:
+
+  checking for curses library headers... checking for ncurses.h... yes
+  checking for curses.h... yes
+  checking for curses library... no
+
+With no curses library, ncftpbookmarks is silently dropped from the
+build and installation later fails with:
+
+  install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory
+
+Follow what autoconf has been doing since 2.50 and consider the build
+cross compilation as soon as --host is given and differs from --build,
+regardless of whether the produced binaries happen to be runnable.
+
+Note: configure is not regenerated during the build, hence the generated
+script is patched directly.
+
+Upstream: N/A, patching a generated file (upstream has neither a public
+VCS nor a bug tracker)
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ configure | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index d955e20..2311c73 100755
+--- a/configure
++++ b/configure
+@@ -845,8 +845,13 @@ int main(void){return(0);}
+ EOF
+ if { (eval echo configure:847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   ac_cv_prog_cc_works=yes
++  # If --host was given and differs from --build, we are cross compiling,
++  # even when the build machine happens to be able to run the binaries
++  # produced by the cross compiler.
++  if test "$host" != NONE && test "$host" != "$build"; then
++    ac_cv_prog_cc_cross=yes
+   # If we can't run a trivial program, we are probably using a cross compiler.
+-  if (./conftest; exit) 2>/dev/null; then
++  elif (./conftest; exit) 2>/dev/null; then
+     ac_cv_prog_cc_cross=no
+   else
+     ac_cv_prog_cc_cross=yes
package/ncftp/ncftp.mk +0 -1
index c56fc86848..4075449c53 100644
@@ -11,7 +11,6 @@ NCFTP_TARGET_BINS = ncftp
 NCFTP_LICENSE = ClArtistic
 NCFTP_LICENSE_FILES = doc/LICENSE.txt
 
-NCFTP_DEPENDENCIES = host-autoconf
 NCFTP_CONF_OPTS = --disable-ccdv
 
 ifeq ($(BR2_PACKAGE_NCFTP_GET),y)
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#7 lore raw
Quoted 58 lines · Yegor Yefremov via buildroot

From: Yegor Yefremov <[email protected]>

ncftp still ships a configure script generated with autoconf 2.13, which determines whether it is cross compiling by simply trying to run a trivial program built with $CC, instead of looking at --host/--build. That heuristic breaks when the build machine is able to execute the binaries produced by the cross compiler, which is typically the case when building for x86/x86-64 on an x86-64 machine:

checking whether the C compiler (...) is a cross-compiler... no

configure then takes the AC_TRY_RUN path for the remaining tests. Those tests link against the target libraries but are executed on the build machine, so they fail as soon as more than the bare C library is involved. The most visible victim is the curses detection, which links the test program against the target libncurses and then runs it:

checking for curses library headers... checking for ncurses.h... yes checking for curses.h... yes
checking for curses library... no

With no curses library, ncftpbookmarks is silently dropped from the build and installation later fails with:

install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory

Other checks are mis-detected the same way, e.g. the 64-bit integral type checks, which end up breaking the build itself:

checking how to scan a 64-bit integral type... cannot scan io_get.c:763:96: error: expected ')' before 'PRINTF_LONG_LONG'

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Regenerating configure instead is not an option: the macros in autoconf_local/aclocal.m4 rely on autoconf 2.13 internals (AC_LANG used as a value, AC_FD_CC, __oline__, ...) and upstream generates configure with a patched autoconf 2.13 (see autoconf_local/acgeneral-2.13.m4.patch and acspecific-2.13.m4.patch). A modern autoconf fails with:

configure.in:53: error: AC_LANG: unknown language:

This regression was introduced by commit f8bc27111531e9607f79121414f61c0c2d5f83c0 ("package/ncftp: bump to version 3.2.9"). Before it, a pre-configure hook regenerated configure with autoconf precisely because the bundled script "doesn't detect cross-compilation correctly". With 3.2.9 that regeneration started to fail, so the hook was dropped, which brought the broken detection back. That commit left the host-autoconf dependency behind though, so drop it now.

The issue is present since 2025.05, and in 2025.02.x since 2025.02.1, where the 3.2.9 bump was backported as commit 6b0e4d82c31ee04e8a6abb48323252a7cd97c177.

Quoted 5 lines

Fixes:
https://autobuild.buildroot.org/results/ab25f98d7ab8b397e2aa4f87af9cf1d814f3d6cc/

Assisted-by Claude:claude-opus-5-5

Applied to master, thanks!

Best regards,

Thomas Petazzoni

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#8 lore raw
In reply to Yegor Yefremov via buildroot

In reply of:

Quoted 56 lines

ncftp still ships a configure script generated with autoconf 2.13, which determines whether it is cross compiling by simply trying to run a trivial program built with $CC, instead of looking at --host/--build. That heuristic breaks when the build machine is able to execute the binaries produced by the cross compiler, which is typically the case when building for x86/x86-64 on an x86-64 machine:

checking whether the C compiler (...) is a cross-compiler... no

configure then takes the AC_TRY_RUN path for the remaining tests. Those tests link against the target libraries but are executed on the build machine, so they fail as soon as more than the bare C library is involved. The most visible victim is the curses detection, which links the test program against the target libncurses and then runs it:

checking for curses library headers... checking for ncurses.h... yes checking for curses.h... yes
checking for curses library... no

With no curses library, ncftpbookmarks is silently dropped from the build and installation later fails with:

install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory

Other checks are mis-detected the same way, e.g. the 64-bit integral type checks, which end up breaking the build itself:

checking how to scan a 64-bit integral type... cannot scan io_get.c:763:96: error: expected ')' before 'PRINTF_LONG_LONG'

So add a patch making the generated configure script follow what autoconf has been doing since 2.50, and consider the build cross compilation as soon as --host is given and differs from --build, regardless of whether the produced binaries happen to be runnable.

Regenerating configure instead is not an option: the macros in autoconf_local/aclocal.m4 rely on autoconf 2.13 internals (AC_LANG used as a value, AC_FD_CC, __oline__, ...) and upstream generates configure with a patched autoconf 2.13 (see autoconf_local/acgeneral-2.13.m4.patch and acspecific-2.13.m4.patch). A modern autoconf fails with:

configure.in:53: error: AC_LANG: unknown language:

This regression was introduced by commit f8bc27111531e9607f79121414f61c0c2d5f83c0 ("package/ncftp: bump to version 3.2.9"). Before it, a pre-configure hook regenerated configure with autoconf precisely because the bundled script "doesn't detect cross-compilation correctly". With 3.2.9 that regeneration started to fail, so the hook was dropped, which brought the broken detection back. That commit left the host-autoconf dependency behind though, so drop it now.

The issue is present since 2025.05, and in 2025.02.x since 2025.02.1, where the 3.2.9 bump was backported as commit 6b0e4d82c31ee04e8a6abb48323252a7cd97c177.

Quoted 5 lines

Fixes:
https://autobuild.buildroot.org/results/ab25f98d7ab8b397e2aa4f87af9cf1d814f3d6cc/

Assisted-by Claude:claude-opus-5-5

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 85 lines

---
Changes v2 -> v3:
- identify the commit that introduced the regression and the affected

    releases, including 2025.02.x (Thomas)

Changes v1 -> v2:
- explain why configure is patched rather than regenerated (Thomas)
- drop the leftover host-autoconf dependency

 ...cross-compilation-from-host-and-buil.patch | 60 +++++++++++++++++++
 package/ncftp/ncftp.mk                        |  1 -
 2 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100644 package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch
package/ncftp/0001-configure-detect-cross-compilation-from-host-and-buil.patch new file +60 -0
new file mode 100644
index 0000000000..c3ecd61d1f
@@ -0,0 +1,60 @@
+From: Yegor Yefremov <[email protected]>
+Date: Thu, 3 Sep 2026 10:00:00 +0200
+Subject: [PATCH] configure: detect cross compilation from --host and --build
+
+ncftp still ships a configure script generated with autoconf 2.13, which
+determines whether it is cross compiling by simply trying to run a
+trivial program built with $CC. That heuristic breaks when the build
+machine is able to execute the binaries produced by the cross compiler,
+which is typically the case when building for x86/x86-64 on an x86-64
+machine: configure then concludes it is not cross compiling and starts
+using AC_TRY_RUN based tests.
+
+Those tests link against the target libraries but are executed on the
+build machine, so they fail as soon as more than the bare C library is
+involved. The most visible victim is the curses detection, which links
+the test program against the target libncurses and then runs it:
+
+  checking for curses library headers... checking for ncurses.h... yes
+  checking for curses.h... yes
+  checking for curses library... no
+
+With no curses library, ncftpbookmarks is silently dropped from the
+build and installation later fails with:
+
+  install: cannot stat '.../build/ncftp-3.3.0/bin/ncftpbookmarks': No such file or directory
+
+Follow what autoconf has been doing since 2.50 and consider the build
+cross compilation as soon as --host is given and differs from --build,
+regardless of whether the produced binaries happen to be runnable.
+
+Note: configure is not regenerated during the build, hence the generated
+script is patched directly.
+
+Upstream: N/A, patching a generated file (upstream has neither a public
+VCS nor a bug tracker)
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ configure | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index d955e20..2311c73 100755
+--- a/configure
++++ b/configure
+@@ -845,8 +845,13 @@ int main(void){return(0);}
+ EOF
+ if { (eval echo configure:847: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+   ac_cv_prog_cc_works=yes
++  # If --host was given and differs from --build, we are cross compiling,
++  # even when the build machine happens to be able to run the binaries
++  # produced by the cross compiler.
++  if test "$host" != NONE && test "$host" != "$build"; then
++    ac_cv_prog_cc_cross=yes
+   # If we can't run a trivial program, we are probably using a cross compiler.
+-  if (./conftest; exit) 2>/dev/null; then
++  elif (./conftest; exit) 2>/dev/null; then
+     ac_cv_prog_cc_cross=no
+   else
+     ac_cv_prog_cc_cross=yes
package/ncftp/ncftp.mk +0 -0
index c56fc86848..4075449c53 100644

package/ncftp/ncftp.mk NCFTP_TARGET_BINS = ncftp · line 16

Quoted 7 lines
package/ncftp/ncftp.mk +0 -1
@@ -11,7 +11,6 @@ NCFTP_TARGET_BINS = ncftp
 NCFTP_LICENSE = ClArtistic
 NCFTP_LICENSE_FILES = doc/LICENSE.txt
 
-NCFTP_DEPENDENCIES = host-autoconf
 NCFTP_CONF_OPTS = --disable-ccdv
 
 ifeq ($(BR2_PACKAGE_NCFTP_GET),y)

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot