tpoechtrager / cctools-port

Apple cctools port for Linux and *BSD
728 stars 167 forks source link

bitcode_hide_symbols support #31

Open muratmat opened 7 years ago

muratmat commented 7 years ago

Hello,

I downloaded and compiled successfuly the last version of cctools. I'm trying to pre-link some object files (containing bitcode) into a single one:

ld -r -x -bitcode_bundle -bitcode_hide_symbols -arch armv7 -o prelinked_mylib.a

and I'm getting the following error: "ld: loaded libLTO doesn't support -bitcode_hide_symbols: LLVM version 3.9.1 for architecture armv7"

Is there a way to get support for 'bitcode_hide_symbols' features? Any idea/switch?

Many thanks in advance, Matteo.

tpoechtrager commented 7 years ago

Seems like you must use Apple's LLVM/Clang version due to lto_codegen_hide_symbols not being present in upstream LLVM/Clang.

wget https://opensource.apple.com/tarballs/clang/clang-800.0.42.1.tar.gz
tar xf clang-800.0.42.1.tar.gz
cd clang-800.0.42.1
mkdir build
cd build
cmake ../src -DCMAKE_INSTALL_PREFIX=/opt/compiler/apple-clang -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF -DLLVM_INCLUDE_TESTS=OFF
make clang LTO llvm-dsymutil llvm-config -j8
[sudo] make install-clang install-clang-headers install-LTO install-llvm-dsymutil install-llvm-config

export PATH=/opt/compiler/apple-clang/bin:$PATH

$ which llvm-config clang
/opt/compiler/apple-clang/bin/llvm-config
/opt/compiler/apple-clang/bin/clang

$ nm /opt/compiler/apple-clang/lib/libLTO.so |grep lto_codegen_hide_symbols
000000000027f820 T lto_codegen_hide_symbols

=> Re-build cctools and ld64 (not tested).


=> Ensure ld64 uses the correct libLTO.so:

$ ldd [...]-ld | grep /opt/compiler/apple-clang/lib
muratmat commented 7 years ago

I followed your instructions and all goes fine until I tried to rebuild cc-tools, with the following commands (that have always worked using the default installed clang/llvm):

mkdir -p "/tmp/ioscross" cd "/tmp/ioscross" wget [edit by tpoechtrager: Removed SDK link] -O iPhoneOS9.3.sdk.tar.bz2 git clone https://github.com/tpoechtrager/cctools-port.git cd cctools-port/usage_examples/ios_toolchain ./build.sh /tmp/ioscross/iPhoneOS9.3.sdk.tar.bz2 arm64

But unfortunately I got some link errors when generating/linking ld64:

libtool: link: clang++ -DDARWIN_UNIX03 -Wall -Wno-long-long -Wno-import -Wno-format -Wno-deprecated -Wno-unused-variable -Wno-unused-private-field -Wno-unused-function -Wno-invalid-offsetof -Wno-int-conversion -Wno-char-subscripts -Wno-shift-negative-value -DLTO_SUPPORT -DTAPI_SUPPORT -D__LITTLE_ENDIAN=1 -I../../../../../../../cctools/include -I../../../../../../../cctools/include/foreign -I../../../../../../../cctools/ld64/src -I../../../../../../../cctools/ld64/src/abstraction -I../../../../../../../cctools/ld64/src/3rd -I../../../../../../../cctools/ld64/src/3rd/BlocksRuntime -I../../../../../../../cctools/ld64/src/3rd/include -I../../../../../../../cctools/ld64/src/ld -I../../../../../../../cctools/ld64/src/ld/parsers -I../../../../../../../cctools/ld64/src/ld/passes -DPROGRAM_PREFIX=\"arm-apple-darwin11-\" -O3 -std=c++0x -isystem /usr/local/include -isystem /usr/pkg/include -fblocks -isystem /tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/include -pthread -Wl,-rpath -Wl,/opt/compiler/apple-clang/lib -Wl,--enable-new-dtags -Wl,-rpath -Wl,/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib -Wl,--enable-new-dtags -Wl,-rpath -Wl,/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib64 -Wl,--enable-new-dtags -Wl,-rpath -Wl,/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib32 -Wl,--enable-new-dtags -o .libs/ld ld-debugline.o ld-InputFiles.o ld-ld.o ld-Options.o ld-OutputFile.o ld-Resolver.o ld-Snapshot.o ld-SymbolTable.o code-sign-blobs/ld-blob.o -L/usr/local/lib -L/usr/pkg/lib -L/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib ../../../ld64/src/3rd/.libs/libhelper.a ../../../ld64/src/3rd/BlocksRuntime/.libs/libBlocksRuntime.a ../../../ld64/src/ld/parsers/.libs/libParsers.a ../../../ld64/src/ld/passes/.libs/libPasses.a -L/opt/compiler/apple-clang/lib -lLTO /usr/local/lib/libxar.so -ldl -ltapi -lz -lcrypto -lxml2 -pthread ld-Options.o: In function Options::buildSearchPaths(int, char const**)': ../../../../../../../cctools/ld64/src/ld/Options.cpp:(.text+0x1a8d8): undefined reference totapi::Version::getFullVersionAsString()' ../../../ld64/src/ld/parsers/.libs/libParsers.a(libParsers_la-textstub_dylib_file.o): In function textstub::dylib::File<x86_64>::File(char const*, unsigned char const*, unsigned long, long, ld::File::Ordinal, bool, bool, bool, Options::Platform, unsigned int, bool, int, int, bool, bool, bool, bool, bool, char const*, bool)': ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x398): undefined reference totapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x404): undefined reference to tapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x418): undefined reference totapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x4d3): undefined reference to tapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x542): undefined reference totapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x569): undefined reference to tapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x615): undefined reference totapi::v1::LinkerInterfaceFile::reexportedLibraries() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI6x86_64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x763): undefined reference to tapi::v1::LinkerInterfaceFile::ignoreExports() const' ../../../ld64/src/ld/parsers/.libs/libParsers.a(libParsers_la-textstub_dylib_file.o): In functiontextstub::dylib::File::File(char const, unsigned char const, unsigned long, long, ld::File::Ordinal, bool, bool, bool, Options::Platform, unsigned int, bool, int, int, bool, bool, bool, bool, bool, char const, bool)': ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x398): undefined reference to tapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x404): undefined reference totapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x418): undefined reference to tapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x4d3): undefined reference totapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x542): undefined reference to tapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x569): undefined reference totapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x615): undefined reference to tapi::v1::LinkerInterfaceFile::reexportedLibraries() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3x86EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x763): undefined reference totapi::v1::LinkerInterfaceFile::ignoreExports() const' ../../../ld64/src/ld/parsers/.libs/libParsers.a(libParsers_la-textstub_dylib_file.o): In function `textstub::dylib::File::File(char const, unsigned char const, unsigned long, long, ld::File::Ordinal, bool, bool, bool, Options::Platform, unsigned int, bool, int, int, bool, bool, bool, bool, bool, char const, bool)': ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x398): undefined reference to tapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x404): undefined reference totapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x418): undefined reference to tapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x4d3): undefined reference totapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x542): undefined reference to tapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x569): undefined reference totapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x615): undefined reference to tapi::v1::LinkerInterfaceFile::reexportedLibraries() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI3armEC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x763): undefined reference totapi::v1::LinkerInterfaceFile::ignoreExports() const' ../../../ld64/src/ld/parsers/.libs/libParsers.a(libParsers_la-textstub_dylib_file.o): In function textstub::dylib::File<arm64>::File(char const*, unsigned char const*, unsigned long, long, ld::File::Ordinal, bool, bool, bool, Options::Platform, unsigned int, bool, int, int, bool, bool, bool, bool, bool, char const*, bool)': ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x398): undefined reference totapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x404): undefined reference to tapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x418): undefined reference totapi::v1::LinkerInterfaceFile::getParentFrameworkName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x4d3): undefined reference to tapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x542): undefined reference totapi::v1::LinkerInterfaceFile::getInstallName() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x569): undefined reference to tapi::v1::LinkerInterfaceFile::allowableClients() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x615): undefined reference totapi::v1::LinkerInterfaceFile::reexportedLibraries() const' ../../../../../../../../cctools/ld64/src/ld/parsers/textstub_dylib_file.cpp:(.text._ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b[_ZN8textstub5dylib4FileI5arm64EC2EPKcPKhmlN2ld4File7OrdinalEbbbN7Options8PlatformEjbiibbbbbS5_b]+0x763): undefined reference to `tapi::v1::LinkerInterfaceFile::ignoreExports() const' clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation) Makefile:543: recipe for target 'ld' failed make[4]: [ld] Error 1 make[4]: Leaving directory '/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/tmp/cctools/ld64/src/ld' Makefile:638: recipe for target 'all-recursive' failed make[3]: [all-recursive] Error 1 make[3]: Leaving directory '/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/tmp/cctools/ld64/src/ld' Makefile:381: recipe for target 'all-recursive' failed make[2]: [all-recursive] Error 1 make[2]: Leaving directory '/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/tmp/cctools/ld64/src' Makefile:382: recipe for target 'all-recursive' failed make[1]: [all-recursive] Error 1 make[1]: Leaving directory '/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/tmp/cctools/ld64' Makefile:414: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1

