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

llvm build failure #16215

Closed
NickStrupat opened this issue Feb 14, 2021 · 6 comments · Fixed by #16232
Closed

llvm build failure #16215

NickStrupat opened this issue Feb 14, 2021 · 6 comments · Fixed by #16232
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@NickStrupat
Copy link
Contributor

Host Environment

  • OS: Windows 10
  • Compiler: 2021-01-13-768d8f95c9e752603d2c5901c7a7c7fbdb08af35

To Reproduce
Steps to reproduce the behavior:
.\vcpkg.exe install --triplet x64-windows llvm[core,lld,target-x86]

Failure logs

...
-- Configuring x64-windows
-- Building x64-windows-dbg
-- Building x64-windows-rel
CMake Error at scripts/cmake/vcpkg_fixup_cmake_targets.cmake:126 (message):
  'C:/Dev/vcpkg/packages/llvm_x64-windows/debug/share/lld' does not exist.
Call Stack (most recent call first):
  ports/llvm/portfile.cmake:207 (vcpkg_fixup_cmake_targets)
  scripts/ports.cmake:131 (include)


Error: Building package llvm:x64-windows failed with: BUILD_FAILED
@yurybura
Copy link
Contributor

Hello @NickStrupat,
lld is part of LLVM tools.
Please try:
.\vcpkg.exe install --triplet x64-windows llvm[core,tools,lld,target-x86]
Anyway I will add a new check in the build script.
Thank you.

@NickStrupat
Copy link
Contributor Author

Thank you @yurybura for your kind help and effort!

@NickStrupat
Copy link
Contributor Author

NickStrupat commented Feb 15, 2021

So that build worked, but when I compile against it with msvc i'm getting...

fatal error LNK1104: cannot open file 'grpc++.lib'

Wondering if you've seen that before or know off the top of your head how to address that?

My CMakeLists.txt incase that gives any quick hints:

cmake_minimum_required (VERSION 3.8)

set(INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
message(${INCLUDE_DIR})
include_directories(${INCLUDE_DIR})

find_package(LLD CONFIG REQUIRED)
find_package(LLVM CONFIG REQUIRED)

add_executable (main "main.cpp" )

target_link_libraries(main PRIVATE lldELF lldCOFF lldCore lldWasm)
target_link_libraries(main PRIVATE LTO LLVMMC grpc++ LLVMLTO)

...and my main.cpp is...

#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
using namespace llvm;

int main()
{
	LLVMContext context;
	Module module("Module", context);
	IRBuilder<> builder(context);

	// Initialize the target registry etc.
	InitializeAllTargetInfos();
	InitializeAllTargets();
	InitializeAllTargetMCs();
	InitializeAllAsmParsers();
	InitializeAllAsmPrinters();

	auto targetTriple = sys::getDefaultTargetTriple();
	module.setTargetTriple(targetTriple);

	return 0;
}

@NickStrupat
Copy link
Contributor Author

NickStrupat commented Feb 15, 2021

I just removed grpc++ from that target_link_libraries entry and it seems fine.

@NancyLi1013 NancyLi1013 added the category:port-bug The issue is with a library, which is something the port should already support label Feb 19, 2021
@NickStrupat
Copy link
Contributor Author

@yurybura I know this is off-topic, but do you happen to know where I can find an example or even a tutorial showing how to use LLD programmatically? You seem to have a strong handle on LLVM in general. I'm hoping to put together a basic front-to-back example of using the LLVM builder and then going all the way to linking an executable binary. So many of the examples I've found seem to gloss over at least a few things.

I've gotten as far as outputting an object file for a given module, but I can't find anything about integrating the linker without system("<lld>") type of thing.

@yurybura
Copy link
Contributor

@NickStrupat Unfortunately, I don't know better documentation for programmable API than the source code.
I think for beginning is better to use MCJT for generating executable binary in your code. MCJIT is much better documented.

Later you may try to use LLD as is for linking your binary from the LLVM module (IR).

strega-nil pushed a commit that referenced this issue Apr 13, 2021
* fix issue #16215

* add more projects and fix issue #16222

* add version

* exclude libc from default projects

* remove libc, add fland to default projects

* update to v11.1.0

* fix compiler-rt install path

* fix SHA for version 11.1.0

* fix libc++ install

* re-fix libc++ install

* fix pstl install

* fix flang's license file name

* install tools in tools/llvm, fix file names

* revert bin directory for libraries

* don't create clang sub-directory in llvm/tools

* overwrite version

* copy tool dependencies

* overwrite version

* remove vcpkg_copy_tools call

* overwrite version

* restore default features

* overwrite version

* overwrite version

* convert manifest to json

* install usage files

* overwrite version

* remove feature `default-projects`

* modernize CMake in usage files

* overwrite version

* update ordering

* override version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants