-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix determination of wasi-sdk version when built in a subdirectory #443
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think by "as a subproject" you mean "out-of-tree build"? If so can you update the title and description accordingly? "subproject" has specific meaning in CMake I believe which initially confused me when reading this PR.
Otherwise LGTM with a minor nit
version.py
Outdated
@@ -14,7 +14,7 @@ | |||
GIT_REF_LEN = 12 | |||
|
|||
|
|||
def exec(command, cwd=None): | |||
def exec(command, cwd=os.path.dirname(sys.argv[0])): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you instead remove the =None
here and this to the exec
call on line 63?
Can you also remove the ='.'
from git_commit
? All the callers the directory name explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Done, although I think it would probably break if you built it as a subproject too. |
By the way, I ended up deciding not to use wasi-sdk in the YoWASP Clang distribution because of these lines: wasi-sdk/cmake/wasi-sdk-sysroot.cmake Lines 70 to 86 in 297b6d0
which assume that |
I'll wait for @abrown to give the final approval here since he wrote this script |
Also @alexcrichton do we not to out-of-tree builds by default with the new cmake build? Should we ? |
I think this build is technically out-of-tree if you build it exactly as specified in README, i.e. first the compiler then the sysroot. If you have an existing compiler build and you want just the sysroot, building the sysroot mangles the compiler runtime dir. |
Sounds like we should update the README so its clear how to just build the sysroot with an existing toolchain. |
Is this actually something that's supported currently? As far as I can tell it will always mangle the sysroot of such a toolchain no matter what you do. Other than that it was clear to me--I feel like this is just a bug, or a design issue perhaps. |
Its probably a missing feature yes. Or maybe a feature that was possible with the old build system but is missing from the new cmake system, I'm not sure which. Also, to be clear, what you say "mangle the sysroot" are you talking about the installation of the wasm compiler-rt library and clang headers? If so, I believe those go in the resource directory of the compiler, not the sysroot. |
Perhaps you could open a bug, asking to add support for building wasi-sdk without building clang/llvm. BTW, I think you do need to eventually install the compiler-rt file from wasi-sdk into your clang resource directory, so there will some pollution of the compiler you want to use. This is because compiler-rt is really part of the compiler and not part of the sysroot. |
This is accurate. I am using the terms somewhat interchangeably in a way that created this confusion because in the build of Clang I'm using that targets Wasm it was by far easiest to merge the two (i.e. have
I could also use an explicit In any case I do have to take care to match the version of all LLVM components used in the Clang build and in the wasi-sdk build, which in itself requires additional work. For now I decided to build compiler-rt, wasi-libc, and libcxxabi/libcxx on my own to avoid this integration work since it wasn't clear if there's a large benefit to it. |
I've thought about this but I'm unsure how much I want to drop TODO list items of uncertain relevance into inboxes of wasi-sdk developers (who I'm sure have plenty to work on), so I thought I'd bring it up here first. |
That sounds like a reasonable solution. The on the main design goals of wasi-sdk was that it should be as "plain llvm/clang" as possible. Building your own should be as easy as possible and wasi-sdk is really just a convenience for folks that want a quick and easy set of pre-builts. This is why, for example, we have stayed away from forking clang or any of its standard libraries here. |
BTW, if you do want just the sysroot and resource-dir (compiler-rt) you can download those two directly from the releases page (without downloading the compiler itself). |
That makes sense! I think the only reservation I have is related to the way wasi-sdk provides support for multiple targets in the same prefix, since I don't fully understand the mechanism by which it does so, or whether there is anything users of the SDK would have to be aware of. But I should just study it more.
I do know that but one of my goals (which is as much my goal as it is a desire of the LLVM community) is to provide daily builds of the SDK with LLVM from |
The sysroot part should be relatively independent the llvm/clang versions. Even the libclang/compiler-rt part is very stable since the interface between clang and compiler-rt very rarely changes so you should be able to build llvm from In emscripten, for example, we always provide llvm/clang from tip-of-tree and compiler-rt pinned to that last stable llvm release. I don't think we have ever had any issues with that. |
Thank you, this is very useful context to know! I'll have to consider which choice would be the best maintenance-wise for YoWASP Clang. |
(also in repsonse to other things mentioning me here) This is one of the major downsides of the "sysroot only build" right now. I couldn't figure out how to actually do that as it seemed that clang required that compiler-rt was in its own directory and clang didn't look in the Now that being said I was unaware of the distinction of Basically this is something I'd like to fix, but I don't know enough how to fix it. It would be easy enough to add a CMake option to disable building compiler-rt though and that should fix the issue here I believe.
This is a function of how CMake is invoked, so it's not really a build-system-specific option codified with a default one way or another. Most CMake builds end up being out-of-tree-builds.
This feature, AFAIK, has never been supported. The old Overall I think the easiest thing for now, if it works for you @whitequark, would be to add a |
Also I'm going to go ahead and merge this PR as it looks like a good change to make and feedback has been addressed. I don't mean to stymie discussion of a sysroot-only build though. I've opened #444 to track sysroot-only builds. |
I guess if want to build a "resource-dir" outside of the toolchains actual/real/own resource dir when we would need/want to create a full resource dir containing both libclang (compiler-rt) and the toolchain headers such as |
The problem though is that with a sysroot-only build where you're not using the host toolchain I don't know where to get the toolchain headers from. If there's a build target in LLVM to install just the headers and not actually build any object files that might be reasonable, but otherwise if we're not building LLVM I'm not sure how to get the headers out other than just copying them from the host toolchain. |
Yes, I was imagining there would be some kind of llvm build target. i.e. |
I think #445 should fix the |
This target is called |
Although I'm not 100% sure that this is the specifically right target and @sbc100 might know better than I do. |
This is just a small wrinkle that happens when I build wasi-sdk as a subproject (where I run
cmake -S wasi-sdk-src -B wasi-sdk-build
, and so the working directory doesn't match the directory with the script).