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

Building Carbon on Windows without WSL #298

Open
mmdriley opened this issue Feb 25, 2021 · 23 comments
Open

Building Carbon on Windows without WSL #298

mmdriley opened this issue Feb 25, 2021 · 23 comments
Assignees
Labels
long term Issues expected to take over 90 days to resolve.

Comments

@mmdriley
Copy link
Contributor

Building on Windows is low priority but it may be helpful to have a common place where we keep track of known problems.

The first problem I hit was https://github.com/google/llvm-bazel fails if it can't create symlinks, which Windows doesn't allow by default for unprivileged users. This can be changed by enabling Developer Mode.

Current blocker is our toolchain configuration expects to find Clang at bin/clang but it's bin/clang.exe. Once that's fixed I assume there will be wrinkles around turning clang.exe into clang++.exe.

@mmdriley mmdriley self-assigned this Feb 25, 2021
@github-actions
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please comment or remove the inactive label. The long term label can also be added for issues which are expected to take time.
This issue is labeled inactive because the last activity was over 90 days ago.

@github-actions github-actions bot added the inactive Issues and PRs which have been inactive for at least 90 days. label Jul 29, 2021
@mmdriley
Copy link
Contributor Author

mmdriley commented Aug 4, 2022

Can you say a bit more about the program you wrote? Was this a batch file? An executable that used ShellExecute? Etc.

@jonmeow
Copy link
Contributor

jonmeow commented Aug 4, 2022

Note, #1754 is already working on this and I think it's using a better approach.

@mmdriley
Copy link
Contributor Author

mmdriley commented Aug 4, 2022

Agree that #1754 looks like a good path forward for resolving this issue.

The "Shell" in ShellExecute is the Windows shell (GUI), i.e. Explorer. Not command or cmd. That said, CreateProcess does some fun parsing too.

@github-actions github-actions bot removed the inactive Issues and PRs which have been inactive for at least 90 days. label Aug 5, 2022
@jonmeow jonmeow mentioned this issue Aug 17, 2022
jonmeow added a commit that referenced this issue Aug 23, 2022
This PR fixes issue #298. I am attempting to build Carbon using Bazel on Windows, without the need to go through WSL. This is still a work in progress, below is a list of issues I have discovered and my fixes for them.

