Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLIBC_2.38 error when installing xeft / compiling xapian-lite on Ubuntu 24.04 #92

Closed
fapdash opened this issue Aug 21, 2024 · 6 comments
Labels
solution-in-comments There is a solution to this issue in the issue comments

Comments

@fapdash
Copy link
Contributor

fapdash commented Aug 21, 2024

The install used to work for me on Ubuntu 20.04, but on Ubuntu 24.04 I get this error when trying to compile the xapian-lite module required by xeft:

(module-open-failed "/home/fap/.emacs.d/elpa/xeft-3.3/xapian-lite.so" "/snap/emacs/2504/usr/bin/../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /home/fap/.emacs.d/elpa/xeft-3.3/xapian-lite.so)")

I tried to use the workaround from #71 like this:

(let* ((emacs-snap-dir (file-name-as-directory (getenv "EMACS_SNAP_DIR")))
       (process-environment (append `(,(concat "CC=" emacs-snap-dir "usr/bin/gcc-10" )
                                      ,(concat "CXX=" emacs-snap-dir "usr/bin/g++-10")
                                      ,(concat "CFLAGS=--sysroot=" emacs-snap-dir " -B" emacs-snap-dir "usr/lib/gcc")
                                      ,(concat "CPATH=" (file-name-directory (car (file-expand-wildcards (concat emacs-snap-dir "usr/include/*/bits")))))
				      ,(concat "CPPFLAGS=--sysroot=" emacs-snap-dir)
				      ,(concat "LDFLAGS=--sysroot=" emacs-snap-dir " -L" emacs-snap-dir "usr/lib" " -L" "/lib/x86_64-linux-gnu/")
                                      ,(concat "PKG_CONFIG_PATH=" (car (file-expand-wildcards (concat emacs-snap-dir "usr/lib/*/pkgconfig")))))
                                    process-environment)))
    (xeft))

Note that I added " -L" "/lib/x86_64-linux-gnu/" so the build finds the libxapian that I installed via sudo apt install libxapian-dev:

$ ldconfig -p | rg xapian
	libxapian.so.30 (libc6,x86-64) => /lib/x86_64-linux-gnu/libxapian.so.30
	libxapian.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libxapian.so

But then I guess libxapian doesn't like the environment from the snap:

/snap/emacs/2504/usr/bin/g++-10 xapian-lite.cc -o xapian-lite.so -shared -fPIC -I/include -std=c++11 -L/lib -lxapian
In file included from /snap/emacs/2504/usr/include/c++/10/cstdio:42,
                 from /snap/emacs/2504/usr/include/c++/10/ext/string_conversions.h:43,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:6557,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/snap/emacs/2504/usr/include/stdio.h:781:10: fatal error: bits/sys_errlist.h: No such file or directory
  781 | #include <bits/sys_errlist.h>
      |          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:18: xapian-lite.so] Error 1
/snap/emacs/2504/usr/bin/g++-10 xapian-lite.cc -o xapian-lite.so -shared -fPIC -I/include -std=c++11 -L/lib -lxapian
In file included from /snap/emacs/2504/usr/include/c++/10/cwchar:44,
                 from /snap/emacs/2504/usr/include/c++/10/bits/postypes.h:40,
                 from /snap/emacs/2504/usr/include/c++/10/bits/char_traits.h:40,
                 from /snap/emacs/2504/usr/include/c++/10/string:40,
                 from xapian-lite.cc:22:
/usr/include/wchar.h:111:30: error: expected initializer before ‘__attr_access’
  111 |   __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 3));
      |                              ^~~~~~~~~~~~~
/usr/include/wchar.h:117:31: error: expected initializer before ‘__attr_access’
  117 |   __THROW __nonnull ((1, 2))  __attr_access ((__read_write__, 1, 3));
      |                               ^~~~~~~~~~~~~
/usr/include/wchar.h:179:24: error: expected initializer before ‘__attr_dealloc_free’
  179 |   __attribute_malloc__ __attr_dealloc_free;
      |                        ^~~~~~~~~~~~~~~~~~~
In file included from /snap/emacs/2504/usr/include/x86_64-linux-gnu/c++/10/bits/gthr-default.h:35,
                 from /snap/emacs/2504/usr/include/x86_64-linux-gnu/c++/10/bits/gthr.h:148,
                 from /snap/emacs/2504/usr/include/c++/10/ext/atomicity.h:35,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:39,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/usr/include/pthread.h:1310:11: error: expected initializer before ‘__attr_access_none’
 1310 |   __THROW __attr_access_none (2);
      |           ^~~~~~~~~~~~~~~~~~
In file included from /snap/emacs/2504/usr/include/x86_64-linux-gnu/c++/10/bits/gthr.h:148,
                 from /snap/emacs/2504/usr/include/c++/10/ext/atomicity.h:35,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:39,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/snap/emacs/2504/usr/include/x86_64-linux-gnu/c++/10/bits/gthr-default.h: In function ‘int __gthread_setspecific(__gthread_key_t, const void*)’:
/snap/emacs/2504/usr/include/x86_64-linux-gnu/c++/10/bits/gthr-default.h:726:10: error: ‘pthread_setspecific’ was not declared in this scope; did you mean ‘pthread_getspecific’?
  726 |   return __gthrw_(pthread_setspecific) (__key, __ptr);
      |          ^~~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/cstdlib:75,
                 from /snap/emacs/2504/usr/include/c++/10/ext/string_conversions.h:41,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:6557,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/usr/include/stdlib.h: At global scope:
/usr/include/stdlib.h:698:5: error: expected initializer before ‘__attr_dealloc_free’
  698 |     __attr_dealloc_free;
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:702:14: error: expected initializer before ‘__attr_dealloc’
  702 |      __THROW __attr_dealloc (reallocarray, 1);
      |              ^~~~~~~~~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/cstdlib:75,
                 from /snap/emacs/2504/usr/include/c++/10/ext/string_conversions.h:41,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:6557,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/usr/include/stdlib.h:725:35: error: expected initializer before ‘__attribute_alloc_align__’
  725 |      __THROW __attribute_malloc__ __attribute_alloc_align__ ((1))
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:931:6: error: expected initializer before ‘__attr_dealloc_free’
  931 |      __attr_dealloc_free __wur;
      |      ^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:1075:5: error: expected initializer before ‘__attr_access’
 1075 |     __attr_access ((__read_only__, 2));
      |     ^~~~~~~~~~~~~
/usr/include/stdlib.h:1080:3: error: expected initializer before ‘__fortified_attr_access’
 1080 |   __fortified_attr_access (__write_only__, 1, 3)
      |   ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:1135:30: error: expected initializer before ‘__fortified_attr_access’
 1135 |      __THROW __nonnull ((2)) __fortified_attr_access (__write_only__, 2, 3);
      |                              ^~~~~~~~~~~~~~~~~~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/ext/string_conversions.h:41,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:6557,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/snap/emacs/2504/usr/include/c++/10/cstdlib:154:11: error: ‘mbstowcs’ has not been declared in ‘::’
  154 |   using ::mbstowcs;
      |           ^~~~~~~~
/snap/emacs/2504/usr/include/c++/10/cstdlib:171:11: error: ‘wcstombs’ has not been declared in ‘::’
  171 |   using ::wcstombs;
      |           ^~~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/cstdio:42,
                 from /snap/emacs/2504/usr/include/c++/10/ext/string_conversions.h:43,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:6557,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/usr/include/stdio.h:195:24: error: expected initializer before ‘__attr_dealloc’
  195 |   __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:207:25: error: expected initializer before ‘__attr_dealloc’
  207 |    __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                         ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:229:39: error: expected initializer before ‘__attr_dealloc_free’
  229 |    __THROW __attribute_malloc__ __wur __attr_dealloc_free;
      |                                       ^~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:266:24: error: expected initializer before ‘__attr_dealloc’
  266 |   __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:291:24: error: expected initializer before ‘__attr_dealloc’
  291 |   __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:300:24: error: expected initializer before ‘__attr_dealloc’
  300 |   __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:309:24: error: expected initializer before ‘__attr_dealloc’
  309 |   __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:315:32: error: expected initializer before ‘__attr_dealloc’
  315 |   __THROW __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                                ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:321:24: error: expected initializer before ‘__attr_dealloc’
  321 |   __attribute_malloc__ __attr_dealloc_fclose __wur;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:328:24: error: expected initializer before ‘__attr_dealloc’
  328 |   __attribute_malloc__ __attr_dealloc_fclose;
      |                        ^~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:655:12: error: expected initializer before ‘__fortified_attr_access’
  655 |      __wur __fortified_attr_access (__write_only__, 1, 2) __nonnull ((3));
      |            ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:679:5: error: expected initializer before ‘__fortified_attr_access’
  679 |     __fortified_attr_access (__write_only__, 1, 2) __nonnull ((3));
      |     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:878:38: error: expected initializer before ‘__COLD’
  878 | extern void perror (const char *__s) __COLD;
      |                                      ^~~~~~
/usr/include/stdio.h:904:24: error: expected initializer before ‘__attr_dealloc’
  904 |   __attribute_malloc__ __attr_dealloc (pclose, 1) __wur;
      |                        ^~~~~~~~~~~~~~
/usr/include/stdio.h:912:3: error: expected initializer before ‘__attr_access’
  912 |   __attr_access ((__write_only__, 1));
      |   ^~~~~~~~~~~~~
/usr/include/stdio.h:919:3: error: expected initializer before ‘__attr_access’
  919 |   __attr_access ((__write_only__, 1));
      |   ^~~~~~~~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/ext/string_conversions.h:43,
                 from /snap/emacs/2504/usr/include/c++/10/bits/basic_string.h:6557,
                 from /snap/emacs/2504/usr/include/c++/10/string:55,
                 from xapian-lite.cc:22:
/snap/emacs/2504/usr/include/c++/10/cstdio:108:11: error: ‘fgets’ has not been declared in ‘::’
  108 |   using ::fgets;
      |           ^~~~~
/snap/emacs/2504/usr/include/c++/10/cstdio:109:11: error: ‘fopen’ has not been declared in ‘::’
  109 |   using ::fopen;
      |           ^~~~~
/snap/emacs/2504/usr/include/c++/10/cstdio:126:11: error: ‘perror’ has not been declared in ‘::’
  126 |   using ::perror;
      |           ^~~~~~
/snap/emacs/2504/usr/include/c++/10/cstdio:139:11: error: ‘tmpfile’ has not been declared in ‘::’
  139 |   using ::tmpfile;
      |           ^~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/cstring:42,
                 from xapian-lite.cc:23:
/usr/include/string.h:56:32: error: expected initializer before ‘__attr_access’
   56 |     __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 4));
      |                                ^~~~~~~~~~~~~
/usr/include/string.h:128:7: error: expected initializer before ‘__attr_access’
  128 |       __attr_access ((__read_only__, 1, 3));
      |       ^~~~~~~~~~~~~
/usr/include/string.h:131:7: error: expected initializer before ‘__attr_access’
  131 |       __attr_access ((__read_only__, 1, 3));
      |       ^~~~~~~~~~~~~
/usr/include/string.h:168:29: error: expected initializer before ‘__attr_access’
  168 |     __THROW __nonnull ((2)) __attr_access ((__write_only__, 1, 3));
      |                             ^~~~~~~~~~~~~
/usr/include/string.h:181:6: error: expected initializer before ‘__attr_access’
  181 |      __attr_access ((__write_only__, 1, 3));
      |      ^~~~~~~~~~~~~
/usr/include/string.h:392:5: error: expected initializer before ‘__attr_access’
  392 |     __attr_access ((__read_only__, 1, 2))
      |     ^~~~~~~~~~~~~
/usr/include/string.h:445:37: error: expected initializer before ‘__attr_access’
  445 |      __THROW __nonnull ((2)) __wur  __attr_access ((__write_only__, 2, 3));
      |                                     ^~~~~~~~~~~~~
In file included from /snap/emacs/2504/usr/include/c++/10/cstring:42,
                 from xapian-lite.cc:23:
/usr/include/string.h:467:5: error: expected initializer before ‘__fortified_attr_access’
  467 |     __fortified_attr_access (__write_only__, 1, 2);
      |     ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/string.h:508:30: error: expected initializer before ‘__attr_access’
  508 |   __THROW __nonnull ((1, 2)) __attr_access ((__write_only__, 1, 3));
      |                              ^~~~~~~~~~~~~
/usr/include/string.h:514:31: error: expected initializer before ‘__attr_access’
  514 |   __THROW __nonnull ((1, 2))  __attr_access ((__read_write__, 1, 3));
      |                               ^~~~~~~~~~~~~
/usr/include/string.h:527:5: error: expected initializer before ‘__attr_access’
  527 |     __attr_access ((__read_write__, 1, 2));
      |     ^~~~~~~~~~~~~
In file included from xapian-lite.cc:23:
/snap/emacs/2504/usr/include/c++/10/cstring:94:11: error: ‘strxfrm’ has not been declared in ‘::’
   94 |   using ::strxfrm;
      |           ^~~~~~~
In file included from xapian-lite.cc:31:
/snap/emacs/2504/usr/include/c++/10/stdlib.h:68:12: error: ‘mbstowcs’ has not been declared in ‘std’
   68 | using std::mbstowcs;
      |            ^~~~~~~~
/snap/emacs/2504/usr/include/c++/10/stdlib.h:80:12: error: ‘wcstombs’ has not been declared in ‘std’
   80 | using std::wcstombs;
      |            ^~~~~~~~
make: *** [Makefile:18: xapian-lite.so] Error 1

Does anyone know how to fix this?


References:

@alexmurray
Copy link
Owner

So to have this work you would need to compile it against the version of libxapian-dev from the Ubuntu 20.04 LTS release (as this is what the rest of the emacs snap is using). As a workaround, I could add this package to the emacs snap itself and then you should be able to do the same kind of workaround as was done for compiling jinx.

alexmurray added a commit that referenced this issue Aug 22, 2024
Signed-off-by: Alex Murray <murray.alex@gmail.com>
@alexmurray
Copy link
Owner

Ok with any luck the change I just added will get automatically built and published to the beta channel in the next few hours - if you are able to test this with the workaround - BUT WITHOUT your change to add " -L" "/lib/x86_64-linux-gnu/" (since we want libxapian to come from the snap, not from the host) - then let me know, that would be great. Thanks.

@alexmurray
Copy link
Owner

alexmurray commented Aug 22, 2024

Looking at the upstream repo for xeft, to compile the module it calls make but the Makefile hardcodes the CXXFLAGS and LDFLAGS - so I don't think you can easily workaround it to get it to compile using the libxapian shipped in the snap - whilst you could specify PREFIX as (concat (file-name-as-directory (getenv "EMACS_SNAP_DIR")) "usr/lib"), I think you would still need to override CXXFLAGS and LDFLAGS to be able to specify --sysroot etc.

So even with this fix in place in the snap, I think it would be worth sending a PR to upstream xeft to make CXXFLAGS / LDFLAGS etc customisable (ie: declare them with the ?= operator rather than just =).

So at the moment, you would at least need to use something more like the following to get it to try to get it to compile but I suspect you would also need to override CXXFLAGS and LDFLAGS as well:

(let* ((emacs-snap-dir (file-name-as-directory (getenv "EMACS_SNAP_DIR")))
       (process-environment (append `(,(concat "CXX=" emacs-snap-dir "usr/bin/g++-10")
                                      ,(concat "PREFIX=" emacs-snap-dir "usr/lib"))
                                    process-environment)))
    (xeft))

