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

error when linking against LLDEnzymeFlags CMake target #1389

Open
samuelpmishLLNL opened this issue Aug 28, 2023 · 12 comments
Open

error when linking against LLDEnzymeFlags CMake target #1389

samuelpmishLLNL opened this issue Aug 28, 2023 · 12 comments

Comments

@samuelpmishLLNL
Copy link
Collaborator

When linking a library/executable against LLDEnzymeFlags:

target_link_libraries(my_library PUBLIC LLDEnzymeFlags)

The link line is producing an error message (this is from a mac build):

ld64.lld: error: unknown argument '--load-pass-plugin=/path/to/my_library/build/lib/LLDEnzyme-16.dylib'

The path in the error message does point to the right shared library, did the method of loading the plugin change? This is from LLVM/clang 16, built with

    CMAKE_ARGS -DLLVM_TARGETS_TO_BUILD:STRING=host
               -DLLVM_ENABLE_PROJECTS:STRING=clang|clang-tools-extra|lld
               -DLLVM_ENABLE_PLUGINS=ON
               -DCMAKE_BUILD_TYPE=Release
               -DLLVM_ENABLE_PLUGINS=ON
               -DLLVM_ENABLE_ASSERTIONS=ON
               -DLLVM_ENABLE_RUNTIMES:STRING=libcxx|libcxxabi
               -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_SOURCE_DIR}/build
               -DDEFAULT_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
@wsmoses
Copy link
Member

wsmoses commented Aug 28, 2023

That is strange since we do test LLDEnzymeFlags https://github.com/EnzymeAD/Enzyme/blob/main/enzyme/test/test_find_package/CMakeLists.txt

@samuelpmishLLNL
Copy link
Collaborator Author

here's the complete invocation:

/path/to/my_library/build/bin/clang++ -O3 -DNDEBUG -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -fuse-ld=lld -Wl,-mllvm -Wl,-load=/path/to/my_library/build/lib/LLDEnzyme-16.dylib -Wl,--load-pass-plugin=/path/to/my_library/build/lib/LLDEnzyme-16.dylib CMakeFiles/differentiate_state_update.dir/tests/differentiate_state_update.cpp.o -o differentiate_state_update  lib/libgtest_main.a lib/libgtest.a -v
clang version 16.0.0
Target: arm64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /path/to/my_library/build/bin
 "/path/to/my_library/build/bin/ld64.lld" -demangle -dynamic -arch arm64 -platform_version macos 13.0.0 13.3 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o differentiate_state_update -search_paths_first -headerpad_max_install_names -mllvm -load=/path/to/my_library/build/lib/LLDEnzyme-16.dylib --load-pass-plugin=/path/to/my_library/build/lib/LLDEnzyme-16.dylib CMakeFiles/differentiate_state_update.dir/tests/differentiate_state_update.cpp.o lib/libgtest_main.a lib/libgtest.a -lc++ -lSystem

ld64.lld: error: unknown argument '--load-pass-plugin=/path/to/my_library/build/lib/LLDEnzyme-16.dylib'
clang-16: error: linker command failed with exit code 1 (use -v to see invocation)

@tgymnich
Copy link
Member

Is it possible that ld64 does not support LLVM plugins?

@wsmoses
Copy link
Member

wsmoses commented Aug 29, 2023

@tgymnich
Copy link
Member

ld64 != lld

@tgymnich
Copy link
Member

I would try something like: -fuse-ld=lld or -DCMAKE_LINKER=lld

@wsmoses
Copy link
Member

wsmoses commented Aug 29, 2023

Yeah though the actual LLVM linker only has support for plugins inside the ELF subcomponent itself, and not the MachO (macOS) subcomponent, so there is no support for plugins.

Recompiling LLVM won't add support, its a feature that needs to be added to upstream LLVM.

@wsmoses
Copy link
Member

wsmoses commented Aug 29, 2023

The old pass manager pipeline exists across all versions, but the new pass manager only exists for ELF.

@tgymnich
Copy link
Member

tgymnich commented Aug 29, 2023

odd. Thought we were using system ld64. Even more odd that ld64.lld does not support plugins.

@wsmoses
Copy link
Member

wsmoses commented Aug 29, 2023

@samuelpmishLLNL can you make an issue on LLVM proper to have lld support plugins on macOS?

@samuelpmishLLNL
Copy link
Collaborator Author

samuelpmishLLNL commented Aug 29, 2023

This is weird, I could have sworn I was using LLDEnzyme on my mac earlier.

edit: ah, maybe I was using the old pass manager previously?


I would try something like: -fuse-ld=lld or -DCMAKE_LINKER=lld

-fuse-ld=lld was in the command, and it was using the lld built with LLVM.

@samuelpmishLLNL can you make an issue on LLVM proper to have lld support plugins on macOS?

Sure, I'll go make the issue but I might have to defer to you guys for clarification.

@samuelpmishLLNL
Copy link
Collaborator Author

Follow up: are you guys able to reproduce the LLDEnzyme error message on macs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants