tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.86k stars 324 forks source link

GCC: Funny paths in libtool's .la files #238

Closed abrodkin closed 4 years ago

abrodkin commented 4 years ago

Indeed this is not very typical use-case (probably not that many mere mortals use libtool), but I bumped into it while trying to build cross-canadian toolchain with help of https://github.com/crosstool-ng/crosstool-ng. I.e. on building of cross-GCC with osxcross-built cross-tools for Mac.

Could be reproduced quite easily.

  1. Build basic tools with ./build.sh
  2. Build GCC with ./build_gcc.sh
  3. Rename or remove build folder as if we prepare for real use of the built tools and don't want to keep a lot of intermediate things (BTW it's about 4 GiB of size so indeed there's not much sense in keeping it after building is done).
  4. Try to link something with libtool:

    $ libtool --tag=CXX --mode=link /osxcross_install/bin/o64-g++ test.cpp -o a.out /osxcross_install/x86_64-apple-darwin14/lib/libstdc++.la
    
    libtool: link: /osxcross_install/bin/o64-g++ test.cpp -o a.out  /osxcross_install/bin/../x86_64-apple-darwin14/lib/libstdc++.dylib -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs -lm -Wl,-rpath -Wl,/osxcross_install/bin/../x86_64-apple-darwin14/lib -Wl,-rpath -Wl,/osxcross_install/bin/../x86_64-apple-darwin14/lib
    ld: warning: directory not found for option '-L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src'
    ld: warning: directory not found for option '-L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs'
    ld: warning: directory not found for option '-L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs'

That happens because generated /osxcross_install/x86_64-apple-darwin14/lib/libstdc++.la has those paths in dependency_libs:

# Libraries that this one depends upon.
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs -lm'

And that's not the only one, see:

$ find /osxcross_install/ -name '*.la' -exec grep "dependency_libs" {} \; -print | grep build
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs -lm'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/libsupc++/.libs'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/libsupc++/.libs'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/libsupc++/.libs -lm'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/libsupc++/.libs -ldl -lpthread '/osxcross_install/bin/../x86_64-apple-darwin14/lib/i386'/libstdc++.la -lm'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/i386/libstdc++-v3/libsupc++/.libs -ldl -lpthread '/osxcross_install/bin/../x86_64-apple-darwin14/lib/i386'/libstdc++.la -lm'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs -ldl -lpthread '/osxcross_install/bin/../x86_64-apple-darwin14/lib'/libstdc++.la -lm'
dependency_libs=' -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/src/.libs -L/osxcross/build/gcc-10.2.0/build/x86_64-apple-darwin14/libstdc++-v3/libsupc++/.libs -ldl -lpthread '/osxcross_install/bin/../x86_64-apple-darwin14/lib'/libstdc++.la -lm'

Note these paths refer to the original build folder. For comparison in cross-toolchain built on Linux machine for Linux machine the same libstdc++.la file contains just that:

# Libraries that this one depends upon.
dependency_libs=' -lm'

so those extra paths somehow got filtered in "normal" case and remain in place in case of osxcross.

I did spend one sleepless night trying to get to the bottom of that but as you see didn't find any good solution. So any help or even hints on what to try here are much appreciated.

tpoechtrager commented 4 years ago

Is it actually causing an error or just a warning?

abrodkin commented 4 years ago

Right it was just a warning indeed. The real problem was very similar to discussed here: https://github.com/crosstool-ng/crosstool-ng/issues/712 and with application of https://github.com/crosstool-ng/crosstool-ng/blob/master/packages/gcc/9.2.0/0000-libtool-leave-framework-alone.patch fixed the build failure.

Thus closing this one and sorry for the noise!