@fapdash
Copy link
Contributor Author

fapdash commented Aug 22, 2024

Thank you for your quick response.

I tried to compile the code with the libxapian from the beta channel:

/snap/emacs/2541/usr/bin/g++-10 xapian-lite.cc -o xapian-lite.so -shared -fPIC -I/snap/emacs/2541/include -std=c++11 -L/snap/emacs/2541/lib -lxapian

But it still complains about glibc mismatch:

(module-open-failed "/home/fap/.emacs.d/elpa/xeft-3.3/xapian-lite.so" "/snap/emacs/2541/usr/bin/../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /home/fap/.emacs.d/elpa/xeft-3.3/xapian-lite.so)")

This is actually the same error that I get when I compile with the non-snap system:

g++ xapian-lite.cc -o xapian-lite.so -shared -fPIC -I/usr/local/include -std=c++11 -L/usr/local/lib -lxapian

Error:

(module-open-failed "/home/fap/.emacs.d/elpa/xeft-3.3/xapian-lite.so" "/snap/emacs/2541/usr/bin/../../lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.38' not found (required by /home/fap/.emacs.d/elpa/xeft-3.3/xapian-lite.so)")

@alexmurray
Copy link
Owner

Yes this is expected - as I said, you also need to specify --sysroot - something like the following may be enough

/snap/emacs/current/usr/bin/g++-10 --sysroot /snap/emacs/current/ xapian-lite.cc -o xapian-lite.so -shared -fPIC  -std=c++11 -lxapian

fapdash added a commit to fapdash/xeft that referenced this issue Aug 22, 2024
This allows compilation with Emacs from snapcraft.
See alexmurray/emacs-snap#92
fapdash added a commit to fapdash/xeft that referenced this issue Aug 22, 2024
This allows compilation with Emacs from snapcraft.
See alexmurray/emacs-snap#92

closes casouri#33
@fapdash
Copy link
Contributor Author

fapdash commented Aug 22, 2024

Oh, sorry overread the part about --sysroot.
Thank you so much for your quick help, xeft works now!

I've opened a PR on xeft: casouri/xeft#34

@fapdash fapdash closed this as completed Aug 22, 2024
@alexmurray alexmurray added the solution-in-comments There is a solution to this issue in the issue comments label Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution-in-comments There is a solution to this issue in the issue comments
Projects
None yet
Development

No branches or pull requests

2 participants