I reproduced this FTBFS on a clean testbed with glibc 2.43 and GCC 15.

During reproduction, three files failed compilation due to const-preserving 
strrchr() under _GNU_SOURCE:
1. src/utils.c:121 (str_replace_ext): pos pointer declared as const char *.
2. src/utils/path.c:32, 54 (path_dirname, path_basename): sep pointer declared 
as const char *.
3. ext_src/quickjs/quickjs.c:27267: p is written to later in 
js_default_module_normalize_name (*p = '\0'), so making p const breaks 
subsequent assignments. Introduced const char *p_base for base_name inspection.

In addition, debian/rules now passes werror=0 to scons so toolchain
diagnostic changes do not abort builds.

With this patch, goxel 0.15.1-1ubuntu1 builds cleanly and the resulting
binary runs without issues.

Forwarded to Debian BTS:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1149680

Attached debdiff: goxel_0.15.1-1ubuntu1.debdiff


** Description changed:

+ [ Impact ]
+ 
+ goxel 0.15.1-1 fails to build from source in Ubuntu stonking (26.10)
+ with glibc >= 2.43.
+ 
+ Under glibc 2.43 and C23 / _GNU_SOURCE, string functions such as strrchr(), 
strchr(), and memchr() are const-preserving macros. Passing a const char * 
returns const char *.
+ In goxel:
+ 1. src/utils.c (str_replace_ext) assigns strrchr(str, '.') to char *pos.
+ 2. src/utils/path.c (path_dirname and path_basename) assigns strrchr(path, 
'/') to char *sep.
+ 3. ext_src/quickjs/quickjs.c (js_default_module_normalize_name) assigns 
strrchr(base_name, '/') to char *p.
+ 
+ Because SConstruct defaults to werror=True (-Werror), -Wdiscarded-
+ qualifiers causes fatal build errors across all architectures.
+ 
+ [ Fix ]
+ 
+ 1. d/p/0001-fix-glibc-2.43-strrchr-const-qualifier.patch:
+    - src/utils.c: declare const char *pos in str_replace_ext().
+    - src/utils/path.c: declare const char *sep in path_dirname() and 
path_basename().
+    - ext_src/quickjs/quickjs.c: introduce const char *p_base for base_name 
inspection while keeping char *p for subsequent mutable operations on filename.
+ 2. debian/rules:
+    - pass werror=0 to scons in override_dh_auto_build to avoid treating 
toolchain warnings as errors.
+ 
+ [ Test Plan ]
+ 
+ 1. In a clean Ubuntu stonking / glibc >= 2.43 environment, extract goxel 
0.15.1-1 source package.
+ 2. Attempt to build using dpkg-buildpackage -us -uc -b: build fails with 
-Werror=discarded-qualifiers on strrchr().
+ 3. Apply 0.15.1-1ubuntu1 debdiff and rebuild: package builds cleanly with 
exit code 0.
+ 4. Verify produced binaries:
+    - dpkg -i goxel_0.15.1-1ubuntu1_amd64.deb
+    - goxel --version / goxel --help executes properly.
+ 
+ [ Where problems could occur ]
+ 
+ The patch only touches pointer qualification (char * to const char *) where 
the target memory is read-only and never modified in place. In quickjs.c, a 
dedicated p_base pointer is used specifically so existing in-place string 
mutation via p on filename is unaltered.
+ Setting werror=0 in debian/rules ensures standard Debian/Ubuntu build policy 
compliance where compiler diagnostic updates do not break archive packages.
+ 
+ [ Other Info ]
+ 
+ - Target release: Ubuntu stonking (26.10 devel series).
+ - Debian BTS bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1149680
+ - Debian unstable currently has goxel 0.15.1-1 built before glibc 2.43 
reached the archive; Debian will hit the same FTBFS upon next rebuild. Patch 
has been forwarded to Debian BTS #1149680.
+ - Full build and installation tested on Ubuntu 26.04/26.10 testbed with glibc 
2.43 and GCC 15.
+ 
+ --- [ Original Report ]
+ 
  goxel 0.15.1-1 fails to build in stonking because glibc 2.43+ made
  strrchr() const-preserving and goxel builds with -Werror.
  
  Build log (amd64, 2026-09-24, libc6-dev 2.44-1ubuntu1, gcc-15 
15.3.0-4ubuntu1):
  https://launchpad.net/ubuntu/+source/goxel/0.15.1-1/+build/33019031
  
    src/utils.c: In function 'str_replace_ext':
    src/utils.c:121:9: error: assignment discards 'const' qualifier from 
pointer target type [-Werror=discarded-qualifiers]
      121 |     pos = strrchr(str, '.');
    src/../ext_src/quickjs/quickjs.c:27267:7: error: assignment discards 
'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
          p = strrchr(base_name, '/');
    cc1: all warnings being treated as errors
  
  == Cause ==
  
  - glibc 2.43 turned strchr, strrchr, memchr, strstr and similar functions 
into macros that return a const-qualified pointer when given a const-qualified 
argument (glibc NEWS, 2.43). This is a C23 feature, but glibc also enables it 
under _GNU_SOURCE, and goxel's src/config.h defines _GNU_SOURCE. So it applies 
even though goxel builds with -std=gnu99.
  - In both places above, strrchr() is called on a const char * and the result 
is stored in a plain char *.
  - goxel's SConstruct defaults to werror=True, so the new 
-Wdiscarded-qualifiers warning becomes a hard error.
  
  Debian is not visibly affected yet: its amd64 0.15.1-1+b1 was built
  around 2026-07-31, before glibc 2.43 reached unstable (2026-08-10). The
  next Debian rebuild should fail the same way. Upstream goxel master
  still has the same code in str_replace_ext().
  
  == Suggested fix (untested) ==
  
  1. Proper fix, for upstream (goxel, and the bundled quickjs):
     - src/utils.c, str_replace_ext(): declare "const char *pos;"
     - ext_src/quickjs/quickjs.c around line 27267: make "p" const, if it is 
not written through later in that function; otherwise keep it char * and cast.
  2. Packaging fix: pass werror=0 to scons in debian/rules (the "scons cycles=0 
debug=0 clang=1 ..." line), so new compiler or glibc warnings do not break 
distribution builds.
  
  Preferably both go to Debian and are synced. Only the amd64 build log
  was checked; other architectures are expected to fail the same way.

** Changed in: goxel (Ubuntu)
       Status: New => Confirmed

** Tags added: ftbfs patch stonking

** Bug watch added: Debian Bug tracker #1149680
   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1149680

** Patch added: "goxel_0.15.1-1ubuntu1 debdiff"
   
https://bugs.launchpad.net/ubuntu/+source/goxel/+bug/2169229/+attachment/6004818/+files/goxel_0.15.1-1ubuntu1.debdiff

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2169229

Title:
  goxel 0.15.1-1 FTBFS: strrchr() const-preserving with glibc >= 2.43 +
  -Werror (discarded-qualifiers)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/goxel/+bug/2169229/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to