Bug 15990 - No function _python_sysroot defined
Summary: No function _python_sysroot defined
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Build (show other bugs)
Version: 4.24.0rc*
Hardware: x86 Linux
: P5 critical (vote)
Target Milestone: ---
Assignee: Samba release manager
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-01-29 14:20 UTC by Aditya
Modified: 2026-02-18 14:18 UTC (History)
1 user (show)

See Also:


Attachments
Samba compilation log (105.04 KB, text/plain)
2026-02-01 02:33 UTC, Aditya
no flags Details
patch to try (2.31 KB, patch)
2026-02-02 21:53 UTC, Douglas Bagnall
no flags Details
one more patch to try (3.71 KB, patch)
2026-02-03 20:10 UTC, Douglas Bagnall
no flags Details
patch for 4.23 (4.33 KB, patch)
2026-02-18 00:58 UTC, Douglas Bagnall
gary: review+
Details
patch for 4.24 (4.22 KB, patch)
2026-02-18 00:59 UTC, Douglas Bagnall
gary: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Aditya 2026-01-29 14:20:05 UTC
I am compiling latest Samba git (3ae8053f6bce3ac8e701fa6d1ea90595ea50a9d0) with minimum patches for latest OpenWrt x86_64, more notable patch is here : 
```
--- a/python/wscript
+++ b/python/wscript
@@ -90,9 +90,9 @@ def configure(conf):
                                       "'python3-iso8601'. Please install "
                                       "one of the packages.")
 
-    if not Options.options.without_ad_dc:
-        for module, package in ad_dc_pkgs.items():
-            find_third_party_module(conf, module, package)
+#    if not Options.options.without_ad_dc:
+#       for module, package in ad_dc_pkgs.items():
+#           find_third_party_module(conf, module, package)
 
 
 def build(bld):
```

It's required in OpenWrt to disable detection of python3-markdown package

The problem with patch above is the following error is being logged : 
```
Checking if compiler accepts -fstack-protector                                                  : no 
Checking if compiler accepts -fstack-clash-protection                                           : yes 
'configure' finished successfully (2m18.369s)
No function '_python_sysroot=/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody' defined in /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/wscript
make[2]: *** [Makefile:485: /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/.configured_618a2b81b6a7ca0e965081e353102573] Error 1
make[2]: Leaving directory '/home/nobody/works/openwrt/feeds/packages/net/samba4'
time: package/feeds/packages/samba4/compile#90.79#52.18#142.28
    ERROR: package/feeds/packages/samba4 failed to build.
make[1]: *** [package/Makefile:187: package/feeds/packages/samba4/compile] Error 1
make[1]: Leaving directory '/home/nobody/works/openwrt'
make: *** [/home/nobody/works/openwrt/include/toplevel.mk:233: package/samba4/compile] Error 2
```

If I am recall, this is not happened before around 7 months ago, I can compiled Samba latest git with above patch.

OpenWrt's Samba Makefile available in here : https://github.com/openwrt/packages/blob/master/net/samba4/Makefile
Comment 1 Douglas Bagnall 2026-01-29 20:06:58 UTC
'_python_sysroot' is not from Samba or cpython, as far as I can tell.

Can you patch the Samba Makefile like this, and we might see more of a traceback:

--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 # simple makefile wrapper to run waf
 
 WAF_BINARY=$(PYTHON) ./buildtools/bin/waf
-WAF=PYTHONHASHSEED=1 WAF_MAKE=1 $(WAF_BINARY)
+WAF=PYTHONHASHSEED=1 WAF_MAKE=1 $(WAF_BINARY) --verbose
 
 all:
 	$(WAF) build
--
Comment 2 Aditya 2026-01-31 17:45:49 UTC
It doesn't make any differences maybe because it hasn't arrived yet at calling waf binary ?.


