adplug / adplay-unix

AdPlug's UNIX console-based frontend
GNU General Public License v2.0
12 stars 15 forks source link

New adplug lib check fails on Gentoo #2

Closed DarkDefender closed 8 years ago

DarkDefender commented 8 years ago

This commit https://github.com/adplug/adplay-unix/commit/7c2735d92a780e0116beb27e9b9dd77ec22c7bef

Makes the configure check fail on my Gentoo system (haven't tried on any other system). However, if I remove it, adplay complies fine and I can use the complied binary without any problems.

Malvineous commented 8 years ago

I've had another non-Gentoo user report the same thing, but it works fine on my Arch Linux system so I'm not sure what the problem is. Can you attach your full config.log or e-mail it to malvineous@shikadi.net so I can have a look and see if that sheds any light on the problem?

DarkDefender commented 8 years ago

Do you want the log when it fails or when I have removed the check?

Malvineous commented 8 years ago

When it fails - I'm hoping to see the command line that runs and the error messages generated. I think the problem is that it can't find the AdPlug library, so I don't yet understand why the main code can find it but that configure test can't. They should both be using the same compiler flags!

DarkDefender commented 8 years ago

Here you go!

log.zip

I agree I feel it's really weird that the test doesn't compile but the adplay code does...

Malvineous commented 8 years ago

As far as I can tell, the test is accurate - it is checking to see whether AdPlug is linked correctly and on your system it appears not to be, so the test fails. What version of the core AdPlug library are you using?

What happens if you look for the missing symbols in the library directly?

$ ldd src/.libs/adplay | grep libadplug
        libadplug-2.3.so.0 => /usr/lib/libadplug-2.3.so.0 (0x00007f4993171000)

$ objdump -T /usr/lib/libadplug-2.3.so.0 | c++filt | grep CPlayer::[C~]
0000000000028790 g    DF .text  0000000000000021  Base        CPlayer::CPlayer(Copl*)
00000000000287d0 g    DF .text  0000000000000012  Base        CPlayer::~CPlayer()
00000000000287c0 g    DF .text  0000000000000002  Base        CPlayer::~CPlayer()
00000000000287c0 g    DF .text  0000000000000002  Base        CPlayer::~CPlayer()
0000000000028790 g    DF .text  0000000000000021  Base        CPlayer::CPlayer(Copl*)

Those CPlayer functions appear to be missing according to the error in your config.log.

DarkDefender commented 8 years ago

I'm using the latest git version of adplug.

If the library is not linked correctly, then why can I successfully compile and run adplay if I remove that test?

The symbols seems to be there:

objdump -T /usr/lib/libadplug-2.3.so.0 | c++filt | grep CPlayer::[C~]
0000000000028f90 g    DF .text  0000000000000021  Base        CPlayer::CPlayer(Copl*)
0000000000028fc0 g    DF .text  0000000000000012  Base        CPlayer::~CPlayer()
0000000000028fb8 g    DF .text  0000000000000001  Base        CPlayer::~CPlayer()
0000000000028fb8 g    DF .text  0000000000000001  Base        CPlayer::~CPlayer()
0000000000028f90 g    DF .text  0000000000000021  Base        CPlayer::CPlayer(Copl*)
Malvineous commented 8 years ago

That's really weird - you definitely don't have any other version of libadplug*.so* on your system that the compiler might be picking up instead? The configure test fails because it can't find those CPlayer functions.

adplay-unix doesn't actually use those functions so I guess I should change the test to pick some other functions it does use, but then technically the problem still exists you just would never notice...

DarkDefender commented 8 years ago

I didn't manage to find any other libadplug version than the one I installed from git on my system.

The weird thing is that I can manually compile the test code if I copy the code to a .cpp and compile it with g++:

g++ -I/usr/include/libbinio -ladplug -lbinio test.cpp

So I tried it with the same compile flags as in the test and I got the same error as before. I managed to make it compile if I remove the "-Wl,--as-needed" line...

Thankfully gentoo had a page explaining why this is happening: https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed#Importance_of_linking_order

The only case when this happens to be a problem is when the libraries get fed into LDFLAGS variable (which is incorrect).

It seems like this is the case as the LDFLAGS variable has libraries in it: LDFLAGS='-Wl,-O1 -Wl,--as-needed -ladplug -lbinio'

The should be in LIBS instead.

Malvineous commented 8 years ago

Aha! Looks like the configure.ac is using an older style for this type of test.

I have created a patch for configure.ac - are you able to apply it and see whether it fixes the issue? If so I'll commit it.

Thanks for finding out the cause of the issue!

DarkDefender commented 8 years ago

Yes, that patch solved the problem nicely for me. The check now passes on my system.

Malvineous commented 8 years ago

Excellent! Thanks for testing. I've committed the fix in 69fd2d2.