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

using clang-cl doesn't set the current cpu #16249

Open
Nov0cx opened this issue Sep 11, 2022 · 5 comments
Open

using clang-cl doesn't set the current cpu #16249

Nov0cx opened this issue Sep 11, 2022 · 5 comments
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: windows team-Rules-CPP Issues for C++ rules type: support / not a bug (process)

Comments

@Nov0cx
Copy link

Nov0cx commented Sep 11, 2022

Description of the bug:

I'm using a platform for compiling with clang-cl and setting the cpu to x86_64 but llvm-lib.exe isn't called correctly.

ERROR: D:/panthera/pch/BUILD.bazel:3:11: Linking pch/pch.lib failed: (Exit 1): llvm-lib.exe failed: error executing command C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin\llvm-lib.exe @bazel-out/x64_windows-dbg/bin/pch/pch.lib-2.params
bazel-out/x64_windows-dbg/bin/pch/_objs/pch/ppch.obj: file machine type x86 conflicts with library machine type x64 (from '/machine:X64' flag)

!!! Compiling is working just linking is broken !!!

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

My Platform build file (located in 'bazel/Platforms'):

package(default_visibility = ["//:__subpackages__"])

platform(
    name = "cl_x64_windows",
    constraint_values = [
            "@platforms//cpu:x86_64",
            "@platforms//os:windows",
            "@bazel_tools//tools/cpp:msvc",
    ],
)

platform(
    name = "x64_windows-clang-cl",
    constraint_values = [
            "@platforms//cpu:x86_64",
            "@platforms//os:windows",
            "@bazel_tools//tools/cpp:clang-cl",
    ],
)

the important part from the workspace:

register_execution_platforms(
    "//bazel/Platforms:x64_windows-clang-cl"
)

register_toolchains(
      "@local_config_cc//:cc-toolchain-x64_windows-clang-cl",
)

build config:

build:clang_cl_win_x64_dbg --enable_runfiles --incompatible_enable_cc_toolchain_resolution --platforms=//bazel/Platforms:x64_windows-clang-cl  --define build_type=debug --compilation_mode=dbg

Which operating system are you running Bazel on?

Windows 10

What is the output of bazel info release?

release 5.3.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

following these instructions: https://docs.bazel.build/versions/main/windows.html#build-c-with-clang

Any other information, logs, or outputs that you want to share?

ERROR: D:/panthera/pch/BUILD.bazel:3:11: Linking pch/pch.lib failed: (Exit 1): llvm-lib.exe failed: error executing command C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\Llvm\bin\llvm-lib.exe @bazel-out/x64_windows-dbg/bin/pch/pch.lib-2.params
bazel-out/x64_windows-dbg/bin/pch/_objs/pch/ppch.obj: file machine type x86 conflicts with library machine type x64 (from '/machine:X64' flag)

Visual Studio 2022, 14.33.31629

@Nov0cx
Copy link
Author

Nov0cx commented Sep 22, 2022

Any changes on this?

@oquenchil oquenchil added platform: windows type: support / not a bug (process) area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed type: bug untriaged labels Oct 26, 2022
@joliveraortega
Copy link

Hi there! This issue reproduces for me as well (with Visual Studio 2019). Any news about it? I am also interested on a fix for this issue. Thanks.

@joliveraortega
Copy link

@Nov0cx Hey, I am wondering whether you have a workaround already for this issue. Thanks in advance.

@joliveraortega
Copy link

#12144 made me wonder about the LLVM compiler version installed and the Bazel version used. I use 5.2.0 locally and was using LLVM 12.0.0. I tried LLMV 11.0.0 and the issue is gone.

@adam-azarchs
Copy link
Contributor

I was able to solve this problem by setting BAZEL_LLVM=".../VC/Tools/Llvm/x64" rather than the auto-detected BAZEL_LLVM=".../VC/Tools/Llvm".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) platform: windows team-Rules-CPP Issues for C++ rules type: support / not a bug (process)
Projects
None yet
Development

No branches or pull requests

5 participants