```
define Build/Compile
	(cd $(PKG_BUILD_DIR); \
		./buildtools/bin/waf ---verbose install \
		--jobs=$(shell nproc) \
		--destdir="$(PKG_INSTALL_DIR)" \
	)
endef
```
Comment 3 Douglas Bagnall 2026-01-31 22:32:37 UTC
(In reply to Aditya from comment #2)
> It doesn't make any differences maybe because it hasn't arrived yet at calling waf binary ?.

Ah yes. You'll need to patch ./configure which itself calls waf.
Comment 4 Aditya 2026-02-01 02:33:34 UTC
Created attachment 18814 [details]
Samba compilation log
Comment 5 Aditya 2026-02-01 12:14:07 UTC
Attached samba compilation log, don't know if it's helps or not.
Comment 6 Aditya 2026-02-01 14:34:57 UTC
I am able to compiled 4.22.7 perfectly fine in here. Does waf upgrade has any issues?
Comment 7 Douglas Bagnall 2026-02-01 21:51:39 UTC
(In reply to Aditya from comment #6)
> Does waf upgrade has any issues?

It does now!

The argument parser did change.

I think waf wants `_python_sysroot=path ./configure --args` rather than `./configure --args _python_sysroot=path`.

Perhaps doesn't need to see _python_sysroot at all, in which case this change to openwrt packages should work:

diff --git a/net/samba4/Makefile b/net/samba4/Makefile
index b33d8e27d..e08e5cba8 100644
--- a/net/samba4/Makefile
+++ b/net/samba4/Makefile
@@ -170,6 +170,7 @@ CONFIGURE_ARGS:=$(filter-out        \
        --program-suffix=%      \
        --disable-nls           \
        --disable-ipv6          \
+       _python_sysroot=                \
        , $(CONFIGURE_ARGS))
 
 HOST_CONFIGURE_ARGS:=$(filter-out      \
Comment 8 Aditya 2026-02-02 07:43:58 UTC
I did your changes but it doens't make any differences, then I am trying by : 
```
CONFIGURE_VARS += \
	CPP="$(TARGET_CROSS)cpp" \
	XSLTPROC=false \
	WAF_NO_PREFORK=1 \
	_python_sysroot=$(STAGING_DIR)
```

Also doesn't make any any differences : 

```
(cd /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/./; if [ -x ./buildtools/bin/waf ]; then find /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/ -name config.guess | xargs -r chmod u+w; find /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/ -name config.guess | xargs -r -n1 cp --remove-destination /home/nobody/works/openwrt/scripts/config.guess; find /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/ -name config.sub | xargs -r chmod u+w; find /home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5/ -name config.sub | xargs -r -n1 cp --remove-destination /home/nobody/works/openwrt/scripts/config.sub; AR="x86_64-openwrt-linux-gnu-gcc-ar" AS="ccache x86_64-openwrt-linux-gnu-gcc -c -mtune=rocketlake -march=rocketlake -O2 -fno-caller-saves -fno-plt -mtune=rocketlake -march=rocketlake -O2 -fhonour-copts -fmacro-prefix-map=/home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5=samba-4.23.5 -ffunction-sections -fdata-sections -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,pack-relative-relocs -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libiconv-full/include -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libintl-full/include -DPIC -fpic" LD="x86_64-openwrt-linux-gnu-ld.bfd" NM="x86_64-openwrt-linux-gnu-gcc-nm" CC="ccache x86_64-openwrt-linux-gnu-gcc" GCC="ccache x86_64-openwrt-linux-gnu-gcc" CXX="ccache x86_64-openwrt-linux-gnu-g++" RANLIB="x86_64-openwrt-linux-gnu-gcc-ranlib" STRIP=x86_64-openwrt-linux-gnu-strip OBJCOPY=x86_64-openwrt-linux-gnu-objcopy OBJDUMP=x86_64-openwrt-linux-gnu-objdump SIZE=x86_64-openwrt-linux-gnu-size CFLAGS="-mtune=rocketlake -march=rocketlake -O2 -fno-caller-saves -fno-plt -mtune=rocketlake -march=rocketlake -O2 -fhonour-copts -fmacro-prefix-map=/home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5=samba-4.23.5 -ffunction-sections -fdata-sections -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,pack-relative-relocs -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libiconv-full/include -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libintl-full/include -DPIC -fpic " CXXFLAGS="-mtune=rocketlake -march=rocketlake -O2 -fno-caller-saves -fno-plt -mtune=rocketlake -march=rocketlake -O2 -fhonour-copts -fmacro-prefix-map=/home/nobody/works/openwrt/build_dir/target-x86_64_glibc_nobody/samba-4.23.5=samba-4.23.5 -ffunction-sections -fdata-sections -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,pack-relative-relocs -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libiconv-full/include -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libintl-full/include -DPIC -fpic -ffunction-sections -fdata-sections -flto=auto -fno-fat-lto-objects " CPPFLAGS="-I/home/nobody/works/openwrt/staging_dir/toolchain-x86_64_gcc-15.2.0_glibc/usr/include -I/home/nobody/works/openwrt/staging_dir/toolchain-x86_64_gcc-15.2.0_glibc/include -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libiconv-full/include -I/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libintl-full/include " LDFLAGS="-L/home/nobody/works/openwrt/staging_dir/toolchain-x86_64_gcc-15.2.0_glibc/usr/lib -L/home/nobody/works/openwrt/staging_dir/toolchain-x86_64_gcc-15.2.0_glibc/lib -fuse-ld=bfd -Wl,--gc-sections -flto=auto -fuse-linker-plugin -zpack-relative-relocs -L/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libiconv-full/lib -Wl,-rpath-link=/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libiconv-full/lib -L/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libintl-full/lib -Wl,-rpath-link=/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib/libintl-full/lib -Wl,--as-needed -L/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/usr/lib -luring "  CPP="x86_64-openwrt-linux-gnu-cpp" XSLTPROC=false WAF_NO_PREFORK=1 _python_sysroot=/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody PATH="/home/nobody/works/openwrt/staging_dir/hostpkg/bin:/home/nobody/works/openwrt/staging_dir/hostpkg/usr/bin:/home/nobody/works/openwrt/staging_dir/toolchain-x86_64_gcc-15.2.0_glibc/bin:/home/nobody/works/openwrt/staging_dir/toolchain-x86_64_gcc-15.2.0_glibc/bin:/home/nobody/works/openwrt/staging_dir/host/bin:/home/nobody/works/openwrt/staging_dir/host/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" PYTHON_CONFIG="/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody/host/bin/python3.13-config"  ./buildtools/bin/waf configure --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info _python_sysroot="/home/nobody/works/openwrt/staging_dir/target-x86_64_glibc_nobody" _python_prefix="/usr" _python_exec_prefix="/usr" --with-iconv --hostcc="ccache /home/nobody/works/openwrt/staging_dir/host/bin/gcc" --cross-compile --cross-answers=cross-answers.txt --disable-cups --disable-iprint --disable-cephfs --disable-fault-handling --disable-glusterfs --disable-spotlight --enable-fhs --without-automount --without-lttng --without-pam --without-systemd --without-utmp --without-dmapi --without-fam --without-gettext --without-regedit --without-gpgme --with-lockdir=/var/lock --with-logfilebase=/var/log --with-piddir=/var/run --with-privatedir=/etc/samba --without-quotas --enable-avahi --without-ldb-lmdb --with-acl-support --with-static-modules=vfs_default,vfs_posixacl,auth_builtin,auth_sam,auth_unix,auth_samba4,pdb_smbpasswd,pdb_tdbsam,pdb_samba_dsdb,pdb_ldapsam,!DEFAULT,!FORCED --with-shared-modules=auth_script,vfs_io_uring,vfs_fruit,vfs_shadow_copy2,vfs_recycle,vfs_fake_perms,vfs_readonly,vfs_cap,vfs_offline,vfs_crossrename,vfs_catia,vfs_streams_xattr,vfs_xattr_tdb,vfs_widelinks,vfs_btrfs,vfs_virusfilter,vfs_shell_snap,vfs_commit,vfs_worm,vfs_netatalk,vfs_dirsort,vfs_fileid,vfs_audit,vfs_extd_audit,vfs_full_audit,vfs_acl_xattr,vfs_acl_tdb,!DEFAULT,!FORCED --bundled-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,com_err,uring,pytalloc-util.cpython-313,pyldb-util.cpython-313 --private-libraries=talloc,tevent,tevent-util,texpect,tdb,ldb,tdr,cmocka,replace,com_err ; fi; )

```
Comment 9 Aditya 2026-02-02 09:24:07 UTC
How about makes waf argument parser accept both of this possibilities?.
Comment 10 Aditya 2026-02-02 15:44:43 UTC
My last test was conclude the following : 
So the last working waf is from Samba version 4.22.x. 

waf from Samba version 4.23.x, 4.24.x, latest trunk/developer version are doesn't work in OpenWrt.
Comment 11 Aditya 2026-02-02 16:48:52 UTC
Also I have tried 
```
export _python_sysroot=$(STAGING_DIR)
export _python_prefix=/usr
export _python_exec_prefix=/usr/bin
```
In my Makefile.
Comment 12 Douglas Bagnall 2026-02-02 21:42:05 UTC
(In reply to Aditya from comment #9)
> How about makes waf argument parser accept both of this possibilities?

Yeah, the difficulty is waf is third party to us, and it has switched to using the python stdlib argparse parser, and we can't easily change that.

However, does this work?:

diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index 1fe4c30a2e8..e6983e47a5d 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -435,7 +435,7 @@ def CHECK_MAKEFLAGS(options):
                 Logs.zones = ['runner']
             if Logs.verbose > 2:
                 Logs.zones = ['*']
-        elif opt[0].isupper() and opt.find('=') != -1:
+        elif (opt[0].isupper() or opt[0] == '_') and '=' in opt:
             # this allows us to set waf options on the make command line
             # for example, if you do "make FOO=blah", then we set the
             # option 'FOO' in Options.options, to blah. If you look in wafsamba/wscript
-- 
2.43.0
Comment 13 Douglas Bagnall 2026-02-02 21:53:46 UTC
Created attachment 18815 [details]
patch to try

Sorry, that won't work, but the attached patch might.
Comment 14 Aditya 2026-02-03 02:57:12 UTC
w00t, it works now even without any modification to my Makefile!.

Thanks a lot, will it be committed to master and backported into 4.23 & 4.24?.
Comment 15 Douglas Bagnall 2026-02-03 09:05:31 UTC
(In reply to Aditya from comment #14)
I expect so, pending review etc.
Comment 16 Douglas Bagnall 2026-02-03 20:10:34 UTC
Created attachment 18823 [details]
one more patch to try

Aditya, can you check that this patch also works?
Comment 17 Aditya 2026-02-04 05:16:48 UTC
Douglas,
Latest patch also works, thanks.
Comment 18 Samba QA Contact 2026-02-18 00:01:04 UTC
This bug was referenced in samba master:

bd66dc2418318716083bf40e447f9815b199fc25
Comment 19 Douglas Bagnall 2026-02-18 00:58:26 UTC
Created attachment 18849 [details]
patch for 4.23
Comment 20 Douglas Bagnall 2026-02-18 00:59:32 UTC
Created attachment 18850 [details]
patch for 4.24
Comment 21 Douglas Bagnall 2026-02-18 01:27:23 UTC
The attached patches should fix the OpenWRT build for 4.24 and 4.23.
Comment 22 Aditya 2026-02-18 14:18:51 UTC
@Douglas,

  Thanks for the additional patches, will come handy.