Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lld-macho] -lto-embed-bitcode=optimized causes report_fatal_error #54805

Closed
elite-sheep opened this issue Apr 7, 2022 · 2 comments
Closed
Assignees

Comments

@elite-sheep
Copy link

elite-sheep commented Apr 7, 2022

Platform: MacOS with Rosette 2.
LLVM version: 13, installed with homebrew
I tried the bitcode embedding for clang. I have a very simple hello world c++ code and it happens that lld cannot recognize this flag. Can anyone help with this?

I get the idea from here: https://reviews.llvm.org/rGc8e0bb3b2c24ef59556d81a275fb1f5db64899d3

Error log:

/usr/local/opt/llvm/bin/clang++ -fuse-ld=lld -flto -Wl,--plugin-opt=-lto-embed-bitcode=optimized test.cpp 
ld64.lld: error: unknown argument '--plugin-opt=-lto-embed-bitcode=optimized'
ld64.lld: error: cannot create /var/folders/t4/qwff9y8x17v323mm2m9k6bcr0000gn/T/cc-06e1f2.o/0.x86_64.lto.o: Not a directory
LLVM ERROR: IO failure on output stream: Bad file descriptor
PLEASE submit a bug report to https://github.com/Homebrew/homebrew-core/issues and include the crash backtrace.
Stack dump:
0.	Program arguments: /usr/local/opt/llvm/bin/ld64.lld -demangle -object_path_lto /var/folders/t4/qwff9y8x17v323mm2m9k6bcr0000gn/T/cc-06e1f2.o -no_deduplicate -dynamic -arch x86_64 -platform_version macos 12.0.0 12.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk -o a.out --plugin-opt=-lto-embed-bitcode=optimized /var/folders/t4/qwff9y8x17v323mm2m9k6bcr0000gn/T/test-8b2272.o -lc++ -lSystem /usr/local/Cellar/llvm/13.0.1_1/lib/clang/13.0.1/lib/darwin/libclang_rt.osx.a
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVM.dylib            0x0000000113e1e1a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  libLLVM.dylib            0x0000000113e1e798 SignalHandler(int) + 248
2  libsystem_platform.dylib 0x00007ff816ccadfd _sigtramp + 29
3  libsystem_platform.dylib 0x0000000000000001 _sigtramp + 18446603370198422049
4  libsystem_c.dylib        0x00007ff816c00d24 abort + 123
5  libLLVM.dylib            0x0000000113d6a875 llvm::report_fatal_error(llvm::Twine const&, bool) + 277
6  libLLVM.dylib            0x0000000116a8943d llvm::report_fatal_error(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 29
7  libLLVM.dylib            0x0000000113df98c6 llvm::raw_fd_ostream::~raw_fd_ostream() + 214
8  lld                      0x000000010443fdba lld::saveBuffer(llvm::StringRef, llvm::Twine const&) + 506
9  lld                      0x00000001047174a8 lld::macho::BitcodeCompiler::compile() + 1544
10 lld                      0x00000001046eeb2c lld::macho::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&, llvm::raw_ostream&) + 25452
11 lld                      0x000000010442ddc4 lldMain(int, char const**, llvm::raw_ostream&, llvm::raw_ostream&, bool) + 820
12 lld                      0x000000010442d900 main + 208
13 dyld                     0x0000000204cf251e start + 462
14 dyld                     0x0000000000000003 start + 18446744065038933171
clang-13: error: unable to execute command: Abort trap: 6
clang-13: error: linker command failed due to signal (use -v to see invocation)

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 8, 2022

@llvm/issue-subscribers-lld-macho

@MaskRay MaskRay changed the title Failed to pass -lto-embed-bitcode=optimized [lld-macho] -lto-embed-bitcode=optimized causes report_fatal_error Apr 8, 2022
@BertalanD BertalanD self-assigned this Jul 14, 2022
@BertalanD
Copy link
Member

BertalanD commented Jul 14, 2022

The IO failure will be fixed by https://reviews.llvm.org/D129705.

The --plugin-opt= option is specific to the ELF lld. With ld64.lld, the -mllvm option can be used for passing options to the LTO backend. Thus, the flag passed to Clang would look like -Wl,-mllvm,-lto-embed-bitcode=optimized.

flemairen6 pushed a commit to ljfitz/llvm-project that referenced this issue Aug 5, 2022
Clang passes a filename rather than a directory in -lto_object_path when
using FullLTO. Previously, it was always treated it as a directory, so
lld would crash when it attempted to create temporary files inside it.

Fixes llvm#54805

Differential Revision: https://reviews.llvm.org/D129705
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants