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

Build fail in installing native gdb: libexpat.so not recognized #2092

Open
ryanmwe opened this issue Jan 23, 2024 · 8 comments
Open

Build fail in installing native gdb: libexpat.so not recognized #2092

ryanmwe opened this issue Jan 23, 2024 · 8 comments

Comments

@ryanmwe
Copy link

ryanmwe commented Jan 23, 2024

crosstool-NG version: 1.26.0.40_6cf65db
Host OS: Arch Linux x86_64 6.7.0-arch3-1
Config and Build Log:
logs.tar.gz

[ALL ] /usr/lib/libexpat.so: file not recognized: file format not recognized
[ERROR] collect2: error: ld returned 1 exit status
[ERROR] make[3]: *** [Makefile:2177: gdb] Error 1
[ALL ] make[3]: Leaving directory '/home/cosca/crosstool-ng/.build/arm-cortex_a8-linux-gnueabihf/build/build-gdb-native/gdb'
[ERROR] make[2]: *** [Makefile:11319: all-gdb] Error 2
[ALL ] make[2]: Leaving directory '/home/cosca/crosstool-ng/.build/arm-cortex_a8-linux-gnueabihf/build/build-gdb-native'
[ERROR] make[1]: *** [Makefile:1021: all] Error 2
[ALL ] make[1]: Leaving directory '/home/cosca/crosstool-ng/.build/arm-cortex_a8-linux-gnueabihf/build/build-gdb-native'
[ERROR]
[ERROR] >>
[ERROR] >> Build failed in step 'Installing native gdb'
[ERROR] >> called in step '(top-level)'
[ERROR] >>
[ERROR] >> Error happened in: CT_DoExecLog[scripts/functions@377]
[ERROR] >> called from: do_gdb_backend[scripts/build/debug/300-gdb.sh@361]
[ERROR] >> called from: do_debug_gdb_build[scripts/build/debug/300-gdb.sh@182]
[ERROR] >> called from: do_debug[scripts/build/debug.sh@35]
[ERROR] >> called from: main[scripts/crosstool-NG.sh@708]
[ERROR] >>
[ERROR] >> For more info on this error, look at the file: 'build.log'
[ERROR] >> There is a list of known issues, some with workarounds, in:
[ERROR] >> https://crosstool-ng.github.io/docs/known-issues/
[ERROR] >>
[ERROR] >> If you feel this is a bug in crosstool-NG, report it at:
[ERROR] >> https://github.com/crosstool-ng/crosstool-ng/issues/
[ERROR] >>
[ERROR] >> Make sure your report includes all the information pertinent to this issue.
[ERROR] >> Read the bug reporting guidelines here:
[ERROR] >> http://crosstool-ng.github.io/support/
[ERROR]
[ERROR] (elapsed: 14:31.04)

@QBos07
Copy link
Contributor

QBos07 commented Jan 23, 2024

The build libexpat was schosen instead of the target one.
Can we get /home/cosca/crosstool-ng/.build/arm-cortex_a8-linux-gnueabihf/build/build-gdb-native/gdb/config.log for further analysis?

@ryanmwe
Copy link
Author

ryanmwe commented Jan 23, 2024

config.log

@QBos07
Copy link
Contributor

QBos07 commented Jan 23, 2024 via email

@cpackham
Copy link
Contributor

I tried building your config in a debain based container and it built fine. I switched to an arch based one and hit the error. I think part of the problem is that debian ends up installing libexpat under /usr/lib/x86_64-linux-gnu/libexpat.so while arch has it in /usr/lib/libexpat.so. The latter being a fairly default place configure tends to find stuff.

@cpackham
Copy link
Contributor

Looks like this code attempts to handle this but obviously that's not working anymore.

@ryanmwe
Copy link
Author

ryanmwe commented Feb 18, 2024

Thanks. Ive had the same result using ubuntu, seems to work there. I'll play around that section a little to see if I can make something work on my arch computer.

@RafalBanaszak
Copy link

RafalBanaszak commented Mar 1, 2024

Hi @ryanmwe ,
I had same issue and solved it using this patch:

diff --git a/scripts/build/debug/300-gdb.sh b/scripts/build/debug/300-gdb.sh
index 73c56c9e..65bc427b 100644
--- a/scripts/build/debug/300-gdb.sh
+++ b/scripts/build/debug/300-gdb.sh
@@ -66,8 +66,8 @@ do_debug_gdb_build()
         # version of expat and will attempt to link that, despite the -static flag.
         # The link will fail, and configure will abort with "expat missing or unusable"
         # message.
-        extra_config+=("--with-expat")
-        extra_config+=("--without-libexpat-prefix")
+        cross_extra_config+=("--with-expat")
+        #cross_extra_config+=("--without-libexpat-prefix")
 
         # ct-ng always builds ncurses in cross mode as a static library.
         # Starting from the patchset 20200718 ncurses defines a special macro
@@ -184,7 +184,8 @@ do_debug_gdb_build()
         # The link will fail, and configure will abort with "expat missing or unusable"
         # message.
         native_extra_config+=("--with-expat")
-        native_extra_config+=("--without-libexpat-prefix")
+        native_extra_config+=("--with-libexpat-type=static")
+        native_extra_config+=("--with-libexpat-prefix=${CT_SYSROOT_DIR}/usr")
 
         do_gdb_backend \
             buildtype=native \

I have found following issues:

  1. extra_config isn't used in the script. The script uses cross_extra_config and native_extra_config.
  2. <cross>_extra_config+=("--without-libexpat-prefix") doesn't make much sense. Expat on arch is in /usr/lib and the configure script doesn't need any extra options to link it to the cross GDB (cross means executed on your host machine to remotely debug a target). The comment above <cross>_extra_config is copied from native_extra_config and very misleading.
  3. The native GDB (executed on the target to debug target programs) requires to explicitly pass a path to the sysroot. native_extra_config+=("--without-libexpat-prefix") didn't change this behavior and a cross compiler still takes libexpat from /usr/lib. native_extra_config+=("--with-libexpat-prefix=${CT_SYSROOT_DIR}/usr") solved the problem.

I noticed the results of the scripts are cached somehow and applying patch isn't enough. I had cleaned the repo (git clean -xfd), applied the patch and then built the crosstool-ng from scratch (./bootstrap, ./configure... and so on). Most probably it's an overkill but works for me.

@ryanmwe
Copy link
Author

ryanmwe commented Mar 2, 2024

This patch worked for me, I also built crosstool-ng from scratch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants