Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 536716 - sys-devel/llvm-3.5.0: fix darwin install name mangling
Summary: sys-devel/llvm-3.5.0: fix darwin install name mangling
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: All OS X
: Normal normal (vote)
Assignee: Gentoo Prefix
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-15 16:18 UTC by Michael Weiser
Modified: 2015-01-31 16:39 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
fix darwin dynamic lib install name mangling (llvm-3.5.0-fix-darwin-installname-mangling.patch,1.47 KB, patch)
2015-01-15 16:18 UTC, Michael Weiser
Details | Diff
fix darwin dynamic lib install name mangling (llvm-fix-darwin-install-name-mangling.patch,2.86 KB, patch)
2015-01-16 08:24 UTC, Michael Weiser
Details | Diff
updated patch to fix darwin dynamic lib install name mangling (llvm-fix-darwin-install-name-mangling-2.patch,4.73 KB, patch)
2015-01-22 12:11 UTC, Michael Weiser
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Weiser 2015-01-15 16:18:34 UTC
Created attachment 394034 [details, diff]
fix darwin dynamic lib install name mangling

sys-devel/llvm-3.5.0 will fail to install with a QA warning that $EPREFIX/usr/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib uses an invalid self reference.

Also it installs a libLTO.dylib that references @rpath/libLLVM-3.5.dylib and thus fails to find it.

The attached patch fixes both.

BTW: Note grep reporting "grep: configure: No such file or directory" in the output below. grepping for PACKAGE_VERSION in configure does not work because a separete BUILD_DIR is used. It doesn't cause problems though since $PV and configure:PACKAGE_VERSON have identical values. Maybe "${S}"/configure should be used instead?

The former error shows as follows:

# CC=clang CXX="clang++ -stdlib=libc++" emerge -1 llvm
Calculating dependencies... done!
>>> Verifying ebuild manifests
>>> Running pre-merge checks for sys-devel/llvm-3.5.0
 * Checking for at least 1200 MiB disk space at "/usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/temp" ...                     [ ok ]
 * Trying to build a C++11 test program ...                                                                                           [ ok ]
>>> Emerging (1 of 1) sys-devel/llvm-3.5.0::gentoo_prefix
>>> Jobs: 0 of 1 complete, 1 running                Load avg: 19.9, 14.6, 14.3
!!! post install failed; exiting.
>>> Failed to emerge sys-devel/llvm-3.5.0, Log file:
>>>  '/usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/temp/build.log'
>>> Jobs: 0 of 1 complete, 1 failed                 Load avg: 13.9, 14.1, 14.2
 * Package:    sys-devel/llvm-3.5.0
 * Repository: gentoo_prefix
 * Maintainer: voyageur@gentoo.org mgorny@gentoo.org
 * USE:        clang elibc_Darwin kernel_Darwin libffi ncurses prefix prefix-guest python_targets_python2_7 static-analyzer userland_GNU x64-macos xml
 * FEATURES:   nostrip preserve-libs sandbox userpriv usersandbox
 * Checking for at least 1200 MiB disk space at "/usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/temp" ...
 [ ok ]
 * Trying to build a C++11 test program ...
 [ ok ]
>>> Unpacking source...
[...]
make[1]: Leaving directory '/usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/work/llvm-3.5.0.src-.amd64/bindings'
grep: configure: No such file or directory
 * fixing install_name of libLLVM-3.5.0.dylib ...
 [ ok ]
 * fixing install_name of libLTO.dylib ...
 [ ok ]
 * fixing install_name of libclang.dylib ...
 [ ok ]
 * fixing install_name of LLVMHello.dylib ...
 [ ok ]
 * fixing install_name of clang/3.5.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib ...
 [ ok ]
 * fixing install_name reference to @rpath/libclang.dylib of c-index-test ...
 [ ok ]
 * python2_7: running python_inst
>>> Completed installing llvm-3.5.0 into /usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/image/
[...]
 * QA Notice: invalid self-reference install_name /usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/work/llvm-3.5.0.src-.amd64/Release/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib in /usr/local/gentoo/usr/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
 * QA Notice: invalid self-reference install_name /usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/work/llvm-3.5.0.src-.amd64/Release/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib in /usr/local/gentoo/usr/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
 * QA Notice: invalid self-reference install_name /usr/local/gentoo/var/tmp/portage/sys-devel/llvm-3.5.0/work/llvm-3.5.0.src-.amd64/Release/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib in /usr/local/gentoo/usr/lib/clang/3.5.0/lib/darwin/libclang_rt.asan_iossim_dynamic.dylib
 * ERROR: sys-devel/llvm-3.5.0::gentoo_prefix failed:
 *   invalid install_name found, your application or library will crash at runtime

The latter error only takes effect if another program (such as ld64 from binutils-apple installed with USE="lto") is linked against libLTO. Then, libLTO will not find libLLVM-3.5.dylib:

michael@box:~ # clang -o t t.c
dyld: Library not loaded: @rpath/libLLVM-3.5.dylib
  Referenced from: /usr/local/gentoo/usr/lib/libLTO.dylib
  Reason: image not found
x86_64-apple-darwin14-clang-3.5.0: error: unable to execute command: Trace/BPT trap: 5
x86_64-apple-darwin14-clang-3.5.0: error: linker command failed due to signal (use -v to see invocation)

michael@box:~ # clang -o t t.c -v
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
 "/usr/local/gentoo/usr/bin/x86_64-apple-darwin14-clang-3.5.0" -cc1 -triple x86_64-apple-macosx10.10.0 -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name t.c -mrelocation-model pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2 -target-linker-version 241.9 -v -dwarf-column-info -resource-dir /usr/local/gentoo/usr/bin/../lib/clang/3.5.0 -fdebug-compilation-dir /Users/michael -ferror-limit 19 -fmessage-length 141 -stack-protector 1 -mstackrealign -fblocks -fobjc-runtime=macosx-10.10.0 -fencode-extended-block-signature -fdiagnostics-show-option -fcolor-diagnostics -o /var/tmp/t-8e0f02.o -x c t.c
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target x86_64-apple-darwin14.0.0
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/local/gentoo/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/gentoo/usr/include
 /usr/local/gentoo/usr/bin/../lib/clang/3.5.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
 "/usr/local/gentoo/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min 10.10.0 -o t /var/tmp/t-8e0f02.o -lSystem /usr/local/gentoo/usr/bin/../lib/clang/3.5.0/lib/darwin/libclang_rt.osx.a
dyld: Library not loaded: @rpath/libLLVM-3.5.dylib
  Referenced from: /usr/local/gentoo/usr/lib/libLTO.dylib
  Reason: image not found
x86_64-apple-darwin14-clang-3.5.0: error: unable to execute command: Trace/BPT trap: 5
x86_64-apple-darwin14-clang-3.5.0: error: linker command failed due to signal (use -v to see invocation)
Comment 1 Michael Weiser 2015-01-16 08:24:22 UTC
Created attachment 394074 [details, diff]
fix darwin dynamic lib install name mangling

The previous patch introduced a new problem. This one fixes that and updates the ebuild for 3.4.2 as well which has the same problems.
Comment 2 Michael Weiser 2015-01-22 12:11:28 UTC
Created attachment 394602 [details, diff]
updated patch to fix darwin dynamic lib install name mangling

also for 3.5.1
Comment 3 Fabian Groffen gentoo-dev 2015-01-31 16:39:57 UTC
Thanks, I applied your patch