- Windows does not support Homebrew; however, I was able to properly install all of the required packages through [Chocolatey](https://chocolatey.org/). This was my first time using the Chocolatey package manager, yet it was fairly easy to use. I believe there are other options as well for Windows.
- As is mentioned in issue #298, your Windows installation must be running in [Developer Mode](https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development). This will allow unprivileged users to create symlinks during the build process.
- As it currently stands in trunk, clang_configuration.bzl will fail when attempting to run the method `_compute_clang_cpp_include_search_paths` on Windows. I have discovered that this is because Clang++.exe fails to execute if you provide it with an input file that does not exist. Thus, I have the build script generate an empty temp file in the Bazel repo for Clang to use when running the above method. 
- A cc toolchain specifically for Windows was created in clang_toolchain.BUILD. I simply mimicked what was done for other platforms, I apologize if this is incorrect since I am fairly new to Bazel.

As I understand it, the next step is to configure clang_cc_toolchain_config.bzl to support the new Windows toolchain. I intend to continue working on this, however as I stated I am quite new so help is seriously appreciated!

Co-authored-by: Jon Ross-Perkins <[email protected]>
@github-actions

This comment was marked as outdated.

@github-actions github-actions bot added the inactive Issues and PRs which have been inactive for at least 90 days. label Nov 4, 2022
@jonmeow

This comment was marked as off-topic.

@jonmeow

This comment was marked as off-topic.

@github-actions github-actions bot removed the inactive Issues and PRs which have been inactive for at least 90 days. label Nov 5, 2022
@Jeangowhy
Copy link

My case is “no such package '@llvm-project//llvm'”
Windows 10

ERROR: C:/download/carbon/explorer/BUILD:33:10: //explorer:explorer depends on @llvm-project//llvm:Support in repository @llvm-project which failed to fetch. no such package '@llvm-project//llvm': Failed to execute overlay script: 'C:/MinGW/bin/python3.exe C:/users/ocean/_bazel_ocean/r4bacw7r/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/ocean/_bazel_ocean/r4bacw7r/external/llvm-raw --overlay C:/users/ocean/_bazel_ocean/r4bacw7r/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 256
stdout:

stderr:
Timed out

This comment was marked as outdated.

@github-actions github-actions bot added the inactive Issues and PRs which have been inactive for at least 90 days. label Jan 20, 2024
@3052

This comment was marked as off-topic.

@github-actions github-actions bot removed the inactive Issues and PRs which have been inactive for at least 90 days. label Jan 21, 2024
@chandlerc chandlerc added the long term Issues expected to take over 90 days to resolve. label Jan 21, 2024
@ddkwork
Copy link

ddkwork commented Jun 20, 2024

Unfortunately, China's network access is limited, and bazel stays in a loop loading dependencies, so I'm willing to try compiling carbon if it works out of the box like cmake.

@jonmeow
Copy link
Contributor

jonmeow commented Jun 24, 2024

@ddkwork This issue is about building Carbon for development (on Carbon, not using Carbon) on Windows. Cmake support for releases is separate (could probably done with add_custom_command already, but Carbon's not stable enough to make it a priority).

@jonmeow
Copy link
Contributor

jonmeow commented Jun 24, 2024

Note, WSL hasn't been mentioned here, but it's my understanding that it generally works. It might still be worth keeping this for native use of bazel to build Carbon on Windows.

@jonmeow jonmeow changed the title Building on Windows Building Carbon on Windows without WSL Jun 24, 2024
@ddkwork
Copy link

ddkwork commented Jun 30, 2024

Note, WSL hasn't been mentioned here, but it's my understanding that it generally works. It might still be worth keeping this for native use of bazel to build Carbon on Windows.

The only way I've tried to use bazel is with clion, and as I mentioned before, either compiling carbon explorer or using explorer to compile carbon code is a terrible operation as long as it requires that you have to use bazel, for China only, as China has no access to the various packages and deps of bazel, and unless there's an official public proxy or mirror, the nuisance caused by bazel is a pain in the ass.

@chandlerc
Copy link
Contributor

Note, WSL hasn't been mentioned here, but it's my understanding that it generally works. It might still be worth keeping this for native use of bazel to build Carbon on Windows.

The only way I've tried to use bazel is with clion, and as I mentioned before, either compiling carbon explorer or using explorer to compile carbon code is a terrible operation as long as it requires that you have to use bazel, for China only, as China has no access to the various packages and deps of bazel, and unless there's an official public proxy or mirror, the nuisance caused by bazel is a pain in the ass.

Sorry its frustrating. =/

We get a lot of benefit from Bazel and being able to scale out our dependencies though. There does seem to be instructions for separating when Bazel accesses the internet: https://bazel.build/run/build#running-bazel-airgapped

I've not tried the repository cache approach, but if you or anyone else tries it out and has useful instructions for how to set it up and what to expect, I think that would be a great contribution to our docs to help folks out where internet access isn't easy.

Beyond that, we are now publishing nightly builds here:
https://github.com/carbon-language/carbon-lang/releases

These should work on WSL, and don't require Bazel or anything else -- you can just extract and try things out. It only has the toolchain, not the explorer, as that's where most of our focus is these days. In general, I would expect these nightly builds to get better and better and be a much easier way to try something out quickly than building everything from source. The latter is really for folks who want to contribute to Carbon.

@ddkwork
Copy link

ddkwork commented Jul 1, 2024 via email

@ddkwork
Copy link

ddkwork commented Jul 1, 2024

@chandlerc
Copy link
Contributor

v0.0.0-0.nightly.2024.07.01 (release)

Will it run on Windows?

It should run on WSL. We don't have native Windows builds yet (that's the subject of this bug).

@ddkwork
Copy link

ddkwork commented Jul 1, 2024 via email

@ddkwork
Copy link

ddkwork commented Jul 1, 2024 via email

@KateGregory
Copy link
Contributor

Beyond that, we are now publishing nightly builds here: https://github.com/carbon-language/carbon-lang/releases

These should work on WSL, and don't require Bazel or anything else -- you can just extract and try things out. It only has the toolchain, not the explorer, as that's where most of our focus is these days. In general, I would expect these nightly builds to get better and better and be a much easier way to try something out quickly than building everything from source. The latter is really for folks who want to contribute to Carbon.

I can confirm that the nightly builds work on WSL with almost no other dependencies. I made a fresh Ubuntu and other than clang-16 needed nothing else to use the nightly builds. No bazel, nothing else.

@ddkwork
Copy link

ddkwork commented Jul 1, 2024 via email

@theoparis
Copy link

theoparis commented Oct 25, 2024

After removing -fPIC from clang_cc_toolchain_config.bzl (which is unsupported by clang on Windows), bazel got stuck on building flex due to libgen.h 😕

INFO: Invocation ID: a17454aa-d9e6-497a-b1e7-7ef704067ee0
ERROR: C:/users/theo/_bazel_theo/5q55gppw/external/rules_flex~~default_toolchain_ext~flex_v2.6.4/BUILD.bazel:20:11: Compiling src/main.c [for tool] failed: (Exit 1): clang failed: error executing CppCompile command (from target @@rules_flex~~default_toolchain_ext~flex_v2.6.4//:flex_lib) C:\Program Files\LLVM\bin\clang -no-canonical-prefixes -fcolor-diagnostics -Werror -Wall -Wextra -Wthread-safety -Wself-assign -Wimplicit-fallthrough -Wctad-maybe-unsupported -Wextra-semi ... (remaining 50 arguments skipped)
In file included from external/rules_flex~~default_toolchain_ext~flex_v2.6.4/src/main.c:35:
external/rules_flex~~default_toolchain_ext~flex_v2.6.4/src\flexdef.h:47:10: fatal error: 'libgen.h' file not found    
   47 | #include <libgen.h> /* for XPG version of basename(3) */
      |          ^~~~~~~~~~
1 error generated.
Target //explorer:explorer failed to build

If I disable building //explorer I get

clang: error: cannot compress debug sections (zlib not enabled) [-Werror,-Wdebug-compression-unavailable]

Removing -Werror from the clang_cc_toolchain_config.bzl file gets me further, but then I get

external/_main~llvm_project~llvm-project/llvm/lib/Support/BLAKE3/blake3_sse41_x86-64_unix.S:26:1: error: unknown directive
.hidden llvm_blake3_hash_many_sse41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
long term Issues expected to take over 90 days to resolve.
Projects
None yet
Development

No branches or pull requests

9 participants