[cfe-dev] macOS ClangdXPC build error

Jan Korous via cfe-dev cfe-dev at lists.llvm.org
Mon Mar 25 20:12:19 PDT 2019


Hi Allen,


Thanks for reporting this.

I sent a patch for review:
https://reviews.llvm.org/D59808 <https://reviews.llvm.org/D59808> [clangd][xpc][cmake] Respect explicit value of CLANGD_BUILD_XPC

I will look into the support for multiple build configurations.

Thanks.

Jan

> On Mar 25, 2019, at 2:33 AM, Haojian Wu <hokein at google.com> wrote:
> 
> +jkorous,  +via clangd-dev <mailto:clangd-dev at lists.llvm.org> 
> 
> It seems that the flag CLANGD_BUILD_XPC is enforced to on for Mac, not sure the motivation, but I think making it optional on Mac is reasonable.
> 
> Currently, you could work around it by removing the cmake configs <https://github.com/llvm-mirror/clang-tools-extra/blob/master/CMakeLists.txt#L2-L4>. 
> 
> On Sat, Mar 23, 2019 at 12:11 AM Allen Cronce via cfe-dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
> Hi all,
> 
> I’m new to this list, so apologies if this is the wrong place to post clang/CMake build issues.
> 
> I'm trying to build the LLVM 8.0.0 final release on macOS High Sierra 10.13.6 using Xcode 9.4.1. But I'm seeing an error while creating the ClangdXPC Framework. It appears to be trying to copy the dylib from the wrong location (not where it was built):
> 
> --snip--
> Creating ClangdXPC framework
> /Applications/CMake.app/Contents/bin/cmake -E copy llvm/llvmorg-8.0.0/src/LLVM-build/tools/clang/tools/extra/clangd/xpc/ClangdXPC.Info.plist llvm/llvmorg-8.0.0/src/LLVM-build/lib/ClangdXPC.framework/Versions/A/Resources/Info.plist
> /Applications/CMake.app/Contents/bin/cmake -E copy llvm/llvmorg-8.0.0/src/LLVM-build/lib/libClangdXPCLib.dylib llvm/llvmorg-8.0.0/src/LLVM-build/lib/ClangdXPC.framework/Versions/A/ClangdXPC
> Error copying file "llvm/llvmorg-8.0.0/src/LLVM-build/lib/libClangdXPCLib.dylib" to "llvm/llvmorg-8.0.0/src/LLVM-build/lib/ClangdXPC.framework/Versions/A/ClangdXPC".
> make[1]: *** [llvm/llvmorg-8.0.0/src/LLVM-build/lib/ClangdXPC.framework] Error 1
> Command /bin/sh failed with exit code 2
> --snip--
> 
> But my actual build location is here:
> 
> llvm/llvmorg-8.0.0/src/LLVM-build/Debug/lib/libClangdXPCLib.dylib
> 
> Note the Debug config in the path. I’ve set up the generated project such that I can build both the Debug and Release into separate directories. That way both can coexist.
> 
> I don't need XPC, so I tried disabling it by passing CLANGD_BUILD_XPC as off. But it looks like it gets forced to on at CMake config time when the platform is Darwin. We’re pulling in LLVM as an ExternalProject, so this results in a build error the first time we build our own project.
> 
> Popping up a layer, I tried disabling the clang build tools via CLANG_BUILD_TOOLS (since there doesn't seem to be build granularity for disabling the clang extra tools), but that resulted in a different build error.
> 
> At this point I had already spent too much time on work arounds, so I started digging into the actual issue. The problem is that CreateClangdXPCFramework.cmake seems to be using the wrong directory, both for where it’s creating the framework and where the built deliverables are located.
> 
> I worked around the copy error by replacing the CreateClangdXPCFramework.cmake script's a priory knowledge of the built binary paths with a target file generator pattern:
> 
> --snip--
>     # Copy the framework binary.
>     COMMAND ${CMAKE_COMMAND} -E copy
>        # PAC 2019-03-22: Work around build error on Mac
>        #"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lib${target}.dylib"
>        "$<TARGET_FILE:ClangdXPCLib>"
>        "${CLANGD_FRAMEWORK_OUT_LOCATION}/${name}"
> --snip--
> 
>  - and -
> 
> --snip--
>     # Copy the Clangd binary.
>     COMMAND ${CMAKE_COMMAND} -E copy
>       # PAC 2019-03-22: Work around build error on Mac
>       #"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/clangd"
>       "$<TARGET_FILE:clangd>"
>       "${CLANGD_XPC_SERVICE_OUT_LOCATION}/MacOS/clangd"
> --snip--
> 
> But while this works around the build failure, I still think that the framework is being built in the wrong place. It’s here:
> 
> llvm_org/build/lib/ClangdXPC.framework
> 
> Instead of here:
> 
> llvm_org/build/Debug/lib/ClangdXPC.framework
> 
> I tried fixing that basic problem, but LLVM is a huge project and I’m new to CMake, so I wasn’t successful. But since we don’t use the ClangdXPC.framework anyway, it wasn’t critical for me to fix this the correct way.
> 
> Maybe someone else can take this the rest of the way and fix it properly.
> 
> Best,
> 
> Allen Cronce
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190325/bffd5cf3/attachment.html>


More information about the cfe-dev mailing list