Any idea? Many thanks in advance!

tpoechtrager commented 7 years ago

Please post the whole build log + tmp/cctools/config.log.

muratmat commented 7 years ago

Here are the steps I've followed:

Build and install xar library:

tar xf ../../tarballs/xar-1.6.1.tar.gz cd xar-1.6.1 patch -p0 < ../../../patches/xar-ext2.patch ac_cv_lib_crypto_OpenSSL_add_all_ciphers=yes ./configure make sudo make install

Build and install tapi lib:

mkdir -p "/tmp/libtapi/" cd "/tmp/libtapi" git clone https://github.com/tpoechtrager/apple-libtapi.git cd apple-libtapi INSTALLPREFIX=/usr/local ./build.sh sudo bash ./install.sh

NB: at the end of these two steps within /usr/local/lib I've:

ll /usr/local/lib/ total 3632 drwxr-xr-x 4 root staff 4096 Apr 3 17:30 . drwxrwsr-x 11 root staff 4096 Apr 3 16:31 .. -rw-r--r-- 1 root root 2445056 Apr 3 17:30 libtapi.so -rw-r--r-- 1 root root 828080 Apr 3 16:33 libxar.a -rw-r--r-- 1 root root 744 Apr 3 16:33 libxar.la lrwxrwxrwx 1 root root 11 Apr 3 16:33 libxar.so -> libxar.so.1 -rwxr-xr-x 1 root root 418480 Apr 3 16:33 libxar.so.1

Redirect clang/llvm in order to point to Apple one:

developer@BuildBox: export PATH=/opt/compiler/apple-clang/bin:$PATH developer@BuildBox: which llvm-config clang /opt/compiler/apple-clang/bin/llvm-config /opt/compiler/apple-clang/bin/clang developer@BuildBox: nm /opt/compiler/apple-clang/lib/libLTO.so |grep lto_codegen_hide_symbols 000000000027f7f0 T lto_codegen_hide_symbols

Now building with the following commands:

mkdir -p "/tmp/ioscross" cd "/tmp/ioscross" wget https://sdks.website/dl/iPhoneOS9.3.sdk.tbz2 -O iPhoneOS9.3.sdk.tar.bz2 git clone https://github.com/tpoechtrager/cctools-port.git cd cctools-port/usage_examples/ios_toolchain ./build.sh /tmp/ioscross/iPhoneOS9.3.sdk.tar.bz2 arm64

whole_log.txt

config.log.txt

tpoechtrager commented 7 years ago

Weird. Could you also upload /tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib/libtapi.so somewhere?

muratmat commented 7 years ago

Sure, I zip it and attach. target_lib_libtapi_so.zip

A question: during the linking phase, does ld will use libtapi generated within target/lib or will it use the one I've installed in the system in /usr/local/lib ?

UPDATE

Just checked, they have two different size:

developer@BuildBox: ll target/lib/libtapi.so -rw-r--r-- 1 developer developer 2508760 Apr 5 10:29 libtapi.so

developer@BuildBox: ll /usr/local/lib/libtapi.so -rw-r--r-- 1 root root 2445056 Apr 3 17:30 /usr/local/lib/libtapi.so

tpoechtrager commented 7 years ago

Remove /usr/local/libtapi.so and /usr/local/include/tapi and try again. The one in target/lib will be used.

muratmat commented 7 years ago

After your suggestion, cctools and ld64 built successfuly! Unfortunately the produced ld does not depend on Apple clang/llvm:

ldd /usr/ioscross/bin/arm-apple-darwin11-ld linux-vdso.so.1 (0x00007ffd909f4000) libLTO.so => /usr/lib/llvm-3.9/lib/libLTO.so (0x00007f5e916c4000) libxar.so.1 => /usr/local/lib/libxar.so.1 (0x00007f5e914ad000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5e9129c000) libtapi.so => not found libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f5e91080000) libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f5e90bed000) libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007f5e90832000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5e904b0000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5e901ac000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5e8ff95000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5e8fd76000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5e8f9d8000) libLLVM-3.9.so.1 => /usr/lib/llvm-3.9/lib/../lib/libLLVM-3.9.so.1 (0x00007f5e8cdb7000) /lib64/ld-linux-x86-64.so.2 (0x0000557ae585e000) libicui18n.so.57 => /usr/lib/x86_64-linux-gnu/libicui18n.so.57 (0x00007f5e8c93d000) libicuuc.so.57 => /usr/lib/x86_64-linux-gnu/libicuuc.so.57 (0x00007f5e8c595000) libicudata.so.57 => /usr/lib/x86_64-linux-gnu/libicudata.so.57 (0x00007f5e8ab18000) liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f5e8a8f0000) libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f5e8a6e7000) libedit.so.2 => /usr/lib/x86_64-linux-gnu/libedit.so.2 (0x00007f5e8a4af000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5e8a2a7000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f5e8a07d000) libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007f5e89e58000) libbsd.so.0 => /lib/x86_64-linux-gnu/libbsd.so.0 (0x00007f5e89c42000)

tpoechtrager commented 7 years ago

Force the linker to use the Apple one.

export LD_LIBRARY_PATH=/opt/compiler/apple-clang/lib

I dont know of a better way at the moment. If possible, uninstall libllvm and libllvm-dev.

muratmat commented 7 years ago

Now it works, simple and dirty. The whole solution sounds just a big workaround, but I'll trust that next official mainstream version of clang will support bitcode ;)

MANY thanks!

tpoechtrager commented 7 years ago

libtapi.so => not found

Uhm, does rpath linking actually work on your system? On my system all libs are used correctly without need to adjust LD_LIBRARY_PATH. I also have libLTO.so in /usr/lib, but ldd -correctly- shows /opt/compiler/apple-clang/lib/libLTO.so.

What dist are you on? Also please let me see the current config.log.

muratmat commented 7 years ago

Just forgot to tell you that after building cctools I've copied libtapi.so to /usr/local/lib Anyway I'm on a Debian 64bit testing

tpoechtrager commented 7 years ago

What's the output of chrpath arm-apple-darwin11-ld?

muratmat commented 7 years ago

chrpath /usr/ioscross/bin/arm-apple-darwin11-ld /usr/ioscross/bin/arm-apple-darwin11-ld: RUNPATH=/usr/lib/llvm-3.9/lib:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib64:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib32

