jwt27 / build-gcc

Shell scripts to build various gcc cross-compilers (primarily djgpp)
https://jw.h4ck.me/debian/
GNU General Public License v3.0
41 stars 9 forks source link

strip breaks static libs #22

Closed stsp closed 3 years ago

stsp commented 3 years ago

Using i586-pc-msdosdjgpp-strip on a static lib, for example on /usr/lib/gcc/i586-pc-msdosdjgpp/9.2.0/libgcc.a results into this error upon linking later:

/usr/lib/gcc/i586-pc-msdosdjgpp/9.2.0/libgcc.a: error adding symbols: archive has no index; run ranlib to add one
jwt27 commented 3 years ago

Must say I've never tried stripping a static library, I think it's more convenient to do so after linking. What I gather from a quick google search is that this is normal behaviour, and you need a flag such as -g or -x or --strip-unneeded to make strip less aggressive and preserve the archive index.

stsp commented 3 years ago

Thanks! --strip-unneeded indeed does the trick. However, I am also getting this, both with and w/o any strip:

$ i586-pc-msdosdjgpp-ranlib libgcc.a
i586-pc-msdosdjgpp-ranlib: /usr/bin/../bin/../lib/bfd-plugins/LLVMgold.so: wrong ELF class: ELFCLASS32

What can that be?

jwt27 commented 3 years ago

When you have any bfd plugins installed, binutils tools will try to use those first to read the input files. If the plugin can't read the file then it will use the built-in reader. I didn't know cross tools would use plugins from the global /usr/lib directory though. If it causes any issues you can set BINUTILS_CONFIGURE_OPTIONS=--disable-plugins before running the build script. Maybe this flag should be set by default.

stsp commented 3 years ago

Thank you! Building now on COPR to see if it works. May I suppose this can also fix my problem with OBS build? Doesn't sound very likely...

jwt27 commented 3 years ago

Worth a try I guess, but that's likely an unrelated issue.

stsp commented 3 years ago

Ah, if this would be that simple... OBS is the most difficult build system I've ever seen. I need to write an xml build recipes, and they provide some "services" to integrate with git on github. But these services work quite poor, for example I don't know how to force the service to purge its cache and re-fetch from github... But I'll ask for the help elsewhere. runlib and strip problems are all solved, thank you!