tpoechtrager commented 7 years ago

Okay, thanks. I will try to look into it. This issue bugs me.

tpoechtrager commented 7 years ago

You moved the whole directory, that's why RPATH is not working.

/usr/ioscross/bin/arm-apple-darwin11-ld: RUNPATH=/usr/lib/llvm-3.9/lib:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib64:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib32

Also I think you compiled with the wrong compiler. Ensure clang and llvm-config are used from /opt/compiler/apple-clang/bin.

$ which clang llvm-config 
/opt/compiler/apple-clang/bin/clang
/opt/compiler/apple-clang/bin/llvm-config

If you really must to move the target directory, add /usr/ioscross/lib to LD_LIBRARY_PATH instead of copying the library to /usr/local/lib.

export LD_LIBRARY_PATH=<path1>:<path2>:<path3>

muratmat commented 7 years ago

Compiler was set correctly (pointed to apple clang), but yes after building I moved the whole directory "sudo mv target /usr/ioscross". Is there a better way to move the built tools (in osxcross it worked)? Anyway, I'm getting errors (not more related to ld/LTO) using -bitcode_hide_symbols :(

ld: could not open bitcode temp file: prelinked_libAmanithVG.a.bundle.3hbs0O/01.bc for architecture armv7

When trying to prelink some object files compiled with embedded bitcode

/usr/ioscross/bin/arm-apple-darwin11-ld -r -x -bitcode_bundle -bitcode_hide_symbols -arch armv7 -o prelinked_libAmanithVG.a aabox.c.o bezier.c.o ellipse.c.o fillers.c.o fillers_Additive.c.o fillers_ColorBurn.c.o fillers_ColorDodge.c.o fillers_Darken.c.o fillers_Difference.c.o fillers_DstAtop.c.o fillers_DstIn.c.o fillers_DstOut.c.o fillers_DstOver.c.o fillers_Exclusion.c.o fillers_HardLight.c.o fillers_Lighten.c.o fillers_Multiply.c.o fillers_Overlay.c.o fillers_Screen.c.o fillers_SoftLight.c.o fillers_Src.c.o fillers_SrcAtop.c.o fillers_SrcIn.c.o fillers_SrcOut.c.o fillers_SrcOver.c.o fillers_Xor.c.o fillers_table.c.o fillers_unpremultiplied.c.o globals.c.o img_fillers_Additive.c.o img_fillers_ColorBurn.c.o img_fillers_ColorDodge.c.o img_fillers_Darken.c.o img_fillers_Difference.c.o img_fillers_DstAtop.c.o img_fillers_DstIn.c.o img_fillers_DstOut.c.o img_fillers_DstOver.c.o img_fillers_Exclusion.c.o img_fillers_HardLight.c.o img_fillers_Lighten.c.o img_fillers_Multiply.c.o img_fillers_Overlay.c.o img_fillers_Screen.c.o img_fillers_SoftLight.c.o img_fillers_Src.c.o img_fillers_SrcAtop.c.o img_fillers_SrcIn.c.o img_fillers_SrcOut.c.o img_fillers_SrcOver.c.o img_fillers_Xor.c.o img_fillers_table.c.o int64_math.c.o integration.c.o intersect.c.o main.c.o mathematics.c.o matrix.c.o rasterizer.c.o rasterizer_better.c.o rasterizer_common.c.o rasterizer_faster.c.o rasterizer_noaa.c.o srecompositing.c.o sredrawingsurface.c.o sremask.c.o sreprimitives.c.o stdlib_abstraction.c.o vg_priv.c.o vgcompositing.c.o vgcontext.c.o vgconversions.c.o vgdrawingsurface.c.o vgext.c.o vgfilters.c.o vgfont.c.o vggetset.c.o vggradients.c.o vgimage.c.o vgmask.c.o vgmatrix.c.o vgpaint.c.o vgpath.c.o vgprimitives.c.o vgscissors.c.o vgstroke.c.o vgtexture.c.o vgu.c.o

tpoechtrager commented 7 years ago

The same applies to llvm-config?

$ cat tmp/cctools/config.log |grep llvm-config|grep found

muratmat commented 7 years ago

developer@BuildBox:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain: which llvm-config clang

/opt/compiler/apple-clang/bin/llvm-config /opt/compiler/apple-clang/bin/clang

developer@BuildBox:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain: cat tmp/cctools/config.log |grep llvm-config|grep found

configure:17438: found /opt/compiler/apple-clang/bin/llvm-config

developer@BuildBox:/tmp/ioscross/cctools-port/usage_examples/ios_toolchain: ldd ./target/bin/arm-apple-darwin11-ld

linux-vdso.so.1 (0x00007ffd22c5d000) libLTO.so => /opt/compiler/apple-clang/lib/libLTO.so (0x00007fc312109000) libxar.so.1 => /usr/local/lib/libxar.so.1 (0x00007fc311ef2000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fc311ce1000) libtapi.so => /tmp/ioscross/cctools-port/usage_examples/ios_toolchain/target/lib/libtapi.so (0x00007fc3118cc000) libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fc3116b0000) libcrypto.so.1.1 => /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007fc31121d000) libxml2.so.2 => /usr/lib/x86_64-linux-gnu/libxml2.so.2 (0x00007fc310e62000) libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fc310ae0000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fc3107dc000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fc3105c5000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fc3103a6000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fc310008000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fc30fe00000) libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007fc30fbd6000) /lib64/ld-linux-x86-64.so.2 (0x0000564030767000) libicui18n.so.57 => /usr/lib/x86_64-linux-gnu/libicui18n.so.57 (0x00007fc30f75c000) libicuuc.so.57 => /usr/lib/x86_64-linux-gnu/libicuuc.so.57 (0x00007fc30f3b2000) libicudata.so.57 => /usr/lib/x86_64-linux-gnu/libicudata.so.57 (0x00007fc30d935000) liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fc30d70f000)

It seems all right, correct?

UPDATE

By not moving the produced tools into /usr/ioscross, but instead redirecting my CMake toolchain configuration in order to point to /tmp/ioscross (i.e. the directory where I built cctools), 'bitcode_hide_symbols' seems to work without problems! So, I can simply build cctools in /usr/ioscross instead of building into /tmp/osxcross + move directory.

The only 'ugly' thing of the overall process is that I must set PATH env variable in order to point to Apple Clang/LLVM instead of the one installed by default in the host system.

tpoechtrager commented 7 years ago

Good. :-)

The only 'ugly' thing of the overall process is that I must set PATH env variable in order to point to Apple Clang/LLVM instead of the one installed by default in the host system.

Add export PATH=/opt/compiler/apple-clang/bin:$PATH to /etc/profile.

Is there a better way to move the built tools (in osxcross it worked)?

OSXCross does not depend on the TAPI library (yet). I want to make sure things are working properly before adding TAPIv2 support to OSXCross.

I think the best solution would be to adjust the RPATH manually with chrpath.

i.e.: chrpath arm-apple-darwin11-ld -r /usr/ioscross/lib:/opt/compiler/apple-clang/lib:/usr/local/lib

Please do not copy libs into /usr/local/lib.

muratmat commented 7 years ago

I decided to move the PATH=/opt/compiler/apple-clang/bin:$PATH into my build script (PATH=... && cmake ...), I prefer this change in order to not touch "global/shell-persistent" PATH variable. Anyway, many thanks again for your precious help!!!

tpoechtrager commented 7 years ago

You are welcome!

You should compile your iOS and macOS projects with "apple-clang" otherwise you might run into problems. LD64 uses libLTO for code generation (LTO and the bitcode stuff).

Edit: Nvm. I think I got your sentence wrong. Anyway, ensure you are always using "apple-clang" when targeting iOS or macOS.